\def\Cite#1{[\cite{#1}]} %%% %%% An article for Baskerville, intended to be the third of n parts %%% \title[Maths in \LaTeX: Part~3]{Maths in \LaTeX: Part~3, Different Sorts of Mathematical Object} \author[R. A. Bailey]{R.~A.~Bailey\\ Queen Mary and Westfield College, University of London} \newcommand{\writer}[1]{{#1}:} \newcommand{\book}[1]{{\it #1},} \newcommand{\publish}[2]{{\rm #1, #2,}} \newcommand{\byear}[1]{{\rm (#1).}} \newtheorem{preqn}{Exercise} \newenvironment{qn}{\begin{preqn}\normalfont\rm}{\end{preqn}} %%% Dear Mr Editor, I should like the content of exercises %%% to come out in what all copy-editors call ROMAN, not in what %%% Frank Mittelbach calls roman. And this should be irrespective %%% of the surrounding text. %%% \newcommand{\latexword}[1]{{\normalfont\tt #1}} \newcommand{\lamport}{{\it \LaTeX: A Document Preparation System\/} by Leslie Lamport} \newcommand{\shortlamp}{{\it The Manual}} %%% \begin{Article} \section{Recall} This is the third in a sequence of tutorials on typesetting Mathematics in \LaTeX. The first two appeared in issues~4.4 and~4.5 of \BV. The series includes some things which can be found in \Cite{leslie}, but I am working in more things which, while straightforward and necessary for Mathematical work, are not in \Cite{leslie} or \Cite{newleslie}. In case you missed the first two tutorials, 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 \begin{verse} School of Mathematical Sciences\\ Queen Mary and Westfield College\\ Mile End Road\\ London E1 4NS \end{verse} with hard copy of your input and output, or email me at \mbox{\tt 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 if you wish. 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 usually 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}. In the `Answers' section below I expand a little on the dangers of using the font-changing commands given in [\cite[Section~3.1]{newleslie}]. Many of the more complicated Mathematical things in this tutorial are not documented in \Cite{leslie} or in \Cite{newleslie}. The \LaTeX\ team warns me that they feel no obligation to support commands that are not in \Cite{newleslie}, so there is a danger that some of these things may change. However, everything given here works, in both \LaTeX\ 2.09 and in \LaTeXe, as at January 1995. Some of the tricks described in this tutorial are at the edge of what you can conveniently do without using the \latexword{amstex} package. That package is undergoing change at the moment: I hope that by the time I reach the end of this sequence of tutorials the \latexword{amstex} package will have stabilized enough for someone to write an article explaining how to use it, including giving better methods than I can give here. \section{Answers} I promised to answer all questions arising from this series of articles (as far as I can). \subsection{Uneven subscripts} In \BV~4.5 Malcolm Clark asks about uneven baselines in subscripts. He gives a method of ensuring that all subscripts have the same baseline. I think that many Mathematical writers will not require that; nonetheless, some of us are uncomfortable with the unevenness in a single term such as \[ 4z_1z_2^3 \] The easy way around this is to put a dummy superscript on the $z_1$, because it is the superscript on the $z_2$ that is pushing the $2$ down: thus \begin{quote} \verb+4 z_1^{} z_2^3+ \qquad $4 z_1^{} z_2^3$. \end{quote} \subsection{Roman text in notation} He also muses on whether to use \verb+\textrm+ or \verb+\mathrm+ or \verb+\rm+ in subscripts, if you are using \LaTeXe. My advice is never to use \verb+\textrm+ in Mathematical notation. In the first place, \verb+\textrm+ does {\em not\/} give you roman type, according to such expert references as \Cite{hart,chamb,chicago}, all of whom say that `roman' type is upright, as opposed to italic. All that \verb+\textrm+ does is give you back serifs and proportional spacing, if you had turned them off. Perhaps he meant \verb+\textup+. But, secondly, I don't think that you should use {\em any\/} of the commands \verb+\text...+ in Mathematical notation, because their effect depends on the surrounding text font but notation should be independent of the surrounding text. For example, try the following and compare the output: \begin{verbatim} {\rm $x_{\textup{big}} + \textup{size}_3$} {\bf $x_{\textup{big}} + \textup{size}_3$} {\bf $x_{\textrm{big}} + \textrm{size}_3$} \end{verbatim} %{\rm $x_{\textup{big}} + \textup{size}_3$} %{\bf $x_{\textup{big}} + \textup{size}_3$} %{\bf $x_{\textrm{big}} + \textrm{size}_3$} Malcolm was concerned because he wanted to obey the instruction in \Cite{companion} to always use commands like \verb+\textit{...}+ rather than switches like \verb+\it+. The trouble with that instruction is %In fact, I disagree quite strongly with the suggestion in \Cite{companion} that %we should refrain from using commands like \verb+\rm+. that the new commands \verb+\text...+ all work in a relative way. In my experience of writing (a lot of) Mathematics I have {\em never\/} needed such a relative change. I always need to specify my fonts absolutely, so that, say, the font chosen for long names of variables to be analysed does not change as the surrounding text font changes. Of course, it is sensible to do this with a macro such as \verb+\variablename+; but that macro needs to call something with a syntax similar to \verb+\textsl{...}+ but which makes an absolute font change. I tried to persuade the \LaTeX\ team to include commands like \verb+\basesl{...}+, \verb+\basett{...}+ for such absolute changes, but I failed. Since the team wants to reserve the right to remove switches like \verb+\tt+ at some future time, this means that most of us will have to write our own macros, with our own idiosyncratic names, something like the following: \begin{verbatim} \DeclareTextFontCommand{\basett}% {\normalfont\ttfamily} \end{verbatim} %\newcommand{\basett}[1]% % {{\normalfont\ttfamily #1}} \subsection{Spaces in subscripts} Malcolm also asked how to get spaces into subscripts. If I need to put a verbal phrase in a subscript then I use \verb+\rm+ and put in the interword spaces by hand. \begin{quote} \begin{tabular}{c} \verb+\sum_{p{\rm\ is\ prime}} \frac{1}{p}+\\[\jot] $\displaystyle\sum_{p{\rm\ is\ prime}} \frac{1}{p}$ \end{tabular} \end{quote} \subsection{Empty set} Kathleen Lyle has queried the symbol I gave last time for the empty set, with the command \verb+\emptyset+. She points out that \Cite{companion} shows a different symbol given by this command, a symbol which looks like a circle with a diagonal line through it and which is much closer to a Mathematician's idea of the empty set than is~$\emptyset$. But \Cite{companion} also gives the command \verb+\varnothing+, available with the package \latexword{amssymb}, which produces the symbol~$\emptyset$. It appears that Knuth made a mistake in using the name \verb+\emptyset+ for the glyph which most of us think of as a variant form of zero. To correct this mistake, the AMS has redefined the command \verb+\emptyset+ to produce the symbol more like the empty set and given us \verb+\varnothing+ for the sake of those authors who really do want a zero with a line through it. It is a pity that \Cite{companion} does not say that its \verb+\emptyset+ is the AMS one rather than the Knuth one. What to do when a software author makes a mistake like this is a controversial question. Personally, much as I prefer the AMS's empty set, I deplore such redefinition of a command, because it destroys portability of documents. Suppose that I write a document without the \latexword{amssymb} package and use \verb+\emptyset+. I may send this document to someone (perhaps the AMS itself\/) who always uses the \latexword{amssymb} package when compiling documents. Even though I have made no explicit calls to commands defined by the package, my empty sets will come out looking different. A topologist may be content with the change; a computer scientist may not. In either case the document is printed with different symbols in the two cases, and this really should not happen. I think that it would have been better if the AMS had used a different name, such as \verb+\trueemptyset+, for their empty set: then authors with access to the \latexword{amssymb} package could choose whether or not to include \begin{verbatim} \renewcommmand{\emptyset}{\trueemptyset} \end{verbatim} at the start of their files. \addtocounter{section}{2} \section{A Spaced-out Interlude} \subsection{Quads} Traditionally, there are certain lengths of space (depending on the type size) which are always used in certain places in Mathematical typesetting. The most useful are the {\it quad\/} space and the two-quad space. When I was a copy-editor I used to just put the marks for these two types of space in the appropriate places in the copy; I did not have to know how big they were. Neither do you. In displayed Maths, use \verb+\qquad+ to obtain a two-quad space between a formula and a short verbal condition or justification. \begin{verbatim} y \in Y \qquad\mbox{by defintion of~$Y$} \end{verbatim} If there are two short formulas linked in a display by a short verbal phrase (perhaps only one word) use \verb+\quad+ to produce a quad space on either side of the phrase. \begin{verbatim} A \subseteq B \quad\mbox{and}\quad A \ne B \end{verbatim} \subsection{Other Spaces} A sequence of much smaller horizontal spaces that you can insert yourself is, in increasing order of magnitude, \begin{quote} \verb+\,+ \quad \verb+\:+ \quad \verb+\;+ \quad \verb*+\ + \end{quote} %\begin{quote} %a \thinspace b \medspace c \thickspace d %rubbish, the last two don't exist %\end{quote} They are called {\it thin space}, {\it medium space}, {\it thick space\/} and {\it interword space\/} respectively; their size also depends on the current type size. The thin space is usually needed after the \verb+!+ in factorials and often needed after a square root. \begin{quote} \begin{tabular}{cc} \verb+\sqrt{3} \, a+ & $\sqrt{3} \, a$\\ \verb+5!\,4!+ & $5!\,4!$ \end{tabular} \end{quote} It is also used before each $dx$~term in an integral. On the other hand, in multiple integrals the integral signs may be too far apart, in which case the {\it negative\/} thin space \verb+\!+ should be inserted between them. For consistency, these adjustments should all be made via macros. For example, \begin{verbatim} \newcommand{\sqrtsp}[1]{\sqrt{#1}\,} \end{verbatim} will make \verb+\sqrtsp+ into the command for a square root with a little extra space, and a macro for factorials can be made similarly. For the integral signs you can use \begin{verbatim} \newcommand{\intt}{\int\!} \end{verbatim} or the rather different solution provided in \latexword{amstex}. A suitable macro for the $dx$ is \begin{verbatim} \newcommand{\diff}[1]{\, d #1} \end{verbatim} which has the added advantage that if you believe that only variables should be in Maths italic then the \verb+{\, d #1}+ can be changed to \verb+{\, {\rm d} #1}+. %These adjustments are all rather finicky, and should usually be left until the %document is almost complete. \subsection{Phantoms} The useful command \verb+\phantom+ allows you to leave a space whose horizontal and vertical dimensions are those of its argument. For example, if you want to define the notation $[\phantom{x}]$ as the least-integer function without specifying a dummy variable, you can type \verb+[\phantom{x}]+. All digits are the same width, so \verb+\phantom{0}+ produces a phantom digit. It is very useful in tables of data when all other methods of alignment fail. Make yourself a macro for it. There are also horizontal and vertical phantoms \verb+\hphantom+ and \verb+\vphantom+ respectively. Each of these measures only one dimension of its argument. \subsection{Horizontal Expanders} In the first tutorial we saw that \verb+\widehat+ and \verb+\widetilde+ expand as far as necessary (up to a given upper bound) to cover their arguments. The following commands also expand horizontally to match the arguments: \begin{quote} \begin{tabular}{cc} \verb+\overline+ & \verb+\underline+\\ \verb+\overrightarrow+ & \verb+\overleftarrow+\\ \verb+\overbrace+ & \verb+\underbrace+ \end{tabular} \end{quote} You can use a superscript to put a label on an overbrace, and a subscript with an underbrace. \begin{verbatim} n\bar{y}^2 + \overbrace{(y_1-\bar{y})^2 + \cdots + (y_n-\bar{y})^2}^{\rm sum\ of\ squares} \end{verbatim} \[ n\bar{y}^2 + \overbrace{(y_1 - \bar{y})^2 + \cdots + (y_n - \bar{y})^2}^{\rm sum\ of\ squares} \] \section{Exercises} \addtocounter{preqn}{22} \begin{qn} \[(x_1 + x_2)^3 = x_1^3 + 3x_1^2x^{}_2 + 3x_1^{}x_2^{2} + x_2^3\] \end{qn} \begin{qn} \[\sum_{n\ {\rm divides}\ 10} n = 18\] \end{qn} \begin{qn} In geometry, $\overrightarrow{AB} + \overrightarrow{BC} = \overrightarrow{AC}$. \end{qn} \begin{qn} We define $P_g$ by \[t(vP_g) = (t^{g^{-1}})v \qquad\mbox{for $v\in {\bf R}^{\cal T}$.}\] \end{qn} \begin{qn} \[ 2^a \times 2^b = \underbrace{2 \times \cdots \times 2}_{a\ \rm factors} \times \underbrace{2 \times \cdots \times 2}_{b\ \rm factors} = 2^{a+b}. \] \end{qn} \begin{qn} An inner product $\langle\phantom{\chi},\phantom{\chi}\rangle$ is defined on~$G^*$ by \[ \langle\theta,\phi\rangle = \frac{1}{|G|}\sum_{g\in G} \theta(g) \overline{\phi}(g). \] \end{qn} \begin{qn} If~ $\overline{\phantom{\chi}}$ denotes complex conjugation, then \[ \overline{\xi + \zeta} = \overline{\xi} + \overline{\zeta}\quad\mbox{and}\quad \overline{\xi\zeta} = \overline{\xi}\,\overline{\zeta}. \] \end{qn} \begin{qn} \[ \int \! \int \phi(r, \theta) \, dr \, d\theta \] \end{qn} \begin{qn} \[ {}^6 C_2 = \frac{6!}{4!\,2!} \] \end{qn} \section{Operators and relations} \subsection{Limits} In the second tutorial I introduced various things that could have their limits, or ranges, typed in as sub- and super-scripts: standard functions with English names, like \verb+\log+; repeated binary operators, like \verb+\sum+; and the integral sign \verb+\int+. \TeX\ thinks of all of these as \latexword{operator}s. Some operators have the limits set above and below in dispayed Maths, but to the right in text; others always have their limits set to the right. You can override these defaults by using one of the commands \verb+\limits+, \verb+\nolimits+, \verb+\displaylimits+ after the name of the operator. The integral sign normally has its limits set to the right: if you want them set above and below type \verb+\int\limits+. \[ \begin{tabular}{cc} \verb+\int_0^2 x^3 \, dx=4+ & $\int_0^2 x^3 \, dx = 4$\\[\jot] \verb+\int\limits_0^2 x^3 \, dx=4+ & $\int\limits_0^2 x^3 \, dx = 4$ \end{tabular} \] If you want the limits to be above and below if the operator happens to be in displayed Maths, but to the right otherwise, use \verb+\displaylimits+ instead of \verb+\limits+. Finally, to ensure that the limits always come to the right, use \verb+\nolimits+. If you want to change the size of the operator as well as the position of its limits, you probably need to see the section on styles below. \subsection{Operators} The standard functions with English names already provided by \TeX\ cannot be enough for the whole of Mathematics. You make new ones by using \verb+\mathop+, usually inside a \verb+\newcommand+. For example, \begin{verbatim} \newcommand{\var}{\mathop{\rm Var}\nolimits} \var X \geq 0 \end{verbatim} \newcommand{\var}{\mathop{\rm Var}\nolimits} \[\var X \geq 0\] (If you have \LaTeXe, you may feel safer using \verb+{\mathrm{Var}}+ in place of \verb+{\rm Var}+.) You may put one of \verb+\limits+, \verb+\nolimits+, \verb+\displaylimits+ after the contents of the \latexword{mathop}, to specify how sub- and super-scripts should behave. Putting nothing is equivalent to putting \verb+\displaylimits+. There is a school of thought that all operators should be in the same font, so that the \verb+\rm+ in the definition of \verb+\var+ should be replaced by a command like \verb+\operatorfont+, which would, of course, be defined in the style file or in the preamble to the document. I do not agree with this. It is not at all unusal to use bold for the expectation operator while retaining roman for the variance. If you make a single letter into an \latexword{operator}, it will be vertically centred, which may not be what you intend: \begin{verbatim} \newcommand{\ee}{\mathop{\rm E}\nolimits} \[\ee X + \ee Y = \ee(X+Y)\] \end{verbatim} \newcommand{\ee}{\mathop{\rm E}\nolimits} \[\ee X + \ee Y = \ee(X+Y)\] To override this, put the single letter in a box: \begin{verbatim} ...\mathop{\mbox{\rm E}}... \end{verbatim} \subsection{Novel uses of operators} In the first tutorial I said that you did not need to think of the symbol~\verb+'+ as a superscript. Usually you do not, but \TeX\ always does, so you occasionally get unexpected results. You might want to write $\mathop{\sum\nolimits'}$ for a variant of the usual summation, perhaps to indicate omission of all~$i$ for which $\lambda_i=0$, as in \[\mathop{\sum\nolimits'}_{i=1}^n \frac{1}{\lambda_i} P_i.\] If you use \verb+\sum'+ it will come out as \[\sum'\] in display, %\[\sum'_{0}^{m}\] and even worse things happen when you try to put limits on. Writing \verb+\sum\nolimits'+ cures the problem about placing the dash, but then you no longer have an \latexword{operator} to put limits on. So you need to make the whole of $\sum\nolimits'$ into an \latexword{operator}: \begin{verbatim} \newcommand{\summ}{\mathop{\sum\nolimits'}} \[\summ_{i=3}^{7}\] \end{verbatim} \newcommand{\summ}{\mathop{\sum\nolimits'}} \[\summ_{i=3}^{7}\] If you look closely you will now see that the limits are centred on the whole of $\summ$. This is logical, but may not be exactly what you intended. I do not know how to do the illogical but more aesthetically pleasing version, but a method is provided in \latexword{amstex}. Sometimes you want to put a range of summation under (or over) the middle of a pair of summation signs. Do this by turning the pair of summation signs into an \latexword{operator}: \begin{verbatim} \newcommand{\twosum}{\mathop{\sum\sum}} \[\twosum_{1