From: gmaltby@unpcs1.cs.unp.ac.za (Gavin Maltby)
Newsgroups: comp.text.tex
Subject: latex notes: 3 of 4
Summary: part 3 of 4
Keywords: latex notes
Date: 27 Jan 93 06:54:20 GMT
Organization: University of Natal, Pietermaritzburg, South Africa
NNTP-Posting-Host: pc038.cc.unp.ac.za

% part 3 of 4
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 \verb@\\@s in typing this table might
as well have been spaces as far as \LaTeX\ is concerned.  Thus
it is common to have the \verb@\hline@ commands following the
\verb@\\@s on the input lines.  We will do this in future examples.

The \verb@\multicolumn@ column can be used to overrule the overall
format of the table for a few columns.  The syntax of this command
is

\begin{syntax}{multicolumn}
\man{n}\man{pos}\man{item}
\end{syntax}

\noindent where $n$ is the number of columns
of the original format that {\em item\/}
is to span, and {\em pos\/} specifies the justification
of the new argument.

\moveright0.1\textwidth\vbox{%
\footnotesize\begin{verbatim}
\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}
\end{verbatim}
}
\noindent produces the following table:

\begin{center}\footnotesize
\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}
\end{center}

\nsubsubsection{{\tt figure} and {\tt table} environments}
Figures (diagrams, pictures, etc.)\ and tables (perhaps created
with the {\tt tabular} environment) cannot be split across
pages.  So \LaTeX\ provides a mechanism for ``floating''
them to a nearby place where there is room for them.  This
may mean that your figure or table may appear a little later in the
document than its declaration in the source file might suggest.
You can suggest to \LaTeX\ that it try to place the figure or
table at the present position if there is room 
or, failing that, at the top or bottom of
the present or following page.  You can also ask for it to be presented by
itself on a ``page of floats''.  

You suggest these options to \LaTeX\ through an optional
argument to the environment.  One lists a combination
of the letters {\tt h}, {\tt t}, {\tt b}, and {\tt p} where
\begin{description}
\item[h] means that the object should be placed {\em here} if there
         is room, so that things will appear in the same order as
         in the source file,
\item[t] means that the object can be placed at the {\em top\/} of the of a text
         page, but no earlier than the present page.
\item[b] means that the object can be placed at the {\em bottom\/} of a text
         page, but no earlier than the present page.
\item[p] means that the object should be set on a {\em page of floats\/} that consists
         only of tables and figures.
\end{description}

A combination of these indicates decreasing order of preference.
The default is {\tt tbp}.  In this document I have tended to use
{\tt htbp}.

\LaTeX\ will also number and caption a figure or table for you,
and compile a list of tables and a list of figures.
Just include  \verb@\listoffigures@ and \verb@\listoftables@
next to your \verb@\tableofcontents@ command at the beginning
of the document.  To caption a table of figure, include
\verb@\caption{@{\em caption text}\verb@}@ just before the
\verb@\end{table}@ or \verb@\end{figure}@ command.  Here's
a sample source file.

\moveright0.1\textwidth\vbox{%
\footnotesize\begin{verbatim}
\begin{table}[htbp]
   \begin{tabular}{lrll}
   ...
   \end{tabular}
\caption{Mark analysis}
\end{table}
\end{verbatim}
}

To leave space for a figure that will inserted by some
other means at a later date, we can use the \verb@\vspace@
command:

\moveright0.1\textwidth\vbox{%
\footnotesize\begin{verbatim}
\begin{figure}[htbp]
\vspace{9.5cm}
\caption{An artists impression}
\end{figure}
\end{verbatim}
}

Including graphics files prepared with drawing packages is
possible, but beyond the scope of this introduction.

\subsection{The {\tt letter} document style}
All this and we still don't know how to prepare
a simple letter!  Actually, there is very little
to it.

Figure~\ref{fig:letter} shows a sample letter.  We declare
our own address and signature before entering the {\tt letter}
environment because we can use repeated {\tt letter}
environments to prepare multiple letters from the same source
file.  The address of the intended recipient of a particular
letter is given as an argument to the {\tt letter} environment.

\begin{figure}[p]
\moveright0.1\textwidth\vbox{%
\footnotesize\begin{verbatim}
\documentstyle[12pt]{letter}
\begin{document}
\address{(Underneath) Lion Bridge\\
Midway down Commercial Road\\
Pietermaritzburg\\
3200}

\signature{F. Basset\\
Public nuisance}

\begin{Letter}{Director of Public Parks\\
Pietermaritzburg Municipality\\
Pietermaritzburg}

\opening{Kind Sir/Madam}

I wish to complain about the shocking practice of
fencing off the base of trees.  I notice with grave
concern that this has occurred in the park bordering
my stately residence.

This has already caused me great inconvenience
and public embarrassment, as you can imagine it would
for a hound of my social standing.  I demand that
you take these obscene obstructions away without
delay.

\closing{Yours anxiously}
\end{letter}
\end{document}
\end{verbatim}
}
\vfil\caption{A sample letter}
\label{fig:letter}
\end{figure}

