\title{Maths in \LaTeX: Part~2, Getting more Serious} \author[R.~A.~Bailey]{R.~A.~Bailey\\ School of Mathematical Sciences\\ Queen Mary and Westfield College\\ Mile End Road\\ London E1 4NS} \def\realrm{\rmfamily\upshape} \newtheorem{preqn}{Exercise} \newenvironment{qn}{\begin{preqn}\realrm}{\end{preqn}} \newcommand{\lamport}{{\it \LaTeX: A Document Preparation System\/} by Leslie Lamport} \newcommand{\shortlamp}{\emph{The Manual}} \let\torl\AllTeX \begin{Article} \section*{Recall} This is the second in a sequence of tutorials on typesetting Mathematics in \LaTeX. It includes some things which can be found in \lamport, but I am gradually working in more things which, while straightforward and necessary for Mathematical work, are not in \shortlamp. In case you missed the first tutorial, two warnings are now repeated. I expect you, the reader, to do some work. Every so often comes a group of exercises, which you are supposed to do. Use \LaTeX\ to typeset everything in the exercise except sentences in italics, which are instructions. If you are not satisfied that you can do the exercise, then tell me. Either write to me at Queen Mary and Westfield College (my full address is given at the end of this article) with hard copy of your input and output, or email me at \mbox{\ttfamily r.a.bailey@qmw.ac.uk} with a copy of the smallest possible piece of \LaTeX\ input file that contains your attempt at the answer. In either case I will include a solution in the following issue of \BV: you will remain anonymous. A word on the controversial issue of fonts. Fonts in Mathematics are handled differently in \LaTeX\ 2.09, in NFSS, and in the new standard \LaTeX, \LaTeXe. Rather than compare these systems every time that I mention fonts, I limit myself to \LaTeX\ 2.09. When you upgrade to \LaTeXe, all these commands will still work, so long as you use the standard styles \latexword{article}, \latexword{report} and \latexword{book}. \addtocounter{section}{1} \section{What does it mean?} \subsection{Arrows} Arrows are relations. Four of them are \[ \begin{tabular}{cc@{\qquad}cc} \verb!\leftarrow! & $\leftarrow$ & \verb!\longleftarrow! & $\longleftarrow$\\ \verb!\Leftarrow! & $\Leftarrow$ & \verb!\Longleftarrow! & $\Longleftarrow$ \end{tabular} \] and eight others can be obtained by replacing {\tt left} by {\tt right} (all versions) or by {\tt up} or {\tt down} (not the long ones). A full list is given on page~45 of \shortlamp. Because of its frequent use in defining functions, \verb+\rightarrow+ has the short alternative name \verb+\to+. It should not be confused with \verb+\mapsto+, which is also used in defining functions. \begin{quote} \verb+x\mapsto g^{-1}xg+ \qquad $x\mapsto g^{-1}xg$ \end{quote} The relation \verb+\iff+, which does indeed stand for the relation `iff', is not quite the same as \verb+\Longleftrightarrow+: it has a little more space on either side. \[ \begin{tabular}{c} \verb!gh^{-1} \in K \iff g \in Kh! \\ $gh^{-1} \in K \iff g \in Kh$ \end{tabular} \] \subsection{Fences} Mathematical typesetters use the word \emph{fence} for anything like a bracket that comes with a mate to enclose part of a formula. \TeX\ calls them \emph{ delimiters}. Obvious examples are parentheses, brackets and braces, produced with \verb+(+, \verb+)+, \verb+[+, \verb+]+, \verb+\{+ and \verb+\}+ respectively. Angle brackets are produced with \verb+\langle+ and \verb+\rangle+: \begin{quote} \verb+\langle u,v \rangle+ \qquad $\langle u,v \rangle$ \end{quote} Don't try to use the keyboard symbols \verb+<+ and \verb+>+ for this: apart from the fact that they do not look right in typeset Maths, \torl\ does not think that they are fences and may well split the line between the $<$ and the~$u$. Use \verb+\lfloor+, \verb+\rfloor+, \verb+\lceil+ and \verb+\rceil+ to obtain `floor' and `ceiling': \begin{quote} \verb+\lceil 3.75 \rceil = 4+ \qquad $\lceil 3.75 \rceil =4$ \end{quote} Other fences are shown on page~48 of \shortlamp. Fences need to grow to enclose large formulas. They will automatically grow to the correct size if you preface the opening fence with \verb+\left+ and the closing fence with \verb+\right+. The \verb+\left+s and \verb+\right+s must come in properly matching pairs, but the fences which they qualify need not obviously match. Compare \begin{quote} $\frac{1}{n} \in (0,1]$ \quad with \quad $\frac{1}{3} \in \left( 0, \frac{1}{2} \right]$: \end{quote} the second half-open interval is produced with \begin{verbatim} \left( 0, \frac{1}{2} \right] \end{verbatim} The solidus \verb+/+ is really a binary operator, but it is treated by \TeX\ as a fence, partly because traditional typesetters do not put the same amount of space around it as they do around other binary operators, partly because it needs to grow when it is between two tall formulas. But it can't grow unless it is matched with another fence, and it doesn't need one. So \TeX\ makes the full stop into an invisible fence (called the \emph{null delimiter}) when it is preceded by \verb!\left! or \verb!\right!. %provides the invisible fences \verb+\left.+ and \verb+\right.+\nobreak\,: \[ \begin{tabular}{c} \verb!a(b+c) \left / \frac{1}{xy} \right.! \\[2\jot] $\displaystyle a(b+c) \left / \frac{1}{xy} \right.$ \end{tabular} \] How would the above expression be different if you typed \verb!\left. a(b+c) \right /! \ldots? Sometimes you need to use \verb+\left+ and \verb+\right+ just to tell \TeX\ that you are using fences, even if you do not need them to change size. A good example is $\left|\phantom{A}\right|$ used for the modulus or cardinality functions. If you type \verb!|+3|!, \TeX\ will typeset the first~$|$ as if it is being added to the~$3$. \[ \begin{tabular}{c@{\qquad}c} \verb!| +3 |! & $| +3 |$\\ \verb!\left| +3 \right|! & $\left| +3 \right|$ \end{tabular} \] \subsection{Standard functions with English names} Some standard functions have written names with two or more letters, based on their full English name. An example is $\cos$ for `cosine'. It is no good simply typing \verb+cos+, for then the output will look like $c$~multiplied by $o$ multiplied by~$s$. So there are standard commands such as \verb+\cos+, \verb+\sin+, \verb+\log+, \verb+\exp+ and \verb+\dim+. \begin{quote} \verb!\cos\pi = -1! \qquad $\cos\pi = -1$ \end{quote} The following ten standard functions \[ \begin{tabular}{ccccc} \verb+\max+ & \verb+\sup+& \verb+\limsup+ & \verb+\lim+ & \verb+\det+ \\ \verb+\min+ & \verb+\inf+ & \verb+\liminf+ & \verb+\gcd+ & \verb+\Pr+ \end{tabular} \] can have expressions above and/or below them to show what range of variables they apply to: these are typed in as if they were super- or subscripts. \[ \begin{tabular}{c} \verb!\lim_{x \to 0} \frac{\sin x}{x} = 1! \\[2\jot] $\displaystyle\lim_{x \to 0} \frac{\sin x}{x} = 1$\\[4\jot] \verb!\max_{i=1}^{n} \theta_i! \qquad $\displaystyle\max_{i=1}^{n} \theta_i$ \end{tabular} \] In displayed Maths the range expressions come above and below the name of the standard function; in text they come somewhat to the right: $\max_{i=1}^{n} \theta_i$. The standard function `modulo' has two forms: \[ \begin{tabular}{ll} \verb!7 = 10 \bmod 3! & $7 = 10 \bmod 3$\\ \verb!7 = 10 \pmod 3! & $7 = 10 \pmod 3$ \end{tabular} \] The remaining standard functions are listed on page~46 of \shortlamp. \subsection{Large repeated binary operators} When a binary operator is commutative and associative it often has a a special symbol to show its repeated application: $\sum$ for repeated~$+$, $\bigcap$ for repeated~$\cap$, and so on. Some of these have special commands in \TeX: \[ \begin{array}{cc@{\qquad}cc@{\qquad}cc} \verb!\sum! & \sum & \verb!\bigcap! & \bigcap & \verb!\bigoplus! & \bigoplus\\ \verb!\prod! & \prod & \verb!\bigcup! & \bigcup & \verb!\bigotimes! & \bigotimes \end{array} \] (Note that the operator \verb+\sum+ is \emph{not} the same as the Greek letter \verb+\Sigma+.) More are shown on page~45 of \shortlamp. Each of these has two sizes: the big one is used in displayed Maths (except inside arrays and fractions) and the small one is used in text. Each can also take sub- and superscripts to show the range of operation: as with the ten listed standard functions, these sub- and superscripts appear above and below the operator in displayed Maths (except inside arrays and fractions) and a little to the right otherwise. \[ \begin{tabular}{c} \verb!x_1 + \cdots + x_n = \sum_{i=1}^{n} x_i! \\[2\jot] $\displaystyle x_1 + \cdots + x_n = \sum_{i=1}^{n} x_i$ \end{tabular} \] \[ \begin{tabular}{c} \verb!M_1 \vee\cdots\vee M_t = \bigvee_1^t M_i! \\[2\jot] $\displaystyle M_1 \vee \cdots \vee M_t = \bigvee_1^t M_i$ \end{tabular} \] But in text: $\alpha_1 \alpha_2 \ldots \alpha_m = \prod_{j=1}^{m} \alpha_j$. \subsection{Integrals} There are two integral signs: \[ \begin{tabular}{cc@{\qquad}cc} \verb!\int! & $\displaystyle \int$ & \verb!\oint! & $\displaystyle \oint$ \end{tabular} \] These behave somewhat like the large repeated operators in that they have a larger size in displayed Maths and their limits are typed in as sub- and superscripts. However, these limits stay in the same position even in displayed Maths. %Alan, this is a deliberate lie, OK? \subsection{More symbols} There are some miscellaneous Mathematical symbols that we have not covered elsewhere. Important ones include: \[ \begin{tabular}{cc@{\qquad}cc@{\qquad}cc} \verb!\emptyset! & $\emptyset$ & \verb!\forall! & $\forall$ & \verb!\Box! & $\Box$\\ \verb!\infty! & $\infty$ & \verb!\exists! & $\exists$ & \verb!\partial! & $\partial$ \end{tabular} \] More are shown on page~45 of \shortlamp. Unfortunately, some of these, such as \verb+\Box+, are not standard in the new standard \LaTeX. To continue using such symbols after you have upgraded, you must include the package \latexword{amsfonts}, if available, or the package \latexword{latexsym}. Some operators and relations have been similarly banished, and can be rescued in just the same way. \subsection{Punctuation} In Maths mode, \torl\ treats a full stop as an ordinary symbol, so that decimal points look right. However, the comma and semi-colon are treated as punctuation, and get a little space after them, but not so much as the space they usually get in text. To suppress the space, put the comma or semi-colon in a pair of braces. The colon is treated as a relation, because of its frequent use in defining sets. To obtain a colon as a piece of punctuation, type \verb+\colon+. Many people think that the punctuation form is more correct for defining functions. \subsection{Braces for grouping} Grouping has two extra properties in Maths mode. In the first place, it can prevent line-breaking. \torl\ is usually very good at knowing where to break a line within a Mathematical expression, but it doesn't always do it exactly to your liking. For example, in Exercise~7 in the first tutorial, one equation was broken after a $+$~sign, leaving the single character~$\varepsilon$ on the next line. This could have been prevented by enclosing the whole right-hand side of the equation in braces: \TeX\ never breaks a line between grouping braces in Maths mode. Use this force sparingly: the more line breaks that you ban the harder is it for \TeX\ to build beautiful paragraphs. The second property is more subtle: injudiciously placed grouping braces can destroy \TeX's fine knowledge of what is a relation, an operator etc., and thus prevent it from applying the proper spacing. \verb!2{+3}! is not the same as \verb!2+3! and neither is \verb!2{+}3!; while \verb!{}-4! is different from \verb!-4!. Likewise, \verb!{\cos} \theta! is not the same as \verb!\cos \theta!: the former turns \verb!\cos! from an operator into a symbol. Some \TeX ies recommend always putting \verb!{}! after a command with no argument. That advice can be disastrous in Maths mode. Look at \begin{quote} \verb!\sum{}_{1}^{3} y_j! \qquad $\displaystyle\sum{}_{1}^{3} y_j$ \end{quote} and compare \[ \begin{tabular}{ll} \verb!k \geq{} -b! & $k \geq{} -b$\\ \verb!k \geq -b! & $k \geq -b$ \end{tabular} \] In the first example the sub-and superscripts have been placed on the \verb!{}!, not on the \verb!\sum!: in particular, they do not move to the correct place in displayed Maths. In the second, the minus sign has become a binary operator between \verb!{}! and~$b$ instead of a unary operator on~$b$. This apparently awkward property of braces can be turned to advantage when \TeX's first interpretation is not the correct one, as we have already seen in some examples. \subsection{Ties} The tie~\verb!~!, which prevents line breaks both within and without Maths mode, can be used to make your Mathematical text easier to read. A piece of notation consisting of a single letter or symbol should almost always be tied to one of its neighbours. If the notation names a noun, tie it to the noun: \verb!group~$G$! and \verb!element~$h$!. If it is the subject or single direct object of a verb, tie it to the verb: \begin{verbatim} If $v$~annihilates~$W$ then ... \end{verbatim} If it follows a preposition, tie it to the preposition: \verb!of~$\Lambda$!, \verb!in~$T$!, \verb!onto~$Y$!. If an adjective qualifies it, tie it to the adjective: \verb!positive~$\delta$!. A notational adjective, particularly a number, should be tied to its following noun: \verb!$n$~points!, \verb!$21$~lines!. Be careful about the beginnings and ends of lists: \begin{verbatim} Only one of $A$, $B$ and~$C$ occurs ... For $i=1$, $2$, \ldots,~$n$, put ... \end{verbatim} Finally, use a tie if a small piece of notation ends a sentence, to prevent a line beginning something like \begin{quote} $B$. Therefore \ldots \end{quote} which makes it look like the second item in a list. Try to get in the habit of inserting these ties when you first type the text: don't leave them until you see bad line-breaks. Of course, like all rules in typography, some of the above rules conflict, so you have to use common sense about which ones to follow. Also, there will always be times when the paragraph simply cannot be broken into lines nicely if all the ties are observed: wait until the final run and then relax the least important ones. \section*{Exercises} \addtocounter{preqn}{10} \begin{qn} The function $f\colon Z\to Z$ defined by $f\colon n\mapsto n^2$ is neither injective nor surjective. However, the function $g\colon R^+ \to R^+$ given by $g(x) = \sqrt[7]{x}$ is both. \end{qn} \begin{qn} If $\{x_1, \ldots, x_n\}$ and $\{y_1, \ldots, y_m\}$ are bases for $\cal X$ and $\cal Y$ respectively then \[ \left\{x_i\otimes y_j: \mbox{$i=1$, \ldots, $n$, $j=1$, \ldots, $m$}\right\} \] is a basis for ${\cal X}\otimes {\cal Y}$. \end{qn} \begin{qn} If $A = \{n\in N: \mbox{$n$ is prime}\}$ and if $B = {\{n\in N: \mbox{$n$ is even}\}}$ then $\left|A\cap B\right|=1 $. \end{qn} \begin{qn} If $z$ is any real number then $\left|+z\right| = \left|-z\right|$. \end{qn} \begin{qn} {\it Express the following use large binary operators instead of dots. Try them both in text and in display.} \[ \begin{array}{ll} x_1 + \cdots + x_{153} & 1 + 2 + \cdots +r \\ 1 + 1/2 + 1/4 + \cdots & p \times (p-1) \times \cdots \times 1 \\ {\cal U}_1 \otimes \cdots \otimes {\cal U}_m & T_4 \cup T_6 \cup \cdots \cup T_{10}\\ \mbox{the sum of $\gamma$ for $\gamma\in\Gamma$} & P_1 \wedge \cdots \wedge P_r \end{array} \] \end{qn} \begin{qn} \[ \prod_{k\ge 0} \frac{1}{(1 - q^kz)} = \sum_{n\ge 0} z^n \left / \prod_{1\le k\le n} (1 - q^k) \right. \] \label{dek} \end{qn} \begin{qn} {\it Redo Exercise~3 from the first tutorial without using built-up fractions. You may want to change the way the square root is shown.} \end{qn} \begin{qn} \[ \sum_{n=1}^{N} n^3 = \left(\frac{N(N+1)}{2}\right)^2 \] \end{qn} \begin{qn} $\int_1^2 \frac{1}{x}dx = [\log x ]_1^2 = \log 2$. \end{qn} \begin{qn} $\lim_{n\to \infty} (1 + \frac{x}{n})^n = \exp (x)$. \end{qn} \begin{qn} If $Z$ is a normal random variable with mean~$\mu$ and variance $\sigma^2$ then \[ \Pr (Z < x) = \int_{-\infty}^{x} \frac{1}{\sqrt{2\pi}\sigma} \exp \left(-\frac{(x-\mu)^2}{\sigma^2}\right). \] \end{qn} \begin{qn} \[\frac{\partial {\rm e}^{-xt}}{\partial t} = -x{\rm e}^{-xt}.\] \end{qn} \end{Article}