\chapter{The Basics} \label{basics} This chapter describes the basic text-producing commands, environments and declarations. Most of these commands specify the logical structure of the text and leave the formatting to \LATEX. However, commands for telling \LATEX{} what typeface to use and how to do some simple formatting, like centering text, are also included. Remember that, as described in Section~\ref{decls}, any declaration can be used as an environment. \section{Changing the Typeface}\label{typeface} As I explained in Section~\ref{modes}, \TEX{} translates an ordinary \index{ordinary printing character} printing character like \xsp{}{\tt A}\xsp{} into a glyph. Whether it's translated into the glyph \xsp{}A\xsp{} or the glyph \xsp{}{\large\it A\/}\xsp{} depends upon the \index{typeface}typeface. You specify a typeface by giving the \index{type size}\index{size,type}size and the \index{type style}\index{style, type} style. {\it For example, this sentence is printed in 10-point italic.} The {\it 10-point\/} is the size, a {\it point\/} being a unit of length used by printers, and {\it italic\/} is the style. A typeface is also called a \index{font}{\it font.} \subsection{Specifying the Type Style}\label{type-style} Below is a list of the type styles available with \LATEX and the declarations for obtaining them. They work like the \verb"\bf" command for generating boldface, which you've already seen in Section~\ref{decls}. Note that, like \verb"\bf", the type-style declaration commands all have two-letter names. \begin{description}{{\tt \bs ww}:} \item[{\tt \bs rm}:]\index{roman}\index{!rm} Roman. This is an example of the Roman typeface; it is the typeface ordinarily used by \LATEX. \item[{\tt \bs it}:]\index{italic}\index{!it} {\it Italic. This is an example of the italic typeface.} \item[{\tt \bs bf}:]\index{boldface}\index{!bf} {\bf Boldface. This is an example of the bold typeface.} \item[{\tt \bs sl}:]\index{slanted}\index{!sl} {\sl Slanted. This is an example of the slanted typeface.} \item[{\tt \bs sf}:]\index{sans serif}\index{!sf} {\sf Sans serif. This is an example of the sans serif typeface.} \item[{\tt \bs sc}:]\index{small caps}\index{!sc} {\sc Small caps. This is an example of the small caps typeface.} \item[{\tt \bs tt}:]\index{typewriter typeface}\index{!tt} {\tt Typewriter.\ This is an example of the typewriter type\-face.} \end{description} The \verb"\rm" command may seem useless, since Roman is what you get when you don't specify any other typeface. However, you can type \verb"{\rm word}" to make just the ``word'' appear in Roman in the middle of a boldface or italic sentence. There's one little trick you should know when using the italic and slanted fonts in order to produce the finest quality output. Examine closely the word \xsp{}\mbox{{\it did}n't\xsp}, which I produced by typing \verb"{\it did}n't". Notice how the slanting \xsp{}{\it d}\xsp{} of \xsp{}{\it did}\xsp{} bumps into the \xsp{}n\xsp{} of \xsp{}\mbox{n't\xsp}. To prevent this, you have to add some extra space after \xsp{}\mbox{\it did\xsp}. The \verb"\/"\index{!/} command adds just the right amount of extra space. You type \verb"{\it did\/}n't" to produce \xsp{}\mbox{{\it did\/}n't\xsp}, which looks much nicer. It's a good idea to use the \verb"\/" whenever switching back from an italic or slanted typeface to an upright one like Roman. The one exception is that you shouldn't put the \verb"\/" right before a period\index{period} or \index{comma}comma. \yspace \noindent {\bf Warning:} If you use a type-style-changing command in math \index{math mode, type-style changing} mode, then the scope of that command should end before \TEX{} ``climbs the stairs'' leading it out of math mode. What this means is that any style-changing command like \verb"\bf" in a math formula should always be enclosed in curly \index{braces} braces that lie within the formula. \subsection{Specifying the Type Size} \index{type size}\label{type-size} \subsubsection{The Normal Type Size}\label{normal-size} Printers specify type size in points\index{points}, where 24-point type is twice as big as 12-point type. The ordinary text of most books is, like this manual, set in 10-point type. It looks quite normal in a book, but you may find it rather small for your own reports and papers---especially if they're printed on standard $8{1\over2}''\times 11''$ paper. You might want to consider 11-point or 12-point type, illustrated in the following two paragraphs. \begin{elevenpt} This paragraph is set in \index{11-point type} 11-point type. You can get \LATEX{} to set your entire document in this size type by choosing an 11-point document \index{document style, 11-point} style. This is done by specifying the {\tt 11pt}\index{11pt substyle} substyle \index{document substyle} for the document style you've chosen. For example, you type \begin{verbatim} \documentstyle{article,11pt} \end{verbatim} in place of the ordinary \verb"\documentstyle" command to get the eleven-point version of the {\tt article} \index{article document style}style, and similarly for the {\tt report} style. Make sure that there are no spaces in the argument. \end{elevenpt} \begin{twelvept} This paragraph is set in 12-point \index{12-point type} type. You can get your entire document set in this type size by choosing the {\tt 12pt}\index{12pt substyle} substyle \index{document substyle} for the document style you've chosen. \end{twelvept} The {\tt 11pt} and {\tt 12pt} document substyles may change the line width and other parameters to produce a more aesthetically pleasing document. You shouldn't judge these type sizes by these two paragraphs, since they were produced with parameters chosen for 10-point type. Instead of specifying a substyle as part of the same \verb"\documentstyle" command, as in \begin{verbatim} \documentstyle{report,12pt} \end{verbatim} you can make it a separate \verb"\documentstyle" command, writing \begin{verbatim} \documentstyle{report} \documentstyle{12pt} \end{verbatim} The main style command, in this case {\tt report}, must come before the substyle command. \subsubsection{Additional Type Sizes} The document style defines the normal type size. \LATEX{} provides the following commands for producing text with different type sizes within the document. Here is what they produce in a 10-point document style; they will usually produce correspondingly larger type in an 11-point or 12-point document style. \begin{description}{{\tt \bs footnotesize}:} \item[{\tt \bs normalsize}:] \index{!normalsize}This is an example of the normal type size. \item[{\tt \bs large}:] \index{!large} \begin{large} This is an example of the large type size. \end{large} \item[{\tt \bs Large}:] \index{!Large} \begin{Large} This is an example of the Large type size. \end{Large} \item[{\tt \bs LARGE}:] \index{!LARGE} \begin{LARGE} This is an example of the LARGE type size.\vspace{4pt} \end{LARGE} \item[{\tt \bs huge}:] \index{!huge} \begin{huge} This is a huge type size.\vspace{4pt} \end{huge} \item[{\tt \bs small}:] \index{!small} \begin{small} This is an example of the small type size. \end{small} \item[{\tt \bs footnotesize}:] \index{!footnotesize} \begin{footnotesize} This is an example of the footnotesize type size. It is the type size normally used in footnotes. \end{footnotesize} \item[{\tt \bs scriptsize}:] \index{!scriptsize} \begin{scriptsize} This is an example of the scriptsize type size. It is the type size normally used in subscripts and superscripts. \end{scriptsize} \item[{\tt \bs tiny}:] \index{!tiny} \begin{tiny} This is an example of the tiny type size. It is the smallest type size provided. \end{tiny} \end{description} Each of these size-changing declarations switches to the Roman type style. Thus, if \TEX{} is currently using the \verb"\normalsize" type size, we have: \begin{verbatim} {\bf normal boldface {\large large Roman} back to normal boldface } \end{verbatim} Because the information needed to generate each typeface takes up valuable room inside \TEX, not all type styles are available in all sizes. Different computer systems may provide a different selection of typefaces. However, all styles should be available in the \verb"\normalsize", \verb"\small" and \verb"\large" sizes. If you request a typeface that's not available, \LATEX{} will produce an error with the following error indication. \begin{verbatim} ! Typeface not available. \end{verbatim} \yspace \noindent {\bf Warning:} If you want to typeset one or more entire paragraphs in a different type size, then you must be sure to end the scope of the size-changing declaration {\it after\/} the blank line \index{blank line} that ends the last paragraph in that size. For example, you should type \begin{verbatim} \begin{large} Beginning of large typeface paragraph ... ... end of large typeface paragraph. \end{large} \end{verbatim} Omitting the blank line before the \verb"\end{large}" command will produce funny-looking output. \yspace \noindent {\bf Warning:} Don't issue a size-changing \index{math mode, type-size changing} command in math mode. If you want to use a different type size for an entire mathematical formula, then put the entire formula in the scope of the size-changing command. If you want part of a formula to be in a different type size, then use an \verb"\mbox"\index{!mbox} in the formula and put the size-changing command inside the \verb"\mbox". \subsection{Accents and Special Symbols} \subsubsection{Accents} \index{accents} \label{accents} \TEX{} enables you to generate any kind of accent you're likely to need. Table~\ref{tab:accents} \begin{table}\centering \begin{tabular}{*{2}{ll@{\s{20pt}}}ll} \multicolumn{1}{c}{\underline{\it Type}} & \underline{\it to get} & \multicolumn{1}{c}{\underline{\it Type}} & \underline{\it to get} & \multicolumn{1}{c}{\underline{\it Type}} & \underline{\it to get}\\[2pt] \verb"\`{o}" & \`{o} & \verb"\={o}" & \={o} & \verb"\t{oo}" & \t{oo}\\ \verb"\'{o}" & \'{o} & \verb"\.{o}" & \.{o} & \verb"\c{o}" & \c{o}\\ \verb"\^{o}" & \^{o} & \verb"\u{o}" & \u{o} & \verb"\d{o}" & \d{o}\\ \verb#\"{o}# & \"{o} & \verb"\v{o}" & \v{o} & \verb"\b{o}" & \b{o}\\ \verb"\~{o}" & \~{o} & \verb"\H{o}" & \H{o} \end{tabular} \caption{Accents.}\label{tab:accents} \end{table} shows how to do it. The letter {\tt o} is used in the table, but you can replace it with any other letter. These accents work properly with all the usual type \index{type styles} styles except for the typewriter\index{typewriter} (\verb"\tt")\index{!tt} style. They can't be used in that style. The letters \xsp{}{\it \index{i, dotless}i\/}\xsp{} and \xsp{}{\it \index{j, dotless}j\/}\xsp{} need special treatment because they should lose their dots when accented---typing \xsp{}\verb"\'{i}"\xsp{} produces \xsp{}\'{i}\Xsp. The commands \xsp{}\verb"\i"\index{!i@}\xsp{} and \xsp{}\verb"\j"\index{!j@}\xsp{} produce a dotless \xsp{}{\it i\/}\xsp{} and \xsp{}{\it j}\Xsp, respectively, so typing \xsp{}\verb"\'{\i}"\xsp{} gives \xsp{}\'{\i}\Xsp. \subsubsection{Symbols} \index{symbols,nonmath} \label{nonm-sym} Table~\ref{tab:lig} shows how to make some of the special \index{special symbols} symbols\index{foreign symbols} used by Western languages other than \begin{table}\centering \begin{tabular}{*{2}{ll@{\s{20pt}}}ll} \multicolumn{1}{c}{\underline{\it Type}} & \underline{\it to get} & \multicolumn{1}{c}{\underline{\it Type}} & \underline{\it to get} & \multicolumn{1}{c}{\underline{\it Type}} & \underline{\it to get}\\[2pt] \verb"\oe" & \oe & \verb"\aa" & \aa & \verb"\l" & \l \\ \verb"\OE" & \OE & \verb"\AA" & \AA & \verb"\L" & \L \\ \verb"\ae" & \ae & \verb"\o" & \o & \verb"\ss" & \ss \\ \verb"\AE" & \AE & \verb"\O" & \O & & \\ \end{tabular} \caption{Foreign Symbols} \label{tab:lig} \end{table} English. These commands can appear in paragraph and LR modes. However, they won't work when a typewriter \index{typewriter} (\verb"\tt")\index{!tt} type style is in effect. There are a large number of mathematical symbols that can be used only in math mode. These are described in Section~\ref{math-symbols}. \TEX{} also provides five special symbols that can be used in any mode: \begin{center} \begin{tabular}{*{3}{ll}} \multicolumn{1}{c}{\underline{\it Type}} & \underline{\it to get} & \multicolumn{1}{c}{\underline{\it Type}} & \underline{\it to get} & \multicolumn{1}{c}{\underline{\it Type}} & \multicolumn{1}{c}{\underline{\it to get}}\\ \verb"\dag" & \dag & \verb"\S" & \S & \verb"\copyright" & \copyright \\ \verb"\ddag" & \ddag & \verb"\P" & \P & & \\ \end{tabular} \end{center} \section{Paragraph-Making Environments} \label{paragraph-making} \index{environments, paragraph-making} This section describes \LATEX{} environments for producing various kinds of paragraphs, used for quotations, poetry, etc. In all these environments, a blank line begins a new paragraph. This causes the appropriate amount of interparagraph vertical space to be inserted. The first line of a paragraph is indented in some environments, but not in others. The output generated by a paragraph-making environment starts on a new line, as does the output that follows the environment. Whether you should leave blank \index{blank lines, before and after environments} lines before and after the environment depends upon the logical structure of the document. Leave a blank line before the \verb"\begin" command unless the environment is logically part of the same paragraph as the preceding text; leave a blank line after the \verb"\end" command unless it is logically part of the same paragraph as the following text. \LATEX{} will automatically format the output to express this logical relationship. For example, it will put a normal paragraph indentation at the beginning of the following text if and only if there is a blank line after the environment. In some paragraph-making environments, like {\tt verse}, you want to specify when to end a line and begin a new one. The standard command for telling \LATEX{} to end a line is \index{!cr}\verb"\\". Spaces before and after the \verb"\\" command have no effect. See Section~\ref{cr} on page~\pageref{cr} for a complete description of this command, including variants for adjusting the interline \index{interline spacing} spacing and preventing \index{page breaking, preventing} page breaking. The \verb"\\" command has both a {\tt *}-form and an optional argument, so remember the anomalies discussed in Section~\ref{command-names}. The \verb"\\" command separates lines; it is not used after the last line of the environment. Two successive \verb"\\" commands should never appear with no intervening text. To produce get a blank line, you must make a line with invisible \index{invisible text} text, as is produced by a \verb"\mbox{}"\index{!mbox, making invisible text with} command. A paragraph-making environment can be used only in paragraph \index{paragraph mode} mode, and \TEX{} is in paragraph mode while processing it. Even in the centering and ``flushing'' environments of Section~\ref{centering}, in which you normally use the \xsp{}\verb"\\"\xsp{} command to end lines, \TEX{} is in paragraph mode and will break a line for you if it's too large. If \TEX{} started in outer paragraph mode, then it's still in outer paragraph mode inside the environment. Paragraph-making environments can be nested \index{nesting of paragraph-making environments} within one another, except where explicitly noted otherwise. \yspace \noindent {\bf Warning:} Most of these environments should not be used in a parbox\index{parbox, paragraph-making environments in} except in the {\tt minipage}\index{minipage} environment. The only ones that can be used in an ordinary parbox are the theorem environments of Section~\ref{theorems} and the centering and flushing environments of Section~\ref{centering}, \subsection{Simple Paragraph-Making Environments} \label{simple-par} The following environments are defined in terms of a general {\tt list} environment\index{list environment} that is described in Section~\ref{list} on page~\pageref{list}. If they don't do what you want, the general the {\tt list} environment will. \subsubsection{Quotations}\index{quotations} \LATEX{} provides two standard environments for quotations: the \hbox{\tt quotation} \index{quotation environment} environment and the {\tt quote} \index{quote environment} environment. Here is a sample of a quotation. \begin{quotation} This is a quotation. Note that the margins are indented on the left and the right, the text is justified at both margins, and there is a paragraph indentation. Leaving a blank line produces a new paragraph like this one. \end{quotation} It was produced by typing \begin{verbatim} \begin{quotation} This is a quotation. Note that ... ... paragraph indentation. Leaving a blank line produces ... \end{quotation} \end{verbatim} The {\tt quote} environment is similar, but paragraphs are not indented. \subsubsection{Verse}\index{verse} The {\tt verse}\index{verse environment} environment is designed for poetry, though you may find other uses for it. You can produce a masterpiece like \begin{verse} There is an environment named {\tt verse} \\ Whose features some poets will curse. For instead of making\\ Them do {\it all\/} line breaking,\\ It allows them to put too many words on a line when they'd rather be forced to be terse. \end{verse} by typing the following input \begin{verbatim} \begin{verse} There is an environment named {\tt verse} \\ Whose features some poets will curse. For instead of making\\ Them do {\it all\/} line breaking,\\ It allows them to put too many words on a line when they'd rather be forced to be terse. \end{verse} \end{verbatim} As usual, \TEX{} ignores where you break lines in your input. You tell it to start a new output by line typing \xsp{}\verb"\\"\Xsp. Since \TEX{} is in paragraph mode, leaving a blank line starts a new paragraph, which in this case leaves some extra vertical space and starts a new line. You don't use a \xsp{}\verb"\\"\xsp{} command after a line that ends a paragraph. \subsubsection{Theorems, Lemmas, Etc.}\index{theorems}\index{lemmas} \label{theorems} If you're writing mathematics, you'll probably want to include some theorems. You'd like to type \begin{verbatim} \begin{theorem} All theorem numbers are interesting. \end{theorem} \end{verbatim} to produce something like the following. \begin{theorem} All theorem numbers are interesting. \end{theorem} I can't anticipate the assortment of theorem-like statements that you will want in your document. You might want lemmas numbered the same as theorems, so Lemma~5 follows Theorem~4, or you might want them numbered separately. You might want propositions numbered within chapters, or numbered consecutively from the beginning. In addition to theorems, lemmas and propositions, you might want to number definitions, axioms, assertions, conjectures, wild guesses, and so on. Rather than trying to force some particular style on you, \LATEX{} provides a \verb"\newtheorem"\index{!newtheorem} command that lets you define your own theorem-like environments. Suppose you want an environment called {\tt guess} to produce something like: \begin{guess} All conjectures are interesting. \end{guess} You define such an environment with the command \begin{verbatim} \newtheorem{guess}{Conjecture} \end{verbatim} This causes your conjectures to be numbered consecutively from the start of the document. If you want them numbered consecutively within sections, you type \begin{verbatim} \newtheorem{guess}{Conjecture}[section] \end{verbatim} The same input as before then produces the following. \begin{xguess} All conjectures are interesting. \label{guess} \end{xguess} This is Conjecture~\ref{guess} because it's the first conjecture in Section~\ref{paragraph-making}. To get your conjectures numbered within chapters instead of sections, you'd type: \begin{verbatim} \newtheorem{guess}{Conjecture}[chapter] \end{verbatim} Finally, suppose you want another environment named {\tt hunch} that is numbered the same as the {\tt guess} environment, but is labeled {\bf Hunch} rather than {\bf Conjecture}. You define this {\tt hunch} environment by typing: \begin{verbatim} \newtheorem{hunch}[guess]{Hunch} \end{verbatim} The input \begin{verbatim} \begin{hunch} Some interesting conjectures are numbered. \end{hunch} \end{verbatim} then produces the following. \begin{hunch} Some interesting conjectures are numbered. \label{hunch} \end{hunch} It is Hunch is number~\ref{hunch} because it is the first {\tt hunch} or {\tt guess} environment after Conjecture~\ref{guess}. This is all summarized below. \begin{displaymath} \begin{picture}(250,83)(0,7) \put(25,60){\makebox(200,10)[l]{\tt \bs newtheorem\lb guess\rb\lb Conjecture\rb[section]}} \put(25,20){\makebox(200,10)[l]{\tt \bs newtheorem\lb hunch\rb [guess]\lb Hunch\rb}} \put(0,30){\makebox(60,30)[r]{\footnotesize environment name }} \put(215,30){\makebox(70,30)[l]{\footnotesize \ printed label}} \put(60,45){\line(1,0){20}} \put(80,45){\vector(1,1){13}} \put(80,45){\vector(1,-1){13}} \put(215,45){\line(-1,0){30}} \put(185,45){\vector(-2,1){26}} \put(185,45){\vector(-1,-1){13}} \put(0,-10){\makebox(60,30)[r]{\footnotesize same numbering as }} \put(60,5){\line(1,0){60}} \put(120,5){\vector(1,1){13}} \put(215,70){\makebox(100,30)[l]{\footnotesize \ numbered within}} \put(215,85){\line(-1,0){10}} \put(205,85){\vector(-1,-1){13}} \end{picture} \end{displaymath} Remember the discussion in Section~\ref{command-names} about not letting a {\tt [} be confused with an optional argument. The numbering of an environment defined with the \hbox{\verb"\newtheorem"} command is controlled by a counter\index{counters} having the same name as the environment. Counters are discussed in Section~\ref{counters}, which tells you how to change both the values of individual theorem numbers and the way those numbers are printed---for example, to get theorems numbered I, II, III, etc. The \verb"\newtheorem" command is a global \index{declaration, global} declara\-tion---one whose scope does not end when \TEX{} ``climbs the stairs'' to a higher level. You can put the \verb"\newtheorem" command anywhere before the environment is used, but it must come after the \index{!documentstyle} \verb"\documentstyle" command. The natural place for it is before the \index{!begin{document}}\verb"\begin{document}" command. \subsection{List-Making Environments}\index{lists}\label{list-making} \LATEX{} provides environments for making three different kinds of lists, which are described below. Like the simple paragraph-making environments described above, they are defined using the general {\tt list} environment\index{list environment} of Section~\ref{list} on page~\pageref{list}. If none of these three list-making environments does what you want, the generic {\tt list} environment will. In all of these environments, each list item including the first is begun with an \verb"\item"\index{!item} command. A blank line within an item begins a new paragraph of that item. Blank lines between items have no effect. Each item in a list environment is marked with a label\index{item label}. For example, in an \hbox{\tt enumerate} \index{enumerate environment} environment, the label is the item number. The \verb"\item" command has a single optional argument, which specifies how the item is to be labeled. If that argument is missing, then the default label is used---for example, the number in an \hbox{\tt enumerate} environment. You normally use the default labels in the \hbox{\tt itemize}\index{itemize environment} and \hbox{\tt enumerate} environments and specify the labels in the \hbox{\tt description}\index{description environment} environment. \subsubsection{Enumerated Lists} Here are some of the things you should know about enumerated lists. \begin{enumerate} \item An enumerated list, like this one, is created with the {\tt enumerate}\index{enumerate environment} environment. \item Enumerations can be: \begin{enumerate} \item Nested within one another, up to four levels deep. \item Nested within other paragraph-making environments. \end{enumerate} \item Each item of an enumerated list begins with an \verb"\item" command. \end{enumerate} This enumerated list was created by the following input. \begin{verbatim} \begin{enumerate} \item An enumerated list, like ... \item Enumerations can be: \begin{enumerate} \item Nested within one another ... \item Nested within other ... \end{enumerate} \item Each item of an ... \end{enumerate} \end{verbatim} The indentation of the input is for clarity only, \TEX{} pays no attention to how many spaces you type---one space is as good as a hundred. However, it's a good idea to format your input like this because it can help you catch missing \verb"\end" commands. The numbering in an {\tt enumerate} environment is controlled by the \linebreak %%%%%% \hbox{\tt enumerate} \index{enumerate counter} counter. See Section~\ref{counters} to find out how to change its value to circumvent the default numbering---for example, to begin with item number~7. \subsubsection{Itemized Lists} The {\tt itemize}\index{itemize environment} environment works the same way as the {\tt enumerate} environment. Thus, replacing {\tt enumerate} by {\tt itemize} in the example from the preceding section yields the following. \begin{itemize} \item An itemized list, like this one, is created with the {\tt itemize}\index{itemize environment} environment. \item Itemizations can be: \begin{itemize} \item Nested within one another, up to four levels deep. \item Nested within other paragraph-making environments. \end{itemize} \item Each item in an itemized list begins with an \verb"\item" command. \end{itemize} \subsubsection{Descriptions}\index{description environment}\index{descriptions} The {\tt description} environment is used to make labeled \index{labeled lists} lists like the following. \begin{description}{Armadillo:} \item[Gnat:] A \index{gnat} very small animal that causes no end of trouble in the North Woods. It should be avoided at all costs. \item[Gnu:] A very large \index{gnu} animal that causes no end of trouble in crossword puzzles. It should be avoided at all costs. \item A \index{armadillo} medium-sized animal having a medium-sized Texas city named after it. \end{description} This list was created with the following input text. \begin{verbatim} \begin{description}{Armadillo:} \item[Gnat:] A very small animal ... \item[Gnu:] A very large animal ... \item[Armadillo:] A medium-sized animal ... \end{description} \end{verbatim} Observe how the optional argument of the \verb"\item" command produces the label. The {\tt description} environment has a single mandatory argument, which should be the widest item label. More precisely, the argument of the environment should be the same as the argument of the \verb"\item" command that produces the widest label. \LATEX{} doesn't look ahead when processing a {\tt description} environment, so it needs the argument to tell it to leave enough space for an \xsp{}{\tt Armadillo:}\xsp{} when making the label \xsp{}{\tt Gnat:}\Xsp. The argument of the {\tt description} environment provides the default label, which you get if you omit the \verb"\item" command's optional argument. Thus, in the above example, I could have typed \verb"\item" instead of \verb"\item[Armadillo:]". This makes it easy to use the {\tt description} environment to make itemized \index{itemized lists, with your choice of tick marks} lists with your own choice of tick marks. \TEX{} is in LR \index{LR mode} mode when processing the argument of an \verb"\item" command. It places the text of the label at the left of a box of the appropriate width. See Section~\ref{spacing} to find out how to move the text elsewhere in the box. \subsection{Centering and ``Flushing''}\index{centering}\index{flushing} \label{centering} \LATEX{} allows you to create a paragraph consisting of lines that are \begin{center} centered\index{centering} \\ like these two. \end{center} You can also create a paragraph with lines that are \begin{flushright} flushed right to the\\ right-hand margin like these \end{flushright} or a with a series of lines that are \begin{flushleft} flushed left to the\\ left-hand margin like these. \end{flushleft} They are created with the {\tt center}\index{center environment}, {\tt flushright}\index{flushright environment}, and {\tt flushleft}\index{flushleft environment} environments, respectively. For example, the last one was produced by typing \begin{verbatim} \begin{flushleft} flushed left to the \\ left-hand margin like these. \end{flushleft} \end{verbatim} As usual, a new line is started with the \verb"\\" command. These three environments can be nested \index{nesting, of paragraph environments} with other paragraph-making environments in reasonable ways. For example, \begin{quote} \begin{flushright} You can put\\ a flushright environment \\ inside a quote. \end{flushright} \end{quote} by typing \begin{verbatim} \begin{quote} \begin{flushright} You can put\\ a flushright environment \\ inside a quote. \end{flushright} \end{quote} \end{verbatim} This is useful because, unlike most of the other paragraph-making environments, the centering and flushing environments don't change the margins. To understand what makes some nestings unreasonable, you need to know that the \verb"\item" command does not actually produce the label. Instead, it causes the label to be attached as an appendage to the first piece of text that follows it. Thus, \begin{verbatim} \begin{itemize} \item The following is reasonable. \begin{center} It produces a centered paragraph within the item. \end{center} \item \begin{center} This is unreasonable. It puts the item label in a strange place. \end{center} \end{itemize} \end{verbatim} \yspace As with all paragraph-making environments, \TEX{} is in paragraph mode when processing these environments, so it will break any line that's too long. The centering and flushing environments work by making certain magical declarations to change how \TEX{} makes paragraphs. These declarations are available by themselves as the \LATEX{} commands \verb"\centering"\index{!centering}, \verb"\raggedleft"\index{!raggedleft} and \verb"\raggedright"\index{!raggedright}. Instead of using the {\tt flushright} environment, the above example could have been made using a \verb"\raggedleft" command as follows. \begin{verbatim} \begin{quote} \raggedleft You can put\\ a flushright environment \\ inside a quote. \end{quote} \end{verbatim} Remember the following correspondence between the environments and the declarations: \begin{center} \begin{tabular}{lcl} \multicolumn{1}{c}{\underline{\it environment}}& & \underline{\it declaration} \\ {\tt center}& $\leftrightarrow$ & \verb"\centering"\\ {\tt flushright} & $\leftrightarrow$ & \verb"\raggedleft"\\ {\tt flushleft} & $\leftrightarrow$ & \verb"\raggedright" \end{tabular} \end{center} These declarations are particularly useful inside \index{parboxes}parboxes. For example, \index{armadillo}\index{gnu} \begin{verbatim} \parbox{3in}{\raggedright Suite 123 \\ 4567 Ave. of the Armadillos \\ Gnu York, G.Y. } \end{verbatim} produces a parbox with three lines moved flush against the left-hand margin of the box. You could also use these declarations in ordinary paragraphs, but there is seldom any need to. Remember that the declarations work by changing the way \TEX{} forms a paragraph. To have any effect, their scope must include the blank line that ends the paragraph. \yspace \noindent {\bf Warning:} You can put any of these three environments inside a parbox. However, if they appear at the beginning or end of the parbox, then they produce an extra vertical space above or below it, respectively. Section~\ref{spacing} on page~\pageref{spacing} tells you how to insert a negative space to cancel this extra space. However, most of the time you'll want the centered or flushed text to fill the entire parbox, so you can use the declarations instead of the environments. \section{Mathematical Formulas}\label{math} \index{mathematical formulas}\index{formulas} If you type \xsp{}\verb"x+y=z"\xsp{} in paragraph or LR mode, you get \xsp{}\hbox{x+y=z}\Xsp. While this may look acceptable, it doesn't look nearly as good as the formula \xsp{}$x+y=z$\xsp{} that \TEX{} produces in math \index{math mode} mode. You want \TEX{} to be in math mode when it's generating mathematical formulas. There are three environments that put \TEX{} in math mode: {\tt math}\index{math environment}, {\tt displaymath}\index{displaymath environment} and {\tt equation}\index{equation environment}. The {\tt math} environment is for formulas that appear right in the text, like the expression $x^{2}+y^{2}$. The {\tt displaymath} environment is for formulas that appear on their own line, like \begin{displaymath} \phiâ??{xy} = {d^{2}x\over dx\,dy} \end{displaymath} The {\tt equation} environment is the same as the {\tt displaymath} environment except that it adds an equation number: \begin{equation} z = \sumâ??{i=1}^{n} xâ??{i}^{2}. \label{eq1} \end{equation} It is equation \index{equation numbering} number~\ref{eq1} because it's the first {\tt equation} environment in Chapter~\ref{basics}. The {\tt report} \index{report document style, equation numbering in} document style numbers equations this way; the {\tt article} \index{article document style, equation numbering in} style numbers them consecutively from the beginning of the document. Other document styles may number equations differently. As explained in Section~\ref{xref}, I can symbolically \index{symbolic labeling of equations} label Equation~\ref{eq1} by inserting the command \verb"\label{eq-sum}"\index{!label} in the {\tt equation} environment, and refer to Equation~\ref{eq1} by typing \begin{verbatim} and refer to Equation~\ref{eq-sum} by typing \end{verbatim} You can replace {\tt eq-sum} by the label of your choice. \yspace The {\tt math} environment can be used in both paragraph \index{paragraph mode} and LR \index{LR mode} mode, but the {\tt displaymath} and {\tt equation} environments can be used only in paragraph mode. The {\tt math} and {\tt displaymath} environments are used so often that they have the following short \index{math environments, short forms}forms: \begin{flushleft} \hspace*{\leftmargini}\index{!(}\index{!)}\verb"\(" $\ldots$ \verb"\)" \ instead of \ \verb"\begin{math}" $\ldots$ \verb"\end{math}"\\ \hspace*{\leftmargini}\index{![}\index{!]}\verb"\[" $\ldots$ \verb"\]" \ instead of \\ \hfill \verb"\begin{displaymath}" $\ldots$ \verb"\end{displaymath}" \end{flushleft} In fact, the {\tt math} environment is so common that it has an even shorter form: you can type \begin{flushleft} \hspace*{\leftmargini}\index{\string\$}\verb"$" $\ldots$ \verb"$" \ instead of \ \verb"\(" $\ldots$ \verb"\)" \end{flushleft} The shorter forms are easier to type, but they make it easier to forget one of the delimiters. I recommend letting the size of the formula determine which form you use, reserving the shorter forms for shorter formulas. For example, you might type: \begin{verbatim} $x+y$ and \( 2a + 3b + 4c + 5d + 26z \), \end{verbatim} using the regular \verb"\begin"--\verb"\end" form for really long formulas. \yspace Most of what goes into a math formula is typed just the way you would expect. The ordinary \index{ordinary printing characters,in math mode} printing characters do what you'd expect them to in math mode. Typing \xsp{}\verb"x+1=y-2<0"\xsp{} produces \xsp{}$x+1=y-2<0$\xsp{}. The \xsp{}{\tt '}\xsp{}\index{',in math mode} character also does what you'd like it to---typing \xsp{}\verb%x'=y''%\xsp{} produces \xsp{}$x'=y''$\Xsp. \TEX{} ignores all spaces \index{spaces, in math mode} in math mode, so \xsp{}\verb"$x+x$"\xsp{} and \xsp{}\verb*"$x + x$"\xsp{} produce the same output. Special commands for adding space to a formula are described in Section~\ref{math-spacing} below. There's no obvious way to generate some things, like subscripts, because there's no natural way to enter them on your terminal. The following subsections tell you how to do all the fancy formatting that makes mathematical formulas so much fun. \yspace In a sentence like \begin{quote} Every $x$ in $S$ is also in $T$. \end{quote} the letters representing mathematical symbols are printed with a different typeface from the others. In fact, they are in the same typeface used for letters in a mathematical formula. To produce such a sentence, you make each of these letters a separate formula, typing: \begin{verbatim} Every $x$ in $S$ is also in $T$. \end{verbatim} As this example illustrates, spaces following a \xsp{}\verb"\)"\index{!), spaces after}\xsp{} or a closing \xsp{}\verb"$"\index{!!dollar, spaces after}\xsp{} are {\it not\/} ignored. This is just what you'd expect to happen when typing formulas inside sentences, and you probably wouldn't even have noticed if I hadn't pointed it out. A \hbox{\tt displaymath} or \hbox{\tt equation} environment should not start a paragraph nor form a paragraph by itself, otherwise you'll get too much space above it. If this can't be avoided, the extra space can be removed with the commands of Section~\ref{spacing}. \yspace \noindent {\bf Warning:} You can't start a new paragraph inside a mathematical formula. Therefore, never leave a blank line in any math environment. \subsection{Subscripts and Superscripts} \index{subscripts@}\index{superscripts@} To get an expression $exp$ to appear as a subscript, you just type \index{!!underscore}\xsp{}\verb"â??{exp}"\xsp{}. To get $exp$ to appear as a superscript, you type \index{!!uparrow}\xsp{}\verb"^{exp}"\Xsp. (See Section~\ref{input-file} for a discussion of where the special characters \xsp{}\verb"â??"\xsp{} and \xsp{}\verb"^"\xsp{} may appear on your \index{keyboard}keyboard.) For example \[ \begin{tabular}{l@{\s{40pt}}l} \underline{\it You type} & \underline{\it to get} \\[2pt] \verb"x^{2y}" & $x^{2y}$ \\ \verb"xâ??{3}" & $xâ??{3}$ \\ \verb"x^{y^{2}}" & $x^{y^{2}}$ \\ \verb"xâ??{1}^{y}" & $xâ??{1}^{y}$ \end{tabular}\] That's all there is to it. \TEX{} handles superscripted superscripts and all of that stuff in the natural way. It even does the right thing when something has both a subscript and a superscript. To save yourself some typing, you can omit the braces if the sub- or superscript has only a single letter---for example, typing \xsp{}\verb"z^2"\xsp{} to get \xsp{}$x^2$\Xsp{}. However, my customized text \index{text editing} editor produces the entire \verb"^{}" with a single keystroke, so I never bother. \subsection{Math Symbols}\index{symbols,math} \label{math-symbols} \TEX{} provides almost any mathematical symbol you're likely to need. The commands for generating them, which are described in this section, can be used only in math \index{math mode}mode. Producing Greek letters\index{Greek letters@} is as easy as \index{!pi}\index{!pi}$\pi$. You just type \begin{verbatim} ... as easy as $\pi$. \end{verbatim} You get \xsp{}$\Pi$\xsp{} by typing \index{!Pi}\xsp{}\verb"$\Pi$"\Xsp, and the same convention holds for all the Greek letters: capitalize the first letter of the name for the upper-case letter. If the upper-case Greek letter is the same as its Roman equivalent, as in upper-case alpha, there is no command to generate it. Some Greek letters have variant \index{Greek letters,variant}\index{variant Greek letters}forms, as shown in Table~\ref{tab:variant}. \begin{table} \centering \begin{tabular}{cl@{\s{30pt}}cl} \underline{\it To get} & \underline{\it you type} & \underline{\it To get} & \underline{\it you type} \\ $\epsilon$ & \verb"\epsilon" & $\sigma$ & \verb"\sigma" \\ $\varepsilon$ & \verb"\varepsilon" & $\varsigma$ & \verb"\varsigma" \\ $\theta$ & \verb"\theta" & $\phi$ & \verb"\phi" \\ $\vartheta$ & \verb"\vartheta" & $\varphi$ & \verb"\varphi" \\ $\rho$ & \verb"\rho" & & \\ $\varrho$ & \verb"\varrho" & & \end{tabular} \caption{Variant Greek letters.\label{tab:variant}} \end{table} Upper-case Greek letters also come in an italic \index{italic, upper-case Greek} version. To produce \index{!mit}\xsp{}${\mit \Pi} = \Pi$\xsp{} you type \xsp{}\verb"${\mit \Pi} = \Pi$"\Xsp. The \xsp{}\verb"\mit"\xsp{} command is a special kind of typeface-changing declaration, which is why you need the curly braces. It is discussed further in Section~\ref{math-style}. You can obtain the twenty-six {\it calligraphic\/} \index{calligraphic symbols} symbols \xsp{}$\cal A$,\index{!cal@} $\cal B$, $\ldots$~, $\cal Z$\xsp{} by typing \verb"{\cal A}", \verb"{\cal B}", etc. The \xsp{}\verb"\cal"\xsp{} command is another typeface-changing declaration. Remember that only these twenty-six upper-case symbols are available with the \xsp{}\verb"\cal"\xsp{} typeface. A few mathematical symbols, like \xsp{}{\tt <}\xsp{}, can be produced by typing ordinary printing characters. The rest are obtained with the commands shown in Tables \ref{tab:1m} through \ref{tab:9m}. \begin{table} \centering \begin{tabular}{cl@{\s{30pt}}cl@{\s{20pt}}cl} $\pm$ &\verb|\pm|&$\cap$ &\verb|\cap|&$\vee$ &\verb|\vee|\\ $\mp$ &\verb|\mp|&$\cup$ &\verb|\cup|&$\wedge$ &\verb|\wedge|\\ $\setminus$ &\verb|\setminus|&$\uplus$ &\verb|\uplus|&$\oplus$ &\verb|\oplus|\\ $\cdot$ &\verb|\cdot|&$\sqcap$ &\verb|\sqcap|&$\ominus$ &\verb|\ominus|\\ $\times$ &\verb|\times|&$\sqcup$ &\verb|\sqcup|&$\otimes$ &\verb|\otimes|\\ $\ast$ &\verb|\ast|&$\triangleleft$ &\verb|\triangleleft|&$\oslash$ &\verb|\oslash|\\ $\star$ &\verb|\star|&$\triangleright$ &\verb|\triangleright|&$\odot$ &\verb|\odot|\\ $\diamond$ &\verb|\diamond|&$\wr$ &\verb|\wr|&$\dagger$ &\verb|\dagger|\\ $\circ$ &\verb|\circ|&$\bigcirc$ &\verb|\bigcirc|&$\ddagger$ &\verb|\ddagger|\\ $\bullet$ &\verb|\bullet|& $\bigtriangleup$ &\verb|\bigtriangleup|& $\amalg$ &\verb|\amalg|\\ $\div$ &\verb|\div|&$\bigtriangledown$ &\verb|\bigtriangledown| & $\unlhd$ & \verb"\unlhd" \\ $\lhd$ & \verb"\lhd" & $\rhd$ & \verb"\rhd" & $\unrhd$ & \verb"\unrhd" \end{tabular} \caption{Binary Operation Symbols.}\label{tab:1m} \end{table} \begin{table} \centering \begin{tabular}{cl@{\s{40pt}}cl@{\s{40pt}}cl} $\leq$ &\verb|\leq|&$\geq$ &\verb|\geq|&$\equiv$ &\verb|\equiv|\\ $\prec$ &\verb|\prec|&$\succ$ &\verb|\succ|&$\sim$ &\verb|\sim|\\ $\preceq$ &\verb|\preceq|&$\succeq$ &\verb|\succeq|&$\simeq$ &\verb|\simeq|\\ $\ll$ &\verb|\ll|&$\gg$ &\verb|\gg|&$\asymp$ &\verb|\asymp|\\ $\subset$ &\verb|\subset|&$\supset$ &\verb|\supset|&$\approx$ &\verb|\approx|\\ $\subseteq$ &\verb|\subseteq|&$\supseteq$ &\verb|\supseteq|&$\cong$ &\verb|\cong|\\ $\sqsubseteq$ &\verb|\sqsubseteq|&$\sqsupseteq$ &\verb|\sqsupseteq|&$\bowtie$ &\verb|\bowtie|\\ $\in$ &\verb|\in|&$\ni$ &\verb|\ni|&$\propto$ &\verb|\propto|\\ $\vdash$ &\verb|\vdash|&$\dashv$ &\verb|\dashv|&$\models$ &\verb|\models|\\ $\smile$ &\verb|\smile|&$\mid$ &\verb|\mid|&$\doteq$ &\verb|\doteq|\\ $\frown$ &\verb|\frown|&$\parallel$ &\verb|\parallel|&$\perp$ &\verb|\perp|\\ $\neq$ & \verb"\neq" \end{tabular} \caption{Relation Symbols} \end{table} \begin{table} \centering \leavevmode\hbox to 0pt{\hss\begin{tabular}{clclcl} $\leftarrow$ &\verb|\leftarrow|&$\longleftarrow$ &\verb|\longleftarrow|& $\uparrow$ &\verb|\uparrow|\\ $\Leftarrow$ &\verb|\Leftarrow|&$\Longleftarrow$ &\verb|\Longleftarrow|& $\Uparrow$ &\verb|\Uparrow|\\ $\rightarrow$ &\verb|\rightarrow|&$\longrightarrow$ &\verb|\longrightarrow|& $\downarrow$ &\verb|\downarrow|\\ $\Rightarrow$ &\verb|\Rightarrow|&$\Longrightarrow$ &\verb|\Longrightarrow|& $\Downarrow$ &\verb|\Downarrow|\\ $\leftrightarrow$ &\verb|\leftrightarrow|&$\longleftrightarrow$ &\verb|\longleftrightarrow|& $\updownarrow$ &\verb|\updownarrow|\\ $\Leftrightarrow$ &\verb|\Leftrightarrow|&$\Longleftrightarrow$ &\verb|\Longleftrightarrow|& $\Updownarrow$ &\verb|\Updownarrow|\\ $\mapsto$ &\verb|\mapsto|& $\longmapsto$ &\verb|\longmapsto|& $\nearrow$ &\verb|\nearrow|\\ $\hookleftarrow$ &\verb|\hookleftarrow|&$\hookrightarrow$ &\verb|\hookrightarrow|& $\searrow$ &\verb|\searrow| \\ $\leftharpoonup$ &\verb|\leftharpoonup|&$\rightharpoonup$ &\verb|\rightharpoonup|& $\swarrow$ &\verb|\swarrow|\\ $\leftharpoondown$ &\verb|\leftharpoondown|&$\rightharpoondown$ &\verb|\rightharpoondown|& $\nwarrow$ &\verb|\nwarrow|\\ $\rightleftharpoons$ &\verb|\rightleftharpoons| &$\leadsto$&\verb"\leadsto" \end{tabular}\hss} \caption{Arrow Symbols} \end{table} \begin{table} \centering \begin{tabular}{cl@{\s{.45in}}cl@{\s{.45in}}cl} $\aleph$ &\verb|\aleph|&$\prime$ &\verb|\prime|&$\forall$ &\verb|\forall|\\ $\hbar$ &\verb|\hbar|&$\emptyset$ &\verb|\emptyset|&$\exists$ &\verb|\exists|\\ $\imath$ &\verb|\imath|&$\nabla$ &\verb|\nabla|&$\neg$ &\verb|\neg|\\ $\jmath$ &\verb|\jmath|&$\surd$ &\verb|\surd|&$\flat$ &\verb|\flat|\\ $\ell$ &\verb|\ell|&$\top$ &\verb|\top|&$\natural$ &\verb|\natural|\\ $\wp$ &\verb|\wp|&$\bot$ &\verb|\bot|&$\sharp$ &\verb|\sharp|\\ $\Re$ &\verb|\Re|&$\Vert$ &\verb!\|! & $\clubsuit$ &\verb|\clubsuit|\\ $\Im$ &\verb|\Im|&$\angle$ &\verb|\angle|&$\diamondsuit$ &\verb|\diamondsuit|\\ $\partial$ &\verb|\partial|&$\triangle$ &\verb|\triangle|&$\heartsuit$ &\verb|\heartsuit|\\ $\infty$ &\verb|\infty|&$\backslash$ &\verb|\backslash|&$\spadesuit$ &\verb|\spadesuit|\\ $\Box$ & \verb"\Box" & $\Diamond$ & \verb"\Diamond" \end{tabular} \caption{Miscellaneous Symbols}\label{tab:9m} \end{table} In addition to making all these symbols, you can also construct others from them. The \xsp{}\verb"\not"\index{!not@}\xsp{} command puts a \xsp{}$\not\;\;$\xsp{} through a symbol. For example, typing \xsp{}\verb"\not<"\xsp{} produces \xsp{}$\not<$, and typing \xsp{}\verb"\not\subset"\xsp{} produces \xsp{}$\not\subset$\Xsp. If the \xsp{}$\not\;\;$\xsp{} doesn't come out in quite the right spot, put one of the spacing commands described in Section~\ref{math-spacing} between the \xsp{}\verb"\not"\xsp{} and the symbol it's modifying. You can also put one symbol above another to form a new symbol, as described in Section~\ref{above} on page~\pageref{above} \TEX{} provides some symbols whose size depends \index{variable-sized math symbols} upon what kind of math environment they appear in, being bigger in the {\tt displaymath} and {\tt equation} environments than in the ordinary {\tt math} environment. These symbols are produced by the commands given in Table~\ref{tab:bigops}, \begin{table} \[ \begin{array}{*{2}{ccl@{\s{.25in}}}ccl} \sum&\displaystyle \sum&\hbox{\verb!\sum!}&\bigcap&\displaystyle \bigcap&\hbox{\verb!\bigcap!}& \bigodot&\displaystyle \bigodot&\hbox{\verb!\bigodot!}\\[3pt] \prod&\displaystyle \prod&\hbox{\verb!\prod!}&\bigcup&\displaystyle \bigcup&\hbox{\verb!\bigcup!}& \bigotimes&\displaystyle \bigotimes&\hbox{\verb!\bigotimes!}\\[3pt] \coprod & \displaystyle \coprod &\hbox{\verb!\coprod!}&\bigsqcup&\displaystyle \bigsqcup&\hbox{\verb!\bigsqcup!}& \bigoplus&\displaystyle \bigoplus&\hbox{\verb!\bigoplus!}\\ \int&\displaystyle \int&\hbox{\verb!\int!}&\bigvee&\displaystyle \bigvee&\hbox{\verb!\bigvee!}& \biguplus&\displaystyle \biguplus&\hbox{\verb!\biguplus!}\\ \oint&\displaystyle \oint&\hbox{\verb!\oint!}&\bigwedge&\displaystyle \bigwedge&\hbox{\verb!\bigwedge!} \end{array} \] \caption{Variable-sized Symbols.} \label{tab:bigops} \end{table} where both the large and small versions are shown. The symbols of Table~{tab:bigops} often have subscript-sized expressions above and below them, as in \begin{equation} \sumâ??{i=1}^{n} \log xâ??{i} = \log \prodâ??{i=1}^{n} xâ??{i} \label{eq:log} \end{equation} These expressions are typed as ordinary subscripts, so Equation~\ref{eq:log} was generated by \begin{verbatim} \begin{equation} \sumâ??{i=1}^{n} log xâ??{i} = log \prodâ??{i=1}^{n} xâ??{i} \end{equation} \end{verbatim} However, these subscripts and superscripts are formatted differently in an ordinary {\tt math} environment, where they appear as follows: \xsp{}$\sumâ??{i=1}^{n}$\Xsp. See Section~\ref{math-style} to find out how to coerce \TEX{} into producing \xsp{}$\sumâ??{i=1}^{n}$\xsp{} in a {\tt displaymath} or {\tt equation} environment, and \xsp{}$\displaystyle \sumâ??{i=1}^{n}$\xsp{} in an ordinary {\tt math} environment. \yspace If you examine Equation~\ref{eq:log} carefully, you'll see that I lied. Typing \verb"log xâ??{i}" in a math environment produces \xsp{}$log xâ??{i}$\xsp{} because \TEX{} ignores spaces. The commands of Section~\ref{math-spacing} can be used to add some space and get \xsp{}$log\;x$\Xsp, but that's not what I did. Equation~\ref{eq:log} has \xsp{}$\log xâ??{i}$\Xsp, with the ``$\log$'' in Roman type, the way it normally appears in math texts. \TEX{} provides a \verb"\log"\index{!log} command to do this, so the $\log xâ??{i}$ is produced by typing \xsp{}\verb"\log xâ??{i}"\Xsp. Table~\ref{tab:log} \begin{table} \begin{verbatim} \arccos \cos \csc \exp \ker \limsup \min \sinh \arcsin \cosh \deg \gcd \lg \ln \Pr \sup \arctan \cot \det \hom \lim \log \sec \tan \arg \coth \dim \inf \liminf \max \sin \tanh \end{verbatim} \caption{``Log-like'' Functions\label{tab:log}.}\index{``Log-like'' functions@} \end{table} lists all the commands for producing ``log-like'' mathematical functions. Some log-like function commands act the same as the variable-sized symbols of Table~\ref{tab:bigops} with respect to subscripts. For example, typing \begin{verbatim} \[ \limâ??{n \rightarrow \infty} x = 0 \] \end{verbatim} produces \[ \limâ??{n \rightarrow \infty} x = 0 \] \remindbox{Remember that all the commands described in this section can be used only in math mode.} \subsection{Spacing in Math Mode} \label{math-spacing} \index{space, in math mode} In a math environment, \TEX{} ignores the spaces\index{space} you type and puts in the spacing that it thinks best. \TEX{} formats mathematics the way it's done in mathematics texts. If you're not a mathematician, you may find this style rather cramped and want to add extra space. You could do this with the commands of Section~\ref{spacing}, but it's better to use spacing commands designed especially for math formulas. \LATEX{} provides the following four spacing commands for use in math mode: \newlength{\foo}\settowidth{\foo}{a negative thin space.} \begin{description}{\hbox{\tt \bs ;} --} \item[\hbox{\tt \bs ;} --] \makebox[\foo][l]{a thick \index{thick space in math mode} space.}\index{!;@} \ \verb"xx \; x"\xsp{} produces \xsp{}$xx\;x$\Xsp. \item[\hbox{\tt \bs :} --] \makebox[\foo][l]{a medium \index{medium space in math mode} space.}\index{!:@} \ \verb"xx \: x"\xsp{} produces \xsp{}$xx\:x$\Xsp. \item[\hbox{\tt \bs ,} --] \makebox[\foo][l]{a thin \index{thin space in math mode}space.}\index{!,@} \ \verb"xx \, x"\xsp{} produces \xsp{}$xx\,x$\Xsp. \item[\hbox{\tt \bs !} --] \makebox[\foo][l]{a negative thin \index{negative thin space in math mode} space.}\index{!!*(neg thin sp)} \ \verb"xx \! x"\xsp{} produces \xsp{}$xx\!x$\Xsp. \end{description} You'll seldom need a negative space, but it can come in handy. \subsection{Arrays}\label{array}\index{arrays}\index{array environment} Arrays are produced with the {\tt array} environment. It has a single mandatory argument describing the number of columns and the alignment within them. Each column is specified by a single letter that tells how items in that row should be positioned: \xsp{}{\tt c}\index{c}\xsp{} for \index{centering, array column}centered, \xsp{}{\tt l}\index{l}\xsp{} for \index{flushleft, array column}flushleft, or \xsp{}{\tt r}\index{r}\xsp{} for \index{flushright, array column}flushright. Thus, typing \begin{verbatim} \begin{array}{lclr} \end{verbatim} starts a four-column array, with items in the first and third columns flushleft, items in the second column centered, and items in the fourth column flushright. The body of the environment is a collection of rows, separated by \xsp{}\verb"\\"\index{!!}\xsp{} commands. See Section~\ref{cr} on page~\pageref{cr} to find out how to about the \xsp{}\verb"\\"\xsp{} command's optional argument to put extra space between rows. Within a row, the different columns' items are separated by \verb"&"\index{\string &} characters. Thus, the array \begin{quote} \( \begin{array}{lcr} a + b + c & uvwxyz & 13,479 \\ a+b & yz & p \\ a & z & qqqqq \end{array} \) \end{quote} is produced by typing the following command in math mode: \begin{verbatim} \begin{array}{lcr} a + b + c & uvwxyz & 13,479 \\ a+b & yz & p \\ a & z & qqqqq \end{array} \end{verbatim} I typed this so neatly to make it readable; \TEX{} pays no attention to how things line up in the input. \TEX{} is in math mode when it processes each array element, so spaces\index{space} are ignored. However, don't leave any spaces in the argument. It goes without saying that you shouldn't leave any space between the \verb"\begin{array}" and its argument. Note that the \xsp{}\verb"\\"\xsp{} commands come between rows, so there's no \xsp{}\verb"\\"\xsp{} after the last row. Arrays can be nested within one another in the obvious way to produce, for example, the following is a \(2\times 2\) array whose top-right and bottom-left elements are themselves arrays. \begin{displaymath} \begin{array}{cc} a & \left( \begin{array}{ccc} bâ??{11}&bâ??{12}&bâ??{13}\\ bâ??{21}&bâ??{22}&bâ??{23} \end{array}\right) \\ \begin{array}{cc} câ??{11}&câ??{12}\\ câ??{21}&câ??{22} \end{array} & d \end{array} \end{displaymath} Section~\ref{delimiters} below describes how to make the big parentheses. An {\tt array} environment can appear just about anywhere in a formula, including in a subscript or superscript. However, its entries produce the same-sized symbols regardless of where the array appears. In the terminology of Section~\ref{math-style}, array entries are always produced in text \index{text math style} style. That section describes how to put smaller symbols in the entries. There are a number of fancy things you can do with arrays by putting other things in the argument of the {\tt array} environment. They are described in full detail in Section~\ref{tabular} on page~\pageref{tabular}. I'll just explain one of them here. Suppose you want to produce a list of equations like \begin{equation} \begin{array}{l@{\;\;+\;\;}l@{\;\;\;=\;\;\;}r} a & x & 17 \\ ab & xy & 177 \\ abc & xyz & 1776 \end{array} \label{eq:array} \end{equation} You can make this with a five-column array, where the second element of each array is \xsp{}$+$\xsp{} and the fourth element is \xsp{}$=$\Xsp. However, there's a way to do this as a three-column array, where the \xsp{}$+$\xsp{} and \xsp{}$=$\xsp{} are text items that come {\it between\/} the columns. To put text between columns, you add an \index{@}\index{@-expression}{\tt @}-{\it expression\/} of the form \xsp{}\verb"@{...}"\xsp{} to the {\tt array} environment's argument, where the ``{\tt ...}'' is the desired text. So, we might type \begin{verbatim} \begin{equation} \begin{array}{l@{+}l@{=}r} a & x & 17 \\ ab & xy & 177 \\ abc & xyz & 1776 \end{array} \end{equation} \end{verbatim} to produce Equation~\ref{eq:array}. This would almost work, except you wouldn't get the same spacing. \LATEX{} normally puts a fixed amount of space between the columns of an array, but it omits the space between two columns when there's an {\tt @}-expression there. Any space that you want there must be part of the {\tt @}-expression's text. The array in Equation~\ref{eq:array} was produced by \begin{verbatim} \begin{array}{l@{\;\;+\;\;}l@{\;\;\;=\;\;\;}r} ... \end{verbatim} where \xsp{}\verb"\;"\xsp{} is the math spacing command described in Section~\ref{math-spacing}. I could use a math spacing command because \TEX{} is in math \index{math mode}mode when processing an {\tt @}-expression in the argument of an {\tt array} environment. You can use an {\tt @}-expression to change the amount of space \index{space, between array columns} between columns of an individual array. For small spaces, use the math-mode spacing commands of Section~\ref{math-spacing}; for larger spaces use the \verb"\s"\index{!s} command described in Section~\ref{spacing} on page~\pageref{spacing}. You can also change the horizontal space between the columns of all your arrays by changing the spacing parameter \hbox{\verb"\arraycolsep"}\index{!arraycolsep} described in Section~\ref{parameters} with the commands of Section~\ref{length}. \yspace \noindent {\bf Warning:} Many commands cannot be used inside an {\tt @}-expression. To be safe, you should use only the following: \begin{itemize} \item The math spacing commands of Section~\ref{math-spacing}. \item The \xsp{}\verb"\s"\index{!s}\xsp{} command described in Section~\ref{spacing}, commands to produce special \index{special symbols} symbols. \item The \xsp{}\verb"\mbox"\index{!mbox}\xsp{} command. \item Simple declarations such as typeface-changing commands. \item Commands you've defined yourself in terms of the above. (Section~\ref{defcom} tells you how to define your own commands.) \end{itemize} \yspace As Equation~\ref{eq:array} shows, the {\tt array} environment can do more than just generate matrices; it can be used whenever you need to align things in a formula. Look at Equation~\ref{eq:array} again and observe the array is vertically centered in the equation, so its middle line has the same vertical position \index{vertical positioning of arrays} on the pages as the equation number. Similarly, you get \[ A = \left( \begin{array}{cc} aâ??{11} & aâ??{12} \\ aâ??{11} & aâ??{12} \\ aâ??{11} & aâ??{12} \end{array} \right) \] by typing \begin{verbatim} \[ A = \left( \begin{array}{cc} ... \end{verbatim} where the \verb"\left("\index{!left} command, which generates the left parenthesis, is described in Section~\ref{delimiters}. The {\tt array} environment has an optional one-letter argument that is used to change its vertical positioning. The argument {\tt t}\index{t} specifies that the top line of the array should line up with the rest of the equation, and {\tt b}\index{b} specifies alignment with the bottom line. Thus, you can produce \begin{equation} \begin{array}[t]{c} t \\ x^{2} \end{array} = \begin{array}[b]{c} y^{3} \\ b \end{array} \end{equation} by typing \begin{verbatim} \begin{equation} \begin{array}[t]{c} ... \end{array} = \begin{array}[b]{c} ... \end{verbatim} \remindbox{Remember that the {\tt array} environment can be used only in math mode. There should be no spaces in the mandatory argument, except within an {\tt @}-expression. The optional argument may consist only of the single letter {\tt t} or {\tt b}.} \subsection{Putting One Thing Above Another} \label{above} One of the trickiest problems in typesetting a complicated formula is getting one subformula above another. The {\tt array} \index{array environment} environment provides a very powerful mechanism for doing this in a wide variety of situations. By using the \xsp{}\index{!!}\verb"\\"\xsp{} command's optional argument to change the vertical space between rows (see Section~\ref{cr}), the commands of Section~\ref{spacing} to put horizontal space in an item, and the commands of Section~\ref{math-style} to change the type size in the items, you can get the {\tt array} environment to solve almost all such alignment problems. However, \TEX{} provides easier ways to handle certain common cases. I often build a new symbol by stacking something above an existing one. This is done with the \verb"\stackrel"\index{!stackrel@} command, as shown by the following examples. \[ \begin{tabular}{l@{\s{20pt}}l} \underline{\it To get} & \underline{\it you type} \\[2pt] $\stackrel{\alphaâ??{i}}{\longrightarrow}$ & \verb"\stackrel{\alphaâ??{i}}{\longrightarrow}"\\ $\stackrel{\rm def}{=}$ & \verb"\stackrel{\rm def}{=}" \end{tabular} \] In math formulas, one often wants to put a horizontal \index{horizontal line in math mode} line \index{overlining}above a symbol or expression, as in \[ \overline{\overline{x}^{2} + \overline{y}^{2}} \] This is done with the \verb"\overline"\index{!overline@} command, whose argument is the item to be overlined, so the above expression is obtained by typing \begin{verbatim} \[ \overline{ \overline{x}^{2} + \overline{y}^{2} } \] \end{verbatim} There's an analogous \verb"\underline"\index{!underline} command for drawing a line \index{underlining} underneath an expression, text, but it's not used too often in math formulas. (Unlike \hbox{\verb"\overline"}, the \hbox{\verb"\underline"} command can also be used in paragraph and LR modes.) You can also put horizontal \index{horizontal braces@} braces above or below an expression with the following commands: \index{!overbrace@} \index{!underbrace@} \[ \begin{tabular}{ll} \underline{\it To get} & \underline{\it you type}\\[3pt] $\overbrace{a+b+c}$ & \verb"\overbrace{a+b+c}"\index{!overbrace}\\[2pt] $\underbrace{x+y+z}$ & \verb"\underbrace{x+y+z}"\index{!underbrace}\\ \end{tabular} \] In a {\tt displaymath} or {\tt equation} environment, you can put a label on the braces by using a subscript or superscript. For example you produce \[ \overbrace{a + b + \cdots + z}^{26} = \underbrace{\alpha+ \cdots + \omega}â??{24} \] by typing \begin{verbatim} \[ \overbrace{ ... }^{26} = \underbrace{ ... }â??{24} \] \end{verbatim} Another instance of putting one symbol above another is the placing of accents on characters. The accent commands described in Section~\ref{accents} are for ordinary text and cannot be used in math mode. \TEX{} provides the commands shown in Table~\ref{macc} for \begin{table} \centering \begin{tabular}{ll@{\s{40pt}}ll} \verb"\hat{a}"&$\hat{a}$ & \verb"\dot{a}"&$\dot{a}$\\ \verb"\check{a}"&$\check{a}$ & \verb"\ddot{a}"&$\ddot{a}$\\ \verb"\tilde{a}"&$\tilde{a}$ & \verb"\breve{a}"&$\breve{a}$\\ \verb"\acute{a}"&$\acute{a}$ & \verb"\bar{a}"&$\bar{a}$\\ \verb"\grave{a}"&$\grave{a}$ & \verb"\vec{a}"&$\vec{a}$ \end{tabular} \caption{Math Mode Accents.\label{macc}} \end{table} putting accents on characters in math mode. You can put a single \verb"\hat" or \verb"\tilde" accent \index{wide accents} over more than one character with a \verb"\widehat"\index{!widehat@} \index{!widetilde}\verb"\widetilde" command. These commands try to choose an appropriate-sized accent to fit over their argument, so typing \begin{verbatim} \( \widehat{1-x} = \widehat{-y} \) \end{verbatim} produces \xsp{}$\widehat{1-x} = \widehat{-y}$\Xsp. However, these accents won't grow too wide. There's one more thing you should know about accents---how to put one on an $i$ or $j$. Typing \xsp{}\verb"\hat i"\xsp{} produces \xsp{}$\hat i$\Xsp, which looks funny because the $i$ has both a dot and an accent. The command \xsp{}\index{!imath@}\verb"\imath"\xsp{} produces a dotless \index{i,dotless} \xsp{}$\imath$\Xsp, so typing \xsp{}\verb"\hat{\imath}"\xsp{} gives \xsp{}$\hat\imath$. Similarly, the command \xsp{}\index{!jmath@}\verb"\jmath"\xsp{} produces a dotless \index{j,dotless} $\jmath$. \subsection{Delimiters}\label{delimiters}\index{delimiters@} A {\it delimiter\/} in a math formula is something that logically acts like a parenthesis. For example, in \begin{displaymath} \left\langle \frac{2(x+y)}{\left| z \right|} \right\rangle \label{eq:delim} \end{displaymath} there are three delimiter pairs: the big \xsp{}$\langle \ldots \rangle$\Xsp, the \xsp{}$(\ldots)$\Xsp, and the \xsp{}$|\ldots|$\Xsp. Table~\ref{tab:delim} lists all the delimiter symbols provided by \TEX{} and the input that generates them. \begin{table} \begin{tabular}{lc@{\s{20pt}}lc} \underline{\it Input}&\underline{\it Delimiter}& \underline{\it Input}&\underline{\it Delimiter}\\[2pt] \verb|(| & $($ & \verb|)| & $)$\\ \verb|[| & $[$ & \verb|]| & $]$\\ \verb|\{| & $\{$ & \verb|\}| & $\}$\\ \verb|\lfloor| & $\lfloor$ & \verb|\rfloor| & $\rfloor$\\ \verb|\lceil| & $\lceil$ & \verb|\rceil| & $\rceil$\\ \verb|\langle| & $\langle$ & \verb|\rangle| & $\rangle$\\ \verb|/| & $/$ & \verb|\backslash| & $\backslash$\\ \verb'|' & $\vert$ & \verb'\|' & $\Vert$\\ \verb|\uparrow| & $\uparrow$ & \verb|\Uparrow| & $\Uparrow$\\ \verb|\downarrow| & $\downarrow$ & \verb|\Downarrow| & $\Downarrow$\\ \verb|\updownarrow| & $\updownarrow$ & \verb|\Updownarrow| & $\Updownarrow$\\ \end{tabular} \caption{Delimiters.\label{tab:delim}} \end{table} Table~\ref{tab:delim} tells you what to type to produce the delimiters that are the size shown. However, delimiters in math formulas need should be big enough to ``fit around'' the expressions that they delimit. \TEX{} will produce the right size delimiter if you precede the input given in Table~\ref{tab:delim} by the command \xsp{}\index{!left@}\verb"\left"\xsp{} or \xsp{}\index{!right@}\verb"\right"\Xsp. For example, you get \begin{displaymath} \left( \begin{array}{c} \left| \begin{array}{cc} xâ??{11} & xâ??{12} \\ xâ??{21} & xâ??{22} \end{array} \right| \\ y \\ z \end{array} \right) \end{displaymath} by typing \begin{verbatim} \begin{displaymath} \left( \begin{array}{c} \left| \begin{array} ... \end{array} \right| \\ ... \end{array} \right) \end{displaymath} \end{verbatim} The \verb"\left"\xsp{} and \xsp{}\verb"\right"\xsp{} commands must come in pairs, but \TEX{} doesn't care what delimiters appear in a matching pair. For example, you can match a \verb"\left(" with a \verb"\right]"---or even with a \verb"\right[". Some formulas, such as \begin{equation} \label{eq:.} x = \left\{ \begin{array}{ll} y & {\rm if} \: y > 0 \\ z+y & {\rm otherwise} \end{array} \right. \end{equation} contain an unmatched \index{delimiter, unmatched} delimiter. Since \verb"\left" and \verb"\right" commands must come in pairs, \TEX{} provides a null \index{null delimiter} delimiter denoted by \xsp{}{\tt .}\xsp{}, so you can put math a real right or left delimiter with \xsp{}\index{!left.}\verb"\left."\xsp{} or \xsp{}\verb"\right."\index{!right.}\xsp{},respectively. Equation~\ref{eq:.} was thus produced by typing \begin{verbatim} \begin{equation} x = \left\{ \begin{array}{ll} ... \end{array} \right. \end{equation} \end{verbatim} \subsection{Mathematical Miscellany} This section describes how to do a bunch of miscellaneous things in math formulas. \yspace \noindent {\bf Fractions:}\index{fractions} Typing \xsp{}{\tt 12/17}\xsp{} obviously produces the fraction 12/17. To get \xsp{}$\frac{12}{17}$\Xsp, you must type \xsp{}\verb"$\frac{12}{17}$"\index{!frac}\Xsp. This doesn't look very good for in-line formulas, but you can do marvelous things with \xsp{}\verb"\frac"\xsp{} in a {\tt displaymath} environment, such as \[ \frac{ x+y }{ z^{3}+\frac{1}{a-b} } \] which I produced by typing \begin{verbatim} \[ \frac{ x+y }{ z^{3} + \frac{1}{a-b} } \] \end{verbatim} \yspace \noindent {\bf \index{roots}Roots:} The command \index{!sqrt@}\verb"\sqrt" produces the square \index{square root} root of its argument. For example, typing \xsp{}\verb"\sqrt{x+y}"\xsp{} gives \xsp{}$\sqrt{x+y}$\Xsp. Other roots are obtained with an optional argument for the \verb"\sqrt" command. For example, \xsp{}$\sqrt[3]{x+y}$\xsp{} is produced by typing \xsp{}\verb"\sqrt[3]{x+y}"\Xsp. \yspace \noindent {\bf \index{ellipsis}Ellipsis:} Typing \xsp{}\verb"..."\xsp{} produces \xsp{}$...$\Xsp, which doesn't look like much of anything. To produce an ellipsis mark that looks like \xsp{}$\ldots$\index{!!ldots}\index{dots}\Xsp, you type \index{!ldots@}\verb"\ldots" in math mode. There's also a \index{!cdots@}\verb"\cdots" command that produces \xsp{}$\cdots$\Xsp, where the dots are raised to the center of the line. If you look closely at the formula \[ (xâ??{1},\ldots,xâ??{n}) = Xâ??{1}+ \cdots + Xâ??{n} \] you'll see that the first ellipsis was produced by \verb"\ldots" and the second by \verb"\cdots"; it wouldn't look right if you did it any other way. \subsection{Changing Typeface and Style} \label{math-style} \TEX{} uses the following four \index{math style} styles \index{style, math} in math mode: \begin{description}{{\it scriptscript\/}:} \item[{\it display\/}:] Entered \index{display math style} at the beginning of a \index{displaymath environment}{\tt displaymath} or \index{equation environment}{\tt equation} environment. \item[{\it text\/}:] Entered \index{text math style} at the beginning of a \index{math environment}{\tt math} environment. \item[{\it script\/}:] Used \index{script math style} for subscripts \index{subscripts} and \index{superscripts}superscripts. \item Used \index{scriptscript math style} for further levels further levels of sub- and superscripting, such as the subscripts of superscripts. \end{description} The display math and text math styles are pretty much the same except for the size of the variable-sized symbols (shown in Table~\ref{tab:bigops} on page~\ref{tab:bigops}) and the placement of subscripts and superscripts on these symbols and on some of the ``log-like'' functions shown in Table~\ref{tab:log} on page~\ref{tab:log}. (See Section~\ref{math-symbols} for a discussion of these symbols and functions.) The script style uses a smaller typeface, and the scriptscript style uses a still smaller typeface. You can force \TEX{} to use a particular style by typing one of the following declarations, which have the obvious effect: \hbox{\verb"\displaystyle"}\index{!displaystyle@}, \hbox{\verb"\textstyle"}\index{!textstyle@}, \hbox{\verb"\scriptstyle"}\index{!scriptstyle@}, or \hbox{\verb"\scriptscriptstyle"}\index{!scriptscriptstyle@}. For example, to produce $e^{\textstyle\Sigmaâ??{i=1}^{n}x(i)}$ instead of $e^{\Sigmaâ??{i=1}^{n}x(i)}$, you type \begin{verbatim} $e^{ \textstyle \Sigmaâ??{i=1}^{n} x(i) }$ instead of $e^{ \Sigmaâ??{i=1}^{n} x(i) }$ \end{verbatim} \yspace At first glance, it looks like \TEX{} uses an ordinary italic typeface \index{typefaces, in math mode} in math formulas. However, observe that typing \hbox{\verb"$different$"} produces $different$, which looks different from the \hbox{\it different\/} produced by typing \hbox{\verb"{\it different}"} in paragraph or LR mode. The typeface \TEX{} normally uses in math mode is called {\it math \index{math italic} italic}.\footnote{This typeface can be obtained at other times by the {\tt \bs mit}\index{!mit} declaration, but the only time you'll ever do so is to produce italic upper-case Greek letters, as described in Section~\ref{math-symbols}.} The declarations described in Section~\ref{type-style} will make \TEX{} switch to one of the ordinary typefaces when used in math mode. However, some type styles don't get smaller as they should when used in a ``smaller'' style. The Roman \index{Roman type style}typeface is the only one guaranteed to work right in all styles. Some type styles might work right in script style but not in scriptscript style, and some might not work right even in script style. Which type styles work where will depend upon the version of \LATEX{} in use at your particular computer installation; you'll just have to try them and see. If a command or environment used in math mode puts \TEX{} into paragraph or LR mode, then \TEX{} reverts to the typeface in use when it entered math mode. For example, \TEX{} is in LR mode when processing the argument of an \verb"\mbox"\index{!mbox} command. The following shows how this works; it assumes that \TEX{} is in paragraph mode with a Roman typeface when it begins processing this text. \begin{verbatim} Roman text \[ math italic \mbox{Roman \bf bold} math italic \] Roman \end{verbatim} Remember that the argument of the \verb"\mbox" is processed in LR mode, so it must not contain any command that can be used only in math mode, unless that command is in a math environment contained inside the \verb"\mbox". \begin{verbatim} Wrong: \[ ... \mbox{not \alpha or} ... \] Right: \[ ... \mbox{not $\alpha$ or} ... \] \end{verbatim} \subsection{What to Do When Nothing Works} If your documents contain many formulas, sooner or later you're going to find one that you just can't handle---perhaps something like this: \begin{center} \setlength{\unitlength}{.25in} \begin{picture}(4,4) \put(0,3){\makebox(1,1){$A$}} \put(3,3){\makebox(1,1){$B$}} \put(3,0){\makebox(1,1){$C$}} \put(1,3){\vector(1,-1){2}} \put(1,3.5){\vector(1,0){2}} \multiput(3.5,1.5)(0,.6){3}{\line(0,1){.3}} \put(3.5,1.33){\vector(0,-1){.33}} \end{picture} \end{center} When that happens, you could read \index{!knuth}\knuth{} to find out what features \TEX{} provides to solve your problem. If you often find yourself running into such problems, then you should learn about \TEX's advanced features. However, if this is just an isolated case, then there's an easier solution. Instead of regarding it as a mathematical formula, think of it as a picture whose components are mathematical formulas. The {\tt picture} \index{picture environment}environment, described in Section~\ref{pictures}, allows you to draw pictures by specifying exactly where each component should go. \section{Text That Migrates} Your input is a sequence of characters, most of which get converted directly into glyphs---a \xsp{}{\tt q}\xsp{} that you type producing a \xsp{}{\it q\/}\xsp{} glyph in the output. Most of the time, these output glyphs appear in the same order as the input characters that produced them. There are three important situations when this isn't the case: footnotes, floating objects like figures and tables, and marginal notes. Text that migrates is assembled in a parbox\index{parbox}---a box that \TEX{} produces in paragraph mode. That parbox is then moved to the appropriate location. Text cannot migrate out of a parbox, so migrating text such as a figure doesn't belong inside another parbox. Thus, the environments and commands that produce migrating text can be used only in outer \index{outer paragraph mode} paragraph mode---that is, when \TEX{} is in paragraph mode but not inside a parbox.\footnote{There is one exception: a footnote may appear in the {\tt minipage}\index{minipage environment, footnotes in} environment described in Section~\ref{parbox} on page~\pageref{parbox}. However, such a footnote is not put at the bottom of the page.} In particular, none of the environments and commands described in this section can be nested inside one another. \subsection[Footnotes]{Footnotes\footnotemark} \index{footnotes@} \label{footnotes} \footnotetext{It's bad style to use lots of footnotes, but, in a section about footnotes, it's hard to resist.} Typing footnotes is a snap with the \verb"\footnote"\index{!footnote@} command.\footnote{This was a snap.} For example, I just typed \begin{verbatim} ... command.\footnote{This was a snap.} For example... \end{verbatim} That's all you need to know for 98\% of your footnotes. The rest of this section only tells you how to handle the other 2\%. A \verb"\footnote" command to put a footnote at the bottom of the page may appear only in outer \index{outer paragraph mode} paragraph mode. (In the {\tt minipage}\index{minipage environment} environment, the footnote is put at the bottom of the box produced by the environment.) However, sometimes you may want to footnote some text that's not produced in outer paragraph mode. For example, I footnoted the heading of this section, even though \TEX{} is in inner paragraph mode when processing the argument of a sectioning command. I also put a footnote in the following formula, when \TEX{} was in math mode. \[ x = \left\{ \begin{array}{ll} y^{2} & \mbox{if $y$ interesting\footnotemark}\\ 0 & {\rm otherwise} \end{array} \right. \] \footnotetext{Isn't this an interesting place for a footnote?} Footnote can be put in these places because \LATEX{} allows you to break a \verb"\footnote" command into two pieces: a \verb"\footnotemark"\index{!footnotemark@} command that puts the footnote number in the text, and a \verb"\footnotetext"\index{!footnotetext@} command that produces the text to be placed at the bottom of the page. The sequence of two commands \begin{verbatim} \footnotemark \footnotetext{This goes below.} \end{verbatim} is completely equivalent to the single command \begin{verbatim} \footnote{This goes below.} \end{verbatim} The \verb"\footnotetext" command can come anywhere after the \hbox{\verb"\footnotemark"} command, so long as there are no intervening \hbox{\verb"\footnote"} or \hbox{\verb"\footnotemark"} commands. The \hbox{\verb"\footnotetext"} command must appear in outer paragraph mode, since it produces migrating text, but the \hbox{\verb"\footnotemark"} can appear in any reasonable place. To produce the footnote in the preceding math formula, I placed a \hbox{\verb"\footnotemark"} command in the formula, and a \hbox{\verb"\footnotetext"} command in the paragraph-mode text that followed the formula. Similarly, I placed the \hbox{\verb"\footnotemark"} command in the argument to the \hbox{\verb"\subsection"}\index{!subsection} command that began this section, and put the \hbox{\verb"\footnotetext"} command afterwards. \yspace \noindent {\bf Warning:} Typing simply \begin{verbatim} \subsection{Footnotes\footnotemark} \end{verbatim} will produce a nasty error. For reasons explained in Section~\ref{sectioning}, you have to type \begin{verbatim} \subsection[Footnotes]{Footnotes\footnotemark} \end{verbatim} The \verb"\footnotetext" command produces a footnote having the same number as the most recent \verb"\footnotemark" or \verb"\footnote" command. This poses a problem if you need to put two or more \verb"\footnotemark" commands before their corresponding \verb"\footnotetext" commands---for example, if you want to put two footnotes in the same math formula. The best way to solve this problem is with commands of the form\index{!addtocounter} \begin{verbatim} \addtocounter{footnote}{...} \end{verbatim} to step the {\tt footnote} \index{footnote counter} counter, as described in Section~\ref{counters} on page~\pageref{counters}. There's an easier way of solving this problem that requires you to know what footnote numbers \LATEX{} will produce. The \verb"\footnotetext" has an optional argument that allows you to specify the footnote number. For example, typing \begin{verbatim} \footnotetext[17]{This was produced by ... } \end{verbatim} produces the footnote numbered 17 at the bottom of this page.\footnotetext[17]{This was produced by \xsp{}\tt \bs footnotetext[17] \lb This was produced by ... } The optional argument to the \verb"\footnote" command is always a number. Even if you're using a document style in which footnotes are labeled $a$, $b$, $c$, $\ldots$~, you'd still write \verb"\footnotetext[17]{...}" to produce a footnote labeled $q$---the $17^{\rm th}$ footnote ``number''. \yspace The \verb"\footnote" and \verb"\footnotemark" commands also have an optional argument that specifies the footnote number. Thus, you can type \begin{verbatim} this.\footnote[9]{Why is this footnote number 9?} \end{verbatim} to produce this.\footnote[9]{Why is this footnote number 9?} Again, the optional argument is always a number, regardless of whether footnotes are labeled with numbers, letters or other symbols. \LATEX{} does a fine job of numbering footnotes, so you'll probably never have to use an optional argument for a \verb"\footnote" or \verb"\footnotemark" command. There's just one exotic situation in which you'll need these optional arguments, and that's if you're using some strange document style in which footnote numbering begins anew on each page---for example if the first footnote on a page is labeled \xsp{}*\Xsp, the second one is labeled \xsp{}\dag\Xsp, and so on. Printers very rarely number footnotes in this way because they first typeset the text in convenient-sized hunks known as \index{galley}{\it galleys}, then break up the galleys into pages. At the time they'd normally typeset the footnote number, they don't know if it will be the first or the seventh footnote on its page. \TEX{} has the same problem, but it's not as flexible as human typesetters, so it sometimes fouls up the numbering. When it does, you'll have to tell it the footnote number by using the optional arguments. Remember, this happens only if you're using a strange document style that numbers footnotes within pages. None of the standard document styles do that. \subsection{Figures, Tables, and Other Floating Bodies}\index{figures@} \index{tables@}\index{floats@} \label{figures} Figures and tables are objects that are not part of the normal text, and are usually ``floated'' to a convenient place, like the top of the page. Such objects are called {\it \index{floats}floats}. Special document styles may also contain other kinds of floats, such as programs\index{programs} or charts. They will work the same as figures and tables, and won't be discussed in this manual. Figures traditionally contain pictorial information, while tables hold tabular information. However, the primary reason for making something a figure or table in \LATEX{} is to allow it to float to a convenient place. For example, Figure~\ref{fig:rn} on page~\pageref{fig:rn} consists of a nine-line sample \LATEX{} input file. I put this file into a picture, rather than putting it in the text, because I wanted to make sure it wasn't split between two pages. I could have guaranteed that it all appeared on the same page by putting it in a parbox\index{parbox} (see Section~\ref{parbox}), but this would have left \TEX{} with no good place for a page break if the parbox happened to straddle the boundary between two pages. By putting the sample file in a figure, I allowed \LATEX{} to float it to the best place, so it would stay together and not mess up the page breaking. \subsubsection{Creating Figures and Tables} \LATEX{} provides a {\tt figure}\index{figure environment@} environment for making figures and a {\tt table}\index{table environment} environment for making tables. They both work the same way, so I'll just describe the {\tt figure} environment here. Figure~\ref{fig:fig} was produced by \begin{figure} \it This is an example of a figure. The text of the figure is produced in a parbox\index{parbox} whose width is the normal text width. Figures will usually contain interesting things in them like \[ \begin{picture}(90,50) \put(0,0){\circle*{5}} \put(0,0){\vector(1,1){31.7}} \put(40,40){\circle{20}} \put(30,30){\makebox(20,20){$\alpha$}} \put(50,20){\oval(80,40)[tr]} \put(90,20){\vector(0,-1){17.5}} \put(90,0){\circle*{5}} \end{picture} \] However, you'll have to look elsewhere in this manual to find out how to produce them. \caption{A Sample Figure.}\label{fig:fig} \end{figure} the following input. \begin{verbatim} ... was produced by \begin{figure} \it This is an example of a figure. The text ... manual to find out how to produce them. \caption{A Sample Figure.} \end{figure} the following input. \end{verbatim} (See Section~\ref{type-style} for an explanation of the \xsp{}\verb"\it"\xsp{} command.) Observe that you type the {\tt figure} environment in the middle of the text---usually right after the first reference to the figure. \LATEX{} will try to put the figure on the same page as the text in which the {\tt figure} environment appears, or on the next possible page. The next section describes how \LATEX{} decides where to put the figure, and how you can influence its decision. \yspace \noindent {\bf Warning:} Notice that in \index{space, around a float environment} creating Figure~\ref{fig:fig}, I left a space before and after the environment. This is the natural thing to do and it almost always works right. However, in some rare cases (such as right after an \index{!item, putting figure after}\verb"\item" command in a list), this will produce an extra horizontal space. If that happens, you'll have to remove the spaces on one side of the environment (it doesn't matter which). Sometimes you may even have to remove the space from both sides of the environment. \yspace The caption is created by the \verb"\caption"\index{!caption@} command. It doesn't matter whether or not you leave a blank line before the \verb"\caption" command. \LATEX{} chooses the figure number and puts the ``Figure~\ref{fig:fig}'' in the caption. Figures are numbered within chapters in the {\tt report} \index{report documentstyle, figure numbering in} document style, and consecutively from the beginning in the {\tt article} \index{article documentstyle, figure numbering in} style. Tables are numbered similarly, but they have independent numbers---there can be both a Table~7.1 and a Figure~7.1 in the same document. Section~\ref{xref} on page~\pageref{xref} explains how to give symbolic names to figures and tables, allowing you to produce a reference like ``Figure~8.5'' without knowing what number \LATEX{} will actually assign to the figure. Two or more figures can be combined in a single {\tt figure} environment by using multiple \verb"\caption" commands, as shown in Figures \ref{fig:mc1} and \ref{fig:mc2}. \begin{figure}\centering \parbox{.4\textwidth}{\centering \begin{picture}(70,70) \put(0,50){\framebox(20,20){}} \put(10,60){\circle*{7}} \put(50,50){\framebox(20,20){}} \put(60,60){\circle*{7}} \put(20,10){\line(1,0){30}} \put(20,10){\line(-1,1){10}} \put(50,10){\line(1,1){10}} \end{picture} \caption{The first half of a two-in-one figure.\label{fig:mc1}}} \hfill \parbox{.4\textwidth}{\centering \begin{picture}(70,70) \put(0,50){\framebox(20,20){}} \put(10,60){\circle*{7}} \put(50,50){\framebox(20,20){}} \put(60,60){\circle*{7}} \put(20,10){\line(1,0){30}} \put(20,10){\line(-1,-1){10}} \put(50,10){\line(1,-1){10}} \end{picture} \caption{The second half of a two-in-one figure.\label{fig:mc2}}} \end{figure} See Section~\ref{boxes} on page~\pageref{boxes} to find out how to put the two figures side by side like this. Section~\ref{toc} on page~\pageref{toc} tells you how to make a list of \index{list of figures} figures and list of \index{list of tables} tables. (They usually go right after the table of \index{table of contents} contents.) If may want the entry in the list of figures to be different from the actual caption, then that entry is given as an optional argument to the \verb"\caption" command. Typing \begin{verbatim} \caption[Gnus Get Going]{The start of the annual ungulate migration in East Africa.} \end{verbatim} makes {\it The start $\ldots$ Africa\/} the caption that appears in the figure, and {\it Gnus Get Going\/} the corresponding entry in the list of figures. \yspace \noindent {\bf Warning:} There are restrictions on what kind of commands can go in the argument of a \verb"\caption" command. These restrictions are the same as for the sectioning commands which are described in Section~\ref{sec-commands} on page~\pageref{sec-commands}. You should read that section before placing any commands other than simple typeface-changing symbol-producing commands in a \verb"\caption" argument. If the \verb"\caption" command has an optional argument, then the restrictions apply only to the optional argument. \yspace A figure or table may be put on a later page than the place where its environments appeared in the input. When you're using the \hbox{\tt report} \index{report document style, figure-placement in} document style, \LATEX{} will not let a figure or table float into the next chapter. The \hbox{\verb"\chapter"}\index{!chapter} command not only starts a new page, but also forces all pending figures and tables to be printed first. It does this by executing \LATEX's \hbox{\verb"\clearpage"}\index{!clearpage} command, which is described in Section~\ref{page-breaking}. \subsubsection{Changing Where They Go} \index{float placement} \index{figure placement} \label{float-place} The fundamental problem in placing floats (figures and tables) is to get each one close to the text that talks about it. \LATEX{} has a sophisticated float-placement algorithm that usually does a good job of this, assuming that you put the environment in with the appropriate text. However, if you're using lots of figures and tables, choosing where to put them is an inherently difficult job, and you may not be satisfied with what \LATEX{} does. To learn how to change where \LATEX{} places floats, you must first understand its algorithm. There are four places where \LATEX{} can possibly put a float: \begin{description}{{\tt b}:} \item[{\tt h}:] {\it Here}---at the position in the text where the float environment appears. \item[{\tt t}:]{\it Top}---at the top of a text page. \item[{\tt b}:] {\it Bottom}---at the bottom of a text page. \item[{\tt p}:] {\it Page of floats}---on a separate float \index{float page} page, which is a page containing no text, only floats. \end{description} Each float is initially assigned a {\it placement \index{float placement specifier} specifier} that specifies in which of these four locations the float can appear. You can choose the placement specifier for a float by giving the environment an optional argument consisting of up to four of the letters \index{h float-placement position}{\tt h}, \index{t float-placement position}{\tt t}, \index{b float-placement position}{\tt b} and \index{p float-placement position}{\tt p}. For example, \begin{verbatim} \begin{figure}[tp] \end{verbatim} specifies that this figure can appear only at the top of a page or on a float page. If this argument is omitted, the placement specifier is determined by the document style. The standard {\tt report} \index{report document style, float-placement in} and {\tt article} \index{article document style, float-placement in} document styles use the default specifier \xsp{}{\tt tbp}\Xsp. \yspace \noindent {\bf Warning:} When using the {\tt h} float-placement option, you must be careful about exactly where the float environment appears in your input. If it comes in the middle of a paragraph, then \LATEX{} tries to place the float right after the current line of text. However, if this line of text is the last line of a paragraph, then \LATEX{} won't leave the right amount of vertical space above and below the float. In that case, you should put the float environment after the current paragraph, preceded by a blank line. \LATEX{} will also mess up the vertical spacing if you use the {\tt h} option to put two floats in a row, without an intervening line of text. You can fix this up by putting extra (positive or negative) vertical space in the float with the commands of Section~\ref{spacing}. However, it's bad style to have two consecutive figures in the middle of your text. \yspace \LATEX{} always tries to put a float on the earliest possible page, starting with the current page---that is, the page where the float environment appears. Within a given text page, its order of preference for where the float should go is \xsp{}{\tt htb}\Xsp. (Of course, the {\tt h} option is a possibility only on the page where the environment appears.) The reason a float doesn't always go on the current page is that \LATEX{} will never violate the following conditions. \begin{itemize} \item It never puts more on a page than will fit. \item Floats of a given type are printed in order. Thus, a figure never appears before another figure that preceded it in the input. However, it may appear before a preceding table. \item The page's float-placement \index{float-placement constraints} constraints must be met. These constraints, described in detail in Section~\ref{float-param}, specify such style parameters as how many floats can appear on a page and how much of the page can be taken up by floats. \end{itemize} If \LATEX{} has to worry about only a single type of float---for example, if you have figures but not tables in that part of the document---then it will do the best possible job of printing floats as early as possible while not violating these conditions. If your document has both figures and tables, you might get \LATEX{} to do a better job by interchanging the order in which a figure and a table appear in the input---especially if you have lots of figures and tables. In that case, there's probably no very good way to get them all close to the text that talks about them. Probably the most effective way to change where \LATEX{} puts your figures and tables is to change the float-placement constraints. For example, to get all the floats on the page where you want them, you may have to change the constraints to allow \LATEX{} to put more floats on a page. Section~\ref{float-param} on page~\pageref{float-param} describes the float-placement constraints, but you must first read Section~\ref{defining} on page~\pageref{defining} to learn the commands for changing them. \subsubsection{Two-Column Figures and Tables}\index{two-column floats} \label{2-col-floats} As described in Section~\ref{two-column}, some document styles produce two-column \linebreak %%%%%%% output---each page having two columns of text. In such a style, everything in the above discussion holds if you replace ``page'' by ``column''. Thus, the {\tt figure} environment produces column-wide figures, which may appear in the middle of a column, at the top or bottom of the column, or in a separate float column. \LATEX{} also provides special commands for producing two-column-wide floats. \linebreak %%%%%% A two-column float can appear only at the top of a text page or on a separate float page that consists only of two-column floats. The {\tt *}-form of a float \index{*-form of float environments} environment produces a two-column float. Thus, you type \begin{verbatim} \begin{figure*} ... \end{figure*} \end{verbatim} to \index{figure* environment} create a two-column-wide figure. There's an analogous {\tt table*}\index{table* environment} environment. These environments, like their unstarred counterparts, have an optional argument that gives the float-placement specifier, but the only meaningful options are {\tt t} and {\tt p}. The relative \index{ordering of floats} ordering among two-column figures is preserved, just as for one-column figures. However, the relative ordering between different kinds of figures is not. Thus, a two-column figure may migrate to a later page than a following one-column figure. \subsection{Marginal Notes}\index{marginal notes} Marginal notes are made with the \verb"\marginpar"\index{!marginpar@} command. I can place a note in the margin adjacent to this line \marginpar{\it Here is a rather dull mar\-gin\-al note.} by typing \begin{verbatim} ... this line \marginpar{\it Here is a rather dull marginal note.} by typing ... \end{verbatim} The argument of the \verb"\marginpar" command is put in a parbox\index{parbox}, so \TEX{} is in inner paragraph mode when processing it. If a \verb"\marginpar" command appears in a paragraph, \LATEX{} tries to put the marginal note adjacent to the line in which the command appears. If the command is placed between paragraphs, \LATEX{} tries to align the marginal note with the bottom line of the preceding paragraph. However, it will move a marginal note down on the page to keep it from bumping into a previous one, producing \index{warning, marginpar moved} the following warning message on your terminal: \begin{verbatim} LaTeX Warning: marginpar on page ... moved. \end{verbatim} You can change the alignment by putting positive and negative vertical spacing commands in the marginal note. These commands are described in Section~\ref{spacing} on page~\pageref{spacing}. \LATEX{} will not break a marginal note across pages; it's you're responsibility to make sure that the note doesn't extend below the bottom of the page. This may require the commands of Section~\ref{page-breaking} to tell \LATEX{} where to start a new page Marginal notes are not handled efficiently by \LATEX, and you shouldn't use very many of them. If you have more than two or three on a page, then you're asking for trouble. \yspace A page has both a left and a right margin; which one \LATEX{} uses for marginal notes depends upon the document style. A document \index{document style} style specifies if \LATEX{} should format its output for the document to be printed on both sides \index{two-sided printing} of the page or on just one \index{one-sided printing} side. Books are printed on both sides, while technical reports and preprints may be printed either on one or two sides. Section~\ref{docsty} describes how to specify one-sided or two-sided printing. If the document style calls for one-sided printing, \LATEX{} normally puts marginal notes in the right margin. For two-sided printing, it normally uses the left margin for even-numbered (left-hand) pages and the right margin for odd-numbered (right-handed) ones. The command \hbox{\verb"\reversemarginpar"}\index{!reversemarginpar@} causes \LATEX{} to use the opposite margin---for example, the left margin for odd-num\-bered pages in two-sided printing. The \hbox{\verb"\normalmarginpar"}\index{!normalmarginpar@} command restores \LATEX's normal behavior. These two commands are declarations, with the usual scoping rules. \yspace \noindent {\bf Warning:} When a marginal note appears in a paragraph, it doesn't matter if the note itself is in the scope of a \verb"\reversemarginpar" declaration; what counts is whether or not the blank line ending the paragraph is in the scope of that declaration. Thus, if both a \verb"\reversemarginpar" and a \verb"\normalmarginpar" command appear in the same paragraph, only the last one has any effect. \yspace \noindent {\bf Warning:} If you switch back and forth between normal and reverse positioning of marginal notes, \LATEX{} may not move a marginal note down to avoid printing on top of a preceding one. If this happens, it means you're using too many marginal notes. \yspace You may want a marginal note to look different if it appears in the left than if it appears in the right margin. For example, I want the marginal note on this \marginpar[\raggedleft $\Rightarrow$]{\raggedright $\Leftarrow$} line to have an arrow pointing to the text. However, as I type this, I don't know in which margin the note will appear, so I don't know if I should use a left-pointing or a right-pointing arrow. I can solve this problem by giving an optional argument to the \verb"\marginpar" command, typing \begin{verbatim} ... note on this \marginpar [ \raggedleft $\Rightarrow$ ]{ \raggedright $\Leftarrow$ } line to have an arrow ... \end{verbatim} The optional argument is used if the note appears in the left margin, and the mandatory argument is used if it appears in the right margin. (Look up the commands in the index if you want to see exactly what the arguments do.) If no optional argument is given, the mandatory argument is used in either case. \section{Sectioning} \label{sectioning} \subsection{The Sectioning Commands} \index{sectioning commands} \label{sec-commands} The commands \verb"\chapter"\index{!chapter}, \verb"\section"\index{!section}, and so on for starting a new sectional unit were introduced in Section~\ref{simple-text}. For simplicity, they are called {\it sectioning\/} commands. Remember that the \verb"\chapter" command is not available in the {\tt article} \index{article document style}document style; the section is the major division in that style. The sectioning commands have {\tt *}-forms that print a title, but do not include a number and do not make a table of contents entry. For example, the command \begin{verbatim} \subsection*{More Sectioning Commands} \end{verbatim} produces the following heading: \subsection*{More Sectioning Commands} \noindent Compare this with the command \begin{verbatim} \subsection{The Sectioning Commands} \end{verbatim} that began this section. This \hbox{\verb"\subsection*"} command did not produce a table of contents entry. In addition to providing the heading in the text, the argument of a sectioning command can appear in two other places: in the table of contents entry and, for some document styles, in the running head at the top of the page. For example, in the the document style I'm using for this book, the arguments of \verb"\chapter" and \verb"\section" commands wind up at the top of a page. You may not want the same thing to appear in these other two places as appears in the text heading. For example, the section name may be too long to fit on a single table-of-contents line. To handle this situation, the sectioning commands have an optional argument that provides the text for these other two purposes. For example, typing \begin{verbatim} \subsubsection [Gnats and Gnus on Gneiss]{Ungulates and Their Parasites in Metamorphic Rock Ecosystems} \end{verbatim} produces the following section heading \subsubsection [Gnats and Gnus on Gneiss]{Ungulates and Their Parasites in Metamorphic Rock Ecosystems} \noindent and uses \begin{verbatim} Gnats and Gnus on Gneiss \end{verbatim} for the table of contents entry, as you can verify by turning to the table of contents. Since the {\tt *}-form of the sectioning commands produce only the in-text heading, they have no optional argument. There's another reason why you might need an optional argument for a sectioning command. The in-text title produced by the command is a parbox, and anything that can be put into an ordinary parbox can go there. However, getting the argument from the sectioning command to the table of contents or page heading involves a tortuous sequence of \TEX{} operations best left unexplained. This process will fail, and its failure will produce cryptic error messages, if the argument contains any but the simplest \LATEX{} commands. The ``simple'' commands that can be put in the table of contents or page heading include the following: \begin{itemize} \item The typeface-changing commands of Section~\ref{typeface}. \item Commands to generate accents and special symbols---the ordinary ones of Sections \ref{accents} and \ref{nonm-sym} and the ones used in math mode that are described in Sections \ref{math-symbols} and \ref{above}. \item Simple math formula commands, like the commands for subscripts and superscripts. \item The \verb"\s"\index{!s} command for inserting horizontal space. (See Section~\ref{spacing}.) \item The \verb"\mbox"\index{!mbox} command. (See Section~\ref{boxes}.) \end{itemize} They do {\it not\/} include the \verb"\footnotemark"\index{!footnotemark} command of Section~\ref{footnotes} or the \hbox{\verb"\label"}\index{!label} command of Section~\ref{xref}. Thus, to add a footnote to a section heading, you must to type something like \begin{verbatim} \section[Armadillos]{Armadillos\footnotemark} \end{verbatim} The \verb"\footnotemark" command can go in the mandatory argument only if there is an optional argument. \subsection{Table of Contents, Etc.}\index{table of contents@} \label{toc} A table of contents is produced a \hbox{\verb"\tableofcontents"}\index{!tableofcontents@} command. You put the command right where you want the table of contents to go; \LATEX{} does the rest for you. It produces a heading, but it does not automatically start a new page. Section~\ref{toc-param} on page~\pageref{toc-param} explains how to change the heading. There are similar commands \index{!listoffigures@}\hbox{\verb"\listoffigures"} and \index{!listoftables}\hbox{\verb"\listoftables"} for producing a list of \index{list of figures@} figures and a list of \index{list of tables@} tables, respectively. Everything works exactly the same as for the table of contents. When \LATEX{} processes the input file {\tt myfile.tex} that has a \linebreak %%%%% \hbox{\verb"\tableofcontents"} command, it produces a file \index{.toc file} \hbox{\tt myfile.toc} containing commands to generate the table of contents. (Further details on how this is done are given in Section~\ref{aux}.) The \hbox{\verb"\tableofcontents"} command reads the version of \hbox{\tt myfile.toc} that was produced the last time you ran \LATEX{} on \hbox{\tt myfile.tex}. Thus, \LATEX{} always produces the table of contents for the previous version of your document, and it generates an empty table of contents the first time around. This is seldom a problem, since you'll be making many changes to your document before it's ready, and the last few rounds of changes will usually be minor ones that don't affect the table of contents. However, just to be safe, you might want to run \LATEX{} over your document twice when producing the final version. The list of figures is produced the same way, using the file {\tt \index{.lof file}myfile.lof}, and the list of tables uses \index{.lot file}{\tt myfile.lot}. The {\tt .toc}, {\tt .lof} and {\tt .lot} files are called {\it contents\/} \index{contents files} files. Remember that a {\tt .toc} file is produced only if you include a \hbox{\verb"\tableofcontents"} command, and similarly for the other contents files. \yspace If you were to look at the {\tt .toc} file for this manual, you'd find the following \LATEX{} commands: \begin{verbatim} \contentsline{chapter}{...{1.}Getting Started}{4} \contentsline{section}{...{1.1.}Preparing an Input File}{4} \end{verbatim} where the {\tt ...} are commands for producing the appropriate horizontal spacing. The first argument of the \hbox{\verb"\contentsline"}\index{!contentsline} command tells what kind of section entry it is for---a chapter, section, subsection or subsubsection. The second argument is the entry, and the third argument is the page number. If \LATEX{} doesn't produce the table of contents exactly the way you want it, a quick and dirty way to fix it is to edit the {\tt .toc} file yourself. However, don't even think of doing this until you're preparing the last, ultimate, final version of your document. If you do change the {\tt .toc} file yourself, you should also add a \verb"\nofiles"\index{!nofiles} command, as described in Section~\ref{aux} on page~\pageref{aux}, to prevent \LATEX{} from writing a new {\tt .toc} file. \LATEX{} also provides commands for adding things to a contents file file. The command\index{!addcontentsline@} \begin{verbatim} \addcontentsline{toc}{subsubsection}{The Wandering Gnus} \end{verbatim} adds the command\\[\topsepcorrection\topsep] \hspace*{\leftmargini}{\tt \addcontentsline{toc}{su`Ï?ubsection}{The Wandering Gnus}\bs contentsline \lb subsubsection\rb\lb The Wandering Gnus\rb\lb\arabic{page}\rb}\\[\topsepcorrection\topsep] to the {\tt .toc} file. You can check this manual's table of contents to see what this command produced. The first argument specifies on which contents file the \hbox{\verb"\contentsline"} command is to go. The next two arguments are the first two arguments of the \hbox{\verb"\contentsline"} command. (\LATEX{} supplies the page number argument.) You should look at the {\tt .lof} or {\tt .lot} file to find out what to put as the second argument for a list of figures or tables entry. The command\index{!addtocontents@} \begin{verbatim} \addtocontents{toc}{This goes on .toc file} \end{verbatim} just writes {\tt This goes on .toc file} onto the {\tt .toc} file. The restrictions on what can be put in the table of contents, described in Section~\ref{sec-commands} above, hold for the \hbox{\verb"\addcontentsline"} and \hbox{\verb"\addtocontents"} commands, with one important exception. This exception allows you to put arbitrary commands in a contents file. (Without it, the \hbox{\verb"\addtocontents"} command would be useless.) Putting \begin{verbatim} \writecommand{\anycommand} \end{verbatim} in the argument of an \hbox{\verb"\addcontentsline"} or \hbox{\verb"\addtocontents"} command will put \hbox{\verb"\anycommand"} on the contents file. For example, to add a footnoted table-of-contents entry, you'd type \begin{verbatim} \addcontentsline{toc}{section}{ ... \writecommand{\footnotemark}} \addtocontents{toc}{\writecommand{\footnotetext}{ ... }} \end{verbatim} This will write \pagebreak[3] \begin{verbatim} \contentsline{section}{ ... \footnotemark} \footnotetext{ ... } \end{verbatim} on the {\tt .toc} file. Section~\ref{footnotes} explains how this produces the desired footnote. \subsection{The Appendix} \index{appendix} The appendix is an optional portion of a document that follows the main part of the text. It has the same sectioning divisions as the main part---for example, in the {\tt report} \index{report document style, appendix} document style, the largest division is the chapter. The appendix is begun by typing \verb"\appendix"\index{!appendix@}. This changes the sectioning commands so they produce the numbering appropriate for an appendix. In the {\tt report} document style, the first \verb"\chapter" \index{!chapter, in appendix} command following the \verb"\appendix" command produces a chapter labeled ``Appendix A''. Its sections are numbered ``A.1'', ``A.2'', and so forth. In the {\tt article} \index{article document style, appendix} document style, the first section after the \verb"\appendix" command is numbered ``A''. The \verb"\appendix" command does not produce any text, nor does it leave space or start a new page. \section{The Title Page}\index{title page}\index{titlepage environment} The {\tt titlepage} environment creates a title page---that is, a page with no printed page number or heading. It also causes the following page to be numbered page one. You can put a {\tt titlepage} environment any place in your document, but there's seldom any reason to put it anywhere but at the beginning. Formatting the title page is left to you. The typeface-changing commands of Section~\ref{typeface}, the environments of Section~\ref{centering} for centering and ``flushing'' text, and the spacing commands of Section~\ref{spacing} tell you just about everything you need to get the title page exactly the way you want it. Don't forget about the \verb"\today"\index{!today} command, mentioned in Section~\ref{command-names}, for generating the date. It's a good idea to put a date on the title page so someone can tell at a glance what version he's reading.