You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 14-Typesetting-with-LaTeX.md
+32-20Lines changed: 32 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -22,15 +22,15 @@ and cast individual bits of type that were exactly the right size needed.
22
22
What you need is a digital typesetting system that's equally as powerful!
23
23
Writing one should only take a summer, so you set to work.
24
24
25
-
In 1989 the first "finished" version of \TeX was completed.
25
+
In 1989 the first "finished" version of \TeX{} was completed.[^further-reading]
26
26
27
27
(Okay, you can stop being Don Knuth now.)
28
28
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)
30
30
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{}**.
32
32
33
-
So, what is \LaTeX good for?[^logo]
33
+
So, what is \LaTeX{} good for?[^logo]
34
34
35
35
Do you think writing should come with more compiler errors?
36
36
Do you ever wish HTML was more arcane and confusing?
@@ -43,28 +43,28 @@ Then you should learn \LaTeX{}!
43
43
44
44
### Takeaways
45
45
46
-
- Learn how to structure \LaTeX documents
46
+
- Learn how to structure \LaTeX{} documents
47
47
- 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
49
49
50
50
## Walkthrough
51
51
52
-
\LaTeX is a language for marking up text.
52
+
\LaTeX{} is a language for marking up text.
53
53
You write plain ASCII text in a `.tex` file (say, `bob.tex`), then run it through the `pdflatex` command[^thrice] (so, `pdflatex bob.tex`).
54
54
`pdflatex`, as its name implies, spits out a PDF file that you can open with your favorite PDF viewer.
55
55
Everyone has a favorite PDF viewer, right?
56
56
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{}`.
58
58
Required arguments are surrounded with `{}`s; optional arguments are listed between `[]`s.
59
59
For example: `\command[option1, option2]{required argument 1}{required argument 2}`.
60
60
61
61
\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}`.
63
63
64
64
### Document Classes
65
65
66
66
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:
68
68
69
69
-`article`: Used for conference and journal articles and typical classroom reports.
70
70
-`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.
87
87
88
88
Here's a short example:
89
89
90
-
```latex
90
+
```{.latex .numberLines}
91
91
\documentclass{article}
92
92
93
93
\title{Do Lizards Run The World?}
@@ -107,7 +107,7 @@ The document class controls the numbering and appearance of the titles for you.
107
107
108
108
Continuing our example:
109
109
110
-
```latex
110
+
```{.latex .numberLines}
111
111
\documentclass{article}
112
112
113
113
\title{Do Lizards Run The World?}
@@ -128,16 +128,19 @@ Continuing our example:
128
128
\subsubsection{Physicists don’t want the truth}
129
129
\subsubsection{This foil hat is perfectly comfortable, thanks}
130
130
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}
132
133
\end{document}
133
134
```
134
135
136
+

137
+
135
138
### Formatting Text
136
139
137
140
For the most part, you can write text as you normally would in a word processor.
138
141
To make a new paragraph, put two newlines in a row:
139
142
140
-
```latex
143
+
```{.latex .numberLines}
141
144
This is a sentence.
142
145
This is a second.
143
146
@@ -152,6 +155,7 @@ You can write them using the escape sequences ``\# \$ \% \^{} \& \_ \{ \} \`{} \
152
155
Opening quotes are written with the `` ` `` character and close quotes with the `'` character.
153
156
So, ``` ``text in double quotes''``` renders like "text in double quotes".
154
157
158
+
155
159
The age-old standbys of bold, italic, and underlined text are present in \LaTeX as well:
156
160
157
161
-`\textbf{bold face text here}`
@@ -160,7 +164,7 @@ The age-old standbys of bold, italic, and underlined text are present in \LaTeX
160
164
161
165
You can also put text in a monospaced font: `\texttt{I am a robot}` renders like \texttt{I am a robot}.
162
166
163
-
Last but not least,URLs and hyperlinks can be added.
167
+
Last but not least,URLs and hyperlinks can be added.
164
168
For this, you need the `hyperref` package, which provides several commands.
165
169
The `\url` command prints a URL in monospaced font; you use it like so: `\url{http://www.funroll-loops.info/}`.
166
170
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:
242
246
243
247
Set notation is a breeze: `\forall n \in \{1,2,3,4\}` appears as $\forall n \in \{1,2,3,4\}$.
244
248
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
246
250
\begin{equation}
247
251
\sum_{i=0}^\infty \frac{1}{3^i} = \frac{3}{2}
248
252
\end{equation}
@@ -259,14 +263,14 @@ For more math commands, consult [the wikibook on \LaTeX{}'s math mode](https://e
259
263
### Figures
260
264
261
265
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).
263
267
The `\caption` command sets a caption for the image.
264
268
You can center the image on the page with the `\centering` command.
265
269
266
270
The 'graphicx' package allows you to include pictures (`.png`, `.jpg`, `.eps`, or `.pdf`) with the `\includegraphics` command.
267
271
Here is an example:
268
272
269
-
```latex
273
+
```{.latex .numberLines}
270
274
\documentclass{article}
271
275
\usepackage{graphicx}
272
276
@@ -292,7 +296,7 @@ Fortunately, there exist many websites, including [http://truben.no/table/](http
292
296
293
297
Here is an example table:
294
298
295
-
```latex
299
+
```{.latex .numberLines}
296
300
\begin{table}
297
301
\begin{tabular}{l|l|l}
298
302
~ & Heading & Another Heading \\ \hline
@@ -302,11 +306,17 @@ Here is an example table:
302
306
\end{table}
303
307
```
304
308
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
+
305
315
\newpage
306
316
## Questions
307
317
Name: `______________________________`
308
318
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?
310
320
\vspace{10em}
311
321
312
322
2. What is the environment used for numbered lists?
[^logo]: Besides having a nifty command for printing out its own logo, of course.
341
351
[^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.
342
352
[^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
0 commit comments