Skip to content

Commit fc8ee56

Browse files
Merge pull request #18 from LearnYouSomeComputer/ch14
Chapter 14 Edits
2 parents 9adbfc3 + e1900a1 commit fc8ee56

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed

14-Typesetting-with-LaTeX.md

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ and cast individual bits of type that were exactly the right size needed.
2222
What you need is a digital typesetting system that's equally as powerful!
2323
Writing one should only take a summer, so you set to work.
2424

25-
In 1989 the first "finished" version of \TeX was completed.
25+
In 1989 the first "finished" version of \TeX{} was completed.[^further-reading]
2626

2727
(Okay, you can stop being Don Knuth now.)
2828

29-
Since \TeX is relatively low-level, Leslie Lamport (a fellow known for wearing silly hats and also verification of distributed systems)
29+
Since \TeX{} is relatively low--level, Leslie Lamport (a fellow known for wearing silly hats and also verification of distributed systems)
3030
wrote a bunch of useful macros that took care of a lot of the day-to-day typesetting stuff.
31-
This collection came to be known as \LaTeX --- **La**mport's **\TeX{}**.
31+
This collection came to be known as \LaTeX{} --- **La**mport's **\TeX{}**.
3232

33-
So, what is \LaTeX good for?[^logo]
33+
So, what is \LaTeX{} good for?[^logo]
3434

3535
Do you think writing should come with more compiler errors?
3636
Do you ever wish HTML was more arcane and confusing?
@@ -43,28 +43,28 @@ Then you should learn \LaTeX{}!
4343

4444
### Takeaways
4545

46-
- Learn how to structure \LaTeX documents
46+
- Learn how to structure \LaTeX{} documents
4747
- Math is beautiful and easy to typeset
48-
- \TeX is definitely something designed in the 70's
48+
- \TeX{} is definitely something designed in the 70's
4949

5050
## Walkthrough
5151

52-
\LaTeX is a language for marking up text.
52+
\LaTeX{} is a language for marking up text.
5353
You write plain ASCII text in a `.tex` file (say, `bob.tex`), then run it through the `pdflatex` command[^thrice] (so, `pdflatex bob.tex`).
5454
`pdflatex`, as its name implies, spits out a PDF file that you can open with your favorite PDF viewer.
5555
Everyone has a favorite PDF viewer, right?
5656

57-
First, a bit about syntax. \LaTeX commands begin with a `\`. So, to write the fancy \LaTeX logo, you'd type `\LaTeX`.
57+
First, a bit about syntax. \LaTeX{} commands begin with a `\`. So, to write the fancy \LaTeX{} logo, you'd type `\LaTeX{}`.
5858
Required arguments are surrounded with `{}`s; optional arguments are listed between `[]`s.
5959
For example: `\command[option1, option2]{required argument 1}{required argument 2}`.
6060

6161
\LaTeX also has 'environments', which are used to wrap larger chunks of text.
62-
These begin with `\begin{environmentname}` and end with `\end{environmentname}`.
62+
These begin with `\begin{environment}` and end with `\end{environment}`.
6363

6464
### Document Classes
6565

6666
The first thing in a `.tex` file is a document class command: `\documentclass{classname}`.
67-
Several document classes come built-in, including the following:
67+
Several document classes come built--in, including the following:
6868

6969
- `article`: Used for conference and journal articles and typical classroom reports.
7070
- `report`: Used for small books or longer reports that span several chapters.
@@ -87,7 +87,7 @@ To insert the title and author, use the `\maketitle` command.
8787

8888
Here's a short example:
8989

90-
```latex
90+
```{.latex .numberLines}
9191
\documentclass{article}
9292
9393
\title{Do Lizards Run The World?}
@@ -107,7 +107,7 @@ The document class controls the numbering and appearance of the titles for you.
107107

108108
Continuing our example:
109109

110-
```latex
110+
```{.latex .numberLines}
111111
\documentclass{article}
112112
113113
\title{Do Lizards Run The World?}
@@ -128,16 +128,19 @@ Continuing our example:
128128
\subsubsection{Physicists don’t want the truth}
129129
\subsubsection{This foil hat is perfectly comfortable, thanks}
130130
131-
\section{Conclusion: Perhaps the real aliens are the friends we made along the way}
131+
\section{Conclusion: Perhaps the real aliens
132+
are the friends we made along the way}
132133
\end{document}
133134
```
134135

136+
![The document structure example, rendered](14/outline.png)
137+
135138
### Formatting Text
136139

137140
For the most part, you can write text as you normally would in a word processor.
138141
To make a new paragraph, put two newlines in a row:
139142