\subsection{Common pitfalls;  Error messages}
By now it should be clear that we have to work quite
accurately when preparing a document.  Typing errors
in the running text can be absorbed, but messing up
a control sequence name will halt the compiler with
an error message.  Before we look at some common errors and
some ways to avoid them, let's have a look at a sample 
error message.

You'll have noticed by now that when you run \LaTeX\
on a source file, the transcript of the compiler
session is written on a log file.  When errors 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 getting used to.  Mistyped control
sequences cause little pain, but a missing
\verb@\end{@{\em environment}\verb@}@ 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 \verb@\bold@ instead of \verb@\bf@ in the following
line:

\moveright0.1\textwidth\vbox{
\footnotesize\begin{verbatim}
this is going to be {\bold very} messy.
\end{verbatim}
}
\noindent  This produces the following error message:

\moveright0.1\textwidth\vbox{
\footnotesize\begin{verbatim}
! Undefined control sequence.
1.683 this is going to be {\bold
                                very} messy.
?
\end{verbatim}
}
That not so bad!  The line beginning with {\tt!} tells us that we
have tried to used a control sequence that was not known to
\LaTeX;  the {\tt 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

\moveright0.1\textwidth\vbox{%
\footnotesize\begin{verbatim}
\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

This shows that H.~Hosepipe's newfound concentration has...
\end{verbatim}
}
i.e., we omit to provide the \verb@\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 item---and will scream blue murder when it
finds that it doesn't conform to the syntax demanded.

\moveright0.1\textwidth\vbox{%
\footnotesize\begin{verbatim}
LaTeX error.  See LaTeX manual for explanation.
              Type  H <return>  for immediate help.
! \begin{tabular} ended by \end{document}.
\@latexerr ...diate help.}\errmessage {#1}
                                          
\@checkend ...urrenvir \else \@badend {#1}
                                          \fi 
\enddocument ->\@checkend {document}
                                    \clearpage \begingroup \if@filesw...
\end #1->\csname end#1\endcsname 
                                 \@checkend {#1}\expandafter \endgrou...
l.58 \end{document}
                   
? 
\end{verbatim}
}

Now {\em that's\/} informative!  Actually it {\em is} if we 
agree to ignore all but the the error indication line
(the one beginning with the {\tt!}) and the line telling us
where \LaTeX\ noticed that all was not well (the one beginning
{\tt 1.58} in this case).  The rest of the error message you can
regard as being for your local \TeX\ wizard to sort your problem
out if you are unable to after consulting the manuals.
Tough as it looks, we can decipher this message straight
away: the error indicator line tell us that a {\tt tabular}
environment was ended incorrectly (in this case by an
\verb@\end{document}@).

\TeX\ error messages aren't all that bad once you've made
enough errors to get used to a few!  Most can be avoided
through {\em careful\/} preparation of the source file.
Typing accurately and knowledge of the command syntax is a good start,
but there are some other precautions that make good sense:
\begin{enumerate}
\item Even if \LaTeX\ is happy with free-form input, try to
      lay your input file out as regularly and logically as 
      possible.  See our examples of environments for
      formats to adopt.
\item It is important that all group delimiters be properly matched,
      i.e., braces and {\tt\bs begin\{\}}\ldots{\tt\bs end\{\}} must
      come in pairs.  A good habit to fall in to is to always type
      such things in pairs and then move the cursor back between
      them and type the intervening material.
\item Don't forget command arguments when they are mandatory.
      Always ask yourself what a particular commands {\em needs
      from you\/} in order to make the decisions that are required of it.
\item Remember the 10 characters that are specially reserved for
      commenting, table item separation, etc.
\item When we look at mathematical typesetting in the next chapter,
      we will see that the same principles apply there.
\item Try to use a text editor that has a \TeX\ mode, or at least
      one that will match brackets for you.      
\end{enumerate}

\section{Summary}
We have learned pretty much all we need to know in order to 
prepare non-mathematical documents.  There has been quite
a lot of material, all told, but we're fortunate that the
average document requires only a fraction of what we've
listed here.  Furthermore, we'll find that what we've
learned equips us with a good deal of the framework
needed for mathematical typesetting.

The important thing to extract from this chapter is some
feel for what I termed the ``spirit of \TeX'' at the
chapter beginning.  I cannot emphasise enough the
importance of getting your mind out of ``word processing''
mode and into ``typesetting'' mode.  Always keep uppermost
in your mind the task at hand:  you are to describe the
logical content of the document to \LaTeX, so furnishing
it with enough information to perform all the formatting
for you.

Many of the earlier sections of this chapter will become
trivially easy to you after just a little experimentation
with \LaTeX.  The best way to learn the syntax of the more
complicated environments is to use them---try typesetting
the examples, for instance.  It is important that you come
to terms with the {\tt tabular} environment, for its
syntax is typical of many of the mathematical constructs 
that we will use.

If you have not already done so, then now is the time
to try preparing some documents of your own.  Try
including all the material from this chapter, for
that is the best way to remember it all.  When
the initial lack of familiarity wears off, you'll
find that \LaTeX\ is really a whole lot friendlier
and easier to use than you expected.

We must also recognise that there is a lot more to some of the command
than detailed here.  Some accept optional argumnets that were not mentioned,
others have more options than we considered.  And even once we have a full
description of each command, there is still much to be learned for there
is much that can be achieved through creative use of some of the environments.





\chapter{Mathematical typesetting with \LaTeX}


The last chapter taught us a good deal of what we need to know in order to
prepare quite complicated non-mathematical documents.  There are still a
number of useful topics that we have not covered (such as cross-referencing),
but we'll defer discussion of those until a later chapter.  In the present
chapter, we'll learn how \LaTeX\ typesets mathematics.  It should come
as no surprise that \LaTeX\ does most of the work for us.

\section{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 {\em mathematical mode}, we have to
describe the logical parts of a formula, matrix, operator, special symbol, etc.
\TeX\ 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 \TeX\ will take care of
the rest.  It will 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, \ldots\ the list of things it has been taught is
enormous.  When you want to revert to setting normal text again, you tell
\LaTeX\ too leave maths 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 {\tt 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 \verb@$@ is specially reserved\footnote{See section \ref{sec:reserved}}
 by \LaTeX\ as the ``math shift'' symbol.  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 \verb@$@ symbol, which shifts \LaTeX\ into mathematical
mode.  It now knows to be on the look-out for the components of a mathematical
expression, rather than for words and paragraphs.  It reads everything
up to the next \verb@$@ sign in this mathemtical mode, and then shifts back to
paragraphing mode (i.e.\ the mode it was in before we took it in to
maths mode).

You must be careful to balance your begin-math and end-math
symbols.  It is often a good idea to type two \verb@$@ 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 \verb@\(@ is
a begin-math instruction, and the control symbol \verb@\)@
is an end-math instruction.  Since it is easy to ``lose'' a \verb@$@
sign when typing a long formula, a math environment is provided
for such occasions:  you can use \verb@\begin{math}@ and
\verb@\end{math}@ as the math-shift instructions.  Of course, you
could just decide to use \verb@$@ and take your chances.

Let's have a look at some mathematics.

\moveright0.1\textwidth\vbox{%
\footnotesize\begin{verbatim}
\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.  \TeX\ has been taught to recognize
the basic elements of an expression, and typeset them appropriately,
choosing spacing, positioning, fonts, and so on.
Typing the above expression without entering maths
mode produces the incorrect result: 2x+3y - 4z= -1
\end{verbatim}
}
\noindent will produce the following paragraph

\result{
\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.  \TeX\ has been taught to recognize
the basic elements of an expression, and typeset them appropriately,
choosing spacing, positioning, fonts, and so on.
Typing the above expression without entering maths
mode produces the incorrect result: 2x+3y - 4z= -1
}

Notice that \LaTeX\ sets space around the binary relation
$=$ and space around the binary operators $+$ and $-$ on the
left hand side of the equation, ignoring the
spacing we typed in the input. It was also able to recognize
that the $-1$ on the right hand side of the equation was
a unary minus---negating the $1$ rather than being used to
indicate subtraction---and so did not put space around it.
It also italicised the
variables $x$, $y$, and $z$.  However, it did not italicise
the number $1$.

In typing a mathematical expression we must remember to keep the
following in mind:
\begin{enumerate}
\item All letters that are not part of an argument to some control
sequence will be italicised.  Arguments to control sequences will
be set according to the definition of the command used.  So
typing \verb@$f(x)>0 for x > 1$@ will produce
$$f(x)>0 for x > 1$$
instead of the expression
$$f(x)>0 \mbox{\quad for\quad} x>1$$
that we intended.  Numerals and punctuation marks are set
in normal roman type but \LaTeX\ will take care of the
spacing around punctuation symbols, as in

\moveright0.1\textwidth\vbox{%
\footnotesize\begin{verbatim}
$f(x,y) \geq 0$
\end{verbatim}
}
\noindent which produces
$$f(x,y) \geq 0\quad.$$

\item Even a single letter can constitute a formula, as in
``the constant $a$''.  To type this you enter \verb@$a$@ in
your source file.  If you do not go in to maths mode to type
the symbol, you'll get things like ``the constant a''.

\item Some symbols have a different meaning when typed in maths
mode.  Not only do ordinary letters become variables, but symbols
such as \verb@-@ and \verb@+@ are now interpreted as mathematical
symbols.  Thus in maths mode \verb@-@ is no longer considered
a hyphen, but as a minus sign.

\item \LaTeX\ ignores all spaces and carriage returns 
when in maths mode, without exception.  So typing something
like \verb@the constant$ a$@ will produce ``the constant$ a$''.
You should have typed \verb@the constant $a$@.  \LaTeX\
is responsible for all spacing when in maths mode, and
(as in paragraphing mode) you have to specially ask to have
spacing changed.  Even if \LaTeX\ does ignore all spaces
when in maths mode you should (as always in \TeX) still employ
spaces to keep your source file readable.
\end{enumerate}

The above means that, at least for most material, a typist need
not understand the mathematics in order to typeset it correctly.
And even if one does understand the mathematics, \LaTeX\ is there to
make sure that you adhere to accepted typesetting conventions (whether
you were aware of their existence or not).

So one could type either

\moveright0.1\textwidth\vbox{
\footnotesize\begin{verbatim}
$f(x, y)  =  2 (x+ y)y/(5xy - 3  )$
\end{verbatim}

\noindent{\normalsize or}

\begin{verbatim}
$f(x,y) = 2(x+y)y / (5xy-3)$
\end{verbatim}
}
\noindent and you'd still get the correct result
$$f(x,y) = 2(x+y)y / (5xy-3)\quad.$$

There are some places where this can go wrong.  For instance,
if we wish to speak of the $x$-$y$ plane then one has to know
that it is an {\em endash\/} that is supposed to be placed between
the $x$ and the $y$, not a minus sign (as \verb@$x-y$@ would produce).
But typing \verb@$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 \verb@the $x$--$y$ plane@.  We are fortunate that \LaTeX\
can recognise 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

\moveright0.1\textwidth\vbox{
\footnotesize\begin{verbatim}
${x : f(x)>0}$
\end{verbatim}
}
\noindent 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~\ref{sec:reserved}, we see how it should be done:

\moveright0.1\textwidth\vbox{
\footnotesize\begin{verbatim}
$ \{ x: f(x)>0 \} $
\end{verbatim}
}

Math shift commands also behave as scope delimiters, so that 
commands issued in an expression cannot affect anything else in
a document.

\section{Displaying a formula}\label{sec:display}
\LaTeX\ considers an expression \verb@$ ... $@ to be word-like in the
sense that it considers it to be eligible for splitting across lines
of a paragraph (but without hyphenation, of course).  \LaTeX\ assigns
quite a high penalty to doing this, thus trying to avoid it (remember
that \LaTeX\ tries to minimize the ``badness'' of a paragraph).
When there is no other way, it will split the expression at a suitable place.
But there are some expressions which are just too 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 {\em display math\/}
mode, which is begun by typing \verb@$$@ 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 \verb@\(@ and \verb@\)@ that we had
for the math shift character \verb@$@, we may use \verb@\[@ and
\verb@\]@ as the display-math shift sequences.  One can also
use the environment

\moveright0.1\textwidth\vbox{%
\footnotesize\begin{verbatim}
\begin{displaymath} ... \end{displaymath}
\end{verbatim}
}
\noindent which is equivalent to \verb@$$ ... $$@ and is suitable for
use with long displayed expressions. If you wish \LaTeX\
to number your equations for you you can use the environment

\moveright0.1\textwidth\vbox{
\footnotesize\begin{verbatim}
\begin{equation} ... \end{equation}
\end{verbatim}
}
\noindent which is the same as the \verb@displaymath@ environment, except that
an equation number will be generated.

It is poor style to have a displayed expression either begin a paragraph
or be a paragraph by itself. This can be avoided if you agree to
{\em never leave a blank line in your input file before a math display}.

We will see later how to typeset an expression that is to span
multiple lines.  For now, let's look at an example of displaying
an expression:

\moveright0.1\textwidth\vbox{%
\footnotesize\begin{verbatim}
For each $a$ for which the Lebesgue-set $L_a(f) \neq \emptyset$ we define
$$ % We could have used \begin{displaymath} here
{\cal B}_a(f) = \{ L_{a+r}(f) : r > 0  \},
$$ % and \end{displaymath} here
and these are easily seen to be completely regular.
\end{verbatim}}
\noindent which produces

\result{
For each $a$ for which the Lebesgue-set $L_a(f) \neq \emptyset$ we define
$$ 
{\cal B}_a(f) = \{ L_{a+r}(f) : r > 0  \},
$$
and these are easily seen to be completely regular.
}

That illustrates how to display an expression, but also shows that
we've got a lot more to learn about mathematical typesetting.  Before
we have a look at how to arrange symbols all over the show (e.g.\
the subscripting above) we must learn how to access the multitude
of symbols that are used in mathematical texts.

\section{Using mathematical symbols}\label{sec:symbols}
\LaTeX\ puts all the esoteric symbols of mathematics at
our fingertips.  They are all referenced by name, with the naming system
being perfectly logical and systematic.  None of the control words that
access these symbols accepts an argument, but we'll soon see that
some of them prepare \LaTeX\ for something that might follow.  For instance,
when you ask for the symbol `$\sum$' \LaTeX\ is warned that any sub- or
superscripts that follow should be positioned appropriately as limits
to a summation.  In keeping
with the \TeX\ spirit, none of this requires any additional work on your
part.

We'll also see that some of the symbols behave differently depending on
where they are used.  For instance, when I ask for $\sum_{i=1}^{n}a_i$ within
the running text, the limits are places differently to when I ask
for that expression to be displayed:
$$\sum_{i=1}^{n}a_i\quad.$$
Again, I typed nothing different here---just asked for display math mode.

It is important to note that {\em almost all of the special maths symbols are
unavailable in ordinary paragraphing mode}. If you need to use one there,
then use an in-line math expression \verb@$...$@.

\subsection{Symbols available from the keyboard}
A small percentage of the available symbols can be obtained from just
a single key press.  They are $+$ $-$ $=$ $<$ $>$ $|$ $/$ $($ $)$
$[$ $]$ and $*$.  Note that these must be typed {\em within maths mode\/}
to be interpreted as math symbols.

Of course, all of $a$--$z$, $A$--$Z$, the numerals $0, 1, 2, \ldots, 9$ and
the punctuation characters $,$ $;$ and $:$ are available directly from the keyboard.
Alphabetic letters will be assumed to be variables that are to be
italicised, unless told otherwise\footnote{See section \ref{sec:mathtext}}.
The numerals receive no special attention, appearing precisely as in
normal paragraphing mode.  The punctuation symbols
are still set in standard roman type when read in maths mode, but a little
space is left after them so that expressions like $\{x_i : i=1,2,\ldots,10\}$
look like they should.  Note that this means that normal sentence punctuation
should not migrate into an expression.

\subsection{Greek letters}

\newcommand{\ds}[1]{$\csname#1\endcsname$ & \tt\bs #1 }
\newcommand{\dsf}[4]{\ds{#1}&\ds{#2}&\ds{#3}&\ds{#4}}
\newcommand{\dst}[3]{\ds{#1}&\ds{#2}&\ds{#3}}

Tables \ref{tab:lgreek} and \ref{tab:ugreek} show the control sequences that produce the
letters of the Greek alphabet.  We see that a lowercase Greek letter
is simply is accessed by typing the control word of the same name
as the symbol, using all lowercase letters.  To obtain an uppercase
Greek letter, simply capitalise the {\em first\/} letter of its name.

Just as \verb@$mistake$@ produces $mistake$ because the letters
are interpreted as variables, so too will \verb@$\tai \epsilon \chi$@
produce the incorrectly spaced $\tau \epsilon \chi$ if you try to
type greek words like this.  \TeX\ can be taught to set Greek, but
this is not the way.  $\tau\!\epsilon\!\chi$, % and nor is this
incidentally, is the Greek word for ``art'' and it is from the initials of the
Greek letters constituting this word that the name \TeX\ was derived.
\TeX\ is ``the art of typesetting''.

\begin{table}[thbp]
\centering\footnotesize
\begin{tabular}{llllllll}
\dsf{alpha}{beta}{gamma}{delta}\\
\dsf{epsilon}{varepsilon}{zeta}{eta}\\
\dsf{theta}{vartheta}{iota}{kappa}\\
\dsf{lambda}{mu}{nu}{xi}\\
\dsf{pi}{varpi}{rho}{varrho}\\
\dsf{sigma}{varsigma}{tau}{upsilon}\\
\dsf{phi}{varphi}{chi}{psi}\\
\ds{omega}
\end{tabular}
\caption{\rm Lowercase Greek letters}
\label{tab:lgreek}
\end{table}

\begin{table}[htbp]
\centering\footnotesize
\begin{tabular}{llllllll}
\dsf{Gamma}{Delta}{Theta}{Lambda}\\
\dsf{Xi}{Pi}{Sigma}{Upsilon}\\
\dst{Phi}{Psi}{Omega}
\end{tabular}
\caption{\rm Uppercase Greek letters}
\label{tab:ugreek}
\end{table}

\subsection{Calligraphic uppercase letters}
The letters $\cal A, \ldots, \cal Z$ are available through use of the
style changing command \verb@\cal@.  This command behaves like
the other style changing commands \verb@\em@, \verb@\it@, etc.\
so its scope must be delimited as with them.  Thus we can type

\moveright0.1\textwidth\vbox{
\footnotesize\begin{verbatim}
... for the filter $\cal F$ we have $\varphi({\cal F}) = \cal G$.
\end{verbatim}
}
\noindent to obtain

\result{%
for the filter $\cal F$ we have $\varphi({\cal F}) = \cal G$.
}

There is no need to tabulate all the calligraphic letters, since they
are all obtained by just a type style changing command.  We will just
list them so that we can see, for reference purposes, what they all look like.
Here they are:

\newcommand{\calf}[5]{\cal{#1}\cal{#2}\cal{#3}\cal{#4}\cal{#5}}
$$  % cos we're using AmSLaTeX, things have changed!
\calf{A}{B}{C}{D}{E}\calf{F}{G}{H}{I}{J}\calf{K}{L}{M}{N}{O}
\calf{P}{Q}{R}{S}{T}\calf{U}{V}{W}{X}{Y}\cal Z
$$

\subsection{Binary operators}
\LaTeX\ has been taught to recognise binary operators and set the
appropriate space either side of one---i.e., it sets the first
argument followed by a little space, then the operator followed
by the same little space and finally the second argument.  
Table~\ref{tab:binops} shows the binary operators that are available
via \LaTeX\ control words (recall that the binary operators $+$,
$-$, and $*$ can be typed from the keyboard).  Here are some examples of their use:

\begin{mathegs}
\verb@$a+b$@ & $a+b$\\
\verb@$(a+b) \ otimes c$@ & $(a+b)\otimes c$\\
\verb@$(a \vee b) \wedge c$@ & $(a \vee b)\wedge c$\\
\verb@$X - (A \cap B) = (X-A) \cup (X-B)$@ & $X - (A \cap B) = (X-A) \cup (X-B)$
\end{mathegs}

\begin{table}
\centering\footnotesize
\begin{tabular}{llllllll}
\dsf{pm}{cap}{diamond}{oplus}\\
\dsf{mp}{cup}{bigtriangleup}{ominus}\\
\dsf{times}{uplus}{bigtriangledown}{otimes}\\
\dsf{div}{sqcap}{triangleleft}{oslash}\\
\dsf{ast}{sqcup}{triangleright}{odot}\\
\dsf{star}{vee}{wedge}{bigcirc}\\
\dsf{dagger}{setminus}{amalg}{circ}\\
\dsf{ddagger}{cdot}{wr}{bullet}
\end{tabular}
\caption{\rm Binary Operation Symbols}
\label{tab:binops}
\end{table}

\subsection{Binary relations}
\LaTeX\ has been taught to recognize the use of binary relations, too.
Table~\ref{tab:binrels} shows those available via \LaTeX\ control words.
There are a few that you can obtain directly from the keyboard:
$<$, $>$, $=$, and $|$.

To negate a symbol you can precede the control word that gives the symbol
by a \verb@\not@.  Some symbols come with ready-made negations, which
should be used above the \verb@\not@'ing method because the slope of the
negating line is just slightly changed to look more pleasing.
Thus \verb@\notin@ should be used above \verb@\not\in@, and
\verb@\neq@ should be used above \verb@\not =@.

If negating a symbol produces a slash whose horizontal positioning
is not to your liking, then use the math spacing characters described
in section~\ref{sec:mathspace} to adjust it.


\begin{table}[htbp]
\centering\footnotesize
\begin{tabular}{llllllll}
\dsf{leq}{geq}{equiv}{models}\\
\dsf{prec}{succ}{sim}{perp}\\
\dsf{preceq}{succeq}{simeq}{mid}\\
\dsf{ll}{gg}{asymp}{parallel}\\
\dsf{subset}{supset}{approx}{bowtie}\\
\ds{subseteq} & \ds{supseteq}& \ds{cong} & $\bowtie$ & \tt\bs Join\\ % lazy?
\dsf{sqsubset}{sqsupset}{neq}{smile}\\
\dsf{sqsubseteq}{sqsupseteq}{doteq}{frown}\\
\dst{in}{ni}{propto}\\
\ds{vdash} & \ds{dashv}
\end{tabular}
\caption{\rm Binary relations}
\label{tab:binrels}
\end{table}

\subsection{Miscellaneous symbols}
Table~\ref{tab:miscsym} shows a number of general-purpose symbols.
Remember that these are only available in maths mode.  Note that
\verb@\imath@ and \verb@\jmath@ should be used when you need to
accent an $i$ or a~$j$ in maths mode\footnote{See section \ref{sec:mathacc}}%
---you cannot use \verb@\i@ or \verb@\j@ that were available in
paragraphing mode.  To get a prime symbol, you can use \verb@\prime@
or you can just type \verb@'@ when in maths mode, as in
\verb@$f''(x)=x$@ which produces $f''(x)=x$.

\begin{table}[htbp]
\centering\footnotesize
\begin{tabular}{llllllll}
\dsf{aleph}{prime}{forall}{infty}\\
\dsf{hbar}{emptyset}{exists}{Box}\\
\dsf{imath}{nabla}{neg}{triangle}\\
\dsf{jmath}{surd}{flat}{triangle}\\
\dsf{ell}{top}{natural}{clubsuit}\\
\dsf{wp}{bot}{sharp}{diamondsuit}\\
\dsf{Re}{|}{backslash}{heartsuit}\\
\dsf{Im}{angle}{partial}{spadesuit}\\
\ds{mho}
\end{tabular}
\caption{\rm Miscellaneous symbols}
\label{tab:miscsym}
\end{table} 

\subsection{Arrow symbols}

\LaTeX\ has a multitude of arrow symbols, which it will set the correct
space around.  Note that vertical arrows can all be used as
delimiters---see section~\ref{sec:delims}.  The available symbols
are listed in table~\ref{tab:arrows}.

\begin{table}[htbp]
\centering\footnotesize
\begin{tabular}{llllll}
\dst{leftarrow}{longleftarrow}{uparrow}\\
\dst{Leftarrow}{Longleftarrow}{Uparrow}\\
\dst{rightarrow}{longrightarrow}{downarrow}\\
\dst{Rightarrow}{Longrightarrow}{Downarrow}\\
\dst{leftrightarrow}{longleftrightarrow}{updownarrow}\\
\dst{Leftrightarrow}{Longleftrightarrow}{Updownarrow}\\
\dst{mapsto}{longmapsto}{nearrow}\\
\dst{hookleftarrow}{hookrightarrow}{searrow}\\
\dst{leftharpoonup}{rightharpoonup}{swarrow}\\
\dst{leftharpoondown}{rightharpoondown}{nwarrow}\\
\ds{rightleftharpoons} & \ds{leadsto} 
\end{tabular}
\caption{\rm Arrow symbols}
\label{tab:arrows}
\end{table}

\subsection{Expression delimiters}\label{sec:delims}
A pair of delimters often enclose an expression, as in
$$
\left[\begin{array}{cc}
a_{11} & a_{12} \\
a_{21} & a_{22} 
\end{array}\right]
\mbox{\quad and\quad}
f(x) = \left\{ \begin{array}{ll}
x & \mbox{if } x < 1 \\
x^2 & \mbox{if } x \geq 1
\end{array}\right.
\quad.$$
\LaTeX\ will scale delimiters to the correct size (determined by what
they enclose) 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 
\verb@\left@ or \verb@\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 \verb@\left.@ and \verb@\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~\ref{sec:arrays} where we learn about arrays.

Table~\ref{tab:delims} shows the symbols that \LaTeX\ will
recognise as delimiters, i.e.\ symbols that may follow
a \verb@\left@ or a \verb@\right@.  Note that you have to 
use \verb@\left\{@ and \verb@\right\}@ in order to get
scaled braces.

\begin{table}[htbp]
\centering\footnotesize
\begin{tabular}{llllll}
$($ & \makebox[90pt][l]{(} & $)$ & \makebox[90pt][l]{)} & $\uparrow$ & \makebox[90pt][l]{\tt\bs uparrow}\\
$[$ & ] & $]$ & ] & $\downarrow$ & \tt\bs downarrow\\
$\{$ & \verb@\{@ & $\}$ & \verb@\}@ & $\updownarrow$ & \tt\bs updownarrow\\
\dst{lfloor}{rfloor}{Uparrow}\\
\dst{lceil}{rceil}{Downarrow}\\
\dst{langle}{rangle}{Updownarrow}\\
$/$ & / & \ds{backslash}\\
$|$ & | & \ds{|}  
\end{tabular}
\caption{\rm Delimiters}
\label{tab:delims}
\end{table}

\subsection{Operators like $\displaystyle\int$ and $\displaystyle\sum$}
These behave differently when used in display-math mode as
compared with in-text math mode.  When used in text, they
will appear in their small form and any limits provided will
be set so as to reduce the overall height of the operator, 
as in $\sum_{i=1}^{N}f_i$.  When used in display-math mode, \LaTeX\
will choose to use the larger form and will not try to
reduce the height of the operator, as in
$$
\sum_{i=1}^{N} f_i \quad .
$$

Table~\ref{tab:bigops} describes what variable-size symbols are
available, showing both the small (in text) and the large (displayed)
form of each.  In section~\ref{sec:subsup} we will learn how to 
place limits on these operators.

\begin{table}[htbp]
\centering\footnotesize
\newcommand{\od}[1]{\makebox[27pt]{$\csname#1\endcsname\hfil\displaystyle\csname#1\endcsname$} & \tt\bs #1}
\newcommand{\odt}[3]{\od{#1} & \od{#2} & \od{#3}}
\begin{tabular}{ll@{\hspace{1.5cm}}ll@{\hspace{1.5cm}}ll}
\odt{sum}{bigcap}{bigodot}\\
\odt{prod}{bigcup}{bigotimes}\\
\odt{coprod}{bigsqcup}{bigoplus}\\
\odt{int}{bigvee}{biguplus}\\
\od{oint} & \od{bigwedge}
\end{tabular}
\caption{\rm Variable-sized symbols}
\label{tab:bigops}
\end{table}

\subsection{Accents}\label{sec:mathacc}
The accenting commands that we learned for paragraphing mode do not
apply in maths mode.  Consult table~\ref{tab:mathacc} to see how
to accent a symbol in maths mode (all the examples there accent
the symbol $u$, but they work with any letter).  Remember that $i$ and $j$
should lose their dots when accented, so \verb@\imath@ and
\verb@\jmath@ should be used.

There also exist commands that give a ``wide hat'' or a 
``wide tilde'' to their argument, \verb@\widehat@ and
\verb@\widetilde@.

\begin{table}[htbp]
\centering\footnotesize
\newcommand{\da}[1]{$\csname#1\endcsname{u}$ & \tt\bs #1\{u\}}
\newcommand{\daf}[4]{\da{#1} & \da{#2} & \da{#3} & \da{#4}}
\begin{tabular}{llllllll}
\daf{hat}{acute}{bar}{dot}\\
\daf{check}{grave}{vec}{ddot}\\
\da{breve} & \da{tilde}
\end{tabular}
\caption{\rm Math accents}
\label{tab:mathacc}
\end{table} 

\section{Some common mathematical structures}
In this section we shall begin to learn how to manipulate
all the symbols listed in section~\ref{sec:symbols}.
Indeed, by the end of this section we'll be able to typeset
some quite large expressions.  In the section following
this we will learn how use various alignment environments
that allow us to prepare material like multi-line expressions
and arrays.

\subsection{Subscripts and superscripts}\label{sec:subsup}
Specifying a sub- or superscript is as easy as you'd hope---%
you just give an indication that you want a sub- or superscript
to the last expression and provide the material to be
placed there, and \LaTeX\ will position things correctly.
So sub- and superscripting a single symbol, an operator, or a big
array all involve the same input, and \LaTeX\ places the material
according to what the expression is that is being sub- or superscripted:
$$
x^2\quad,\quad \prod_{i=1}^{N}X_i \quad,\quad
\left[\begin{array}{ccc}
a_{11} & a_{12} & a_{13}\\
a_{21} & a_{22} & a_{23}\\
a_{31} & a_{32} & a_{33}
\end{array}\right]^2
\quad.$$

To tell \LaTeX\ that you want a single character set as a superscript
to the last expression, you just type a \verb@^@ before it.  The 
``last expression'' is the preceding group or, if there is no preceding
group, the single character or symbol that the \verb@^@ follows:

\begin{mathegs}
\verb@$x^2$@ & $x^2$\\
\verb@$a^b$@ & $a^b$\\
\verb@$Y^X$@ & $Y^X$\\
\verb@$\gamma^2$@ & $\gamma^2$\\
\verb@$(A+B)^2$@ & $(A+B)^2$\\
\verb@$\left[ \frac{x^2+1}{x^2 + y^2} \right]^n$@ & $\left[ \frac{x^2+1}{x^2 + y^2} \right]^n$
\end{mathegs}

Subscripts of a single character are equally easy---you just use
the underscore character \verb@_@ where you used \verb@^@ for
superscripting:

\begin{mathegs}
\verb@$x_2$@ & $x_2$\\
\verb@$x_i$@ & $x_i$\\
\verb@$\Gamma_1(x)$@ & $\Gamma_1(x)$
\end{mathegs}

--
Gavin Maltby, University of Natal, Pietermaritzburg, South Africa
gmaltby@unpcs1.cs.unp.ac.za, maltby@unpsun1.cc.unp.ac.za
Any opinion expressed is mine and mine alone.
------------------------------------------------------------------
Newsgroups: comp.text.tex