summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/plain/impatient/usingtex.tex
blob: b23c9e2a9e582898a5d5e5022c77f89ed693655d (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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
% $Id: usingtex.tex,v 1.5 2020/01/01 23:29:59 karl Exp $
% This is part of the book TeX for the Impatient.
% Copyright (C) 2003-2020 Paul W. Abrahams, Kathryn A. Hargreaves, Karl Berry.
% See file fdl.tex for copying conditions.

\input macros
\chapter{Using \TeX}

\chapterdef{usingtex}

% Avoid underfull box complaint about the empty paragraph
% that precedes the first section heading.
% 
\def\par{{\parfillskip = 0pt plus 1fil\endgraf}\let\par=\endgraf}
\vglue-\abovesectionskip % we've skipped enough already
\vskip0pt % Make \combineskips work.

\section Turning input into ink

\subsection Programs and files you need

In order to produce a \TeX\ document, you'll need to run the \TeX\
program and several related programs as well.  You'll also need
supporting files for \TeX\ and possibly for these other programs.  In
this book we can tell you about \TeX, but we can't tell you about the
other programs and the supporting files except in very general terms
because they depend on your local \TeX\ environment.  The people who
provide you with \TeX\ should be able to supply you with what we call
\emph{local information}.
\pix^^{local information}
The local information tells you how to
start up \TeX, how to use the related programs, and how to gain access
to the supporting files.

Input to \TeX\ consists of a file of ordinary text that you can prepare
with a ^{text editor}.  A \TeX\ input file, unlike an input file for a
typical word processor, doesn't ordinarily contain any invisible
^{control characters}.
Everything that \TeX\ sees is visible to you too if you
look at a listing of the file.

Your input file may turn out to be little more than a skeleton that
calls for other input files.  \TeX\ users often organize large documents
such as books this way.  You can use the ^|\input| command (\xref\input)
to embed one input file within another.  In particular, you can use
|\input| to incorporate files containing \emph{macro definitions}---%
^^{macros//in auxiliary files}
auxiliary definitions that enhance \TeX's capabilities.
If any macro files are available at your \TeX\ installation, the local
information about \TeX\ should tell you how to get at the macro files
and what they can do for you.  The standard form of \TeX,
the one described in this book, incorporates a
collection of macros and other definitions known as ^{\plainTeX}
(\xref{\plainTeX}).

When \TeX\ processes your document, it produces a file called the
^{\dvifile}.  The abbreviation ``|dvi|'' stands for ``device
independent''.  The abbreviation was chosen because the information in
the \dvifile\ is independent of the device that you use to print or
display your document.

To print your document or view it with a \emph{previewer},
^^{previewer}
you need to process the ^{\dvifile} with
a \emph{device driver\/} program.
^^{device drivers}
(A previewer is a program  that
enables you to see on a screen some approximation of what the typeset
output will look like.)
Different output devices usually
require different device drivers.
After running the device driver,
you may also need to transfer the output of the device driver to the
printer or other output device.
^^{printers} ^^{output devices}  
The local information about \TeX\ should tell
you how to get the correct device driver and use it.

Since \TeX\ has no built-in knowledge of particular fonts, it uses
\emph{font files}
^^{font files}
to obtain information about the fonts used in your
document.  The font files should also be part of your local \TeX\
environment.  Each font normally requires two files: one containing the
dimensions of the characters in the font (the \emph{metrics file})
^^{metrics file}
and one containing the shapes of the characters (the \emph{shape file}).
^^{shape file}
Magnified versions of a font share the metrics file but have
different shape files. ^^{magnification} Metrics files are sometimes
referred to as ^{\tfmfile}s, and the different varieties of shape files
are sometimes referred to as ^{\pkfile}s, ^{\pxlfile}s, and ^{\gffile}s.
These names correspond to the names of the files that \TeX\ and its
companion programs use.  For example, |cmr10.tfm| is the metrics file
for the |cmr10| font (10-point Computer Modern Roman).

\TeX\ itself uses only the metrics file, since it doesn't care what the
characters look like but only how much space they occupy.  The device
driver ordinarily uses the shape file, since it's responsible for
creating the printed image of each typeset character.  Some device
drivers need to use the metrics file as well.  Some device drivers can
utilize fonts that are resident in a printer and don't need shape files
for those fonts.
\secondprinting{\vfill\eject}


\subsection Running {\TeX}

\bix^^{running \TeX}
You can run \TeX\ on an input file |screed.tex| by typing 
^^{input files}
something like `|run tex|' or just `|tex|' (check your local information).
\TeX\ will respond with something like:
% 4/23/90 is Shakespeare's 426th birthday, and Karl's 26th.
\csdisplay
This is TeX, Version 3.0 (preloaded format=plain 90.4.23)
**
|
The ``preloaded format'' here refers to a predigested form of the
^{\plainTeX} macros that come with \TeX.
You can now type `|screed|' to get \TeX\ to process your file.
When it's done, you'll see something like:
\csdisplay
(screed.tex [1] [2] [3] )
Output written on screed.dvi (3 pages, 400 bytes).
Transcript written on screed.log.
|
displayed on your terminal, or printed in the record of your
run if you're not working at a terminal.  Most of this output is
self-explanatory.
The numbers in brackets are page numbers that \TeX\ displays when it
ships out each page of your document to the \dvifile.
\TeX\ will usually assume an
extension `|.tex|' to an input file name
if the input file name you gave doesn't
have an extension.  For some forms of \TeX\ you may be able to
invoke \TeX\ directly for an input file by typing:
\csdisplay
tex screed
|
or something like this.

Instead of providing your \TeX\ input from a file, you can type it directly at
your terminal.  To do so, type `^|\relax|' instead of `|screed|' at the 
`|**|' prompt.
\TeX\ will now prompt you with a `|*|' for each line of input and interpret
each line of input as it sees it.
To terminate the input, type a command such as `|\bye|' that tells \TeX\
you're done.
Direct input is sometimes a handy way of experimenting with \TeX.

When your input file contains other embedded input files, the displayed
information indicates when \TeX\ begins and ends processing each 
embedded file.
^^{input files//embedded}
\xrdef{infiles}
\TeX\ displays a left parenthesis and the file name
when it starts working on a file and displays the corresponding right
parenthesis when it's done with the file. 
If you get any ^{error messages} in the displayed output, you can match
them with a file by looking for the most recent unclosed left parenthesis.

For a more complete explanation of how to run \TeX,
see \knuth{Chapter~6} and your ^{local information}.
\eix^^{running \TeX}


\section Preparing an input file

In this section we explain some of the conventions that you must follow in
preparing input for \TeX\null.  Some of the information given here also
appears in the examples in \chapterref{examples} of this book.
^^{input, preparing}

\subsection Commands and control sequences

\bix^^{commands}
\bix^^{control sequences}
Input to \TeX\ consists of a sequence of commands that tell \TeX\ how to
typeset your document.  Most characters act as commands of a particularly
simple kind: ``typeset me''.  The letter `|a|', for instance, is a
command to typeset an `a'.  But there's another kind of command---a
\emph{control sequence}---that gives \TeX\ a more elaborate
instruction.  A control sequence ordinarily starts with a backslash
(|\|), though you can change that convention if you need to.
\xrdef{@backslash}
For instance, the input:

\csdisplay
She plunged a dagger (\dag) into the villain's heart.
|
contains the control sequence |\dag|; it produces the typeset output:
\display{%
She plunged a dagger (\dag) into the villain's heart.
}
\noindent Everything in this example except for the |\dag| and the spaces
acts like a ``typeset me'' command.  We'll explain more about spaces
on \xrefpg{spaces}.

There are two kinds of control sequences: \emph{control words}
^^{control words}
and \emph{control symbols}:
^^{control symbols}
\ulist\compact
\li A control word consists of a
backslash followed by one or more letters, e.g., `|\dag|'.
The first character that isn't a letter marks the end
of the control word.
\li A control symbol consists of a backslash followed by a single character
that isn't a letter, e.g., `|\$|'.
The character can be a space or even the end of a line (which is a perfectly
legitimate character).
\endulist
\noindent
A control word (but not a control symbol)
absorbs any spaces or ends of line that follow it.
^^{control sequences//absorbing spaces}
If you don't want to lose a space after a control word,
follow the control sequence with a ^{control space}
(|\!visiblespace|) or with `|{}|'.  Thus either:
\csdisplay
The wonders of \TeX\!visiblespace!.shall never cease!!
|
or:\hfil\ 
\csdisplay
The wonders of \TeX{} shall never cease!!
|
produces:
\display{%
The wonders of \TeX{} shall never cease!
}
\noindent rather than:
\display{%
The wonders of \TeX shall never cease!
}
\noindent
which is what you'd get if you left out the `|\|\visiblespace'
or the `|{}|'.

Don't run a control word together with the text that follows it---\TeX\
won't know where the control word ends.  For instance, the |\c| control
sequence places a cedilla accent on the character that follows it.  The
French word {\it gar\c con\/} must be typed as
`|gar\c!visiblespace!.con|', not `|gar\ccon|'; if you write the latter,
\TeX\ will complain about an undefined control sequence |\ccon|.

A control symbol, on the other hand, doesn't absorb anything that
follows it.  Thus you must type `\$13.56' as `|\$13.56|', not
`|\$!vs13.56|'; the latter form would produce `\hbox{\$ 13.56}'.
However, those accenting commands that are named by control symbols are
defined in such a way that they produce the effect of absorbing a
following space.  Thus, for example, you can type the French word {\it
d\'eshabiller\/} either as `|d\'eshabiller|' or as
`|d\'!visiblespace!.eshabiller|'.

Every control sequence is also a command, 
but not the other way around.
^^{commands//versus control sequences}
^^{control sequences//versus commands}
For instance, the letter `|N|'
is a command, but it isn't a control sequence.
In this book we ordinarily use ``command'' rather than
``control sequence'' when either term would do.
We use ``control sequence'' when we want to emphasize aspects of \TeX\
syntax that don't apply to commands in general.

\eix^^{control sequences}
\eix^^{commands}


\subsection Arguments

\xrdef{arg1}
Some commands need to be followed by one or more
\emph{arguments} ^^{arguments}
that help to determine what the command does.
For instance, the |\vskip| command, which 
tells \TeX\ to skip down (or up) the page,
expects an argument specifying how much space to skip.  To skip
down two inches, you would type `|\vskip 2in|', where |2in|
is the argument of |\vskip|. 

Different commands expect different kinds of arguments.  Many commands
expect dimensions, such as the |2in| in the example above.
Some commands, particularly those defined by macros,
expect arguments that are either a single character or some
text enclosed in braces.
Yet others require that their arguments be enclosed in braces, i.e.,
they don't accept single-character arguments.
The description of each command in this book tells you what kinds of arguments,
if any, the command expects.
In some cases, required braces define a group (see \xref{bracegroup}).

\secondprinting{\vfill\eject}


\subsection Parameters

\xrdef{introparms}
Some commands are parameters (\xref{parameter}).
^^{parameters//as commands}
You can use a parameter in either of two ways:
\olist
\li You can use the value of a parameter 
as an argument to another command.  For example, the command
\hbox{|\vskip\parskip|}
causes a vertical skip by the value of the |\parskip| (paragraph skip)
glue parameter.
\li You can change the value of the parameter by assigning
something to it.  For example, the assignment \hbox{|\hbadness=200|}
causes the value of the |\hbadness| number parameter to be $200$.
\endolist
\noindent
We also use the term ``parameter'' to refer to entities such as |\pageno|
that are actually registers but behave just like parameters.
^^{registers//parameters as}

Some commands are names of tables.  These commands are used like
parameters, except that they require an additional argument that
specifies a particular entry in the table. For example, |\catcode| names
a table of category codes (\xref{category code}). Thus
the command
\hbox{|\catcode`~=13|} sets the category code of the `|~|'
character to $13$.


\subsection Spaces

\xrdef{spaces}
\bix^^{spaces}
You can freely use extra spaces in your input.  Under nearly all circumstances
\TeX\ treats several spaces in a row as being equivalent to a
single space.  For instance, it doesn't matter whether you put one space
or two spaces after a ^{period} in your input.  Whichever you do, \TeX\
performs its end-of-sentence maneuvers and leaves the appropriate
(in most cases) amount of space after the period.
\TeX\ also treats the end of an input line as equivalent to a space.
Thus you can end your input lines wherever it's convenient---%
\TeX\ makes input
lines into
paragraphs in the same way no matter where the line breaks are in your
input.

A blank line in your input marks the end of a paragraph.
^^{paragraphs//ending}
Several blank lines are equivalent to a single one.

\TeX\ ignores input spaces within math formulas (see below).  Thus you can
include or omit spaces anywhere within a math formula---\TeX\ doesn't care.
Even within a math formula, however,
you must not run a control word together with a following letter.

If you are defining your own macros, you need to be particularly careful about
where you put ends of line in their definitions.
It's all too easy to define a macro that produces an
^{unwanted space} in addition to whatever else it's supposed to do.
We discuss this problem elsewhere since it's somewhat
technical; see \xrefpg{unwantedspace}.

A space or its equivalent between two words in your input doesn't simply turn
into a space character in your output.
A few of these input spaces turn into ends of lines
in the output,
since input lines generally don't correspond to output lines.
The others turn into spaces of variable width called ``glue'' (\xref{glue}),
which has a natural size (the size it ``wants to be'')
but can stretch or shrink.
When \TeX\ is typesetting a paragraph
that is supposed to have an even right margin (the usual
case), it adjusts the widths of the glue in each line
to get the lines to end at the margin.
(The last line of a paragraph is an exception, since it isn't ordinarily
required to end at the right margin.)

You can prevent an input space from turning into an end of line by using a
^{tie} (^|~|).
For example, you wouldn't want \TeX\ to put a line break between the
`Fig.' and `8' of `Fig.~8'.
By typing `|Fig.~8|' you can prevent such a line break.
\eix^^{spaces}
\needspace{2in}

\subsection Comments

\xrdef{comments}
\pix\bix^^{comments}
You can include comments in your \TeX\ input.
When \TeX\ sees a comment it just passes over it, so 
what's in a comment doesn't affect your typeset document in any way.
Comments are useful for
providing extra information about what's in your input file.
For example:
\csdisplay
% ========= Start of Section `Hedgehog' =========
|

{\indexchar % }%
A comment starts with a percent sign (|%|) and extends to the end of the
input line.
\TeX\ ignores not just the comment but the end of the line as well, so
comments have another very
important use: connecting two lines so that the end of line
^^{line breaks//deleting}
between them is invisible to \TeX\ and doesn't generate
an output space or an end of line.
For instance, if you type:
\csdisplay
A fool with a spread%
sheet is still a fool.
|
you'll get:
\display{
A fool with a spread%
sheet is still a fool.
}
\eix^^{comments}


\subsection Punctuation

\null
\xrdef{periodspacing}
\TeX\ normally adds some extra space after what it thinks is a
^{punctuation} mark at the end of a sentence,
namely, `^|.|', `^|?|', or `|!!|' \indexchar !
^^{period} ^^{question mark} ^^{exclamation point}
followed by an input space.
\TeX\ doesn't add
the extra space if the punctuation mark follows
a capital letter, though, because it assumes the capital
letter to be an initial in someone's name.
You can force the extra space where it wouldn't otherwise occur by
typing something like:
\csdisplay
A computer from IBM\null?
|
The |\null| doesn't produce any output, but it does prevent \TeX\
from associating the capital `M' with the question mark.
On the other hand, you can cancel the
extra space where it doesn't belong by typing a control space
after the punctuation mark, e.g.:
\csdisplay
Proc.\!visiblespace!.Royal Acad.\!visiblespace!.of Twits
|
so that you'll get:
\display{Proc.\ Royal Acad.\ of Twits}
\noindent rather than:
\display{Proc. Royal Acad. of Twits}

Some people prefer not to leave more space after punctuation at the
end of a sentence.  You can get this effect with the
^|\frenchspacing| command (\xref\frenchspacing).
|\frenchspacing| is often recommended for ^{bibliographies}.

For single ^{quotation marks}, you should use the left and right
single quotes
(|`| and |'|) on your keyboard.  For left and right
double quotation marks, use two left single
quotes or two right single quotes (|``| or |''|) rather
than the double quote (|"|) on your keyboard.
The keyboard double quote
will in fact give you a right double quotation mark in
many fonts, but the two right single quotes
are the preferred \TeX\ style.
For example:

\csdisplay
There is no `q' in this sentence.
``Talk, child,'' said the Unicorn.
She said, ``\thinspace`Enough!!', he said.''
|
These three lines yield:
\display{\par\restoreplainTeX
There is no `q' in this sentence.
\par ``Talk, child,'' said the Unicorn.
\par She said, ``\thinspace`Enough!', he said.''
}
\noindent
The |\thinspace| in the third input line prevents
the single quotation mark from coming
too close to the double quotation marks.
Without it, you'd just see three 
nearly equally spaced quotation marks in a row.

\TeX\ has three kinds of ^{dashes}:
\ulist
\li Short ones (hyphens) like this ( - ). You get them by typing~`^|-|'.
\li Medium ones (en-dashes) like this ( -- ). You get them by typing~`^|--|'.
\li Long ones (em-dashes) like this ( --- ). You get them by typing~`^|---|'.
\endulist
\vskip0pt plus2pt % this page is spacey, just live with it
\eject

\noindent
Typically you'd use hyphens to indicate compound words like
``will-o'-the-wisp'',
en-dashes to indicate
page ranges such as ``pages~81--87'', and em-dashes to indicate
a break in continuity---like this.


\subsection Special characters

Certain characters have special meaning to \TeX, so you shouldn't use them
in ordinary text.  They are:

\csdisplay
    $  #  &  %  _  ^  ~  {  }  \
|
^^|$//in ordinary text|
^^|#//in ordinary text|
^^|&//in ordinary text|
^^|_//in ordinary text|
^^|^//in ordinary text|
^^|~//in ordinary text|
^^|%//in ordinary text|
^^|{//in ordinary text|
^^|}//in ordinary text|
{\recat!ttidxref[\//in ordinary text]]
\noindent
In order to produce them in your typeset document,
you need to use circumlocutions.  For the first five,
you should instead type:
^^|\$|
^^|\#|
^^|\&|
^^|\%|
^^|\_|
\csdisplay
    \$  \#  \&  \%  \_
|

\noindent
For the others, you need something more elaborate:

\csdisplay
   \^{!visiblespace}   \~{!visiblespace}   $\{$   $\}$   $\backslash$
|


\subsection Groups

\bix^^{groups}
A \emph{group} 
consists of material enclosed in matching left and right braces (|{| and 
|}|).
^^|{//starting a group|
^^|}//ending a group|
By placing a command within a group, you can limit its effects to
the material within the group.  
For instance, the |\bf| command tells \TeX\ to set
something in {\bf boldface} type.  If you were to put |\bf| into your input
and do nothing else to counteract it, everything in your document following the
|\bf| would be set in boldface.
By enclosing |\bf| in a group,
you limit its effect to the group.  For example, if you type:
\csdisplay
We have {\bf a few boldface words} in this sentence.
|
\noindent you'll get:
\display{We have {\bf a few boldface words} in this sentence.}

\noindent You can also use a group to limit the effect of
an assignment to one of \TeX's parameters.
These parameters contain values that affect how \TeX\ typesets your document.
For example, the value of the |\parindent|
parameter specifies the indentation at the beginning of a paragraph.
The assignment |\parindent = 15pt|
sets the indentation to $15$ printer's points.
By placing this assignment at the beginning
of a group containing a few paragraphs, you can change
the indentation of just those paragraphs.  If you don't enclose
the assignment in a group,
the changed indentation will apply to the rest of the document (or up to the
next assignment to |\parindent|, if there's a later one).

\xrdef{bracegroup}
Not all pairs of braces indicate a group.
In particular, the braces associated with an argument for which the
braces are \emph{not} required don't indicate a group---they just
serve to delimit the argument.
Of those commands that do require braces for their arguments,
some treat the braces as defining a group
and the others interpret the argument in some special way that depends on
the command.\footnote
{More precisely, for primitive commands either
the braces define a group or they enclose tokens that aren't processed in
\TeX's stomach.
For |\halign| and |\valign| the group has a trivial
effect because everything within the braces either doesn't reach the stomach
(because it's in the template) or is enclosed in a further inner group.
^^|\halign//grouping for|
^^|\valign//grouping for|
}
\eix^^{groups}


\subsection Math formulas

\bix^^{math}
\xrdef{mathform}
A math formula can appear in text (\emph{text math})
^^{text math}
or set off on a line by itself
with extra vertical space around it (\emph{display math}).
^^{display math}
You enclose a text formula in single dollar signs (|$|)
and a displayed formula in double dollar signs (|$$|).
\ttidxref{$}\ttidxref{$$}
For example:

\csdisplay
If $a<b$, then the relation $$e^a < e^b$$ holds.
|
\noindent This input produces:
\display{\centereddisplays
If $a<b$, then the relation $$e^a < e^b$$ holds.}
\smallskip
\noindent \TeX\ does its own spacing inside math, ignoring any spaces in
the input.

\chapterref{math} describes the commands that are useful
in math formulas.
\eix^^{math}


\section How \TeX\ works

In order to use \TeX\ effectively, it helps to 
have some idea of how \TeX\ goes about
its activity of transmuting input into output.
You can imagine \TeX\ as a kind of organism with ``eyes'', 
``mouth'', ``gullet'',
``stomach'', and ``intestines''.
Each part of the organism transforms its input in some way and passes
the transformed input to the next stage.

The ^{eyes} transform an input file into a sequence of characters.
The ^{mouth} transforms the sequence of characters into a sequence of
\emph{tokens},
^^{tokens}
where each token is either a single character or a control sequence.
^^{control sequences//as tokens}
The gullet expands the tokens into a sequence of 
\emph{primitive commands}, which are also tokens.
^^{expanding tokens}
The ^{stomach} carries out the operations specified by the primitive commands,
producing a sequence of pages.
Finally, the ^{intestines} transform each page into the form required
for the \dvifile\ and send it there.
^^{\dvifile//created by \TeX's intestines}
These actions are described in more detail 
in \chapterref{concepts} under \conceptcit{\anatomy}.
^^{\anatomy}

The real typesetting goes on in the stomach.
The commands instruct \TeX\ to typeset such-and-such a character in
such-and-such a font, to insert an interword space, to end a paragraph, and
so on.
Starting with individual typeset characters and other simple typographic
elements, \TeX\ builds up a page ^^{pages} as a nest of
^{boxes} within boxes within boxes \seeconcept{box}.
Each typeset character occupies a box, and so does an entire page.
A box can contain not just smaller boxes but also \emph{glue} ^^{glue}
(\xref{glue}) and a few other things.
The glue produces
space between the smaller boxes.  
An important property of glue is that it can stretch and shrink;
thus \TeX\ can make a box
larger or smaller by stretching or shrinking
the glue within~it.

Roughly speaking, a line is a box containing a sequence of character boxes,
and a page is a box containing a sequence of line boxes.
There's glue between the words of a line and between the lines of a page.
\TeX\ stretches or shrinks
the glue on each line so as to make the right margin
of the page come out even and the glue on each page
so as to make the bottom margins of different pages be equal.
Other kinds of typographical elements can also appear in a line or in a page,
but we won't go into them here.

As part of the process of assembling pages, \TeX\ needs to break paragraphs
into lines and lines into pages.  The stomach first sees a paragraph as one
long line, in effect.  It inserts \emph{line breaks}
^^{line breaking}
in order to transform
the paragraph into a sequence of lines of the right length, performing a
rather elaborate analysis in order to choose the set of breaks
that makes the paragraph look best
\seeconcept{line break}.
The stomach carries out a similar
but simpler process in order to transform a sequence of lines into a page.
Essentially the stomach accumulates lines until no more lines can fit on the
page.  It then chooses a single place to break the page, putting the lines
before the break on the current page
and saving the lines after the break for the
next page \seeconcept{page break}. ^^{page breaks//inserted by \TeX's stomach}

When \TeX\ is assembling an entity from a list of items (boxes, glue, etc.),
it is in one of six
\emph{modes} ^^{modes} (\xref{mode}).
The kind of entity it is assembling defines the mode that it is in.  
There are two ordinary modes: ordinary horizontal mode for assembling
paragraphs (before they are broken into lines) 
and ordinary vertical mode for assembling pages.
There are two restricted modes:
restricted horizontal mode for appending items horizontally to form
a horizontal box
and internal vertical mode for appending items vertically to form
a vertical box (other than a page).
Finally, there are two math modes: text math mode for assembling math formulas
within a paragraph and display math mode for assembling math formulas that are
displayed on lines by themselves (see ``Math formulas'', \xref{mathform}).


\section New \TeX\ versus old {\TeX}

\xrdef{newtex}
In 1989 Knuth made a major revision to \TeX\ in order to 
adapt it to the
character sets needed to support typesetting for languages other than
English.\space ^^{foreign languages}
The revision included a few minor extra features that could be added
without disturbing anything else.
This book describes ``^{\newTeX}''.
If you're still using an older version
of \TeX\ (version $2.991$ or earlier),
you'll want to know what features of {\newTeX} you can't use.
The following features aren't available in the older versions:
\ulist\compact
\li ^|\badness| (\xref\badness)
\li ^|\emergencystretch| (\xref\emergencystretch)
\li ^|\errorcontextlines| (\xref\errorcontextlines)
\li ^|\holdinginserts| (\xref\holdinginserts)
\li ^|\language|, ^|\setlanguage|, and |\new!-lan!-guage|
(\pp\xrefn\language, \xrefn{\@newlanguage}) ^^|\newlanguage|
\li ^|\lefthyphenmin| and ^|\righthyphenmin| (\xref\lefthyphenmin)
\li ^|\noboundary| (\xref\noboundary)
\li ^|\topglue| (\xref\topglue)
\li The |^^|$xy$ notation for hexadecimal digits (\xref{hexchars})
\endulist
\noindent
We recommend that you obtain new \TeX\ if you can.

\section Resources

\xrdef{resources}
A number of resources are available to help you in using \TeX.
\texbook\ is the definitive source of information on \TeX:

\smallskip
{\narrower\noindent
^{Knuth, Donald E.}, \texbook.  Reading, Mass.: Addison-Wesley, 1984.\par}
\smallskip
\noindent
Be sure to get the seventeenth printing (January 1990) or later;
the earlier printings don't cover the features of new \TeX.

^{\LaTeX} is a very popular collection of commands designed to simplify the use
of \TeX.  It is described in:
\smallskip
{\narrower\noindent\frenchspacing\spaceskip = 3.33pt plus 2pt minus 1.2pt
^{Lamport, Leslie}, {\sl The \LaTeX\ Document Preparation System}.
Reading, Mass.: Addison-Wesley, 1986.\par}
\smallskip
\noindent
^{\AMSTeX} is the collection of commands adopted by the American Mathematical
Society as a standard for submitting mathematical man\-u\-scripts
electronically.
It is described in:
\smallskip
{\narrower\noindent
^{Spivak, Michael~D.}, {\sl The Joy of \TeX}. Providence, R.I.:
American Mathematical Society, 1986.
\par}
\smallskip
\noindent
You can join the ^{\TUG} (TUG), which publishes a newsletter
called {\it ^{TUGBoat}}.
TUG is an excellent source not only for information about \TeX\ but also
for collections of macros, including \AMSTeX.
Its address is:
\smallskip
{\obeylines
^{\TUG}
c/o American Mathematical Society
P.O. Box 9506
Providence,  RI  02940
U.S.A.
}
\smallskip
\noindent
Finally, you can obtain copies of the ^|eplain.tex| macros
described in \chapterref{eplain} as well as the macros used in typesetting
this book.
They are available through the Internet network by anonymous \ftp\ from the
following hosts:
{\obeylines\display{\tt
labrea.stanford.edu [36.8.0.47]
ics.uci.edu [128.195.1.1]
june.cs.washington.edu [128.95.1.4]}}

The electronic version includes additional macros 
that format input for the
^{\BibTeX}\ computer program, written by Oren Patashnik at Stanford
University, ^^{Patashnik, Oren}
and print the output from that program.
If you find bugs in the macros, or think of improvements, you can send
electronic mail to Karl at {\tt karl@cs.umb.edu}.

The macros are also available for US \$10.00 on $5\frac1/4$\inches\
or $3\frac1/2$\inches\ PC-format diskettes from:
\smallskip
{\obeylines
Paul Abrahams
214 River Road
Deerfield,  MA  01342
\vskip\tinyskipamount
Email: {\tt Abrahams\%Wayne-MTS@um.cc.umich.edu}
}
\smallskip
\noindent
These addresses are correct as of June 1990; please be aware that they may
change after that, particularly the electronic addresses.

\endchapter\byebye