A Brief Introduction To L TEX For Bard Students
A Brief Introduction To L TEX For Bard Students
December 2002
Contents
1 Introduction 1
1.1 This Document . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 What is TEX . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Bard Senior Project Style . . . . . . . . . . . . . . . . . . . . 2
1.4 The basic idea of using TEX . . . . . . . . . . . . . . . . . . . 2
1.5 Sample document . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 LATEX Basics 6
2.1 Document classes . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Inputting AMS-LATEX & the Bard Senior Project Style . . . . 7
2.3 Sentences and paragraphs . . . . . . . . . . . . . . . . . . . . 8
2.4 Punctuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5 Ties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.6 Specially reserved symbols . . . . . . . . . . . . . . . . . . . . 13
2.7 Control words and symbols . . . . . . . . . . . . . . . . . . . . 14
2.8 Commands to change text font and size . . . . . . . . . . . . . 17
2.9 Accents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.10 Over-ruling some of TEX’s choices . . . . . . . . . . . . . . . . 19
2.11 Commenting your document . . . . . . . . . . . . . . . . . . . 20
2.12 Footnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.13 Topmatter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.14 Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.15 Sectioning commands . . . . . . . . . . . . . . . . . . . . . . . 22
2.16 LATEX environments . . . . . . . . . . . . . . . . . . . . . . . . 23
2.16.1 quote and quotation environments . . . . . . . . . . . 23
2.16.2 center environment . . . . . . . . . . . . . . . . . . . 24
2.16.3 verbatim environment . . . . . . . . . . . . . . . . . . 25
2.16.4 itemize, enumerate, description environments . . . 26
i
2.16.5 tabbing environment . . . . . . . . . . . . . . . . . . . 29
2.16.6 tabular environment . . . . . . . . . . . . . . . . . . . 30
2.16.7 figure and table environments . . . . . . . . . . . . . 32
2.17 The letter document class . . . . . . . . . . . . . . . . . . . 34
2.18 Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.19 Common pitfalls; Error messages . . . . . . . . . . . . . . . . 36
ii
3.6 Some Standard TEX Mistakes . . . . . . . . . . . . . . . . . . 64
3.7 Theorems, Propositions, Lemmas, . . . . . . . . . . . . . . . . . 65
iii
Chapter 1
Introduction
1
maximally flexible. The enormous success of Knuth’s design is apparent from
the vast number of diverse applications TEX has found.
To make the raw power of TEX more manageable and user friendly, some
macros (discussed below) must be defined. The most widely use set of macros
for TEX is called LATEX. We recommend that everyone use LATEX; we will be
referring to LATEX in this manual. It is necessary to use the latest version of
LATEX, which is called LATEX 2ε . Do not use earlier versions of LATEX, such as
LATEX2.09.
LATEX does not have all the mathematical abilities one might want, and so
we will add to it a set of macro packages and mathematical fonts and symbols
known as AMS-LATEX, which was commissioned by the American Mathemat-
ical Society. We will explain below how to input these packages. Unless oth-
erwise noted, all the commands described below are standard LATEX. In the
few situation where we use commands that require the AMS-LATEX packages,
we will state the need for these packages.
The common American way to pronounce TEX is “tek.” If you want to
be really fancy, you can say “tech,” where the “ch” is pronounced as in the
German “Bach” or the Scottish “Loch.” Do NOT say “tex.” Some people
pronounce LATEX as “lay-tek,” and others say “lah-tek.”
2
no errors, then the program outputs something that can then be viewed.
The file with your input, known as the “TEX file,” is a text file that has
the suffix .tex. The file that TEX produces if there are no errors in the
TEX file is called the “DVI file,” and it has the same name as your TEX file,
except that it has the suffix .dvi (which is short for “device independent”).
This last file can viewed, printed, etc. The particular implementation of TEX
varies from system to system, but the basic ideas of TEX are the same in
all implementations. The portability of a TEX document between systems is
one of the advantages of TEX.
The basic idea underlying TEX is that the author should be concerned
with content, and with the logical structure of the document, but should
not have to worry about nuisance-value formatting details. We inform TEX
of the logical structure of our document by telling it when to begin a new
paragraph, subsection, section, chapter, theorem, definition, remark, poem,
list etc. When typing a particular element of the logical structure, we need
pay little attention to how we lay our source file out. Starting a new line, for
instance, entails more than just pressing Return because TEX will just regard
the next word you type as exactly that—the next word in the paragraph.
You have to specifically ask for a line to be terminated. Things like this may
seem to be a bit of a nuisance, but it is a small price to pay for the automatic
formatting that necessitated it. Further, such small inconveniences have been
localized to rare events.
3
\documentclass[12pt]{report}
\usepackage{amssymb, amsmath, amsthm, amsfonts}
\begin{document}
The above file, which would have a name such as filename.tex, is what
you type in a word processor (and which must be saved as a text file). The
completed TEX file is then run through LATEX, and it produces the following
output:
4
Let p : [0, ∞) → R be given by p(x) = x2 for all x ∈ [0, ∞). Then p
has no right inverse, but many left inverses, of which we show two. Let
q, r : R → [0, ∞) be given by
√ √
x, if x ≥ 0 x, if x ≥ 0
q(x) = and r(x) =
1, if x < 0, sin x, if x < 0.
x ∈ [0, ∞). We leave it to the reader to show that p has no right inverse.
Among other things to notice in the TEX file are the first two lines (which
declare the type of document, and inputs some extra mathematical packages);
the third line (which defines a new LATEX command); the many entries that
begin with \ (which are LATEX commands); the many $ signs (which denote
math mode); the \begin{ } and \end{ } commands (which denote special
environments). All these features will be described in this manual.
5
Chapter 2
LATEX Basics
6
as font size, columns, etc. The syntax for declaring a document class is as
follows:
\documentclass[options]{class}
where class is the main document class (e.g. report) and the optional ar-
gument options is a list of document class options. Note thatan argument
in square brackets is optional, and can omitted altogether (including the
brackets).
Some of the more common options are the following:
11pt chooses 11-point as the default font size for the document, instead of
the default 10-point.
titlepage applies to the article class only, causing the title and abstract to
appear on a page each.
which will allow the user to make use of various AMS-LATEX fonts, symbols
and other mathematical constructs.
To make use of the Bard Senior Project style, you first need to download
the file bardproj.sty from the website given in Section 1.3, and then put
the file in the same folder on your computer as your TEX file. Then, add
7
the following line to your TEX file immediately after declaring the document
class:
\usepackage{bardproj}
8
Words within a sentence are ended by spaces. One space between
words is equivalent to any number. Pressing Return at the end of a line
and starting a new word on the next line just serves to separate words,
not to cut a line short. The end of a sentence is indicated by a period
followed by one or more spaces.
The end of a paragraph is indicated by leaving a blank line. All this
means that we can type without too much regard for layout, and the
typesetter will sort things out for us.
Note that we have learned more than just how LATEX recognizes words,
sentences and paragraphs. We’ve also seen how to specify our choice of docu-
ment class and how to tell LATEX where our document begins and ends. Any
material that is to be printed must lie somewhere between the declaration
of \begin{document} and that of \end{document}. Definitions that are to
apply to the entire document can be made before the declaration of the doc-
ument beginning. The specification of document class must precede all other
material.
In future examples we won’t explicitly display the commands that select
document class, input the AMS-LATEX packages, and delimit the start and
end of the document. But if you wish to try any of the examples, don’t
forget to include those commands. The article document class will do for
most of our examples. Of course, the preceding example looks not at all like
an article because it is so short and because we specified no title or author
information.
LATEX automatically makes ligatures. These are combinations of letters
within words which should be typeset as a single special symbol because they
will “clash” with each if this is not done. Have a look at these words
In the first set I let LATEX run as it usually does. In the second I overruled
it somewhat, and stopped it from creating ligatures. Notice how the ‘fl’, ‘ff’,
and ‘fi’ combinations are different in the two sets—in the former they form a
single symbol (a ligature) and in the latter they are comprised of two disjoint
symbols. There are other combinations that yields ligatures as well.
LATEX has been taught how to hyphenate the majority of words. It will
hyphenate a word if it feels that the overall quality of the paragraph will be
9
improved. For long words it has been taught several potential hyphenation
positions.
LATEX also goes to a lot of trouble to try to choose pleasing page breaks.
It avoids “widows”, which are single lines of a paragraph occurring by them-
selves at either the bottom of a page (where it would have to be the first line
of a paragraph) or at the top of a page (where it would have to be the last).
It also “vertically justifies” your page so that all pages have exactly the same
height, no matter what appears on them.
2.4 Punctuation
Typists have a convention whereby a single space is left after a mid-sentence
comma, and two spaces are left after a sentence-ending period. How do we
enforce this if LATEX treats a string of spaces just like a single one? The
answer, unsurprisingly, is that we don’t.
To have a comma followed by the appropriate space, we simply
type a comma follows by at least one space. To end a sentence
we type a period with at least one following space. No space will
be inserted if we type a comma or period followed straight away
by something other than a space, because there are times when
we won’t require any space, i.e., we do what comes narurally.
will produce
To have a comma followed by the appropriate space, we simply type
a comma follows by at least one space. To end a sentence we type a
period with at least one following space. No space will be inserted if we
type a comma or period followed straight away by something other than
a space, because there are times when we won’t require any space, i.e.,
we do what comes naturally.
LATEX will produce suitable space after commas, periods, semi-colons and
colons, exclamation marks, question marks etc. if they are followed by a
space. In stretching a line to justify to the right margin, it also knows
that space after a punctuation character should be more “stretchable” than
normal inter-word space and that space after a sentence-ending period should
be stretched more than space after a mid-sentence comma. TEX knows the
nature of punctuation if you stick to the simple rules outlined here. As we’ve
already said, those rules tell LATEX how to distinguish consecutive words,
sentences, phrases, etc.
10
Actually, there is more to ending sentences than mentioned above. Since
LAT EX cannot speak English, it works on the assumption that a period followed
by a space ends a sentence unless the period follows a capital letter. This
works most of the time, but can fail. To get a normal inter-word space after
a period that doesn’t end a sentence, follow the period by a control space—a
\ (a \ character followed by a space or return). Very rarely, you will have to
force a sentence to end after a period that follows a capital letter (remember
that LATEX assumes this doesn’t end a sentence). This is done by preceding
the period with a \@ command (you can guess from the odd syntax that this
is rarely needed).
It’s time we saw some examples of this. After all, this is our first experi-
ence of control symbols (don’t worry, there are many more to come).
We must be careful not to confuse intra-sentence periods
with periods that end a sentence, i.e.\ we must remember
that our task is to describe the sentence structure. Periods
that the typesetter requires a little help with typically result
from abbreviations, as in etc.\ and others. We have to work
somewhat harder to break a sentence after a capital letter,
but that shouldn’t bother us to much if we keep up our intake
of vitamin E\@. All this goes for other sentence-ending
punctuation characters, so I could have said vitamin E\@!
Fortunately, these are rare occurrences.
results in
We must be careful not to confuse intra-sentence periods with pe-
riods that end a sentence, i.e. we must remember that our task is to
describe the sentence structure. Periods that the typesetter requires a
little help with typically result from abbreviations, as in etc. and oth-
ers. We have to work somewhat harder to break a sentence after a
capital letter, but that shouldn’t bother us to much if we keep up our
intake of vitamin E. All this goes for other sentence-ending punctuation
characters, so I could have said vitamin E! Fortunately, these are rare
occurrences.
Quotation marks is another area where LATEX will do some work for us.
Keyboards have the characters ‘, ‘, and " but we want to to have access to
each of ‘, ’, “, and ”. So we proceed like this:
11
‘\LaTeX’ is no conventional word-processor, and
to to get quotes, like ‘‘this’’, we type repeated
‘ and ’ characters. Note that modern
convention is that ‘‘punctuation comes after
the closing quote character’’.
yields
12
Theorems 1–3 concern the semi-completeness of our new construct—
in the case that it satisfies the first axiom.
2.5 Ties
When you always remember to use ties, you know that you are becoming
TEXnically inclined. Ties are used to prevent LATEX from breaking lines at
certain places. LATEX will always choose line breaks that result in the most
aesthetically pleasing paragraph as judged by its stringent rules. But because
LATEX does not actually understand the material it is setting so beautifully,
it can make some poor choices.
A tie is the character ~. It behaves as a normal interword space in all
respects except that the line-breaking algorithm will never break a line at
that point. Thus
Dr. Seuss should be typed as Dr.~Seuss
for this makes sure that LATEX will never leave the ‘Dr’ at the end of one line
and put the ‘Seuss’ at the beginning of the next.
One should try to get in to the habit of typing ties first-time, not after
waiting to see if LATEX will make a poor choice This will allow you to make
all sorts of changes to your text without ever having to go back and insert
a tie at a point that has migrated to the end of a line from the middle of a
line as a result of those changes. Remember, of course, that the line-breaks
Here are some more examples of places where you should remember to
place ties.
13
# $ % & ~ _ ^ \ { }
are reserved for special use. Indeed, we have seen already that \ and ~ are
non-printing characters that perform special services (and we’ll have a lot
more to say about the use of \).
But what if we need one of these special symbols to appear in our doc-
ument? The answer for seven of the symbols is to precede them by a \
character, so forming another control symbol (remember that \ followed by
a space was also a control symbol).
It is not 100\% straightforward to typeset the
characters \$ \& \% \_ \{ \}, but given the
enormous convenience of the use they are normally
reserved for this is a small price to pay.
produces
It is not 100% straightforward to typeset the characters $ & %
{ }, but given the enormous convenience of the use they are normally
reserved for this is a small price to pay.
14
• \@ was a control symbol that told told LATEX that the very next period
did really end the sentence,
• \LaTeX is a control word that tell LATEX to insert its own name at the
current point,
• \S inserts a ¶ symbol,
15
We need to dwell on a TEXnicality for a moment. How does LATEX
know where the name of a control sequence ends? Will it accept both
\pounds3 and \pounds 3 in order to set £3? What about \poundsthree
vs. \pounds three? The answer is easy when you remember that a control
word consists only of alphabetic characters, and a control symbol consists of
exactly one nonalphabetic character.
So to determine which control sequence you typed, LATEX does the fol-
lowing:
This has one important consequence: The character in the input file
immediately after a control symbol will be “seen” by LATEX, but any space
following a control word will be discarded and never processed. This does not
affect one much if you adopt the convention of always typing a space after a
control sequence name.
There is a rare circumstance where this necessitates a little extra work
and thought, which we illustrate by example:
If we type a control word like \LaTeX in the running text
then we must be cautious, because the string of spaces that
come after it will be discarded by the \LaTeX\ system.
16
If we type a control word like LATEXin the running text then we
must be cautious, because the string of spaces that come after it will be
discarded by the LATEX system.
Each of the type style selection commands selects the specified style but
does not change the size of font being used. The default type style is roman
(you are reading a roman style font now).
Commands for changing type size work differently than commands for
changing type style. The commands for changing type size apply to any text
that follows the command. To limit the area of text over which one of these
commands has effect (its scope) we make that text into what is called a group
by using braces. Groups are used extensively in LATEX to keep effects local
to an area, rather than affecting the whole document. Apart from enhancing
usability, this also in a sense protects distinct parts of a document from each
other. To change type size you issue one of the type size changing commands
shown below, which will select the indicated size in the currently active style.
17
The point-size option referred to above is that specified in the \documentclass
command issued at the beginning of the input file. Through it you select that
base (or default) font for your document to be 10, 11, or 12 point Roman. If
no options are specified, the default is 10-point Roman. The table shows, for
instance, that if I issue a \large in this document for which I chose the 12pt
document class option the result will be a 14-point Roman typeface.
Here is an example of text style and size changes:
We \emph{emphasize} by putting the emphasized text
in the braces following the control word, and the same
goes for \textbf{emboldened} and other style changes.
For changing sizes, for example {\LARGE large} and
{\scriptsize scriptsize}, we put the control word and the
text inside braces.
2.9 Accents
LATEX provides many accents, which are accessed through a variety of control
symbols and single-letter control worlds which accept a single argument—the
letter to be accented. These control sequences are:
18
2.10 Over-ruling some of TEX’s choices
We’ve seen that ties can be used to stop linebreaks occurring between words.
But how can we stop LATEX from hyphenating a particular word? More
generally, how can we stop it from splitting any given group of characters
across two lines. The answer is to make that group of characters appears as
one solid box, through use of an \mbox command.
For instance, if we wanted to be sure that the word
19
2.11 Commenting your document
It is handy to be able to make comments to yourself in the source file for a
document. Things like “I must rewrite this section” and “This is version 3
of the document” are likely. It would also be useful to be able to make the
compiler ignore certain parts of the document at times. For this purpose we
can use the % character, for all text on an input line that is after a % which
is not part of an occurrence of the control symbol \% is discarded by the
compiler. Here is an example:
There was a 100\% turnout today,
an all-time record. %perhaps I should check this claim!
%Indeed, there are lots of unsubstantiated claims here!
This made for an extremely productive session.
will yields
There was a 100% turnout today, an all-time record. This made for
an extremely productive session.
2.12 Footnotes
Footnotes are considered bad form in mathematical writing. If you want to
use them nonetheless, inserting footnotes is easy in LATEX, because they will
be positioned and numbered automatically. You just indicate exactly where
the footnote marker should go, and provide the text of the footnote. The
footnote text will be placed at the bottom of the present page in a somewhat
smaller font, and be separated from the main text by a short horizontal rule1
to conform with convention. The footnote in the last line was typed like this:
...rule\footnote{See for yourself! It’s easy ...work.} to conform
No space was typed between the rule and the \footnote, because we
want the footnote marker to appear right next to the last letter of the word.
Multiple footnotes2 are obtained just by using the \footnote command
again and again.
1
See for yourself! It’s easy when you don’t have to do any work.
2
Here is another footnote
20
2.13 Topmatter
We declare the title and author information using the \title and \author
commands, each of which accept a single argument. Multiple authors are all
listed in the argument of \title, separated by \and’s. The \date command
can be used to date a document. After we have declared each of these, we
issue a \maketitle command to have them typeset for us. In the book and
article document styles this will result in a separate page; in the article
style the “top matter” will be placed at the top of the first page. The style
files determine the placement and the choice of font.
\title{A Thought for the Day}
\author{Fred Basset \and Horace Hosepipe}
\date{November 1992}
\maketitle
This topmatter must appear after the \begin{document} and before any
other printing material.
2.14 Labels
One of the great features of LaTEX is that chapters, sections, theorems, equa-
tions and the like are numbered automatically. Thus, if you decide to insert a
new section in the middle of an existing chapter, everything after that is au-
tomatically renumbered. The way automatic numbering works is that every-
thing that is numbered is given a label, usually written \label{labelname},
where labelname can be any character string starting made of numbers, let-
ters and punctuation, starting with a letter. Of course, each labeled item
must have a unique label. Because the label does not appear in the printed
version of the text, you can choose anything you want for the label; some-
thing mnemonic is always a good idea. For example, the label used for the
current section of this manual is \label{sec:labels}.
21
To refer to the labeled item, for example this section, we would write
Section~\ref{sec:labels}, which would produce Section 2.14. The \ref{ }
command works with chapters, sections, theorems, equations, etc. Such a
reference could be anywhere in the text, even before the item being refered
to.
Notice that no section number was given in the above command, and that
is because LATEX numbers the sections automatically!
22
There are occasions when you want a heading to have all the appearance
of a particular sectioning command, but shouldn’t be numbered as a section
in its own right or produce a table of contents entry. This can be achieved
through using the *-form of the command, as in \section*{...}. We’ll see
that many LATEX commands have such a *-form which modify their behaviour
slightly.
LATEX can automatically make a table of contents. Just include the com-
mand \tableofcontents after the \begin{document} command.
23
Horace smiled and retaliated:
\begin{quote}
You can mock the non-WYSIWYG nature of \TeX\
all you like. You don’t understand that that is
precisely what makes \TeX\ enormously more powerful
than that lame excuse for a typesetter you use.
In your case, what you see
is \emph{all} you get!
\end{quote}
and then continued with composing his masterpiece of the
typesetting art.
24
The \texttt{center} environment takes care of the vertical
spacing before and after it, so we don’t need to leave any.
\begin{center}
If we leave no blank line after the\\
\texttt{center} environment\\
then the ensuing text will not\\
be regarded as part of a new\\
paragraph, and so will not be indented.\\
\end{center}
In this case we left a blank line after the environment, so the new
text was regarded as starting a new paragraph.
25
\begin{verbatim}
In the verbatim environment we can type anything
we like.
So we don’t need to look out for uses of %, $, & etc,
nor will control sequences like \newline have any
effect.
\end{verbatim}
26
There is delightfully little to learn in order to be able to create lists.
The only new command is \item which indicates the beginning of a new
list item (and the end of the last one if this is not the first item). This
command accepts an optional argument (which means you’d enclose it in
square brackets) that can be used to provide an item label. If no optional
argument is given, then LATEX will provide the item label for you; in an
itemize list it will bullet the items, in an enumerate list it will number the
items, and in a list of descriptions the default is to have no label (which
would look a bit odd, so you’re expected to use the optional argument there).
Remember that \item is used to separate list items; it does not accept
the list item as an argument.
\begin{itemize}
\item an item is begun with \verb@\item@
\item if we don’t specify labels, then
\LaTeX\ will bullet the items for us
\item I indent lines after the first in the
input file, but that is just to keep things
readable. As always, \LaTeX\ ignores additional
spaces.
Lists can also be embedded within one another, for they are just environ-
ments and we said that environments have this property. Remember that we
27
must nest them in the correct order. We demonstrate with the following list,
which also shows how to use the enumerate environment.
\noindent I still have to do the following things:
\begin{enumerate}
\item Sort out LAN accounts for people on the course
\begin{itemize}
\item Have new accounts created for those not already
registered on the LAN
\item Make sure all users have a personal directory
on the data drive
\end{itemize}
\item Have a \TeX\ batch file added to a directory that
is on a public search path
\end{enumerate}
See how I lay the source file out in a readable fashion. This is to assist
myself, not LATEX.
The description environment is, unsurprisingly, for making lists of de-
scriptions.
\begin{description}
\item[\texttt{itemize}] an environment for setting itemised lists.
\item[\texttt{enumerate}] an environment for setting numbered lists.
\item[\texttt{description}] an environment for listing descriptions.
\end{description}
28
2.16.5 tabbing environment
This environment simulates tabbing on typewriters. There one chose the tab
stops in advance (analysing the material to be typed for the longest item in
each column) and typed entries consecutively, hitting the tab key to move to
the next tab stop and return to move to the next line.
In the tabbing environment, we proceed similarly. We look for the worst-
case line (that which will determine the desired tab stops) and use it to set
the tabs by inserting \= control symbols at the points where we want tab
stops. We then discard that line using \kill, since the worst-case line might
not be the first line in the material we have to type. We then type each line,
using \> to move to the next tab stop and \\ to end a line.
\begin{tabbing}
Cheddar cheese \= Recommended \= \$2.00 \kill
Green Ham \> Recommended \> \$2.00
Eggs \> 1 a week \> \$1.50
Cheddar cheese \> Hmmm \> \$0.80
Yak cheese \> Avoid \> \$0.05
\end{tabbing}
In the format line I chose the longest entry from each of the prospective
columns. I lined some of the \> commands up in the source just to keep
things readable.
Remember that excess spaces are ignored. LATEX sets the \killed line
normally and sees where the tab stops requested will be needed in the typeset
text. Note also that commands given within the tabbing environment are
local to the current item.
Actually, we use the above approach in the case that we require uniformly
tabbed columns. The format line is not compulsory, and we can define tab
stops dynamically. See if you can make sense of the following.
29
\begin{tabbing}
Entry in position 1,1 \= Entry 1,2 \= Entry 1,3\\
Entry in position 2,1 \> Entry 2,2 \> Entry 2,3\\
Entry 3,1 \= Entry 3,2 \> Entry 3,3\\
Entry 4,1 \> Entry 4,2 \> Entry 4,3
\end{tabbing}
which produces
The are additional commands that can be used within the tabbing envi-
ronment to achieve special effects, but we won’t be discussing them here.
30
\begin{tabular}{llrrl}
\texbf{Student name} & \textbf{Number} & \textbf{Test 1}
& \textbf{Test 2} & \textbf{Comment}\\
F. Basset & 865432 & 78 & 85 & Pleasing\\
H. Hosepipe & 829134 & 5 & 10 & Improving\\
I.N. Middle & 853931 & 48 & 47 & Can make it
\end{tabular}
31
Student name Number Test 1 Test 2 Comment
F. Basset 865432 78 85 Pleasing
H. Hosepipe 829134 5 10 Improving
I.N. Middle 853931 48 47 Can make it
That way of laying out the source file makes it clear where the lines will
go. As we (by now) well know, the returns that we pressed after the \\s in
typing this table might as well have been spaces as far as LATEX is concerned.
Thus it is common to have the \hline commands following the \\s on the
input lines. We will do this in future examples.
The \multicolumn column can be used to overrule the overall format of
the table for a few columns. The syntax of this command is
\multicolumn {n }{pos }{item }
where n is the number of columns of the original format that item is to span,
and pos specifies the justification of the new argument.
\begin{tabular}{||l|c|c|c||} \hline
\multicolumn{4}{|c|}{\LaTeX\ size changing commands}\\ \hline
Style option & 10pt (default) & \tt 11pt & \tt 12pt\\ \hline
\tt\bs footnotesize & 8pt & 9pt & 10pt\\ \hline
\tt\bs small & 9pt & 10pt & 11pt\\ \hline
\tt\bs large & 12pt & 12pt & 14pt\\ \hline
\end{tabular}
32
You suggest these options to LATEX through an optional argument to the
environment. One lists a combination of the letters h, t, b, and p where
ht means that the object should be placed here if there is room, so that
things will appear in the same order as in the source file,
t means that the object can be placed at the top of the of a text page, but
no earlier than the present page.
b means that the object can be placed at the bottom of a text page, but no
earlier than the present page.
p means that the object should be set on a page of floats that consists only
of tables and figures.
To leave space for a figure that will inserted by some other means at a
later date, we can use the \vspace command:
\begin{figure}[ht]
\vspace{9.5cm}
\caption{An artists impression}
\end{figure}
33
2.17 The letter document class
To write a letter, we can make use of the letter document class. We give
here a sample letter:
\documentclass[12pt]{letter}
\usepackage{amssymb, amsmath, amsthm, amsfonts}
\begin{document}
\begin{Letter}{Director of Public Parks\\
Pietermaritzburg Municipality\\
Pietermaritzburg}
\signature{F. Basset}
\opening{Kind Sir/Madam,}
\closing{Yours anxiously,}
\end{letter}
\end{document}
2.18 Bibliography
LATEX has a very convenient system of making a bibliography, in that it
automatically numbers bibliographic entries. Below is an example of a bib-
liography; such a bibliography is usually put at the very end of a document
(right before \end{document}), though in principle it could be put anywhere.
(Note that the bibliographic style used below corresponds to the style of the
American Mathematical Society, and is somewhat different than other bibli-
ographics styles, such as in the humanities.)
34
\begin{thebibliography}{99}
\bibitem{MARK}
Markov, A. A.,
\emph{Unsolvability of the problem of homeomorphism},
Proc. Int. Cong. Math.,
1958,
pp.~300--306
(Russian).
\bibitem{MU1}
Munkres, James R.,
\emph{Topology, A First Course},
Prentice-Hall,
Englewood Cliffs, NJ,
1975.
\bibitem{ir63}
Richards, Ian,
\emph{On the classification of noncompact surfaces},
Trans. Amer. Math. Soc.,
\textbf{106}~(1963),
259--269.
\end{thebibliography}
35
Bibliography
[1] Markov, A. A., Unsolvability of the problem of homeomorphism, Proc. Int. Cong.
Math., 1958, pp. 300–306 (Russian).
[2] Munkres, James R., Topology, A First Course, Prentice-Hall, Englewood Cliffs, NJ,
1975.
[3] Richards, Ian, On the classification of noncompact surfaces, Trans. Amer. Math. Soc.,
106 (1963), 259–269.
36
have accumulated to the point that LATEX is hopelessly confused, it is time
to debug your source file. The log file contains a reference to the line, or
lines, of your source file that generated the error together with a description
of the error.
TEX and LATEX error messages appear frightening at first sight, to say
the least. They are actually very informative, but they can take some get-
ting used to. Mistyped control sequences cause little pain, but a missing
\end{environment} can cause a good deal of confusion because it has the
effect of making LATEX try to set material into that environment that was
never intended/designed to fit in such a place. Also, ommiting a mandatory
argument can cause great confusion.
Suppose we type \textbold instead of \textbf in the following line:
this is going to be \textbold{very} messy.
That’s not so bad! The line beginning with ! tells us that we have tried
to used a control sequence that was not known to LATEX; the 1.683 tells us
that the error occurred on line 683 of the source file; and the error message
is split over two lines with the break occurring at the point where LATEX
detected a problem.
But suppose we try the following
\begin{tabular}{llrrl}
Student name & Number & Test 1 & Test 2 & Comment\\
F. Basset & 865432 & 78 & 85 & Pleasing\\
H. Hosepipe & 829134 & 5 & 10 & Improving\\
I.N. Middle & 853931 & 48 & 47 & Can make it
i.e., we omit to provide the \end{tabular} that delimits the end of the
environment. Not having been told that the environment is supposed to be
concluded, LATEX will try to set the text of the next paragraph as a table
37
item—and will scream blue murder when it finds that it doesn’t conform to
the syntax demanded.
LaTeX error. See LaTeX manual for explanation.
Type H <return> for immediate help.
! \begin{tabular} ended by \end{document}.
\@latexerr ...diate help.}\errmessage {#1}
38
make the decisions that are required of it.
6. Try to use a text editor that has a TEX mode, or at least one that will
match brackets for you.
39
Chapter 3
3.1 Introduction
In text-only documents we saw that our task was to describe the logical
components of each sentence, paragraph, section, table, etc. When we tell
LATEX to go into mathematical mode, we have to describe the logical parts of
a formula, matrix, operator, special symbol, etc. LATEX has been taught to
recognize a binary operation, a binary relation, a variable, an operator that
expects limits, and so on. We just need to supply the parts that make up
each of these, and LATEX will automatically leave appropriate space around
operators, italicise variables, set an operator name in roman type, leave the
correct space after colons, place sub- and superscripts in the correct positions
(based on what it is you’re working with), choose the correct typesizes, and
more. When you want to revert to setting normal text again, you tell LATEX
too leave math mode and go back into the mode it was in (paragraphing
mode).
LATEX cannot be expected to perform these mode shifts itself, for it is not
always clear just when it is mathematics that has been typed. For example,
should an isolated letter a in the input file be regarded as a word (as in the
definite article) or a mathematical variable (as in the variable a). There are
no reliable rules for LATEX to make such decisions by, so the begin-math and
end-math mode switching is left entirely to you.
The symbol $ is specially reserved by LATEX as the “math shift” symbol
40
(see Section 2.6). When LATEX starts setting a document it is in paragraphing
mode, ready to set lines of the input file into paragraphs. It remains in this
mode until it encounters a $ symbol, which shifts LATEX into mathematical
mode. It reads everything up to the next $ sign in this mathemtical mode,
and then shifts back to the mode it was in before we took it in to math mode.
You must be careful to balance your begin-math and end-math symbols.
It is often a good idea to type two $ symbols and then move back between
them and type the mathematical expression. If the math-shift symbols in a
document are not matched, then LATEX will become confused because it will
be trying to set non-mathematical material as mathematics.
For those who find having the same symbol for both math-begin and
math-end confusing or dangerous, there are two control symbols that perform
the same operations: the control symbol \( is a begin-math instruction, and
the control symbol \) is an end-math instruction. Because it is easy to
“lose” a $ sign when typing a long formula, a math environment is provided
for such occasions: you can use \begin{math} and \end{math} as the math-
shift instructions. However, most often the $ sign suffices.
Let’s have a look at some mathematics.
\LaTeX\ is normally in paragraphing mode, where
it expects to find the usual paragraph material. Including
a mathematical expression, like $2x+3y - 4z= -1$, in the
paragraph text is easy.
Typing the above expression without entering math
mode produces the incorrect result: 2x+3y - 4z= -1
41
lowing in mind:
1. All letters that are not part of an argument to some control sequence
will be italicised. So typing $f(x)>0 for x > 1$ will produce
$f(x,y) \geq 0$
which produces
f (x, y) ≥ 0 .
3. Some symbols have a different meaning when typed in math mode. Not
only do ordinary letters become variables, but symbols such as - and
+ are now interpreted as mathematical symbols. Thus in math mode -
is no longer considered a hyphen, but as a minus sign.
4. LATEX ignores all spaces and carriage returns when in math mode,
without exception. So typing something like the constant$ a$ will
produce “the constanta”. You should have typed the constant $a$.
LATEX is responsible for all spacing when in math mode, and (as in
paragraphing mode) you have to specially ask to have spacing changed.
Even if LATEX does ignore all spaces when in math mode you should (as
always in TEX) still employ spaces to keep your source file readable.
42
$f(x, y) = 2 (x+ y)y/(5xy - 3 )$
or
There are some places where LATEX’s automatic spacing can go wrong.
For instance, if we wish to speak of the x–y plane then one has to know that
it is an endash that is supposed to be placed between the x and the y, not a
minus sign (as $x-y$ would produce). But typing $x--y$ will produce x−−y
since both dashes are interpreted as minus signs. To avoid speaking of the
x − y plane or the x − −y plane, we should type it as the $x$--$y$ plane.
Fortunately, LATEX can recognize and cope with by far the majority of our
mathematical typesetting needs.
Another thing to look out for is the use of braces in an expression. Typing
${x : f(x)>0}$
will not produce any braces. This is because, as we well know, braces are
reserved for delimiting groups in the input file. Looking back to Section 2.6,
we see how it should be done:
$ \{ x: f(x)>0 \} $
43
long to fit into the running text without looking awkward. These are best
“displayed” on a line by themselves. Also, some expressions are sufficiently
important that they should be made to stand out. These, too, should be
displayed on a line of their own.
The mechanism for displaying an expression is the display math mode,
which is begun by typing $$ and ended by typing the same sequence (which
again means that we’d better be sure to type them in pairs). Corresponding
to the alternatives \( and \) that we had for the math shift character $, we
may use \[ and \] as the display-math shift sequences. One can also use the
environment
\begin{displaymath} ... \end{displaymath}
which is equivalent to $$ ... $$ and is suitable for use with long displayed
expressions. If you wish LATEX to number your equations for you you can use
the environment
\begin{equation}\label{labelname} ... \end{equation}
which produces
44
For each a for which the Lebesgue-set La (f ) = ∅ we define
45
space is left after them so that expressions like {xi : i = 1, 2, . . . , 10} look like
they should. Note that this means that normal sentence punctuation should
not migrate into an expression.
These two font change command, which work only in math mode, and
only for uppercase letters, are \mathbb{ } and \mathcal{ }.
We list here all the blackboard bold and calligraphic letters, so that we
can see, for reference purposes, what they all look like:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEF GHIJ KLMN OPQRST UVWX YZ
46
There are other change of text style commands that work specifically in
math mode, including \mathbf{ } (bold), \mathsf{ } (sans serif) and
\mathit{ } (italic). Use these commands only in math mode, and don’t
use the regular change of text style commands (for example \textbf{ } in
math mode).
Type To produce
$a+b$ a+b
$(a+b) \ otimes c$ (a + b) ⊗ c
$(a \vee b) \wedge c$ (a ∨ b) ∧ c
$X - (A \cap B) = (X-A) \cup (X-B)$ X − (A ∩ B) = (X − A) ∪ (X − B)
47
≤ \leq ≥ \geq ≡ \equiv |= \models
≺ \prec \succ ∼ \sim ⊥ \perp
# \preceq $ \succeq % \simeq | \mid
& \ll ' \gg ( \asymp ) \parallel
⊂ \subset ⊃ \supset ≈ \approx \bowtie
⊆ \subseteq ⊇ \supseteq ∼
= \cong \Join
\sqsubset \sqsupset = \neq \smile
.
/ \sqsubseteq 0 \sqsupseteq = \doteq ! \frown
∈ \in 1 \ni ∝ \propto
3 \vdash 4 \dashv
To negate a symbol you can precede the control word that gives the
symbol by a \not. Some symbols come with ready-made negations, which
should be used above the \not’ing method because the slope of the negating
line is just slightly changed to look more pleasing. Thus \notin should be
used above \not\in, and \neq should be used above \not =.
If negating a symbol produces a slash whose horizontal positioning is
not to your liking, then use the math spacing characters described in Sec-
tion 3.4.14 to adjust it.
Note that \imath and \jmath should be used when you need to accent
an i or a j in math mode (see Section 3.3.10)—you cannot use \i or \j that
were available in paragraphing mode.
48
Section 3.3.8. The available arrow symbols are:
LATEX will scale delimiters to the correct size (determined by what they en-
close) for you, if you ask it to. There are times when you don’t want a
delimiter to be scaled, so it is left up to you to ask for scaling.
To ask that a delimter be scaleable, you precede it by \left or \right
according as it is the left or right member of the pair. Scaled delimiters must
be balanced correctly. It sometimes occurs, as in the right-hand example
above, that only one member of a delimiting pair is to be visible. For this
purpose, use the commands \left. and \right. which will produce no
visible delimiter but can be used to correctly balance the delimiters in an
expression. For examples of the use of delimiters, see Section 3.4.11, where
we learn about arrays. The available delimiters are:
( ( ) ) ↑ \uparrow
[ ] ] ] ↓ \downarrow
{ \{ } \} d \updownarrow
l \lfloor m \rfloor ⇑ \Uparrow
n \lceil o \rceil ⇓ \Downarrow
p \langle q \rangle f \Updownarrow
/ / \ \backslash
| — ) \|
49
3.3.9 Operators like and
to use the larger form and will not try to reduce the height of the operator,
as in
N
fi .
i=1
If you want one of these operators to be used in text, but you want it to
look as it does when it is in display-math mode, simply insert the com-
mand \displaystyle at the start of the in-text math mode. For example, if
N
we write $\displaystyle \sum_{i=1}^{N}f_i$, we will obtain fi even
i=1
though it is in text. (The \displaystyle command should be used with
caution, because the resulting changes to line spacing often looks rather un-
pleasant, as in the previous sentence.
The available operators of this type are:
\sum \bigcap \bigodot
\prod \bigcup \bigotimes
\coprod \bigsqcup \bigoplus
\int \bigvee \biguplus
\oint \bigwedge
50
Remember that i and j should lose their dots when accented, so \imath
and \jmath should be used. There also exist commands that give a “wide
hat” or a “wide tilde” to their argument, \widehat and \widetilde.
Type To produce
$x^2$ x2
$\gamma^b$ γb
$(A+B)^2$ (A + B)2
% 2 &n
x +1
$\left[ \frac{x^2+1}{x^2 + y^2} \right]^n$ x2 +y 2
Subscripts of a single character are equally easy—you just use the under-
score character _ where you used ^ for superscripting:
51
Type To produce
$x_2$ x2
$x_i$ xi
$\Gamma_1(x)$ Γ1 (x)
Now let’s see how to set a sub- or superscript that consists of more than
just one character. This is no more difficult than before if we remember the
following rule: The symbols _ and ^ set the group that follows them as a
sub- and superscripts to the group that precedes the sub- and superscript
symbols. We see now now that our initial examples worked by considering a
single character to be a group by itself. Here are some examples:
Type To produce
$a^2b^3$ a2 b 3
$2^{21}$ 221
$2^21$ 22 1
$a^{x+1}$ ax+1
2
+1
$a^{x^2+1}$ ax
$(x+1)^3$ (x + 1)3
$\Gamma_{\alpha\beta\gamma}$ Γαβγ
${}_1A_2$ 1 A2
52
and the latter has rather more braces in it that require balancing.
Here are some more examples, showing how LATEX will set things just as
we want without any further work on our part:
Type To produce
z
$x^{y^z}$ xy
2
$2^{(2^2)}$ 2(2 )
2ℵ0
$2^{2^{2^{\aleph_0}}}$ 22
d
$\Gamma^{z_c^d}$ Γz c
We can also make use of empty groups in order to stagger sub- and
superscripts to an expression, as in
$\Gamma_{\alpha\beta}{}^{\gamma}{}_\delta$
3.4.2 Primes
LATEX provides the control word \prime (6) for priming symbols. Note that
it is not automatically at the superscript height, so that to get f you would
have to type
$f^\prime$ .
in order to get
f (g(x))g (x)h (x) .
53
3.4.3 Fractions
LATEX provides the \frac command that accepts two arguments: the numer-
ator and the denominator (in that order). Before we look at examples of its
use, let us just note that many simple in-text fractions are often better writ-
ten in the form num/den, as with 3/8 which can be typed as $3/8$. This is
also often the better form for a fraction that occurs within some expression.
Type To produce
x+1
$\frac{x+1}{x+2}$
x+2
1
$\frac{1}{x^2+1}$ 2
x +1
1 + x2
$\frac{1+x^2}{x^2+y^2} + x^2 y$ + x2 y
x2 + y 2
1
$\frac{1}{1 + \frac{x}{2}}$
1 + x2
1
$\frac{1}{1+x/2}$
1 + x/2
3.4.4 Roots
The \sqrt command accepts two arguments. The first, and optional, argu-
ment specifies what order of root you desire if it is anything other than the
square root. The second, and mandatory, argument specifies the expression
that the root sign should enclose:
Type To produce
√
$\sqrt{a+b}$ a+b
√
5
$\sqrt[5]{a+b}$ a+b
'
n 1+x
$\sqrt[n]{\frac{1+x}{1+x^2}}$ 2
√ +x
1
x+1
$\frac{\sqrt{x+1}} {\sqrt[3]{x^3+1}}$ √3
x3 + 1
54
3.4.5 Ellipsis
Simply typing three periods in a row will not give the correct spacing of the
periods if it is an ellipsis that is desired. So LATEX provides the commands
\ldots and \cdots. Centered ellipsis should be used between symbols like
+, −, ∗, ×, and =. Here are some examples:
Type To produce
$a_1+ \cdots + a_n$ a1 + · · · + an
$x_1 \times x_2 \times \cdots \times x_n$ x1 × x2 × · · · × xn
$v_1 = v_2 = \cdots = v_n = 0$ v1 = v2 = · · · = vn = 0
$f(x_1,\ldots,x_n) = 0$ f (x1 , . . . , xn ) = 0
Type To produce
$f_i(x) \leq 0 \text{ for } x \in I$ fi (x) ≤ 0 for x ∈ I
$\Gamma(n)=(n-1)! \text{ when $n$ is an integer}$ Γ(n) = (n − 1)! when n is an integer
In section 3.4.14 we’ll learn of some special spacing commands that can
be used in math mode. These are often very useful in positioning text within
an expression, enhancing readability and logical layout.
55
and
sin h
lim =1 .
h→0 h
logθ .
Type To produce
$f(x)=\sin x + \log(x^2)$ f (x) = sin x + log(x2 )
$\delta = \min \{ \delta_1, \delta_2 \}$ δ = min{δ1 , δ2 }
$\chi(X) = \sup_{x\in X} \chi(x)$ χ(X) = supx∈X χ(x)
$\lim_{n \rightarrow \infty} S_n = \gamma$ limn→∞ Sn = γ
Notice how LATEX does more than just set an operation like sup in roman
type. It also knew where a subscript to that operator should go.
As is the case with operators, when a log-like function takes a sub-
script, it looks different when in text and when in display, though that
difference can be overridden with the \displaystyle command. Compare
$\lim_{x \rightarrow 0} f(x)$, which produces limx→0 f (x), with
$$\lim_{x \rightarrow 0} f(x)$$, which produces
lim f (x),
x→0
56
3.4.8 Over- and Underlining and bracing
The \underline command will place an unbroken line under its argument,
and the \overline command will place an unbroken line over its argument.
These two commands can also be used in normal paragraphing mode (but be
careful: LATEX will not break the line within an under- or overlined phrase,
so don’t go operating on large phrases).
You can place horizontal braces above or below an expression by making
that expression the argument of \overbrace or \underbrace. You can place
a label on an overbrace (resp. underbrace) by superscripting (resp. subscript-
ing) the group defined by the bracing command.
Type To produce
$\overline{a+bi} = a- bi$ a + bi = a − bi
$\overline{\overline{a+bi}} = a+bi$ a + bi = a + bi
will produce
n terms
( )* +
A = A× A× ...× A
n
and
∀x ∃y(y x)
* +( )
scope of ∀
57
3.4.10 Operators; Sums, Integrals, etc.
Each of the operation symbols listed in Section 3.3.9 can occur with limits.
They are specified as sub- and superscripts to the operator, and LATEX will
position them appropriately. In an in-text formula they will appear in more-
or-less the usual scripting positions; but in a displayed formula they will be
set below and above the symbol (which will also be a little larger). The
following should give you an idea of how to use them:
Type To produce
N
$\sum_{i=1}^{N} a_i$ ai
b i=1
$\int_a^b f$ f
a
$\oint_{\cal C}f(x)\,dx$ f (x) dx
C
$\prod_{\alpha \in A} X_\alpha$ α∈A Xα
$\lim_{N\rightarrow\infty}\sum_{i=1}^{N}f(x_i)\Delta x_i$ limN →∞ N i=1 f (xi )∆xi
We’ll have more to say about the use of \, in section 3.4.14. Let’s have
a look at each of those expressions when displayed:
N b
N
ai , f , f (x) dx , Xα , lim f (xi )∆xi
a C N →∞
i=1 α∈A i=1
3.4.11 Arrays
The array environment is provided for typesetting arrays and array-like ma-
terial. It accepts two arguments, one optional and one mandatory. The
optional argument specifies the vertical alignment of the array—use t, b, or
c to align the top, bottom, or centre of the array with the centreline of the
line it occurs on (the default being c). The second argument is as for the
tabular environment: a series of l, r, and c’s that specify the number of
columns and the justification of these columns. The body of the array en-
vironment uses the same syntax as the tabular environment to specify the
individual entries of the array.
For instance the input
58
let $A = \left[\begin{array}{rrr}
12 & 3 & 4\\
-2 & 1 & 0\\
3 & 7 & 9
\end{array}\right] $
which produces
, ,
, a11 a12 ··· a1n ,
, ,
, a21 a22 ··· a2n ,
, ,
det A = , . .. .. .. ,
, .. . . . ,
, ,
, am1 am2 ··· amn ,
A special case of an array is the cases environment, which is as follows:
f(x) = \begin{cases}
x & \text{for $x<1$}\\
x^2 & \text{for $x \geq 1$}
\end{cases}.
59
3.4.12 Alignment
Recall that the equation environment can be used to display and automati-
cally number a single-line equation (see Section 3.2). The align environment
is used for displaying and automatically numbering either a single expression
that spreads over several lines or multiple expressions, while taking care of
alignment for us. The align* environment does this without numbering any
equations. It is necessary to input the amsmath package to use the align
and align* environments. Do NOT use $$ ... $$ symbols when using the
align environment.
\begin{align}
(a+b)(a+b) & = a^2 + 2ab + b^2\\
(a+b)(a-b) & = a^2 - b^2
\end{align}
will give
Observe that the & sign is used to mark the place in each line that is
aligned. We can also leave entries empty, to obtain effect like the following:
\begin{align*}
\frac{d}{dx} \sin x & = \lim_{h\rightarrow0}\frac{\sin(x+h)-\sin x}{h}\\
& = \lim_{h\rightarrow0}\frac{\sin x\cos h + \cos x\sinh - \sin x}{h}\\
& = \lim_{h\rightarrow0}\frac{\sin x(\cos h-1)}{h} + \cos x\frac{\sin h}{h}\\
& = \cos x
\end{align*}
which produces
60
d sin(x + h) − sin x
sin x = lim
dx h→0 h
sin x cos h + cos x sinh − sin x
= lim
h→0
h -
sin x(cos h − 1) sin h
= lim + cos x
h→0 h h
= cos x
will give
(a + b)2 = a2 + 2ab + b2
(a + b)3 = a3 + 3a2 b + 3ab2 + b3
By comparison,
$$(a+b)^2 = a^2 + 2ab + b^2$$
$$(a+b)^3 = a^3 + 3a^2b + 3ab^2 + b^3$$
will give
61
(a + b)2 = a2 + 2ab + b2
(a + b)3 = a3 + 3a2 b + 3ab2 + b3
which has extra space between the two equations.
Another useful environment is multline, which is used for breaking up a
long equation. (Note: it does NOT say multiline.) The syntax is similar to
that of the align environment, but again there are no & signs, because there
is no alignment. The multline* environment does the same thing without
numbering any equations. It is necessary to input the amsmath package to
use the multline and multline* environments. For example:
\begin{multline}
\sum_{\sigma^n \in K} \frac{(-1)^n(n-1)}2 =
- \sum_{\sigma^{n-1} \in K} T_n({\sigma^{n-1}}) (-1)^{\dim \sigma^{n-1}}\\
- \sum_{\sigma^n \in K} T_n({\sigma^n}) (-1)^{\dim \sigma^n}.
\end{multline}
will give
(−1)n (n − 1) n−1
=− Tn (σ n−1 )(−1)dim σ
σn ∈K
2
σn−1 ∈K
n
− Tn (σ n )(−1)dim σ . (3.3)
σn ∈K
The spacing commands \,, \quad, and \qquad can be used in paragraph-
ing mode, too. Here are some examples of these spacing commands used to
make subtle modifications to some expressions.
62
Type To produce
√
$\sqrt{2} \, x$ 2x
b
$\int_a^b f(x)\,dx$ a
f (x) dx
$\Gamma_{\!2}$ Γ2
b d
$\int_a^b \! \int_c^d f(x,y)\,dx\,dy$ a c
f (x, y) dx dy
$x / \! \sin x$ x/sin x
√
$\sqrt{\,\sin x}$ sin x
Then, every time you want to write (x1 , . . . , xn ), all you need to do is write
$\vec$.
There are three important points to keep in mind when defining macros:
(1) Do not include the $ signs in the formula given in \newcommand; including
the $ signs in the macro would cause problems. (2) Use a mnemonic name
when defining a macro, but do not use a name that TEX already uses. (3)
TEX is case sensitive; that is, the name \vec is not the same as \Vec.
Next, suppose that in some places you want to write (x1 , . . . , xn ), and
other places you want to write (x1 , . . . , xk ). It would be silly to make a
different macro for each of these two formulas. Rather, we use a variable in
the macro. For example, we could use:
\newcommand{\vecn}[1]{(x_1, \ldots, x_{#1})}
63
because TEX will then look for a macro called \vecnk, which is not what you
defined, and so you will receive an error message.) If we want the formula
(x1 , . . . , xk+1 ) we would simply write $\vecn{k+1}$.
It is possible to have more than one variable in a macro. For example,
suppose that in some places you want to write (x1 , . . . , xn ), and other places
you want to write (y1 , . . . , yk ). We could then use the macro:
\newcommand{\vecxn}[2]{({#1}_1, \ldots, {#1}_{#2})}
Then, if we want the formula (x1 , . . . , xk ) we would write $\vecxn xn$, and
if we want the formula (w1 , . . . , wr−3) we would write $\vecxn w{r-3}$.
As a rule of thumb, if you use any built up mathematical formula more
than a few times, it is worth making a macro for it.
Finally, we point out that LATEX, AMS-LATEX, and the Bard Senior
Project style are themselves just lengthy collections of TEX macros.
64
f\colon A \to B
Observe that the colon is written \colon, NOT : (which would produce
the wrong spacing).
Theorem 1. X is normal if, and only if, each pair of disjoint closed sets in
X is completely separated.
65
Notice that LATEX italicises the theorem statement, and that you still
have to shift in to math mode when you want to set symbols and expression.
Typically, it is the style file that determines what a theorem will appear like—
so don’t go changing this if you are preparing for submission for publication
(because the journal staff want to substitute their production style for your
document class choice, and not be over-ridden by other commands).
LATEX automatically numbers theorems and the like. To refer to a theo-
rem or similar structure, use the theorem’s label in the say way that you refer
to chapter and section names. For example, to refer to the theorem written
above, simply write Theorem~\ref{thm:normal}, which will produce The-
orem 1. It is possible to have different structures, such as theorems and
lemmas, be numbered consecutively, but we will not discuss that here; please
see other LATEX manuals.
66