140-
```latex
143+
```{.latex .numberLines}
141144
This is a sentence.
142145
This is a second.
143146
@@ -152,6 +155,7 @@ You can write them using the escape sequences ``\# \$ \% \^{} \& \_ \{ \} \`{} \
152155
Opening quotes are written with the `` ` `` character and close quotes with the `'` character.
153156
So, ``` ``text in double quotes''``` renders like "text in double quotes".
154157

158+
155159
The age-old standbys of bold, italic, and underlined text are present in \LaTeX as well:
156160

157161
- `\textbf{bold face text here}`
@@ -160,7 +164,7 @@ The age-old standbys of bold, italic, and underlined text are present in \LaTeX
160164

161165
You can also put text in a monospaced font: `\texttt{I am a robot}` renders like \texttt{I am a robot}.
162166

163-
Last but not least,URLs and hyperlinks can be added.
167+
Last but not least, URLs and hyperlinks can be added.
164168
For this, you need the `hyperref` package, which provides several commands.
165169
The `\url` command prints a URL in monospaced font; you use it like so: `\url{http://www.funroll-loops.info/}`.
166170
The `\href` command lets you add hyperlinks: `\href{http://url.com}{displayed, underlined text}` makes the text clickable
@@ -242,7 +246,7 @@ Subscripts and superscripts can be stacked to your heart's content:
242246

243247
Set notation is a breeze: `\forall n \in \{1,2,3,4\}` appears as $\forall n \in \{1,2,3,4\}$.
244248

245-
Summations (and products) can be done using subscripts and superscripts: `\sum_{i=0}^\infty \frac{1}{3^i} = \frac{3}{2}` renders to
249+
Summations (as well as products and integrals) can be done using subscripts and superscripts: `\sum_{i=0}^\infty \frac{1}{3^i} = \frac{3}{2}` renders to
246250
\begin{equation}
247251
\sum_{i=0}^\infty \frac{1}{3^i} = \frac{3}{2}
248252
\end{equation}
@@ -259,14 +263,14 @@ For more math commands, consult [the wikibook on \LaTeX{}'s math mode](https://e
259263
### Figures
260264

261265
Figures go in the 'figure' environment, which positions them and lets you give them a caption.
262-
\LaTeX will place the figure in a spot on the page that makes sense, usually at the top or the bottom (but you can tweak this manually if you like).
266+
\LaTeX{} will place the figure in a spot on the page that makes sense, usually at the top or the bottom (but you can tweak this manually if you like).
263267
The `\caption` command sets a caption for the image.
264268
You can center the image on the page with the `\centering` command.
265269

266270
The 'graphicx' package allows you to include pictures (`.png`, `.jpg`, `.eps`, or `.pdf`) with the `\includegraphics` command.
267271
Here is an example:
268272

269-
```latex
273+
```{.latex .numberLines}
270274
\documentclass{article}
271275
\usepackage{graphicx}
272276
@@ -292,7 +296,7 @@ Fortunately, there exist many websites, including [http://truben.no/table/](http
292296

293297
Here is an example table:
294298

295-
```latex
299+
```{.latex .numberLines}
296300
\begin{table}
297301
\begin{tabular}{l|l|l}
298302
~ & Heading & Another Heading \\ \hline
@@ -302,11 +306,17 @@ Here is an example table:
302306
\end{table}
303307
```
304308

309+
We've barely scratched the surface of what \LaTeX{} can do ---
310+
there's a reason it's the standard tool for writing papers in most scientific and engineering fields.
311+
It also has bibliography management tools, packages that can syntax highlight code, packages that you can use to draw gorgeous figures...
312+
whatever document feature your heart desires, there's probably at least one package out there for it.
313+
Go forth and make beautiful documents!
314+
305315
\newpage
306316
## Questions
307317
Name: `______________________________`
308318

309-
1. How would you write an equation, such as $y^2 + x^2 = 1$, in the middle of a sentence?
319+
1. How would you write the equation $y^2 + x^2 = 1$ in the middle of a sentence?
310320
\vspace{10em}
311321

312322
2. What is the environment used for numbered lists?
@@ -340,3 +350,5 @@ Name: `______________________________`
340350
[^logo]: Besides having a nifty command for printing out its own logo, of course.
341351
[^thrice]: Sometimes twice, and sometimes thrice! `pdflatex` is a one-pass parser and, well, some things just can't be done in one pass. Yes, this is poor design.
342352
[^caret]: Usually `\^` and `\~` are used to write accents on letters; for instance, `\~n` renders like ñ.
353+
[^further-reading]: See [this essay](http://www.practicallyefficient.com/2017/10/13/from-boiling-lead-and-black-art.html) for more about
354+
the history of mathematical typesetting.

0 commit comments

Comments
 (0)