summaryrefslogtreecommitdiff
path: root/info/tcdmanual/pl_intro.tex
blob: ab43265065f8ee2718984b9a05d0a1b1dbf1b6ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
\sectiontitle{Introduction to Plain \TeX}
\label{pl-intro}
\subsectiontitle{What is Plain \TeX?}
\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 various `dialects' of \TeX, including \LaTeX.
Plain \TeX\ (created by D.~E.~Knuth) is the basic version
of \TeX\ on which these other `dialects' are based.  The
reference manual for Plain \TeX\ is ``The \TeX book'', by
D.~E.~Knuth.

\subsectiontitle{A Typical Plain \TeX\ Input File}
In order to produce a document using \TeX, 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
Plain \TeX\ input file:
\begin{quote}
\begin{verbatim}

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.

\bye

\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 \TeX.  Note
that the line
\begin{quote}
\begin{verbatim}
\bye
\end{verbatim}
\end{quote}
is placed at the end of the input file.  This is to tell \TeX
when the end of the document has  been reached.
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.