From bcbc4dbfae2accfb39e031373f95198409be7362 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Fri, 18 Mar 2022 01:07:21 +0000 Subject: [PATCH 1/1] Initial version. --- example.tex | 119 ++++++++++++++ latex-intro.tex | 487 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 606 insertions(+) create mode 100644 example.tex create mode 100644 latex-intro.tex diff --git a/example.tex b/example.tex new file mode 100644 index 0000000..c15baed --- /dev/null +++ b/example.tex @@ -0,0 +1,119 @@ +\documentclass[a4paper]{article} +\usepackage{amssymb} +\usepackage[T1]{fontenc} +\usepackage[british]{babel} +\usepackage{hyperref} +\usepackage[utf8]{inputenc} + +\renewcommand{\rmdefault}{ppl} +\renewcommand{\sfdefault}{phv} +\renewcommand{\ttdefault}{pcr} + +\newcommand{\dd}[1]{\mathrm{d}#1} +\newcommand{\res}{\mathop{\mathrm{res}}\nolimits} +\newcommand{\punct}[1]{\,\textrm{#1}} + +\title{An example document} +\author{Mark Wooding} + +\begin{document} +\maketitle + +\begin{abstract} + This is a simple example of a \LaTeX\ document, demonstrating some + important features. +\end{abstract} + +\tableofcontents + +\section{An initial section} \label{sec:init} + +This is an initial paragraph +which doesn't look as though it merits careful attention. +In fact, however, it demonstrates a few features +which aren't immediately obvious. + +This is a second paragraph, +which is separated from the first by a blank line. +No explicit markup was required. +More interesting things will happen in Section~\ref{sec:next}. + +\section{A subsequent section} \label{sec:next} + +This is another section. There was a cross-reference from +Section~\ref{sec:init}. + +\subsection{Lists and suchlike} + +\begin{itemize} +\item We can typeset lists of things. + \begin{itemize} + \item We can nest lists. + \item Four levels are usually allowed + before \LaTeX\ runs out of bullet symbols. + \end{itemize} +\item + \begin{enumerate} + \item We can also have lists with numbered entries. + \item This emphasizes that their ordering is relevant. + \item \label{en:item} It also allows us to refer to items later. + \item \begin{enumerate} + \item These lists can also be nested. + \item A nested list can form the entirety of a list item. + \end{enumerate} + \end{enumerate} +\item We can \emph{emphasize} words. +\item We can set words in \textbf{boldface}. +\item We can switch to \textsf{sans-serif} + or \texttt{monospace} typefaces. +\item If I don't refer to item~\ref{en:item} above + then it would have been pointless to have labelled it. +\end{itemize} + +See Table~\ref{tab:example} for an example table. +(Notice how it's ended up at the top of the page, +above this text which precedes the table in the source code. +Also observe that there's insufficient vertical space +around the horizontal rules.) + +\begin{table} + \centering + \begin{tabular}{lcr} \hline + \textbf{Left} & \textbf{Centre} & \textbf{Right} \\ \hline + Left-aligned & Mid! & Right-aligned \\ + Stuff & \multicolumn{2}{r}{spanning two columns} \\ + More & random & nonsense \\ \hline + \end{tabular} + \caption{An example table which contains little information of value.} + \label{tab:example} +\end{table} + +\subsection{Mathematics} + +This is sort of the whole point. +Silverman~\cite[\textsection VI.2, p.~151]{silverman:curves} +deduces from the residue theorem that +\[ \sum_{w\in\mathbb{C}/\Lambda} \res_w(f) + = \frac{1}{2\pi i} \int_{\partial D} f(z) \,\dd{z} \punct{.} \] +Elsewhere, Lang~\cite[\textsection VIII.4, p.~516]{lang:algebra} +defines the \emph{Vandermonde determinant} +$V = V(x_1, \ldots, x_n)$ to be +\[ V = \left| \begin{array}{cccc} + 1 & 1 & \cdots & 1 \\ + x_1 & x_2 & \cdots & x_n \\ + \vdots & \vdots & \ddots & \vdots \\ + x^{n-1}_1 & x^{n-1}_2 & \cdots & x^{n-1}_n \\ + \end{array} \right| \punct{.} \] + +\begin{thebibliography}{99} +\bibitem{lang:algebra} + Lang, Serge, + \emph{Algebra, Revised Third Edition}, + (Springer Verlag, 2005). +\bibitem{silverman:curves} + Silverman, Joseph H., + \emph{The Arithmetic of Elliptic Curves}, + (Springer Verlag, 1986). +\end{thebibliography} + +\end{document} diff --git a/latex-intro.tex b/latex-intro.tex new file mode 100644 index 0000000..68c6d53 --- /dev/null +++ b/latex-intro.tex @@ -0,0 +1,487 @@ +\documentclass[t]{beamer} +\usetheme{Madrid} +\usefonttheme{professionalfonts} +\usefonttheme[stillsansseriflarge, stillsansserifsmall]{serif} + +\usepackage[T3, T1]{fontenc} +\usepackage[utf8]{inputenc} +\usepackage{at} +\usepackage{cmtt} +\usepackage[palatino, helvetica, courier, maths=cmr]{mdwfonts} +\usepackage{mflogo} +\usepackage{sverb} +\usepackage{syntax} +\usepackage{tikz} + \usetikzlibrary{calc} + \usetikzlibrary{positioning} + \usetikzlibrary{shapes.geometric} +\usepackage{tipa} + +\errorcontextlines=999 +\let\listingsize=\relax + +\title{Whirlwind Tour of \LaTeX} +\author{Mark Wooding} +\date{18 March 2022} + +\atdef|#1|{\mtt{#1}} +\atdef<#1>{\textit{#1}} + +\tikzset{every picture/.style={>=stealth, thick}} + +\begin{document} + +\frame{\titlepage} +\frame{\frametitle{Outline} + \tableofcontents[sectionstyle=show/show, + subsectionstyle=shaded/show/hide]} +\AtBeginSection{\frame{\frametitle{Outline} + \tableofcontents[sectionstyle=show/shaded, + subsectionstyle=show/show/hide]}} + +\section{What is \LaTeX?} + +\subsection{Background and history} + +\begin{frame}{So what even is this \LaTeX\ thing anyway?} + \begin{itemize}[<+->] + \item \LaTeX\ is a `document preparation system' based on Knuth's \TeX\ and + \MF\ programs. + \item You describe the document you want in a plain text file (or several), + run some programs, and they generate printable output. + \end{itemize} + + \centering \vfill + \begin{tikzpicture} + [file/.style={draw=black, outer sep=1mm, + text height=\ht\strutbox, text depth=\dp\strutbox}, + input/.style={file, rectangle, fill=blue!30}, + output/.style={file, rectangle, fill=green!30}, + program/.style={file, ellipse, fill=yellow!30}] + + \uncover<+-> + {\node[input] (tex0) at (0, 0) {\phantom{\texttt{foo.tex}}}; + \node[input] (tex1) at ($(tex0) - (2mm, -2mm)$) {\phantom{\texttt{foo.tex}}}; + \node[input, outer xsep=5mm, outer ysep=5mm] + (texn) at ($(tex1) - (2mm, -2mm)$) {\texttt{foo.tex}};} + + \uncover<+-> + {\node[program, below=7mm of texn] (latex) {\texttt{latex}}; + \node[output, right=6mm of latex] (dvi) {\texttt{foo.dvi}}; + \draw[->] (texn) to (latex); + \draw[->] (latex) to (dvi);} + \uncover<+-> + {\node[program, right=6mm of dvi] (dvips) {\texttt{dvips}}; + \node[output, right=6mm of dvips] (ps) {\texttt{foo.ps}}; + \draw[->] (dvi) to (dvips); + \draw[->] (dvips) to (ps);} + \uncover<+-> + {\node[program, right=6mm of ps] (ps2pdf) {\texttt{ps2pdf}}; + \node[output, above=10mm of ps2pdf] (pdf) {\texttt{foo.pdf}}; + \draw[->] (ps) to (ps2pdf); + \draw[->] (ps2pdf) to (pdf);} + \uncover<+-> + {\node[program] (pdflatex) at ($(texn)!.5!(pdf)$) {\texttt{pdflatex}}; + \draw[->] (texn) to (pdflatex); + \draw[->] (pdflatex) to (pdf);} + \end{tikzpicture} +\end{frame} + +\begin{frame}{Where does this stuff come from?} + \begin{itemize}[<+->] + \item Donald E.\ Knuth wrote the original versions of \TeX\ and \MF\ back + in the late 1970s because he was dissatisfied with the appearance of the + second editions of \emph{The Art of Computer Programming}. He stopped + evolving \TeX\ in 1982, and \MF\ in 1984. + + \item These programs implement \emph{languages}: + \begin{itemize} + \item the \MF\ language describes bitmap glyphs in terms of lines and + curves; and + \item the \TeX\ language describes page layouts in terms of text, boxes, + and glue. + \end{itemize} + + \item Both languages have a similar structure: + \begin{itemize} + \item a base layer of primitive commands; and + \item a macro layer to sequence the commands. + \end{itemize} + \end{itemize} +\end{frame} + +\begin{frame}{Writing and saying the names} + This is unfortunately tricky. + \pause + \begin{itemize}[<+->] + \item The letters in \TeX\ are \emph{Greek}: capital tau, epsilon, chi. So + it should be pronounced as \textipa{/tEx/}. \uncover<+->{`\emph{When you + say it corretly to your computer, the terminal may become slightly + moist.}'} + \item While Knuth was working on \TeX, Honeywell's `Text EXecutive' + processor appeared, so it was important that they not be confused. + \item In print, ideally the `E' should be lowered. In media that don't + allow this, it's usual to write the `E' in lowercase, as `\texttt{TeX}'. + \item The name `\LaTeX' is short for `Lamport \TeX', after its initial + author. + \item Lamport is not proscriptive about pronunciation: \textipa{/"lA:tEk/}, + \textipa{/"lEItEk/}, \textipa{/"lA:tEx/}, \textipa{/"lEItEx/}, + \textipa{/"lA:tEks/}, \textipa{/"lEItEks/} are all fine (but the last + risks confusion with dispersons of polymer microparticles in water). + \item In writing, the `A' of `\LaTeX' is reduced, raised and kerned over + the `L'; in media that can't do this, it's usual to write it in + lowercase, as `\texttt{LaTeX}'. + \end{itemize} +\end{frame} + +\begin{frame}{So, err, again, what's this \LaTeX\ thing?} + \begin{itemize}[<+->] + \item \LaTeX\ is a \emph{macro package} (called a `format') for \TeX. It + provides the machinery to describe \emph{documents} in terms of their + \emph{content}, \emph{structure}, and \emph{style}. + \item \LaTeX\ was originally written by Leslie Lamport. The moderm + version, \LaTeXe\ was extensively reworked by `The \LaTeX~3 Project'; + \LaTeX~3 is still basically vapourware. + \item Other \TeX\ formats exist, notably Hans Hagen's Con\TeX{}t. + \end{itemize} +\end{frame} + +\subsection{Strengths and weaknesses} + +\begin{frame}{What \TeX\ is good at} + \begin{itemize}[<+->] + \item Knuth developed an excellent line-breaking algorithm, which examines + whole paragraphs at a time to decide how best to split them into lines. + General page layout is excellent. + \item Typesetting mathematics well was one of Knuth's primary objectives + for \TeX. Knuth studied mathematical typsetting practices of the time + carefully; \TeX\ has pretty much taken over as the standard, since it's + been used for just about all serious mathematical communication for the + last thirty years. + \item \LaTeX's \emph{float} machinery, for placing tables and figures at + the top or bottom of pages `near' to the right place, generally works + rather well, though sometimes it needs some gentle kicking. + \end{itemize} +\end{frame} + +\begin{frame}{What \TeX\ is bad at} + \begin{itemize}[<+->] + \item The default fonts (Knuth's Computer Modern family) are widely + considered to be rather ugly. + \item Cross-references and tables of contents are good; but \TeX\ processes + the document strictly start-to-finish, and you must run \texttt{latex} + multiple times to get the document to converge. + \item Multiline text in tables is annoying: you must specify the column + width explicitly. + \item Complex layout and graphics are possible using extensions (e.g., + \texttt{pstricks}, Ti\textit{k}Z), but this is something of an acquired + taste. + \item In particular, trying to place graphics in paragraphs, with the text + flowing around them, is extremely difficult and doesn't work well. + \item Generally trying to do things off the well-trodden path leaves you + having to program \TeX\ to do things the hard way. Alas, \TeX's + programming facilities are weird and primitive, and this is widely + considered not to be very enjoyable. + \end{itemize} +\end{frame} + +\section{How do I install \LaTeX?} + +\begin{frame}{\TeX\ distributions} + \begin{itemize}[<+->] + \item The \TeX\ system is one of the most widely ported serious programs + ever. Ports will be available for every system you might want to run it + on. + \item There are \emph{lots} of pieces. Fitting them together is no fun at + all. + \item A \TeX\ \emph{distribution} comes will all of the necessary pieces + set up for you ready to go. + \item The `\TeX\ Live' distribution is free and runs on Unix (including + Linux), Windows and Mac\,OS. It's Unixy in flavour. This is what I use. + \item If you run Linux, your distribution should provide \TeX\ Live + packages. On Debian and Ubuntu, \texttt{apt install texlive-full}. + \item For Windows, MiK\TeX\ seems to be the popular choice. + \item For Mac\,OS, Mac\TeX seems to be the \TeX\ Live distribution of + choice. + \end{itemize} +\end{frame} + +\section{How do I use \LaTeX?} + +\subsection{Basic syntax} + +\begin{frame}[fragile]{A minimal document} + The following will give you a single sheet of paper with the text `Hello, + world!' printed on it. + \begin{listing} +\documentclass{article} +\begin{document} +Hello, world! +\end{document} + \end{listing} + \pause + Unfortunately, it will want to give you a sheet of \emph{US letter}-sized + paper. + \begin{listing} +\documentclass[a4paper]{article} +\begin{document} +Hello, world! +\end{document} + \end{listing} +\end{frame} + +\begin{frame}[fragile]{Magical characters} + The \TeX\ language steals quite a lot of characters for its own purposes. + There are more-or-less convenient ways of typesetting them literally. + \begin{itemize}[<+->] + \item The backslash `@|\\|' introduces \emph{control sequences}. + \item Braces `@|\{|\dots@|\}|' surround arguments and group things + together. + \item The percent sign `@|\\\%|' starts a comment which continues to the + end of the line. + \item The dollar sign `@|\$|' switches into or out of mathematical text. + \item The ampersand `@|\&|' separates cells in tables. + \item The ampersand `@|\#|' indicates where to substitute argument values + in macros and alignments. + \item The underscore `@|\_|' and caret `@|\^|' indicate mathematical + \emph{subscripts} and \emph{superscripts}. + \item The tilde `@|\~|' is like a space, but prevents line breaking. + \end{itemize} +\end{frame} + +\begin{frame}{Whitespace} + Whitespace is somewhat significant to \TeX. + \begin{itemize}[<+->] + \item Spaces separate words and allow line breaking. Multiple spaces mean + the same a single space. + \item A single newline acts just like a space, so you can break paragraphs + in your source text however you like. + \item A \emph{blank line} indicates a paragraph break. (\TeX\ actually + synthesizes a @|\\par| command internally when it sees a blank line.) + \item A comment, and its terminating newline, are \emph{entirely} ignored. + \item White space \emph{also} terminates alphabetic control-sequence + names. Use `@|\\ |' to force an actual space to the output. + \end{itemize} +\end{frame} + +\begin{frame}[fragile]{Example document: Basic structure} + (Download the PDF from \url{https://odin.gg/u/VlC}.) + \begin{block}<+->{Overview} +\begin{listing} +\documentclass[a4paper]{article} +... +\title{...} +\author{...} +\begin{document} +\maketitle +\begin{abstract} + ... +\end{abstract} +\tableofcontents +\section{...} +... +\end{document} +\end{listing} + \end{block} +\end{frame} + +\begin{frame}[fragile]{Example document: Paragraphs} + \begin{block}<+->{Paragraphs} +\begin{listing} +This is an initial paragraph ... + +This is a second paragraph, ... +\end{listing} + \end{block} + \begin{block}<+->{Lists} +\begin{listing} +\begin{itemize} +\item We can typeset lists of things. +\item + \begin{enumerate} + \item ... + \end{enumerate} +... +\end{itemize} +\end{listing} + \end{block} +\end{frame} + +\begin{frame}[fragile]{Example document: Font changes} + \begin{block}<+->{Font changes} +\begin{listing} +... \emph{...} ... +... \textbf{...} ... +... \textsf{...} ... +... \texttt{...} ... +\end{listing} + \end{block} +\end{frame} + +\begin{frame}[fragile]{Example document: Cross-references} + \begin{block}<+->{Labelling things} +\begin{listing} +\section{...} \label{sec:...} +... +\begin{enumerate} +\item \label{en:...} +\end{enumerate} +\end{listing} + \end{block} + \begin{block}<+->{Referring to things} +\begin{listing} +... Section~\ref{sec:...} ... +... +... item~\ref{en:...} ... +\end{listing} + \end{block} +\end{frame} + +\begin{frame}[fragile]{Example document: Tables} + \begin{block}<+->{Table} +\begin{listing} +\centering +\begin{tabular}{...} \hline + ... & ... & ... \\ \hline + ... & ... & ... \\ + ... & \multicolumn{2}{...}{...} \\ + ... & ... & ... \\ \hline +\end{tabular} +\end{listing} + \end{block} + \begin{block}<+->{Floating environments} +\begin{listing} +\begin{table} + ... + \caption{...} + \label{tab:...} +\end{table} +\end{listing} + \end{block} +\end{frame} + +\begin{frame}[fragile]{Example document: Mathematics} + \begin{block}<+->{Inline maths; display maths} +\begin{listing} +... $...$ ... +\[ ... \] +\end{listing} + \end{block} + \begin{block}<+->{More symbols} +\begin{listing} +\usepackage{amssymb} +\end{listing} + \end{block} + \begin{block}<+->{General stuff} +\begin{listing} +... x^{n-1}_2 ... +... \frac{...}{...} ... +\end{listing} + \end{block} + \begin{block}<+->{Matrices} +\begin{listing} +\left( \begin{array}{...} + ... & ... & ... \\ ... +\end{array} \right) +\end{listing} + \end{block} +\end{frame} + +\begin{frame}[fragile]{Example document: Miscellaneous niceties} + \begin{block}<+->{Character sets} +\begin{listing} +\usepackage[T1]{fontenc} +\usepackage[utf8]{inputenc} +\end{listing} + \end{block} + \begin{block}<+->{Localization} +\begin{listing} +\usepackage[british]{babel} +\end{listing} + \end{block} + \begin{block}<+->{Hyperlinking} +\begin{listing} +\usepackage{hyperref} +\end{listing} + \end{block} + \begin{block}<+->{Non-default fonts} +\begin{listing} +\renewcommand{\rmdefault}{ppl} +\renewcommand{\sfdefault}{phv} +\renewcommand{\ttdefault}{pcr} +\end{listing} + \end{block} +\end{frame} + + +\section{What useful packages are there?} + +\begin{frame}{\LaTeX\ packages} + \begin{itemize}[<+->] + \item Generally, the answer to `How do I do this thing in \LaTeX?' is + `Someone wrote a package to do just that.' + \item Trying to do things yourself gets you enmired in raw \TeX\ + programming. If that sounds like fun then go right ahead. + \item The \TeX\ Live distribution comes bundled with \emph{over two + thousand} packages, pretty much everything in the Comprehensive \TeX\ + Archive Network (CTAN). You just need to add the right @|\\usepackage| + command to your document preamble. + \end{itemize} +\end{frame} + +\begin{frame}{The most important packages} + My highly individual view: + \begin{itemize}[<+->] + \item The standard package collection includes \texttt{color}, + \texttt{dcolumn}, \texttt{graphicx}, \texttt{longtable}, and + \texttt{tabularx}. + \item \texttt{babel} supports `foreign' -- i.e., not American English -- + languages, with many of their distinctive typesetting conventions. + \item \texttt{hyperref} does automatic hyperlinking in PDF documents. + \item \texttt{tikz} does drawings and diagrams. + \item \texttt{beamer} makes presentations like this one. + \item \texttt{memoir} is an extremely versatile document class, intended + mostly for high-quality books. + \end{itemize} +\end{frame} + +\section{How do I find out more?} + +\begin{frame}{Books} + Alas, much basic documentation is in conventionally-published books. \\ + \begin{itemize}[<+->] + \item \emph{The \LaTeX{}book} by Leslie Lamport. + \item \emph{The \LaTeX\ Companion} by the \LaTeX\ maintainers. + \item \emph{The \TeX book} by Don Knuth. + \end{itemize} + \uncover<+->{(All published by Addison Wesley.)} \medskip + + \uncover<+->{There is \emph{\LaTeXe: An unofficial reference manual}, by + Stephen Gilmore, Torsten Martinsen, and Karl Berry, included with \TeX\ + Live.} +\end{frame} + +\begin{frame}{Online} + \begin{block}<+->{Learning} + \begin{itemize}[<+->] + \item<.-> There is much good information at \url{https://texfaq.org/}. + \item \url{https://texfaq.org/FAQ-man-latex} links to many introductions + to \LaTeX. \emph{I've not read any of them.} + \end{itemize} + \end{block} + \begin{block}<+->{Asking for help} + \begin{itemize}[<+->] + \item<.-> Traditionally, Usenet \texttt{comp.text.tex}. + \item Now, probably \url{https://tex.stackexchange.com/} looks like your + best bet. + \end{itemize} + \end{block} +\end{frame} + +\end{document} + +%%% Local variables: +%%% mode: latex +%%% TeX-PDF-mode: t +%%% TeX-master: t +%%% End: -- 2.11.0