\sectiontitle{Introduction to \LaTeX}
\label{la-intro}
\subsectiontitle{What is \LaTeX?}
\TeX\ is a computer program for typesetting documents. It
takes a computer file, prepared according to the rules of
\TeX, and converts it to a form that may be printed on a
high-quality printer, such as a laser writer, to produce
a printed document of a quality comparable with good
quality books and journals. Simple documents, which do
not contain mathematical formulae or tables may be produced
very easily: effectively all one has to do is to type the
text straight in (though observing certain rules relating to
quotation marks and punctuation dashes). Typesetting
mathematics is somewhat more complicated, but even here
\TeX\ is comparatively straightforward to use when one
considers the complexity of some of the formulae that it
has to produce and the large number of mathematical symbols
which it has to produce.
There are several `dialects' of \TeX, all based on the
version of \TeX\ created by D.~E.~Knuth which is known as
Plain \TeX. \LaTeX\ (created by L.~B.~Lamport) is one of
these `dialects'. It is particularly suited to the
production of long articles and books, since it has
facilities for the automatic numbering of chapters, sections,
theorems, equations etc., and also has facilities for
cross-referencing. It is probably the most suitable
version of \TeX\ for beginners to use, and the manual
``\LaTeX---User's Guide and Reference Manual'' is certainly
easier to read than the corresponding manual
(i.e., ``The \TeX book'') for Plain \TeX.
\subsectiontitle{A Typical \LaTeX\ Input File}
In order to produce a document using \LaTeX, we must first
create a suitable {\it input file\/} on the computer. We
apply the \TeX\ program to the input file and then use the
printer to print out the so-called `DVI' file produced by
the \TeX\ program (after first using another program to
translate the `DVI' file into a form that the printer
can understand). Here is an example of a typical
\LaTeX\ input file:
\begin{quote}
\begin{verbatim}
\documentstyle[tcda,12pt]{article}
\begin{document}
The foundations of the rigorous study of {\it analysis}
were laid in the nineteenth century, notably by the
mathematicians Cauchy and Weierstrass. Central to the
study of this subject are the formal definitions of
{\it limits} and {\it continuity}.
Let $D$ be a subset of $\bf R$ and let
$f \colon D \to {\bf R}$ be a real-valued function on
$D$. The function $f$ is said to be {\it continuous} on
$D$ if, for all $\epsilon > 0$ and for all $x \in D$,
there exists some $\delta > 0$ (which may depend on $x$)
such that if $y \in D$ satisfies
\[ |y - x| < \delta \]
then
\[ |f(y) - f(x)| < \epsilon. \]
One may readily verify that if $f$ and $g$ are continuous
functions on $D$ then the functions $f+g$, $f-g$ and
$f.g$ are continuous. If in addition $g$ is everywhere
non-zero then $f/g$ is continuous.
\end{document}
\end{verbatim}
\end{quote}
When we apply \TeX\ to these paragraphs we produce the text
\begin{quotation}
\small
The foundations of the rigorous study of {\it analysis}
were laid in the nineteenth century, notably by the
mathematicians Cauchy and Weierstrass. Central to the
study of this subject are the formal definitions of
{\it limits} and {\it continuity}.
Let $D$ be a subset of $\bf R$ and let
$f \colon D \to {\bf R}$ be a real-valued function on
$D$. The function $f$ is said to be {\it continuous} on
$D$ if, for all $\epsilon > 0$ and for all $x \in D$,
there exists some $\delta > 0$ (which may depend on $x$)
such that if $y \in D$ satisfies
\[ |y - x| < \delta \]
then
\[ |f(y) - f(x)| < \epsilon. \]
One may readily verify that if $f$ and $g$ are continuous
functions on $D$ then the functions $f+g$, $f-g$ and
$f.g$ are continuous. If in addition $g$ is everywhere
non-zero then $f/g$ is continuous.
\end{quotation}
This example illustrates various features of \LaTeX. Note
that the lines
\begin{quote}
\begin{verbatim}
\documentstyle[tcda,12pt]{article}
\begin{document}
\end{verbatim}
\end{quote}
are placed at the beginning of the input file. These are followed
by the main body of the text, followed by the concluding line
\begin{quote}
\begin{verbatim}
\end{document}
\end{verbatim}
\end{quote}
Note also that, although most characters occurring in this file
have their usual meaning, yet there are special characters such
as \verb?\?, \verb?$?, \verb?{? and \verb?}? which have special
meanings within \TeX. Note in particular that there are
sequences of characters which begin with a `backslash'
\verb?\? which are used to produce mathematical symbols and
Greek letters and to accomplish tasks such as changing fonts.
These sequences of characters are known as
{\it control sequences}.
\subsectiontitle{Characters and Control Sequences}
We now describe in more detail some of the features of
\TeX\ illustrated in the above example.
Most characters on the keyboard, such as letters and
numbers, have their usual meaning. However the characters
\begin{quote}
\begin{verbatim}
\ { } $ ^ _ % ~ # &
\end{verbatim}
\end{quote}
are used for special purposes within \TeX. Thus typing one of
these characters will not produce the corresponding character
in the final document. Of course these characters are very
rarely used in ordinary text, and there are methods of
producing them when they are required in the final document.
In order to typeset a mathematical document it is
necessary to produce a considerable number of special
mathematical symbols. One also needs to be able to
change fonts. Also mathematical documents often contain
arrays of numbers or symbols (matrices) and other complicated
expressions. These are produced in \TeX\ using {\it control
sequences}. Most control sequences consist of a backslash
\verb?\? followed by a string of (upper or lower case) letters.
For example, \verb?\alpha?, \verb?\it?, \verb?\sum? and
\verb?\TeX? are control sequences.
In the example above we used the control sequences
\verb?\it? and \verb?\bf? to change the font to {\it italic}
and {\bf boldface} respectively. Also we used the control
sequences \verb?\to?, \verb?\in?, \verb?\delta? and
\verb?\epsilon? to produce the mathematical symbols $\to$
and $\in$ and the Greek letters $\delta$ and $\epsilon$.
\begin{quotation}
\footnotesize
There is another variety of control sequence which consists
of a backslash followed by a {\it single} character that
is not a letter. Examples of control sequences of this sort
are \verb?\{?, \verb?\"? and \verb?\$?.
\end{quotation}
The special characters \verb?{? and \verb?}? are used for
{\it grouping} purposes. Everything enclosed within
matching pair of such brackets is treated as a single unit.
We have applied these brackets in the example above whenever
we changed fonts. We shall see other instances where one needs
to use \verb?{? and \verb?}? in \TeX\ to group words and symbols
together (e.g., when we need to produce superscripts and
subscripts which contain more than one symbol).
The special character \verb?$? is used when one is
changing from ordinary text to a mathematical expression
and when one is changing back to ordinary text. Thus we
used
\begin{quote}
\begin{verbatim}
for all $\epsilon > 0$ and for all $x \in D$,
\end{verbatim}
\end{quote}
to produce the phrase
\begin{quote}
\small
for all $\epsilon > 0$ and for all $x \in D$,
\end{quote}
in the example given above. Note also that we used
\verb?\[? and \verb?\]? in the example above to mark the beginning
and end respectively of a mathematical formula that is displayed
on a separate line.
The remaining special characters
\begin{quote}
\begin{verbatim}
^ _ % ~ # &
\end{verbatim}
\end{quote}
have special purposes within \TeX\ that we shall discuss
later.