Initial version.
[latex-intro] / latex-intro.tex
CommitLineData
bcbc4dbf
MW
1\documentclass[t]{beamer}
2\usetheme{Madrid}
3\usefonttheme{professionalfonts}
4\usefonttheme[stillsansseriflarge, stillsansserifsmall]{serif}
5
6\usepackage[T3, T1]{fontenc}
7\usepackage[utf8]{inputenc}
8\usepackage{at}
9\usepackage{cmtt}
10\usepackage[palatino, helvetica, courier, maths=cmr]{mdwfonts}
11\usepackage{mflogo}
12\usepackage{sverb}
13\usepackage{syntax}
14\usepackage{tikz}
15 \usetikzlibrary{calc}
16 \usetikzlibrary{positioning}
17 \usetikzlibrary{shapes.geometric}
18\usepackage{tipa}
19
20\errorcontextlines=999
21\let\listingsize=\relax
22
23\title{Whirlwind Tour of \LaTeX}
24\author{Mark Wooding}
25\date{18 March 2022}
26
27\atdef|#1|{\mtt{#1}}
28\atdef<#1>{\textit{#1}}
29
30\tikzset{every picture/.style={>=stealth, thick}}
31
32\begin{document}
33
34\frame{\titlepage}
35\frame{\frametitle{Outline}
36 \tableofcontents[sectionstyle=show/show,
37 subsectionstyle=shaded/show/hide]}
38\AtBeginSection{\frame{\frametitle{Outline}
39 \tableofcontents[sectionstyle=show/shaded,
40 subsectionstyle=show/show/hide]}}
41
42\section{What is \LaTeX?}
43
44\subsection{Background and history}
45
46\begin{frame}{So what even is this \LaTeX\ thing anyway?}
47 \begin{itemize}[<+->]
48 \item \LaTeX\ is a `document preparation system' based on Knuth's \TeX\ and
49 \MF\ programs.
50 \item You describe the document you want in a plain text file (or several),
51 run some programs, and they generate printable output.
52 \end{itemize}
53
54 \centering \vfill
55 \begin{tikzpicture}
56 [file/.style={draw=black, outer sep=1mm,
57 text height=\ht\strutbox, text depth=\dp\strutbox},
58 input/.style={file, rectangle, fill=blue!30},
59 output/.style={file, rectangle, fill=green!30},
60 program/.style={file, ellipse, fill=yellow!30}]
61
62 \uncover<+->
63 {\node[input] (tex0) at (0, 0) {\phantom{\texttt{foo.tex}}};
64 \node[input] (tex1) at ($(tex0) - (2mm, -2mm)$) {\phantom{\texttt{foo.tex}}};
65 \node[input, outer xsep=5mm, outer ysep=5mm]
66 (texn) at ($(tex1) - (2mm, -2mm)$) {\texttt{foo.tex}};}
67
68 \uncover<+->
69 {\node[program, below=7mm of texn] (latex) {\texttt{latex}};
70 \node[output, right=6mm of latex] (dvi) {\texttt{foo.dvi}};
71 \draw[->] (texn) to (latex);
72 \draw[->] (latex) to (dvi);}
73 \uncover<+->
74 {\node[program, right=6mm of dvi] (dvips) {\texttt{dvips}};
75 \node[output, right=6mm of dvips] (ps) {\texttt{foo.ps}};
76 \draw[->] (dvi) to (dvips);
77 \draw[->] (dvips) to (ps);}
78 \uncover<+->
79 {\node[program, right=6mm of ps] (ps2pdf) {\texttt{ps2pdf}};
80 \node[output, above=10mm of ps2pdf] (pdf) {\texttt{foo.pdf}};
81 \draw[->] (ps) to (ps2pdf);
82 \draw[->] (ps2pdf) to (pdf);}
83 \uncover<+->
84 {\node[program] (pdflatex) at ($(texn)!.5!(pdf)$) {\texttt{pdflatex}};
85 \draw[->] (texn) to (pdflatex);
86 \draw[->] (pdflatex) to (pdf);}
87 \end{tikzpicture}
88\end{frame}
89
90\begin{frame}{Where does this stuff come from?}
91 \begin{itemize}[<+->]
92 \item Donald E.\ Knuth wrote the original versions of \TeX\ and \MF\ back
93 in the late 1970s because he was dissatisfied with the appearance of the
94 second editions of \emph{The Art of Computer Programming}. He stopped
95 evolving \TeX\ in 1982, and \MF\ in 1984.
96
97 \item These programs implement \emph{languages}:
98 \begin{itemize}
99 \item the \MF\ language describes bitmap glyphs in terms of lines and
100 curves; and
101 \item the \TeX\ language describes page layouts in terms of text, boxes,
102 and glue.
103 \end{itemize}
104
105 \item Both languages have a similar structure:
106 \begin{itemize}
107 \item a base layer of primitive commands; and
108 \item a macro layer to sequence the commands.
109 \end{itemize}
110 \end{itemize}
111\end{frame}
112
113\begin{frame}{Writing and saying the names}
114 This is unfortunately tricky.
115 \pause
116 \begin{itemize}[<+->]
117 \item The letters in \TeX\ are \emph{Greek}: capital tau, epsilon, chi. So
118 it should be pronounced as \textipa{/tEx/}. \uncover<+->{`\emph{When you
119 say it corretly to your computer, the terminal may become slightly
120 moist.}'}
121 \item While Knuth was working on \TeX, Honeywell's `Text EXecutive'
122 processor appeared, so it was important that they not be confused.
123 \item In print, ideally the `E' should be lowered. In media that don't
124 allow this, it's usual to write the `E' in lowercase, as `\texttt{TeX}'.
125 \item The name `\LaTeX' is short for `Lamport \TeX', after its initial
126 author.
127 \item Lamport is not proscriptive about pronunciation: \textipa{/"lA:tEk/},
128 \textipa{/"lEItEk/}, \textipa{/"lA:tEx/}, \textipa{/"lEItEx/},
129 \textipa{/"lA:tEks/}, \textipa{/"lEItEks/} are all fine (but the last
130 risks confusion with dispersons of polymer microparticles in water).
131 \item In writing, the `A' of `\LaTeX' is reduced, raised and kerned over
132 the `L'; in media that can't do this, it's usual to write it in
133 lowercase, as `\texttt{LaTeX}'.
134 \end{itemize}
135\end{frame}
136
137\begin{frame}{So, err, again, what's this \LaTeX\ thing?}
138 \begin{itemize}[<+->]
139 \item \LaTeX\ is a \emph{macro package} (called a `format') for \TeX. It
140 provides the machinery to describe \emph{documents} in terms of their
141 \emph{content}, \emph{structure}, and \emph{style}.
142 \item \LaTeX\ was originally written by Leslie Lamport. The moderm
143 version, \LaTeXe\ was extensively reworked by `The \LaTeX~3 Project';
144 \LaTeX~3 is still basically vapourware.
145 \item Other \TeX\ formats exist, notably Hans Hagen's Con\TeX{}t.
146 \end{itemize}
147\end{frame}
148
149\subsection{Strengths and weaknesses}
150
151\begin{frame}{What \TeX\ is good at}
152 \begin{itemize}[<+->]
153 \item Knuth developed an excellent line-breaking algorithm, which examines
154 whole paragraphs at a time to decide how best to split them into lines.
155 General page layout is excellent.
156 \item Typesetting mathematics well was one of Knuth's primary objectives
157 for \TeX. Knuth studied mathematical typsetting practices of the time
158 carefully; \TeX\ has pretty much taken over as the standard, since it's
159 been used for just about all serious mathematical communication for the
160 last thirty years.
161 \item \LaTeX's \emph{float} machinery, for placing tables and figures at
162 the top or bottom of pages `near' to the right place, generally works
163 rather well, though sometimes it needs some gentle kicking.
164 \end{itemize}
165\end{frame}
166
167\begin{frame}{What \TeX\ is bad at}
168 \begin{itemize}[<+->]
169 \item The default fonts (Knuth's Computer Modern family) are widely
170 considered to be rather ugly.
171 \item Cross-references and tables of contents are good; but \TeX\ processes
172 the document strictly start-to-finish, and you must run \texttt{latex}
173 multiple times to get the document to converge.
174 \item Multiline text in tables is annoying: you must specify the column
175 width explicitly.
176 \item Complex layout and graphics are possible using extensions (e.g.,
177 \texttt{pstricks}, Ti\textit{k}Z), but this is something of an acquired
178 taste.
179 \item In particular, trying to place graphics in paragraphs, with the text
180 flowing around them, is extremely difficult and doesn't work well.
181 \item Generally trying to do things off the well-trodden path leaves you
182 having to program \TeX\ to do things the hard way. Alas, \TeX's
183 programming facilities are weird and primitive, and this is widely
184 considered not to be very enjoyable.
185 \end{itemize}
186\end{frame}
187
188\section{How do I install \LaTeX?}
189
190\begin{frame}{\TeX\ distributions}
191 \begin{itemize}[<+->]
192 \item The \TeX\ system is one of the most widely ported serious programs
193 ever. Ports will be available for every system you might want to run it
194 on.
195 \item There are \emph{lots} of pieces. Fitting them together is no fun at
196 all.
197 \item A \TeX\ \emph{distribution} comes will all of the necessary pieces
198 set up for you ready to go.
199 \item The `\TeX\ Live' distribution is free and runs on Unix (including
200 Linux), Windows and Mac\,OS. It's Unixy in flavour. This is what I use.
201 \item If you run Linux, your distribution should provide \TeX\ Live
202 packages. On Debian and Ubuntu, \texttt{apt install texlive-full}.
203 \item For Windows, MiK\TeX\ seems to be the popular choice.
204 \item For Mac\,OS, Mac\TeX seems to be the \TeX\ Live distribution of
205 choice.
206 \end{itemize}
207\end{frame}
208
209\section{How do I use \LaTeX?}
210
211\subsection{Basic syntax}
212
213\begin{frame}[fragile]{A minimal document}
214 The following will give you a single sheet of paper with the text `Hello,
215 world!' printed on it.
216 \begin{listing}
217\documentclass{article}
218\begin{document}
219Hello, world!
220\end{document}
221 \end{listing}
222 \pause
223 Unfortunately, it will want to give you a sheet of \emph{US letter}-sized
224 paper.
225 \begin{listing}
226\documentclass[a4paper]{article}
227\begin{document}
228Hello, world!
229\end{document}
230 \end{listing}
231\end{frame}
232
233\begin{frame}[fragile]{Magical characters}
234 The \TeX\ language steals quite a lot of characters for its own purposes.
235 There are more-or-less convenient ways of typesetting them literally.
236 \begin{itemize}[<+->]
237 \item The backslash `@|\\|' introduces \emph{control sequences}.
238 \item Braces `@|\{|\dots@|\}|' surround arguments and group things
239 together.
240 \item The percent sign `@|\\\%|' starts a comment which continues to the
241 end of the line.
242 \item The dollar sign `@|\$|' switches into or out of mathematical text.
243 \item The ampersand `@|\&|' separates cells in tables.
244 \item The ampersand `@|\#|' indicates where to substitute argument values
245 in macros and alignments.
246 \item The underscore `@|\_|' and caret `@|\^|' indicate mathematical
247 \emph{subscripts} and \emph{superscripts}.
248 \item The tilde `@|\~|' is like a space, but prevents line breaking.
249 \end{itemize}
250\end{frame}
251
252\begin{frame}{Whitespace}
253 Whitespace is somewhat significant to \TeX.
254 \begin{itemize}[<+->]
255 \item Spaces separate words and allow line breaking. Multiple spaces mean
256 the same a single space.
257 \item A single newline acts just like a space, so you can break paragraphs
258 in your source text however you like.
259 \item A \emph{blank line} indicates a paragraph break. (\TeX\ actually
260 synthesizes a @|\\par| command internally when it sees a blank line.)
261 \item A comment, and its terminating newline, are \emph{entirely} ignored.
262 \item White space \emph{also} terminates alphabetic control-sequence
263 names. Use `@|\\ |' to force an actual space to the output.
264 \end{itemize}
265\end{frame}
266
267\begin{frame}[fragile]{Example document: Basic structure}
268 (Download the PDF from \url{https://odin.gg/u/VlC}.)
269 \begin{block}<+->{Overview}
270\begin{listing}
271\documentclass[a4paper]{article}
272...
273\title{...}
274\author{...}
275\begin{document}
276\maketitle
277\begin{abstract}
278 ...
279\end{abstract}
280\tableofcontents
281\section{...}
282...
283\end{document}
284\end{listing}
285 \end{block}
286\end{frame}
287
288\begin{frame}[fragile]{Example document: Paragraphs}
289 \begin{block}<+->{Paragraphs}
290\begin{listing}
291This is an initial paragraph ...
292
293This is a second paragraph, ...
294\end{listing}
295 \end{block}
296 \begin{block}<+->{Lists}
297\begin{listing}
298\begin{itemize}
299\item We can typeset lists of things.
300\item
301 \begin{enumerate}
302 \item ...
303 \end{enumerate}
304...
305\end{itemize}
306\end{listing}
307 \end{block}
308\end{frame}
309
310\begin{frame}[fragile]{Example document: Font changes}
311 \begin{block}<+->{Font changes}
312\begin{listing}
313... \emph{...} ...
314... \textbf{...} ...
315... \textsf{...} ...
316... \texttt{...} ...
317\end{listing}
318 \end{block}
319\end{frame}
320
321\begin{frame}[fragile]{Example document: Cross-references}
322 \begin{block}<+->{Labelling things}
323\begin{listing}
324\section{...} \label{sec:...}
325...
326\begin{enumerate}
327\item \label{en:...}
328\end{enumerate}
329\end{listing}
330 \end{block}
331 \begin{block}<+->{Referring to things}
332\begin{listing}
333... Section~\ref{sec:...} ...
334...
335... item~\ref{en:...} ...
336\end{listing}
337 \end{block}
338\end{frame}
339
340\begin{frame}[fragile]{Example document: Tables}
341 \begin{block}<+->{Table}
342\begin{listing}
343\centering
344\begin{tabular}{...} \hline
345 ... & ... & ... \\ \hline
346 ... & ... & ... \\
347 ... & \multicolumn{2}{...}{...} \\
348 ... & ... & ... \\ \hline
349\end{tabular}
350\end{listing}
351 \end{block}
352 \begin{block}<+->{Floating environments}
353\begin{listing}
354\begin{table}
355 ...
356 \caption{...}
357 \label{tab:...}
358\end{table}
359\end{listing}
360 \end{block}
361\end{frame}
362
363\begin{frame}[fragile]{Example document: Mathematics}
364 \begin{block}<+->{Inline maths; display maths}
365\begin{listing}
366... $...$ ...
367\[ ... \]
368\end{listing}
369 \end{block}
370 \begin{block}<+->{More symbols}
371\begin{listing}
372\usepackage{amssymb}
373\end{listing}
374 \end{block}
375 \begin{block}<+->{General stuff}
376\begin{listing}
377... x^{n-1}_2 ...
378... \frac{...}{...} ...
379\end{listing}
380 \end{block}
381 \begin{block}<+->{Matrices}
382\begin{listing}
383\left( \begin{array}{...}
384 ... & ... & ... \\ ...
385\end{array} \right)
386\end{listing}
387 \end{block}
388\end{frame}
389
390\begin{frame}[fragile]{Example document: Miscellaneous niceties}
391 \begin{block}<+->{Character sets}
392\begin{listing}
393\usepackage[T1]{fontenc}
394\usepackage[utf8]{inputenc}
395\end{listing}
396 \end{block}
397 \begin{block}<+->{Localization}
398\begin{listing}
399\usepackage[british]{babel}
400\end{listing}
401 \end{block}
402 \begin{block}<+->{Hyperlinking}
403\begin{listing}
404\usepackage{hyperref}
405\end{listing}
406 \end{block}
407 \begin{block}<+->{Non-default fonts}
408\begin{listing}
409\renewcommand{\rmdefault}{ppl}
410\renewcommand{\sfdefault}{phv}
411\renewcommand{\ttdefault}{pcr}
412\end{listing}
413 \end{block}
414\end{frame}
415
416
417\section{What useful packages are there?}
418
419\begin{frame}{\LaTeX\ packages}
420 \begin{itemize}[<+->]
421 \item Generally, the answer to `How do I do this thing in \LaTeX?' is
422 `Someone wrote a package to do just that.'
423 \item Trying to do things yourself gets you enmired in raw \TeX\
424 programming. If that sounds like fun then go right ahead.
425 \item The \TeX\ Live distribution comes bundled with \emph{over two
426 thousand} packages, pretty much everything in the Comprehensive \TeX\
427 Archive Network (CTAN). You just need to add the right @|\\usepackage|
428 command to your document preamble.
429 \end{itemize}
430\end{frame}
431
432\begin{frame}{The most important packages}
433 My highly individual view:
434 \begin{itemize}[<+->]
435 \item The standard package collection includes \texttt{color},
436 \texttt{dcolumn}, \texttt{graphicx}, \texttt{longtable}, and
437 \texttt{tabularx}.
438 \item \texttt{babel} supports `foreign' -- i.e., not American English --
439 languages, with many of their distinctive typesetting conventions.
440 \item \texttt{hyperref} does automatic hyperlinking in PDF documents.
441 \item \texttt{tikz} does drawings and diagrams.
442 \item \texttt{beamer} makes presentations like this one.
443 \item \texttt{memoir} is an extremely versatile document class, intended
444 mostly for high-quality books.
445 \end{itemize}
446\end{frame}
447
448\section{How do I find out more?}
449
450\begin{frame}{Books}
451 Alas, much basic documentation is in conventionally-published books. \\
452 \begin{itemize}[<+->]
453 \item \emph{The \LaTeX{}book} by Leslie Lamport.
454 \item \emph{The \LaTeX\ Companion} by the \LaTeX\ maintainers.
455 \item \emph{The \TeX book} by Don Knuth.
456 \end{itemize}
457 \uncover<+->{(All published by Addison Wesley.)} \medskip
458
459 \uncover<+->{There is \emph{\LaTeXe: An unofficial reference manual}, by
460 Stephen Gilmore, Torsten Martinsen, and Karl Berry, included with \TeX\
461 Live.}
462\end{frame}
463
464\begin{frame}{Online}
465 \begin{block}<+->{Learning}
466 \begin{itemize}[<+->]
467 \item<.-> There is much good information at \url{https://texfaq.org/}.
468 \item \url{https://texfaq.org/FAQ-man-latex} links to many introductions
469 to \LaTeX. \emph{I've not read any of them.}
470 \end{itemize}
471 \end{block}
472 \begin{block}<+->{Asking for help}
473 \begin{itemize}[<+->]
474 \item<.-> Traditionally, Usenet \texttt{comp.text.tex}.
475 \item Now, probably \url{https://tex.stackexchange.com/} looks like your
476 best bet.
477 \end{itemize}
478 \end{block}
479\end{frame}
480
481\end{document}
482
483%%% Local variables:
484%%% mode: latex
485%%% TeX-PDF-mode: t
486%%% TeX-master: t
487%%% End: