Você está na página 1de 96

A Gentle Introdu

tion to TEX

A Manual for Self-study

Mi hael Doob
Department of Mathemati s
The University of Manitoba
Winnipeg, Manitoba, Canada R3T 2N2
MDOOBUOFMCC.BITNET
MDOOBCCU.UMANITOBA.CA

Introdu tion

First the bad news: TEX is a large and ompli ated program that goes to extraordinary
lengths to produ e attra tive typeset material. This very ompli ation an ause unexpe ted
things to happen at times. Now the good news: straightforward text is very easy to typeset
using TEX. So it's possible to start with easier text and work up to more ompli ated
situations.
The purpose of this manual is to start from the very beginning and to move towards
these more ompli ated situations. No previous knowledge of TEX is assumed. By pro eeding a se tion at a time, greater varieties of text an be produ ed.
Here are a few suggestions: there are some exer ises in ea h se tion. Be sure and do
them! The only way to learn TEX is by using it. Better yet, experiment on your own;
try to make some variations on the exer ises. There is no way that you an damage the
TEX program with your experiments. You an nd a omplete answer to most exer ises by
looking at the TEX sour e le that was used to produ e this do ument. You'll noti e that
there are referen es in the right margin to The TEXbook1 . When you feel that you want
more information on a topi , that's where to look.
In identally, there are a few bs that appear in this manual; they are used to hide ompli ations (I look at this as something like poeti li ense). As you be ome more experien ed
at using TEX, you'll be able to nd them.
TEX is a publi domain program that is available for no li ense fee. It was developed
by Donald Knuth at Stanford University as a major proje t. In the pro t-oriented market
pla e, the program would ertainly ost many thousands of dollars. The TEX Users Group
(TUG) is a nonpro t organization whi h distributes opies of TEX, this manual, updates
software, and gives information about new developments in both hardware and software in
its publi ations TUGboat and TEXniques. Joining this users group is inexpensive; please
onsider doing so. The address is:
TEX Users Group
P.O. Box 869
Santa Barbara, CA 93102
U.S.A.
1 Addison-Wesley, Reading,Massa husetts, 1984, ISBN 0-201-13488-9

A TEX intro (Canadian spelling)

Introdu tion

This manual would not have ome into being without the aid of others. In parti ular the proofreading and suggestions of the following people have been invaluable: Waleed
A. Al-Salam (University of Alberta), Debbie L. Alspaugh (University of California), Nelson H. F. Beebe (University of Utah), Barbara Beeton (Ameri an Mathemati al So iety),
Anne Bruggemann-Klein (University of Freiburg), Bart Childs (Texas A. & M. University),
Mary Coventry (University of Washington), Dimitrios Diamantaras (Temple University),
Roberto Dominimanni (Naval Underwater Systems Center), Lin oln Durst (Providen e,
RI), Vi tor Eijkhout (University of Nijmegen), Moshe Feder (St. Lawren e University),
Josep M. Font (Universidad Bar elona), Jonas de Miranda Gomes (Instituto de Matemati a
Pura e Apli ada - Brazil), Rob Gross (Boston College), Klaus Hahn (University of Marburg), Anita Hoover (University of Delaware), Jurgen Koslowski (Ma alester College), Kees
van der Laan (Rijksuniversiteit Groningen), John Lee (Northrop Corporation), Silvio Levy
(Prin eton University), Robert Messer (Albion College), Emily H. Moore (Grinnell College),
Young Park (University of Maryland), Craig Platt (University of Manitoba), Kauko Saarinen (University of Jyvaskyla), Jim Wright (Iowa State University), and Dominik Wujastyk
(Well ome Institute for the History of Medi ine).
In addition several people have sent me parts or all of their lo al manuals. I have
re eived a few others on the rebound. In parti ular Elizabeth Barnhart (TV Guide),
Stephan v. Be htolsheim (Purdue University), Nelson H. F. Beebe (University of Utah)
and Leslie Lamport (Digital Equipment Corporation), Marie M Partland-Conn and Laurie Mann (Stratus Computer), Robert Messer (Albion College), Noel Peterson (Library of
Congress), Craig Platt (University of Manitoba), Alan Spragens (Stanford Linear A elerator Center, now of Apple Computers), Christina Thiele (Carleton University), and Daniel
M. Zirin (California Institute of Te hnology) have written various types of le ture notes that
have been most helpful.

ii

Contents

Introdu tion : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : i
Contents : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : iii
1. Getting Started : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1
1.1 What TEX is and what TEX isn't : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1
1.2 From TEX le to readable output, the big set up : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 2
1.3 Let's do it! : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 4
1.4 TEX has everything under ontrol : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 7
1.5 What TEX won't do : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 8
2. All hara ters great and small : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 9
2.1 Some hara ters are more spe ial than others : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 9
2.2 Typesetting with an a ent : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 10
2.3 Dots, dashes, quotes, : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 13
2.4 Di erent fonts : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 15
3. The shape of things to ome : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 19
3.1 Units, units, units : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 19
3.2 Page shape : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 20
3.3 Paragraph shape : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 22
3.4 Line shape : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 26
3.5 Footnotes : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 27
3.6 Headlines and footlines : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 28
3.7
Overfull and underfull boxes : : : : : : o
: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 29
n


4. Groups, Groups, fand More Groupsg : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 31
5. No math anxiety here! : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 33
5.1 Lots of new symbols : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 33
5.2 Fra tions : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 37
5.3 Subs ripts and supers ripts : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 38
5.4 Roots, square and otherwise : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 39
5.5 Lines, above and below : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 39
5.6 Delimiters large and small : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 40
5.7 Those spe ial fun tions : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 41
5.8 Hear ye, hear ye! : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 42
5.9 Matri es : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 43
5.10 Displayed equations : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 45
6. All in a row : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 48
6.1 Pi king up the tab : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 48
6.2 Horizontal alignment with more sophisti ated patterns : : : : : : : : : : : : : : : : : : : : : : : 51
7. Rolling your own : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 55
iii

A TEX intro (Canadian spelling)

Contents

7.1 The long and short of it : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :


7.2 Filling in with parameters : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
7.3 By any other name : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
8. To err is human : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
8.1 The forgotten bye : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
8.2 The misspelled or unknown ontrol sequen e : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
8.3 The misnamed font : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
8.4 Mismat hed mathemati s : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
8.5 Mismat hed bra es : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
9. Digging a little deeper : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
9.1 Big les, little les : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
9.2 Larger ma ro pa kages : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
9.3 Horizontal and verti al lines : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
9.4 Boxes within boxes : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
10. Control word list : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
11. I get by with a little help : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :

iv

55
57
60
62
62
62
64
64
65
68
68
69
70
72
77
80

Se tion 1
Getting Started

1.1 What TEX is and what TEX isn't


First of all, let's see what steps are ne essary to produ e a do ument using TEX. The
rst step is to type the le that TEX reads. This is usually alled the TEX le or the input
le, and it an be reated using a simple text editor (in fa t, if you're using a fan y word
pro essor, you have to be sure that your le is saved in ASCII or nondo ument mode without
any spe ial ontrol hara ters). The TEX program then reads your input le and produ es
what is alled a DVI le (DVI stands for DeVi e Independent). This le is not readable, at
least not by humans. The DVI le is then read by another program ( alled a devi e driver)
that produ es the output that is readable by humans. Why the extra le? The same DVI
le an be read by di erent devi e drivers to produ e output on a dot matrix printer, a
laser printer, a s reen viewer, or a phototypesetter. On e you have produ ed a DVI le that
gives the right output on, say, a s reen viewer, you an be assured that you will get exa tly
the same output on a laser printer without running the TEX program again.
The pro ess may be thought of as pro eeding in the following way:
edit text

TEX
input
le

DVI
le

TEX program

devi e driver

readable
output

This means that we don't see our output in its nal form when it is being typed at
the terminal. But in this ase a little patien e is amply rewarded, for a large number of
symbols not available in most word pro essing programs be ome available. In addition, the
typesetting is done with more pre ision, and the input les are easily sent between di erent
omputers by ele troni mail or on a magneti medium.
Our fo us will be on the rst step, that is, reating the TEX input le and then running
the TEX program to produ e appropriate results. There are two ways of running the TEX
program; it an be run in bat h mode or intera tively. In bat h mode you submit your
TEX input le to your omputer; it then runs the TEX program without further intervention
and gives you the result when it is nished. In intera tive mode the program an stop and
get further input from the user, that is, the user an intera t with the program. Using
1

TEXbook: 23

A TEX intro (Canadian spelling)

Se tion 1: Getting Started

TEX intera tively allows some errors to be orre ted by the user, while the TEX program
makes the orre tions in bat h mode as best it an. Intera tive is the preferred mode, of
ourse. All personal omputer and many mainframe implementations are intera tive. On
some mainframes, however, the only pra ti al method of running TEX is in bat h mode.

1.2 From TEX le to readable output, the big set up


[Note from MD: This is the only system dependent se tion in the manual and may be
repla ed by a lo al guide. No referen e is made to it outside of the se tion itself. The
following lo al information should be in luded:
 What initial steps, if any, should be taken by the reader to permit the running of TEX
and your lo al devi e driver(s).
 How to run TEX.
 How to read the log le.
 How to preview and/or print the dvi le.
The following sample is appli able here at the University of Manitoba. We use a lo ally
written editor (MANTES) on an Amdahl running MVS; I'm fairly ertain that it's the worst
possible ase.
In this se tion we'll see how to run TEX at the University of Manitoba. It is assumed
that the reader is familiar with MANTES and an reate text les using it.
First, there are several things that must be done one time only. To start you must
do the following (you type in the material that looks like typewriter type):
(1) allo ate the les that TEX will use by typing the following lines (while in MANTES):
C: allo da=sour e.tex format=vb,256,6144
C: allo da=dvi format=fb,1024,6144
(2) Create a le alled RUNTEX in your MANTES aggregate ontaining the following
JCL:
// JOB ,'RUN TEX'
// EXEC TEXC
//SRC DD DSN=<userid>.SOURCE.TEX,DISP=SHR
//DVI DD DSN=<userid>.DVI,DISP=OLD

A TEX intro (Canadian spelling)

Se tion 1: Getting Started

The name <userid> is repla ed by your own user id, of ourse. The use of upper ase
and the spa es must be followed exa tly.
(3) Create a le alled PRINTTEX in your MANTES aggregate ontaining the following
JCL:
// JOB ,'PRINT TEX'
// EXEC TEXP
//DVIFILE DD DSN=<userid>.DVI,DISP=SHR

On e you have ompleted these three steps, you are ready to run a TEX job. The les
you have reated will allow you to produ e about ten pages of ordinary text.
Here are the steps you use ea h time you run a job.
(1) reate a MANTES le ontaining your TEX input.
(2) save and submit your le using the ommands
C: save f/l to da=sour e.tex noseq
C: submit runtex
(3) when you get a message saying that your job is nished, enter the ommand
C: out <jobname>; list ttyout
In this ommand, <jobname> is repla ed by your user id with a dollar sign appended.
This le listing will tell you of any errors that might have o urred. It is an abbreviated
version of what is alled the \log le"; we will use the term \log le" to refer to the ttyout
le produ ed by TEX.
If you want, you an he k on the status of your job while it is exe uting by using the
ommand
C: q <jobname>
When you are nished looking at the log le, the ommand end s rat h will throw
away the log le while the ommand end release will send the log le to the printer, and
it an then be pi ked up with your TEX output.

A TEX intro (Canadian spelling)

Se tion 1: Getting Started

(4) when your output from RUNTEX program is error free, TEX will have reated a legal
DVI le. To print it, use the ommand
C: submit printtex nohold
As in (3), you an he k on the status of your job while it is exe uting.
(5) Pi k up your output at the I/O window, sixth oor Engineering building. It usually
takes about twenty minutes for the output to be ready. Ask for it by \<jobname>".
The les reated are large enough for running TEX jobs of about 10 pages. A job of
that size will take about one se ond of CPU time to run through TEX. It will take about 15
se onds of CPU time to print 10 pages on the Xerox 8600 using the urrent devi e driver.
You an print your own opy of this manual using the ommand %do u tex. You an
also nd lots of other useful online information about TEX by using %texinfo.

1.3 Let's do it!


So, from our viewpoint, the name of the game is to reate the TEX le that produ es
the right readable output. What does a TEX le look like? It onsists of hara ters from an
ordinary terminal, that is, upper and lower ase letters, numbers, and the usual pun tuation
and a ent hara ters (these are the usual ASCII hara ters). Text, for the most part, is
just typed normally. Spe ial instru tions usually start with one of a few spe ial symbols
su h as # or & (these will be des ribed in more detail later). Here is an example of a TEX
input le:
Here is my first \TeX\ senten e.
\bye

First note that the hara ters in this example look like typewriter type. We use these
hara ters with all examples that are meant to be typed from the omputer terminal. Se ond, note that the ba kslash appears three times in the text. We'll soon see that this is one
of the spe ial symbols mentioned previously, and it is used very frequently when making
TEX do uments. Make a le ontaining this example. Use the TEX program to make a DVI
le and a devi e driver to see what you have produ ed. If all goes well, you'll have a single
page with the following single senten e:
Here is my rst TEX senten e.
4

A TEX intro (Canadian spelling)

Se tion 1: Getting Started

There will also be a page number at the bottom of the page. If you've gotten this far,
ongratulations! On e you an produ e one TEX do ument, it's just a matter of time before
you an do more ompli ated ones. Now let's ompare what we typed in with what we got
out. The straightforward words were just typed in normally, and TEX set them in ordinary
type. But the word \TEX", whi h an't be typed in on a terminal be ause the letters aren't
on the same line, is entered by using a word starting with a ba kslash, and TEX made the
proper interpretation. Most symbols that are not ordinary letters, numbers, or pun tuation
are typeset by entering a word starting with a ba kslash. If we look a little loser, we'll note
that the word \ rst" is also hanged. The rst two letters have been joined together and
there isn't a separate dot over the letter \i". This is standard typesetting pra ti e: ertain
letter ombinations are joined up to form what are alled ligatures. There is a tually a
good stheti reason for this. Compare the rst two letters of \ rst" and \first" to see the
di eren e. We note that \bye appears in the input le with no orresponding word in the
nal opy. This a typesetting instru tion that tells TEX that the input is nished. We'll
learn about lots of di erent typesetting instru tions as we go along.
Let's look at the log le that was reated when we ran TEX. It may vary slightly at
your site, but should look something like this:
1.
2.
3.
4.
5.
6.
7.
8.

This is TeX, MVS Version 2.9 (no format preloaded)


** File PLAIN.FMT <-- DD=FMTLIB MEM=PLAIN
** File SRC.TEX <-- DD=SRC
(sr .tex [1
Output written on DVI (1 page, 256 bytes).
Trans ript written on TEXLOG.

This is the le that will ontain any error messages. On line 6, (sr .tex indi ated
that TEX has started reading that le. The appearan e of [1 indi ates that page 1 has
been pro essed. If there were errors on page 1, they would be listed at that point.

. Exer ise 1.1 Add a se ond senten e to your original TEX le to get:
Here is my first \TeX\ senten e.
I was the one who typeset it!
\bye

Use TEX and look at your output. Is the se ond senten e on a new line?
5

TEXbook: 4

A TEX intro (Canadian spelling)

Se tion 1: Getting Started

. Exer ise 1.2 Now add this line to the beginning of your le:
\nopagenumbers

Guess what will happen when you run the new le through TEX. Now try it and see what
happens.

. Exer ise 1.3 Add three or four more senten es to your le. Use letters, numbers, periods,
ommas, question marks, and ex lamation points, but don't use any other symbols.
. Exer ise 1.4 Leave a blank line and add some more senten es. You an now get new
paragraphs.
We have now seen a major prin iple on erning the preparation of TEX input les. The
pla ement of the text on your omputer terminal does not ne essarily orrespond to the
pla ement of the text on your output. You an not, for example, add spa e between words
in your output by adding spa es in your input le. Several onse utive spa es and one spa e
will produ e exa tly the same output. As would be expe ted, a word at the end of one line
will be separated from the rst word of the following line. In fa t, sometimes when working
on a le that will be heavily edited, it is onvenient to start ea h senten e on a separate
line. Spa es at the beginning of a line, however, are always ignored.

. Exer ise 1.5 Add the following senten e as a new paragraph, and then typeset it:
Congratulations! You re eived a grade of 100% on your latest
examination.

The % sign is used for omments in your input le. Everything on a line following this
symbol is ignored. Noti e that even the spa e that normally separates the last word on one
line from the rst word on the next line is lost. Now put a ba kslash in front of the % sign
to orre t the senten e.

. Exer ise 1.6 Add the following senten e as a new paragraph:


You owe me $10.00 and it's about time you sent it to me!

A TEX intro (Canadian spelling)

Se tion 1: Getting Started

This will produ e an error in your log le (if your implementation of TEX is intera tive, that
is, sends you messages and waits for answers, just hit the arriage return or enter key when
you get the error message). You will get output, but not what you might expe t. Look
at the log le and see where the error messages are listed. Don't worry about the a tual
messages. We'll have a lot more to say about errors (in luding this one) later. Now x the
error by putting a ba kslash in front of the $ sign, and typeset the result (there are a small
number of hara ters like the per ent and dollar signs that TEX uses for its own purposes.
A table of these hara ters will be provided shortly).

1.4 TEX has everything under ontrol


We have seen that the ba kslash has a spe ial role. Any word starting with a ba kslash
will be given a spe ial interpretation when TEX reads it from your input le. Su h a word
is alled a ontrol sequen e. There are, in fa t, two types of ontrol sequen es: a ontrol
word is a ba kslash followed by letters only (for example, \TeX) and a ontrol symbol is a
ba kslash followed by a single nonletter (for example, \$). Sin e a spa e is a nonletter, a
ba kslash followed by a spa e is a legitimate ontrol symbol. When we want to emphasize
that a spa e is present, we will use a spe ial symbol to indi ate the spa e, as in the ontrol
symbol \ . This onvention is used in The TEXbook as well as in this manual.
When TEX is reading your input le and omes to a ba kslash followed by a letter, it
knows that a ontrol word is being read. So it ontinues reading the name of the ontrol
word until a nonletter is read. So if your le ontains
I like \TeX!

the ontrol word \TeX is terminated by the ex lamation point. But this presents a problem
if you want to have a spa e after a ontrol word. If you have, for example, the senten e
I like \TeX and use it all the time.

in your input le, the ontrol word \TeX is terminated by the spa e (whi h is, of ourse,
a nonletter). But then you won't have a spa e between the words \TEX" and \and";
inserting more spa es won't help, sin e TEX doesn't distinguish between one spa e and
several onse utive spa es. But if you put the ontrol symbol \ after a ontrol word, you
will both terminate the ontrol word and insert a spa e. It's really easy to forget to put in
7

TEXbook: 7{8

A TEX intro (Canadian spelling)

Se tion 1: Getting Started

something like \ after a ontrol word. I promise you that you will do it at least on e while
you're learning to use TEX.

. Exer ise 1.7 Make an input le that will produ e the following paragraph:
I like TEX! On e you get the hang of it, TEX is really easy to use. You just have to
master the TEXni al aspe ts.
Most ontrol words are named so as to give a hint of their uses. You an use \par to
make a new paragraph, for example, instead of putting in a blank line.

1.5 What TEX won't do


TEX is very good at setting type, but there are things that TEX an't do well. One
is making gures. Spa e an be left to insert gures, but there are no graphi pro edures
built into the language (at present). Some implementations allow graphi instru tions to
be inserted using the \spe ial ontrol word but these are ex eptional and de nitely site
dependent.
TEX sets type in horizontal straight lines and not in straight lines at other angles. In
parti ular, it is generally not possible to make insertions in \lands ape mode", that is, with
the text rotated so that the baseline is parallel with the long edge of the paper, or to in lude
text that has a urve for a baseline. Perspe tive type (gradually in reasing or de reasing in
height) is not handled well by TEX.
We have seen that there is an \edit, TEX, driver" y le that is ne essary for ea h di erent
opy of output. This is true even when the output devi e is a terminal. In parti ular, it's
not possible to type the input le and see the results on the s reen immediately without
going through the full y le. Some implementations have both text and graphi s displays
with reasonably qui k turnaround (a few se onds for a single page); as hardware be omes
less expensive and pro essors be ome faster, we may see improvement.

Se tion 2
All hara ters great and small

2.1 Some hara ters are more spe ial than others
We saw in the last se tion that most text is entered at the terminal as senten es of
ordinary words just as when typing with a typewriter. But we also saw that, in parti ular,
the ba kslash ould be used for at least two di erent purposes. It an be used for symbols
(or ombinations of symbols) that don't appear on the keyboard su h as typing \TeX to get
TEX. It an also be used to give TEX spe ial instru tions su h as typing \bye to indi ate
the end of the input le. In general, a word starting with a ba kslash will be interpreted by
TEX as one requiring spe ial attention. There are several hundred words that TEX knows,
and you an de ne more yourself, and so the ba kslash is very important. We'll spend a
lot of time as we pro eed learning some of these words; fortunately we'll only need to use a
small number of them most of the time.
There are ten hara ters whi h, like the ba kslash, are used by TEX for spe ial purposes,
and we now want to give the omplete list. What if we want to use a senten e with one of
these spe ial hara ters in it? With this in mind we'll ask the following questions:
(1) What are the di erent spe ial hara ters?
(2) How do we use a spe ial hara ter if we really want to typeset it in our text?
Here is a table of ea h spe ial hara ter, its purpose, and the method of typesetting
the spe ial hara ter itself if you need it:

TEXbook: 37{38

A TEX intro (Canadian spelling)

Se tion 2: All hara ters great and small

Chara ters requiring spe ial input


Chara ter

n
f
g

%
&
~
$
^
#

Purpose

Spe ial symbols and instru tions


Open group
Close group
Comments
Tabs and table alignments
Unbreakable spa e
Starting or ending math text
Math supers ripts
Math subs ripts
De ning repla ement symbols

Input for literal output


$\ba kslash$
$\{$
$\}$
\%
\&
\~{}
\$
\^{}
\ {}
\#

2.2 Typesetting with an a ent


Now we're going to start using some of TEX's goodies! So far we've just been using
TEX to make our output look attra tive, but now we'll start to do things that are di ult
or impossible on the typewriter. In parti ular, we're going to look at a ents now. How
do you produ e an a ent when the symbol doesn't appear on the keyboard? Just as with
the symbol TEX, it is ne essary to enter a word starting with a ba kslash. For the word
\premiere", as a rst example, you need to type in premi\`ere (you may have to hunt
around to nd the \ba k prime" or \grave" symbol ` on your keyboard, but it's there
somewhere2). In general, to put an a ent on a letter, the appropriate ontrol sequen e
pre edes the letter.
2 If you have a very old or obs ure keyboard and the ba k prime is really not there, you
an use \lq{} instead. Similarly \rq{} an be used for the symbol '. You an think of the
symbols as being abbreviations for \left quote" and \right quote." In addition, \lq\lq{}
and \rq\rq{} give the usual quotation marks. But this won't work as a method to produ e
an a ent over the following letter, so you're really better o with a proper keyboard.

10

A TEX intro (Canadian spelling)

Se tion 2: All hara ters great and small

Here are some examples:

TEX input

TEX output

a la mode
resume
soup on
Noel
nave

\`a la mode
r\'esum\'e
soup\ on
No\"el
na\"\i ve

We see several prin iples illustrated by these examples. Most a ents are produ ed by
using a ontrol symbol with a similar shape. A few of them are produ ed by ontrol words
ontaining a single letter. Some are must be used in this ase, for a spa e must be used to
terminate the ontrol word. If you have soup\ on in your le, for example, TEX will look
for the ontrol word \ on3.
Noti e that there is a ontrol word \i also. This produ es the letter \i" without the
dot over it; this allows an a ent to be put over the lower part of the letter. There is an
analogous ontrol word \j that produ es a dotless \j" for a enting purposes.

A ents that may be immediately followed by a letter


Name

grave
a ute
ir um ex
umlaut/dieresis/tremat
tilde
ma ron
dot

TEX input
\`o
\'o
\^o
\"o
\~o
\=o
\.o

TEX output
o
o
^o
o
~o
o
o_

3 We'll see that there is another method when we look at the grouping on ept in Se tion 4.

11

TEXbook: 52{53

A TEX intro (Canadian spelling)

Se tion 2: All hara ters great and small

A ents requiring an intervening spa e


Name

edilla
underdot
underbar
ha ek
breve
tie
Hungarian umlaut

TEX input
\ o
\d o
\b o
\v o
\u o
\t oo
\H o

TEX output
o
o.
o
o
o
oo
}o

TEX also allows some letters from languages other than English to be typeset.

Available foreign language symbols


Example

gean, stheti s
uvres, hors d'uvre

Angstrom
re, Kbenhavn
Lodz, lodka
Nu
>Si?
<Si!
Se~nor

TEX input
\AE, \ae
\OE \oe
\AA, \aa
\O, \o
\L, \l
\ss
?`
!`
\~
{\it\$}

TEX output
, 
, 

A, a
, 
L, l

>
<
~

Typeset the senten e in ea h of the following exer ises:

. Exer ise 2.1 Does s hylus understand dipus?


. Exer ise 2.2 The smallest internal unit of TEX is about 53.63
A.
. Exer ise 2.3 They took some honey and plenty of money wrapped up in a $5 note.
12

A TEX intro (Canadian spelling)

Se tion 2: All hara ters great and small

 eves, refusez vos le ons! Jetez vos ha^nes!


. Exer ise 2.4 El

. Exer ise 2.5 Zasto tako polako pijete  aj?


. Exer ise 2.6 Mein Tee ist hei.
. Exer ise 2.7 Peut-^etre qu'il prefere le afe gla e.
. Exer ise 2.8 >Por que no bebes vino blan o? <Porque esta avinagrado!
. Exer ise 2.9 Mn ideeen worden niet benvloed.

. Exer ise 2.10 Can you take a ferry from Oland
to 
Aland?

. Exer ise 2.11 Turk e konusan yegenler nasillar?

2.3 Dots, dashes, quotes, : : :


Typing has always been a ompromise: the small number of keys ( ompared to the
number of typeset symbols available) has for ed some hanges on the typist. When preparing
material using TEX, there is no need to be so restri ted. In this se tion we'll look at some
di eren es between typing and using TEX.
There are four types of dashes that are used. The hyphen is used for ombining words
into one unit as with mother-in-law. The en-dash is used to indi ate a sequen e of page
numbers, years or su h things. The em-dash is a grammati al symbol. The minus sign is
used for negative numbers. Here they are with their uses:

13

TEXbook: 3{5

A TEX intro (Canadian spelling)

Se tion 2: All hara ters great and small

Di erent types of dashes


Name

hyphen
en-dash
em-dash
minus sign

TEX input
---$-$

TEX output
{
|

Example

The spa e is 3-dimensional.


Read pages 3{4.
I saw them|there were 3 men alive.
The temperature dropped to 3 degrees.

. Exer ise 2.12 I entered the room and|horrors|I saw both my father-in-law and my
mother-in-law.
. Exer ise 2.13 The winter of 1484{1485 was one of dis ontent.
Another di eren e between typing and using TEX is the use of quotation marks. Opening and losing quotation marks are the same on a typewriter. They are produ ed in TEX
by using the apostrophe or prime key ' and ba kprime key `. An open quote is produ ed
by `` and the lose quote by ''. Similarly the opening single quote is produ ed by ` and
the losing single quote by '. Noti e that there is no need to use the usual typing quotation
mark (it normally gives a lose quote, but don't ount on it).

TEXbook: 3

. Exer ise 2.14 His \thoughtfulness" was impressive.


. Exer ise 2.15 Frank wondered, \Is this a girl that an't say `No!'?"
Sometimes ellipses (three dots) are used to indi ate a passage of time or missing material. Typing three periods will give three dots very lose together. The dots with proper
spa ing will be produ ed by having \dots in your input le.

. Exer ise 2.16 He thought, \: : : and this goes on forever, perhaps to the last re orded
syllable."
Another problem with dots is that the period after an abbreviation normally has less
spa e after it than does the period at the end of a senten e. There are two ways to solve
14

TEXbook: 173

A TEX intro (Canadian spelling)

Se tion 2: All hara ters great and small

this problem: the dot an be followed by either \ or ~ to hange the spa ing. The se ond
alternative will give an unbreakable spa e; when su h a spa e is between two words, these
words must typeset on the same line. The input Prof.~Knuth would ause those two words
to be typeset on one line. This is desirable for names like Van ouver, B. C. and Mr. Jones
so that \Mr." and \Jones" do not end up on separate lines. Noti e that no ba kslash is
used with the unbreakable spa e.

TEXbook: 91{92

. Exer ise 2.17 Have you seen Ms. Jones?


. Exer ise 2.18 Prof. Smith and Dr. Gold ew from Halifax N. S. to Montreal, P. Q. via
Mon ton, N. B.

2.4 Di erent fonts


The most obvious di eren e between typewritten text and TEX output is undoubtedly
the di erent fonts or types of symbols used. When TEX starts up it has sixteen fonts available. Some of these are used for te hni al purposes, but even so there are several di erent
typefa es available as an be seen in the following table. A omplete list of the sixteen
fonts is given in Appendix F of The TEXbook. Most of them are used automati ally;
a mathemati al subs ript, for example, is put in smaller type by TEX with no spe ial user
intervention.
To hange from the usual (roman) typefa e to itali , the ontrol word \it is used.
To hange ba k to the usual roman typefa e, use \rm. For example, you ould have the
following senten e: I started with roman type, \it swit hed to itali type, \rm
and returned to roman type. This would give the following: I started with roman type,
swit hed to itali type,4 and returned to roman type.
Typefa es other than itali are also available. Those given below are the ones most
ommonly used. They are available immediately when TEX starts. A little later we'll see
how to use other typefa es that aren't available when TEX starts.
4

Noti e that the omma and this footnote are in itali type, and this looks a little funny.
We'll see that there is another method for hanging fonts when we talk about grouping in
Se tion 4.

15

TEXbook: 427{432

A TEX intro (Canadian spelling)

Se tion 2: All hara ters great and small

Font Samples
Font name

Roman
Boldfa e
Itali
Slanted
Typewriter
Math symbol5

TEX swit h sequen e


\rm
\bf
\it
\sl
\tt
\ al

Sample of typefa e
This is roman type.

This is boldfa e type.

This is itali type.

This is slanted type.


This is typewriter type.

SOME SCRIPT LET T ERS .

The slanted and itali fonts seem quite similar at rst. It is easy to see the di eren e
between the letter \a" in ea h sample. When hanging from a slanted or itali font to a
roman font, the last letter in the rst font will lean towards the rst letter of the roman
font; this looks ramped, and to ompensate there is a little extra spa e that an be added
alled the itali orre tion. This is done using the ontrol symbol \/. In the following
senten e, there is no itali orre tion after the rst sequen e of itali letters but there is
after the se ond sequen e; see the di eren e: If the itali orre tion is not used the letters
are too lose together, but if the orre tion is used, the spa ing is better. There is no need
for the itali orre tion when the itali hara ters are followed by a omma or a period, but
your text will de nitely look better if you use it before quotation marks or parentheses.
It is possible to use fonts other than those initially de ned in TEX when desired (assuming that they are available on your omputer system, of ourse). Di erent sizes an be used
with the aid of the ontrol word \magstep. To de ne your new font you will have to know
its name on your omputer system. For example, the roman typefa e is alled \ mr10" on
most systems. If you use \font\bigrm = mr10 s aled \magstep 1, you an then use
\bigrm in exa tly the same way as you use \it or \rm.
Swit hing via \bigrm will give roman type that is larger than the usual by 20%.
\font\bigbigrm = mr10 s aled \magstep 2 will de ne a font that is about 44% larger
than the usual roman typefa e. The sizes \magstep 0 to \magstep 5 are available. On
most omputers \magstephalf is also available; this represents an enlargement of about
9.5%. Here are some samples at various sizes:
5 This example is heating sin e you need to know a little about mathemati s input to
use it, but I wanted to in lude it anyway. You'll be able to use these letters after you study
the use of mathemati al symbols.
16

TEXbook: 13{17

A TEX intro (Canadian spelling)

Se tion 2: All hara ters great and small

Di erent Font Magni ations


Magni ation

Sample

\magstep 0
\magstephalf
\magstep 1
\magstep 2

Sample text at magstep 0.

\magstep 3

Sample text at magstep 3.

\magstep 4

Sample text at magstep 4.

\magstep 5

Sample text at magstep 5.

Sample text at magstephalf.

Sample text at magstep 1.

Sample text at magstep 2.

It's also possible to use ompletely new typefa es. These are dependent on system availability, of ourse. Many systems have a le alled CMSS10 whi h is a font that ontains sans
serif letters. Using \font\sf = mss10 will allow the ontrol word \sf to be used in the
same manner as \bf. Having made this de nition, the input
\sf Here is a sample of our new Sans Serif font.

will produ e
Here is a sample of our new Sans Serif font.

. Exer ise 2.19 What problem might have arisen if we had used \ss instead of \sf to turn
on the Sans Serif font? Hint: if the answer doesn't o ur to you at rst, think about the
German alphabet and it will nally ome to you.
. Exer ise 2.20 Typeset a paragraph of magni ed sans serif text.
The extra fonts available may vary from site to site. The ones in the following table
are available at most pla es.

17

A TEX intro (Canadian spelling)

Se tion 2: All hara ters great and small

External Fonts Names


CMBSY10
CMBX6
CMDUNH10
CMMIB10
CMMI8
CMR6
CMSL12
CMSSI12
CMSS10
CMSY5
CMTEX10
CMTI8
CMU10

CMBXSL10
CMBX7
CMEX10
CMMI10
CMMI9
CMR7
CMSL8
CMSSI17
CMSS12
CMSY6
CMTEX8
CMTI9
CMVTT10

CMBXTI10
CMBX8
CMFF10
CMMI12
CMR10
CMR8
CMSL9
CMSSI8
CMSS17
CMSY7
CMTEX9
CMTT10

CMBX10
CMBX9
CMFIB8
CMMI5
CMR12
CMR9
CMSSBX10
CMSSI9
CMSS8
CMSY8
CMTI10
CMTT12

CMBX12
CMB10
CMFI10
CMMI6
CMR17
CMSLTT10
CMSSDC10
CMSSQI8
CMSS9
CMSY9
CMTI12
CMTT8

CMBX5
CMCSC10
CMITT10
CMMI7
CMR5
CMSL10
CMSSI10
CMSSQ8
CMSY10
CMTCSC10
CMTI7
CMTT9

Here's a little ba kground about these names. The rst two letters CM stands for Computer
Modern, the name given to this font family by the designer. The number at the end is the
point size: 10 point type is the normal size, 7 point is the normal size for subs ripts, and 5
point is the normal size for subs ripts of subs ripts, 12 point is 20% larger than 10 point,
et . If the letters CM are followed by B, it is a boldfa e type. Similarly R indi ates roman, I
is for itali s, CSC is for small aps, SL is for slanted, SS is for sans serif, SY is for symbols,
and TT is for typewriter type.

. Exer ise 2.21 Find the fonts available on your system, and print out all the letters and
numbers in several of them.
. Exer ise 2.22 The font CMR12 is 20% larger than CMR10. Also \magstep 1 magni es
the type by 20%. Take some text and print it using CMR12 then using CMR10 s aled by
\magstep 1. The results are quite di erent!

18

Se tion 3
The shape of things to ome

In this se tion we want to see how to make text have di erent shapes or sizes. One
may use TEX with the default sizes, of ourse, just as we have been doing so far. We'll now
be ome more reative with our output. In dis ussing the size of various parts of a page of
text, there are several units of measure we an use.

3.1 Units, units, units


TEX an measure length using many types of units. The most ommon are the in h,
the entimetre, the point, the pi a. The abbreviations for these units are in, m, pt, and
p respe tively. The point is de ned by the equation 1 in h = 72.27 points, and the pi a by
1 pi a = 12 points. Thus a point is rather small and is about the size of a de imal point.
Here is a sample to give an idea of the omparative sizes:

TEXbook: 57

1 in h:
1 entimetre:
20 points:
1 pi a:
Thus points are used to make ne hanges; a pi a is about the distan e between the
baselines of two onse utive lines of (unmagni ed) normal text. TEX is quite exa t about
dimensions; internally its smallest unit is less than one four-millionth of an in h. Hen e it
is the resolution of the output devi e that will determine the a ura y of the output.
There are two other units that are sometimes useful that have di erent sizes in di erent
fonts. The ex is about the height of a small \x" and the em is a little smaller than the width
of a apital \M".
The shape of the output is generally determined by ontrol words. There are many
su h words; these allow very ne ontrol of the resulting text. But most of the time only a
small number of them are ne essary.
19

TEXbook: 60

A TEX intro (Canadian spelling)

Se tion 3: The shape of things to ome

3.2 Page shape


The text on a page onsists of three basi parts. There is the headline above the main
text; this often ontains a hapter title, se tion title, or a page number, and may di er on
odd and even pages. Below this is the main text, whi h in ludes any footnotes. And nally
there is the footline that might ontain a page number.
In the examples we have seen so far, the headline has been blank. The footline has
ontained either a entred number or, if \nopagenumbers had been used, has also been
blank. We'll have more to say about headlines and footlines later in this se tion. For the
moment let's on entrate on the main text.
To nish one page and start a new one, \vfill \eje t an be used. The ontrol word
\eje t for es the ompletion of the urrent page, while \vfill auses any left over verti al
spa e to be gathered at the bottom of the page (you might try leaving out the \vfill as
an experiment to see how the verti al analogue of justi ed horizontal lines of text works).

The urrent horizontal width of the text on the page is des ribed by the ontrol word \hsize. It an be hanged, say to
4 in hes, by \hsize = 4 in at any desired time using methods
to be des ribed in the next few se tions. The value of \hsize in
e e t when the paragraph is ompleted determines the width of
the paragraph. As an be seen in this paragraph, the text width
an be hanged (in this ase to 4 in hes) for a single paragraph.
Be ause it represents the urrent value of the horizontal width,
expressions su h as \hsize = 0.75\hsize an make a new value
that is relative to the old one.
The verti al analogue of \hsize is \vsize, whi h is the urrent height of the main text.
It an be reset, just like \hsize. Thus, \vsize = 8 in an be used to hange the verti al
height of the main text. Note that \vsize is the size of the text ex lusive of any headline
or footline material.
Text an also be shifted a ross the page. The upper left orner of the text is one in h
down and one in h in from the upper left orner of the page. The ontrol words \hoffset
and \voffset are used to shift the text horizontally and verti ally. Thus \hoffset = .75
in and \voffset = -.5 in would shift the text an additional .75 in hes to the right and
.5 in hes up. Most of the time you'll need to set \hoffset, \voffset, and \vsize at the
beginning of your do ument only.

20

TEXbook: 251

A TEX intro (Canadian spelling)

Se tion 3: The shape of things to ome

Control words for page sizes


Name

horizontal width
verti al width
horizontal o set6
verti al o set6

TEX Control Word


\hsize
\vsize
\hoffset
\voffset

TEX default value (in hes)


6.5
8.9
0
0

. Exer ise 3.1 Enter a paragraph of text that is a few lines long. Take several opies of
your paragraph and put \hsize = 5 in before one and \hsize = 10 m in front of a
se ond one. Try a few other values for \hsize.
. Exer ise 3.2 Put \hoffset = .5 in and \voffset = 1 in before the rst paragraph
of your previous exer ise.
. Exer ise 3.3 Take your previous exer ise and put \vsize = 2 in before the rst paragraph.
In the previous se tion we saw that it is possible to use fonts of larger size by using
the \magstep ontrol word. It's also possible to magnify the entire do ument at on e.
If \magnifi ation = \magstep 1 appears at the top of your do ument, then all of your
output is magni ed by 20%. The other values of \magstep an be used, too. It should be

emphasized that \magnifi ation an only be used before even a single hara ter
is typeset. This magni ation reates a problem in units; if the do ument is to be magni ed

by 20% and \hsize = 5 in appears in the TEX input le, should the nal output have an
\hsize of 5 in hes or should it be magni ed by 20% to 6 in hes? Unless told otherwise, all
the dimensions will be magni ed so that, in this ase, \hsize would be 6 in hes in the nal
output. This means that all the dimensions will in rease uniformly when \magnifi ation
is used. But for some spe ial situations it might not be desirable for this to happen; for
example, you might want to leave a spa e of exa tly 3 in hes to insert a gure. In this
ase any unit an be modi ed by true so that \hsize = 5 true in will always set the line
width to 5 in hes, regardless of magni ation.
6 The text is initially 1 in h down and 1 in h in from upper left orner of the page.

21

TEXbook: 59{60

A TEX intro (Canadian spelling)

Se tion 3: The shape of things to ome

. Exer ise 3.4 Put \magnifi ation = \magstep 1 as the rst line in one of your input
les and see how the output hanges.

3.3 Paragraph shape


When TEX is reading the text to be typeset from your input le, it reads in a paragraph
at a time and then typesets it. This means that there is a lot of ontrol over paragraph
shapes, but also that some are must be taken. We've already seen that \hsize an be used
to ontrol the width of a single paragraph. But suppose the following appeared as part of
your input le:
\hsize = 5 in
Four s ore and seven years
.
.
.

:::

: : : from this earth.


\hsize = 6.5 in

What is the width of the paragraph? The \hsize was hanged at the start of the
paragraph and again at the end. Sin e the paragraph was not ompleted (by putting in a
blank line or \par) until after the se ond hange, the paragraph would be typeset with a
width of 6.5 in hes. However, if a blank line were inserted before \hsize = 6.5 in, then
the paragraph would be typeset with a width of 5 in hes. So, in general, when a paragraph
is set, the values of the parameters that are in e e t when the paragraph is ompleted are
the ones that are used.
Here is a table with some paragraph parameters:

Some paragraph shape parameters


Fun tion

width
indentation on rst line
distan e between lines
distan e between paragraphs

TEX Control Word


\hsize
\parindent
\baselineskip
\parskip

TEX default
6.5 in hes
20 points
12 points
0 points

The ontrol word \noindent may be used at the beginning of a paragraph to avoid the
automati indentation on the rst line. This ontrol word will only a e t the paragraph
22

A TEX intro (Canadian spelling)

Se tion 3: The shape of things to ome

being set when it is invoked (of ourse \parindent = 0 pt will ause no indentation for all
paragraphs).
A more exible way to ontrol the width of a paragraph is to use \rightskip
and \leftskip. Setting \leftskip = 20 pt auses the left margin of the paragraph to be moved in an extra twenty points. Negative values may be assigned
to \leftskip to move the left margin out. The ontrol word \rightskip does
the same to the right side of the paragraph. The single ontrol word \narrower is
the equivalent of setting both \leftskip and \rightskip equal to \parindent.
This is quite useful for long quotations, and this paragraph is an example of its
use. As with \hsize, the value of \leftskip and \rightskip in e e t when the
paragraph is ompleted is the one whi h will apply to the whole paragraph.

TEXbook: 100

. Exer ise 3.5 Make two paragraphs with the following spe i ations: the left margin of
both paragraphs is indented by 1.5 in hes, the right margin of the rst paragraph is indented
by 0.75 in hes, and the right margin of the se ond paragraph is indented by 1.75 in hes.
Lines an be made with di erent lengths within one paragraph by using \hangindent
and \hangafter. The amount of the indentation is determined by value of \hangindent.
If \hangindent is positive, the indentation is made from the left, and if it is negative it is
made from the right. The lines on whi h the indentation o urs is ontrolled by \hangafter.
If \hangafter is positive then it determines the number of lines at full width before the
indentation starts. Thus if \hangindent = 1.75 in and \hangafter = 6, then the rst
six lines will be at full width and the rest will be indented by
1.75 in hes from the left. On the other hand if \hangindent =
-1.75 in and \hangafter = -6, then the rst six lines will be
indented by 1.75 in hes from the right and the rest will be at
full width. TEX resets to the default values \hangindent = 0
pt and \hangafter = 1 after ea h paragraph. These ontrol
words are useful for paragraphs with \hanging indents" and
for owing a paragraph around spa e reserved for a gure.
The ontrol word \hang at the beginning of the paragraph will
ause the rst line to be of full width (\hangafter=1) and the
rest of the paragraph to be indented by the urrent value of
\parindent. But you do have to use \noindent if you want
the rst line to extend all the way to the left margin.
Here is the previous paragraph repeated with \hangafter = -6 and \hangindent =

-1.75 in.

23

TEXbook: 355
TEXbook: 102

A TEX intro (Canadian spelling)

Se tion 3: The shape of things to ome

Lines an be made with di erent lengths within one paragraph by using \hangindent and \hangafter. The amount
of the indentation is determined by value of \hangindent. If
\hangindent is positive, the indentation is made from the left,
and if it is negative it is made from the right. The lines on
whi h the indentation o urs is ontrolled by \hangafter. If
\hangafter is positive then it determines the number of lines at full width before the indentation starts. Thus if \hangindent = 1.75 in and \hangafter = 6, then the rst six
lines will be at full width and the rest will be indented by 1.75 in hes from the left. On
the other hand if \hangindent = -1.75 in and \hangafter = -6, then the rst six lines
will be indented by 1.75 in hes from the right and the rest will be at full width. TEX resets to the default values \hangindent = 0 pt and \hangafter = 1 after ea h paragraph.
These ontrol words are useful for paragraphs with \hanging indents" and for owing a
paragraph around spa e reserved for a gure. The ontrol word \hang at the beginning of
the paragraph will ause the rst line to be of full width (\hangafter=1) and the rest of
the paragraph to be indented by the urrent value of \parindent. But you do have to use
\noindent if you want the rst line to extend all the way to the left margin.

TEXbook: 355
TEXbook: 102

The ontrol word \parshape an be used to make paragraphs with a greater variety of
shapes.

TEXbook: 101

Another useful ontrol word for setting paragraphs is \item. It an be used to make
various types of itemized lists, and is invoked using the pattern \item{: : :}. This auses
the next paragraph to be formed with every line indented by \parindent and, in addition,
the rst line labeled on the left by whatever is between the bra es. It is usually used with
\parskip = 0 pt, sin e that ontrol word determines the verti al spa e between the di erent items. The ontrol word \itemitem is the same as \item ex ept that the indentation is
twi e as far, that is, twi e the value of \parindent. Here is an example:

TEXbook: 102

\parskip = 0pt \parindent = 30 pt


\noindent
Answer all the following questions:
\item{(1)} What is question 1?
\item{(2)} What is question 2?
\item{(3)} What is question 3?
\itemitem{(3a)} What is question 3a?
\itemitem{(3b)} What is question 3b?

will produ e

24

A TEX intro (Canadian spelling)

Se tion 3: The shape of things to ome

Answer all the following questions:


(1) What is question 1?
(2) What is question 2?
(3) What is question 3?
(3a) What is question 3a?
(3b) What is question 3b?

. Exer ise 3.6 Make a paragraph several lines long and use it with the \item ontrol word
to see the \hanging indent." Now take the same paragraph and use it with di erent values
of \parindent and \hsize.
Now let's see how to put spa e between paragraphs. The ontrol word \parskip is used
to determine how mu h spa e is normally left between paragraphs. So if you put \parskip
= 12 pt at the beginning of your TEX sour e le, there will be 12 points between paragraphs
unless other instru tions are given. The ontrol word \vskip an be used to insert extra
verti al spa e between paragraphs. If \vskip 1 in or \vskip 20 pt appears between two
paragraphs, then the extra spa e is inserted.
There are a ouple of pe uliarities of \vskip that seem quite strange at rst. If you
have \vskip 3 in and the skip starts two in hes from the bottom of the page, the rest of the
page is skipped, but the extra one in h is not skipped at the top of the next page. In other
words, \vskip will not insert spa e a ross page boundaries. In fa t, \vskip 1 in
will have no e e t at all if it happens to appear at the top of a page! For many types of
verti al spa ing this is quite appropriate. The spa e before a se tion heading, for example,
should not ontinue a ross page boundaries.
A similar phenomenon o urs at the beginning of your do ument. If, for example, you
want a title page with the title about half way down the page, you an not insert the spa e
at the top of the page using \vskip.
But what if you really want some blank spa e at the top of a page? You ould start the
page with \ but this in e e t typesets a one line paragraph ontaining a blank. So while
nothing is typeset, the extra spa e due to the values of \baselineskip and \parskip will
add extra spa e. An easier method is to use \vglue instead of \vskip to get the desired
result. Thus \vglue 1 in will leave one in h of blank spa e at the top of the page.
We an note in passing that there is another more general method to put material at
the top of a page using the ontrol words \topinsert and \endinsert. If \topinsert : : :
\endinsert is used within a page, the material between \topinsert and \endinsert will
appear at the top of the page, if possible. For example:
25

TEXbook: 352

A TEX intro (Canadian spelling)

Se tion 3: The shape of things to ome

\topinsert
\vskip 1 in
\ enterline{Figure 1}
\endinsert

TEXbook: 115

is useful for inserting gures of a pres ribed size.


There are also some spe ial ontrol words for making small verti al skips. They are

\smallskip, \medskip, and \bigskip. Here is the size of ea h one:


\medskip:

\smallskip:

\bigskip:

3.4 Line shape


For most material TEX does a good job of breaking up a paragraph into lines. But
sometimes it's ne essary to add further instru tions. It's possible to for e a new line by
inserting \hfill \break in your input le. It's also possible to put some text on a line
by itself using the ontrol word \line{: : :}; then the material between the bra es will be
restri ted to one line (although the result will be spread out over the whole line and may
be horrible). The ontrol words \leftline{: : :}, \rightline{: : :}, and \ enterline{: : :}
will, respe tively, set the material between the bra es on a single line on the left margin, on
the right margin, or entred. Thus
\leftline{I'm over on the left.}
\ enterline{I'm in the entre.}
\rightline{I'm on the right.}
\line{I just seem to be spread out all over the pla e.}

produ es the four lines:


I'm over on the left.
I

just

seem

I'm in the entre.


to

be

spread

out

all

over

I'm on the right.


the
pla e.

Other types of spa ing an be obtained by using the ontrol word \hfil. This auses
all the extra spa e in the line to be a umulated at the position where \hfil appears. Thus
if we alter our last example to \line{I just seem to be spread out \hfil all over
the pla e.} we will get
26

A TEX intro (Canadian spelling)

Se tion 3: The shape of things to ome

I just seem to be spread out

all over the pla e.

If we have more than one \hfil, they will divide any extra spa e among themselves
equally. Hen e \line{left text \hfil entre text \hfil right text.} will produ e
left text
entre text
right text.

. Exer ise 3.7 Typeset the following line:


left end
left ta kle
left guard
entre

right guard

right ta kle

right end

. Exer ise 3.8 Typeset the following line with twi e as mu h spa e between \left" and
\right- entre" as between \right- entre" and \right":
left
right- entre
right
It's possible to move horizontally using \hskip in a manner analogous with \vskip.

. Exer ise 3.9 What happens with the following input:


\line{\hskip 1 in ONE \hfil TWO \hfil THREE}

The right justi ation an be an eled by using the ontrol word \raggedright.

3.5 Footnotes
The general pattern to make footnotes using TEX is \footnote{: : :}{: : :}.
The footnote mark goes in between the rst set of bra es. Some available marks are

\dag (y), \ddag (z), \S (x), and \P ({). The text of the footnote goes between the

se ond set of bra es. The use of numbers as marks is a little less straightforward. The
footnote21 at the bottom of the page was produ ed by using \footnote{${}^{21}$}{This
is the footnote at the bottom of the page.} after the word \footnote" in the text.
This onstru tion is somewhat ompli ated; we'll see why it's this way when we know a
little more about typesetting mathemati s. But for the moment we an look at it as a way
of getting the job done. You may want to use \rm within the footnote to ensure that the
right font appears. Usually you will not want a spa e between the text and the ontrol word
footnote.
21 This is the footnote at the bottom of the page.
27

TEXbook: 117

Page 28

. Exer ise 3.10 Make up a page with a relatively long footnote spanning several lines.
. Exer ise 3.11 Make up a page with two di erent footnotes on it.

3.6 Headlines and Footlines


The lines for title and page numbers that go above and below the main text are produ ed
by using \headline={: : :} and \footline={: : :}.

TEXbook: 252{253

The prin iple is the same as using the ontrol word \line{: : :} within the usual text on
the page. A helpful ontrol word is \pageno whi h represents the urrent page number. Thus
\headline={\hfil \tenrm Page \the\pageno} would ause the page number to appear
in the upper right orner pre eded by the word \Page" (now look at the upper right orner
of this page). It is safer to expli itly name the font that you want to use (in this ase \tenrm
to use the 10 point roman font), sin e you are never guaranteed that a parti ular font will
be in use when the headline or footline is set. The ontrol word \the takes the internal
value of the next word if it is an appropriate ontrol word and prints it as text. You an
also use the ontrol word \folio instead of \the \pageno. The di eren e is that \folio
will give roman numerals when \pageno is negative.
You an also assign values to \pageno if you want your do ument to use a di erent
sequen e of page numbers from the usual. Roman numerals an be produ ed by using
negative numbers; \pageno=-1 at the beginning of a do ument will ause page numbers to
be in roman numerals.
Di erent headlines an be produ ed for even and odd pages in the following manner:
\headline={\ifodd \pageno {: : :}\else {: : :}\fi}

where the material between the rst set of bra es is for the right-hand pages and the material
between the se ond set of bra es is for the left-hand pages.

. Exer ise 3.12 Change the footline so that the page number is entred with an en-dash
on either side.

28

TEXbook: 252

A TEX intro (Canadian spelling)

Se tion 3: The shape of things to ome

3.7 Overfull and underfull boxes


One of the most frustrating experien es for the new TEX user is the o urren e of
overfull and underfull boxes. They are duly noted in the log le and are also written to the
s reen when TEX is being run intera tively. Overfull boxes are also marked on the output by
a slug (a large lled-in bla k re tangle that looks like this: ) in the right margin. Various
obs ene terms are applied to this slug. It appears even though there is nothing wrong with
the TEX input. So why is the slug there and what an be done about it?
A good way to visualize the way TEX organizes a page is to think of the printed material
as being put into boxes. There are two types of boxes: hboxes and vboxes. Most of the time
these orrespond to the organization of horizontal text into lines and verti al paragraphs
into pages. In parti ular, it is the spa ing of the words in a hbox orresponding to a line of
text that auses the slug to appear.
Re all that TEX reads in the omplete paragraph before de iding how to break it up
into lines. This is better than working a line at a time, sin e a slight improvement in one line
might ause atastrophi hanges farther down in the paragraph. When words are gathered
together to form a line, spa e is added between the words to justify the right margin. Very
large spa es between words is obviously undesirable; the badness of the line is a measure
of how badly the words are spa ed. An underfull hbox means that there is too mu h spa e
between words. More spe i ally, the badness of any line is a number between 0 (perfe t)
and 10000 (horrible). There is a parameter alled \hbadness whose default value is 1000.
Any line whose badness is greater than \hbadness is reported as an underfull hbox. If
the value of \hbadness is in reased, then fewer underfull hboxes will be reported. In fa t
\hbadness = 10000 will suppress the reporting of underfull hboxes altogether. Similarly,
if the words must be squeezed into a line so that the spa es are very small or even so the
words extend a little into the right margin, then an overfull hbox results.
In a similar way, sometimes TEX allows a line to be slightly longer than \hsize in order
to a hieve a more balan ed appearan e. The ontrol word \toleran e determines when this
happens. If the badness of a line is greater than \toleran e, TEX will make the line longer
by adding a new word at the end of the line, even though it might ex eed the value of
\hsize. A line whi h is only slightly longer is set without being reported. The ontrol word
\hfuzz determines how mu h ex ess is allowed; the default is \hfuzz = 0.1 pt. A line that
is more than slightly longer than \hsize is obviously a serious problem; TEX puts a slug in
the margin to make its point for efully. It's possible to avoid overfull hboxes altogether by
in reasing the value of \toleran e. With \toleran e = 10000 there will never be overfull
boxes or slugs. The default is \toleran e = 200.

29

TEXbook: 29

A TEX intro (Canadian spelling)

Se tion 3: The shape of things to ome

The width of the slug is determined by the ontrol word \overfullrule. In luding
\overfullrule = 0 pt in your le will delete any further printing of the slugs. The overfull
boxes will still be there, of ourse, and they will probably be harder to spot.

So we see why overfull boxes and underfull boxes are reported; we an also hange the
reporting by hanging the values of \badness, \hfuzz, and \toleran e. In addition, a
small value of \hsize obviously makes it more di ult to set lines and auses more overfull
and underfull hboxes to be reported. These are warnings that you ignore at your own peril!
Adding new possibilities of hyphenation will sometimes eliminate an overfull box. TEX
has automati hyphenation and usually nds good pla es to hyphenate a word; however, it's
possible to add hyphenations to let lines break at new pla es. For example, the automati
hyphenation will never put a hyphen in the word \database". If you type in data\-base, it
will allow a hyphen to be inserted after the se ond letter \a" in the word. More generally, if
you put \hyphenation{data-base} in the beginning of your input le, then all o urren es
of the word \database" will allow hyphenation after the letter \a". The log le will show
the possible hyphenations on the line ontaining the overfull or underfull box. Sometimes
the best solution to an overfull or underfull hbox is a little judi ious editing of the original
do ument.
Our dis ussion has involved the setting of type into lines, that is, the horizontal page
stru ture. There are several verti al analogues. Overfull and underfull hboxes indi ate how
well words are gathered into lines. Similarly, overfull and underfull vboxes are reported
when paragraphs are gathered to form pages. A large table that an't be broken in the
middle, for example, an produ e an underfull vbox that is reported in the log le when
the page being typeset is ompleted. The ontrol word \vbadness works for the verti al
pla ement of text in the same way as \hbadness works for horizontal text.

. Exer ise 3.13 Take a few paragraphs and print them using various (small) values of

\hsize to see what kind of overfull boxes result. Repeat with various values of \hbadness,
\hfuzz, and \toleran e.

30

TEXbook: 28

Se tion
4
n

Groups, Groups,

fand

More Groupsg

The on ept of gathering text into groups allows TEX input les to be greatly simpli ed.
A new group is started by the hara ter { and terminated by the hara ter }. Changes made
within a group will lose their e e t when the group terminates. So, for example if {\bf
three boldfa e words} appears in your text, the opening bra e starts the group, the \bf
ontrol word hanges to a boldfa e font, and the losing bra e nishes up the group. Upon
ompletion of the group the font being used is the one in e e t before the group started.
This is the (easier) way of having a few words in a di erent font. It's also possible to have
groups nested within groups.
As another example, size hanges an be made in the text that are only temporary. For
example
{
\hsize = 4 in
\parindent = 0 pt
\leftskip = 1 in
will produ e a paragraph that is four
.
.
.
(this is an easy mistake to make).
\par
}

will produ e a paragraph that is four in hes wide


with the text o set into the paragraph by one in h
regardless of the settings in e e t before the start
of the group. This paragraph is set with those values. After the end of the group, the old settings
are in e e t again. Note that it is ne essary to
in lude \par or to use a blank line before the losing bra e to end the paragraph, sin e otherwise
the group will end and TEX will go ba k to the
old parameters before the paragraph is a tually
typeset (this is an easy mistake to make).

31

A TEX intro (Canadian spelling) Se tion 4: Groups, Groups, fand More Groupsg

When line-spa ing ontrol words (like \ enterline) a t on text following it in bra es,
that text is impli itly in a group. Thus \ enterline{\bf A bold title} will produ e a
entred boldfa e line, and the text following that line will be in whatever font was in e e t
before the \ enterline was invoked.
The empty group {} is useful. One use allows a ents to be typeset with no a ompanying letter. For example, \~{} will print a tilde with no letter under it. It an also be
used to stop TEX from eating up onse utive spa es. Hen e I use \TeX{} all the time
will leave a spa e after \TEX" in the output. This is an alternative to using \ as we did in
Se tion 1.
Grouping an also be used to avoid spa es in the middle of a word when in luding
a ents. Either soup\ on or soup\ { }on will produ e the word soup on.

. Exer ise 4.1 Change the dimensions of one paragraph on a page using the grouping idea.
. Exer ise 4.2 Mathemati ians sometime use the word \iff" as an abbreviation for \if and
only if". In this ase it looks better if the rst and se ond letter \f" are not joined as a
ligature. How do you do this (there are several solutions)?
It's really easy to forget to mat h bra es properly. The e e t an be dramati ; if you get
output that suddenly hanges to an itali font for the rest of the do ument, a mismat hed
bra e is probably the ause. If you have an extra { TEX will give a message in the log le:
(\end o urred inside a group at level 1). An extra } will result in the message
! Too many }'s.

Here's a little hint to help you keep tra k of the bra es in more ompli ated groups:
put the opening bra e on a line by itself and do the same for the losing bra e. If there are
bra es nested within the original ones, put them on separate lines also, but indent them a
few spa es. The text within the nested bra es an also be indented sin e TEX ignores all
spa es at the beginning of a line. The mat hing bra es will then stand out when you look
at your TEX sour e le. In fa t, if your editor is smart enough, you an reate the two lines
with the bra es rst and then insert the appropriate material within them with automati
indenting.

. Exer ise 4.3 In se tion 2 we hanged fonts the following method: I started with
roman type, \it swit hed to itali type, \rm and returned to roman type. Get
the same result using the idea of grouping.
32

TEXbook: 19{21

Se tion 5
No math anxiety here!

TEX is at its best when typesetting mathemati s. The onventions for doing this are
many and omplex, and the ability of TEX to take them into a ount makes the produ tion
of high quality, attra tive mathemati al output possible. If you plan to produ e papers with
mathemati al symbols in them, this se tion will give you all the basi s ne essary for reating
beautiful output in almost all ir umstan es; TEX may be used without any mathemati s,
of ourse, and if this is your goal, then the following two subse tions are probably su ient
for your needs.

5.1 Lots of new symbols


Mathemati al text is inserted into normal text in two possible ways: it an be in-line ,
that is, as part of the usual lines of text. It an also be displayed, that is, entred in a gap
between the usual text. The results in the P
spa ing and pla ement
of symbols an be quite
12 = 2 is easily seen to be di erent from
di erent in ea h ase. The in-line equation 1
k=1 k
6
the same equation when displayed:
1 1 2
X
= :
k2 6
k=1
Sin e the spa ing and the fonts used for mathemati s are quite di erent from those of
ordinary text, TEX needs to be told when mathemati s rather than normal text is being
typeset. This is done using the $ symbol. More spe i ally, mathemati s is typeset inline by surrounding the symbols to be entered by single dollar signs: $: : :$, and is typeset
displayed by surrounding the symbols to be entered by double dollar signs: $$: : :$$. Hen e
$x = y+1$ will give x = y + 1 in-line while $$x = y+1.$$ will display

x = y + 1:
The spa ing for both in-line and displayed mathemati s is ompletely ontrolled by
TEX. Adding spa es to your input has no e e t at all. What if you need a spa e or some
text in the middle of some mathemati s? You an insert text by inserting it into an hbox
(don't worry about the de nition of an hbox for now): \hbox{: : :}. This is parti ularly
33

A TEX intro (Canadian spelling)

Se tion 5: No math anxiety here!

useful for displayed mathemati s. Hen e \x = y + 1 whenever y = x 1" an be typeset


using $x=y+1 \hbox{ whenever }y=x-1$. Note the spa es on either side of the word within
the bra es. Usually it isn't ne essary to insert spa es into mathemati al text, but here are
the ontrol sequen es that do the job.

Adding spa e to mathemati al text


Name
Double quad
Quad
Spa e
Thi k spa e
Medium spa e
Thin spa e
Negative thin spa e

Control Sequen e
\qquad
\quad
\
\;
\>
\,
\!

Size!

If you look losely at the negative thin spa e, you'll noti e that, unlike the other entries,
the two arms overlap. This is be ause the negative spa e is one in the opposite dire tion,
that is, while the other ontrol sequen es in rease the amount of spa e between two symbols
being typeset, the negative thin spa e de reases the spa e between them, even if it auses
them to overlap.

. Exer ise 5.1 Typeset the following: C (n; r) = n!=(r! (n


denominator.

r)!). Note the spa ing in the

You shouldn't have any blank lines between the dollar signs delimiting the mathemati al
text. TEX assumes that all the mathemati al text being typeset is in one paragraph, and a
blank line starts a new paragraph; onsequently, this will generate an error message. This
turns out to be useful, for one of the easiest errors to make is to forget to put in the trailing
dollar sign(s) after the mathemati al input (I promise that you'll do it at least on e while
learning TEX); if TEX allowed more than one paragraph to be between the dollars signs,
then one omitted trailing dollar sign might ause the rest of the do ument to be typeset as
mathemati s.
Most mathemati al text is entered in exa tly the same way for in-line typesetting as for
displayed typesetting (ex ept for the surrounding dollar signs, of ourse). The ex eptions,
su h as aligning multiline displays and pla ing equation numbers at the left or right margin
will be dis ussed in the last part of this se tion.
34

TEXbook: 167

A TEX intro (Canadian spelling)

Se tion 5: No math anxiety here!

Many new symbols an appear when typesetting mathemati s. Most of the ones that
a tually appear on the keyboard an be used dire tly. The symbols + - / * = ' | < > (
and ) are all entered dire tly. Here they are as mathemati s: + = = 0 j < > ( ).

. Exer ise 5.2 Typeset the equation a + b =


mathemati al text.

d = xy = w=z as in-line and displayed

. Exer ise 5.3 Typeset the equation (fg)0 = f 0 g +fg0 as in-line and displayed mathemati al
text.
Many other symbols, as you would expe t, are prede ned ontrol words. All Greek
letters are available. Here is a table of them:

TEXbook: 434

Greek letters




o


!



\alpha
\epsilon
\theta
\lambda
o
\sigma
\phi
\omega
\Lambda
\Upsilon


"
#


&
'













\beta
\varepsilon
\vartheta
\mu
\pi
\varsigma
\varphi
\Gamma
\Xi
\Phi

\gamma
\zeta
\iota
\nu
\rho
\tau
\ hi
\Delta
\Pi
\Psi




%




\delta
\eta
\kappa
\xi
\varrho
\upsilon
\psi
\Theta
\Sigma
\Omega

. Exer ise 5.4 Typeset = + as in-line and displayed mathemati al text.


. Exer ise 5.5 Typeset (n) = (n 1)! as in-line and displayed mathemati al text.
Sometimes a ents are put above or below symbols. The ontrol words used for a ents
in mathemati s are di erent from those used for normal text. The normal text ontrol words
may not be used for mathemati s and vi e-versa.
35

TEXbook: 135{136

A TEX intro (Canadian spelling)

Se tion 5: No math anxiety here!

Mathemati al a ents
o^
o
o
~o

\hat o
\a ute o
\ddot o
\ve o

o
o
o

ab

\ he k o
\grave o
\breve o
\widehat {ab }

o~
o_
o
f
ab

\tilde o
\dot o
\bar o
\widetilde {ab }

Binary operators ombine two mathemati al obje ts to get another obje t. Ordinary
addition and multipli ation, for example, ombine two numbers to get another number, and
so they are binary operators. When a binary operator su h as + or  is typeset, a little
extra spa e is put around it. Here is a list of some of the available binary operators:

TEXbook: 436

Binary operators

\


\ dot
\ ir
\ ap
\oplus



[



_

\times
\bullet
\ up
\ominus

\ast
\div
\vee
\otimes


^

\star
\diamond
\wedge
\odot

Ellipses are ommonly used with binary operators. The ontrol word \ dots will raise
the dots so that they are level with the binary operator. Thus $a + \ dots + z$ will
produ e a +    + z . The ontrol word \ldots will put the dots on the baseline, and so
$1\ldots n$ produ es 1 : : : n.

. Exer ise 5.6 Typeset: x ^ (y _ z ) = (x ^ y) _ (x ^ z ).


. Exer ise 5.7 Typeset: 2 + 4 + 6 +    + 2n = n(n + 1).
A relation indi ates a property of two mathemati al obje ts. We already know how
to show two obje ts equal, or how to show one number less than or greater than another
number (sin e these are symbols on most terminal keyboards). To negate a relation, the
ontrol word \not is put in front of the relation. Here are some relations:
36

TEXbook: 436

A TEX intro (Canadian spelling)

Se tion 5: No math anxiety here!

Relations



'

2

\leq
\equiv
\simeq
\subset
\in

6
6
6'

3

\not \leq
\not \equiv
\not \simeq
\subseteq
\ni





k

\geq
\sim
\approx
\supset
\parallel

6
6
6

?

\not \geq
\not \sim
\not \approx
\supseteq
\perp

. Exer ise 5.8 Typeset: ~x  ~y = 0 if and only if ~x ? ~y.


. Exer ise 5.9 Typeset: ~x  ~y 6= 0 if and only if ~x 6? ~y.
TEXbook: 435{438

Here are some other available mathemati al symbols:

Mis ellaneous symbols




r
:

\aleph
\partial
\nabla
\neg

1
n
[

<
k
8

\ell
\infty
\ba kslash
\flat

\Re
\|
\forall
\sharp

=
6

9
\

\Im
\angle
\exists
\natural

. Exer ise 5.10 Typeset: (8x 2 <)(9y 2 <) y > x.

5.2 Fra tions


There are two methods of typesetting a fra tion: it an be typeset either in the form
1=2 or in the form 12 . The rst ase is just entered with no spe ial ontrol sequen es,
that is, $1/2$. The se ond ase uses the ontrol word \over and the following pattern:
{<numerator> \over <denominator>}. Hen e $${a+b \over +d}.$$ gives
a+b
:
+d
37

TEXbook: 139{140

A TEX intro (Canadian spelling)

Se tion 5: No math anxiety here!

. Exer ise 5.11 Typeset the following: a+ b b+a a+1b+ 6= a1 + 1b + 1 .


 f (x; y ) =  f (x; y ) = 0?
. Exer ise 5.12 Typeset: What are the points where x
y

5.3 Subs ripts and supers ripts


Subs ripts and supers ripts are parti ularly easy to enter using TEX. The hara ters
and ^ are used to indi ate that the next hara ter is a subs ript or a supers ript. Thus $x^2$
gives x2 and $x 2$ gives x2 . To get several hara ters as a subs ript or supers ript, they
are grouped together within bra es. Hen e we an use $x^{21}$ to get x21 and $x {21}$ to
get x21 . Noti e that the supers ripts and subs ripts are automati ally typeset in a smaller
type size. The situation is only slightly more ompli ated for a se ond layer of subs ripts
or supers ripts. You an not use $x 2 3$ sin e this ould have two possible interpretations,
namely, $x {2 3}$ or ${x 2} 3$; this gives two di erent results: x23 and x2 3 , the rst of
whi h is the usual mathemati al subs ript notation. Thus you must put in the omplete
bra es to des ribe multiple layers of subs ripts and supers ripts. They may be done to any
level.

TEXbook: 128{130

To use both subs ripts and supers ripts on one symbol, you use both the and ^ in
either order. Thus either $x 2^1$ or $x^1 2$ will give x12 .
x
. Exer ise 5.13 Typeset ea h of the following: ex e x ei + 1 = 0 x0 x20 x0 2 2x .

. Exer ise 5.14 Typeset:

r2 f (x; y) = x2 f2 + y2 f2 .

A similar P
method is used for summations and integrals.R The input of $\sum {k=1}^n
n k 2 , and $\int 0^x f(t) dt$ will give x f (t)dt.
k=1
0

k^2$ will give

Another use of this type of input is for expressions involving limits. You an use

n
$\lim {n\to \infty}({n+1 \over n})^n = e$ to get limn!1 ( n+1
n ) = e.
1
. Exer ise 5.15 Typeset the following expression: limx!0 (1 + x) x = e.

. Exer ise 5.16 Typeset: The ardinality of (


38

1; 1) is 1 .

TEXbook: 144{145

A TEX intro (Canadian spelling)

Se tion 5: No math anxiety here!

. Exer ise 5.17 Typeset: limx!0+ xx = 1.


Here's a hint
R x to make integrals look a little ni er: look at the di eren e between
f
(
t
)
dt
and
0
0 f (t) dt. In the se ond ase there is a little extra spa e after f (t), and
it looks ni er; \, was used to add the additional spa e.

Rx

R
. Exer ise 5.18 Typeset the following integral: 01 3x2 dx = 1.

5.4 Roots, square and otherwise


To typeset a square root itpis only ne essary to use the onstru tion \sqrt{: : :}. Hen e
x2 + y2 . Noti e that TEX takes are of the pla ement of
symbols and the height and length of the
p radi al. To make ube or other roots, the ontrol
words \root and \of are used. You get n 1 + xn from the input $\root n \of {1+x^n}$.

$\sqrt{x^2+y^2}$ will give

TEXbook: 130{131

A possible
alternative is to use the ontrol word \surd; the input $\surd 2$ will
p
produ e 2.

. Exer ise 5.19 Typeset the following: 2

x+y
x y

p3

10

p
e x.

. Exer ise 5.20 Typeset: kxk = x  x.


R
2
. Exer ise 5.21 Typeset: (t) = p12 0t e x =2 dx.

5.5 Lines, above and below


Use the onstru tions \overline{: : :} and \underline{: : :} to put lines above or below
mathemati al expressions. Hen e $\overline{x+y}=\overline x + \overline y$ gives
x + y = x + y. But noti e that the lines over the letters are at di erent heights, and so
some are is ne essary. The use of \overline{\strut x} will raise the height of the line
over x.
To underline non-mathemati al text, use \underbar{: : :}.
39

TEXbook: 130{131

A TEX intro (Canadian spelling)

Se tion 5: No math anxiety here!

. Exer ise 5.22 Typeset the following: x y x + y.

5.6 Delimiters large and small


The most ommonly used mathemati al delimiters are bra kets, bra es, and parentheses. As we have seen, they may be produ ed by using [ \{ \} ( ) to get [ f g ( ) .
Sometimes larger delimiters in rease the larity of mathemati al expressions, as in


a  (b + ) (a  b) + :
To make larger left delimiters the ontrol words \bigl, \Bigl, \biggl, and \Biggl are used
in front of the delimiter; similarly, \bigr, \Bigr, \biggr,h and \Biggr
are used for the right
i
delimiters. Hen e $\Bigl[$ and $\Bigr$ will produ e and .

TEXbook: 145{147

Here is a table to ompare the size of some of the delimiters.

Delimiters of various sizes


n


\{
\bigl\{
\Bigl\{

\biggl\{
(

\}
\bigr\}

\Bigr\}

\biggr\}

(
\bigl(
\Bigl(




\biggl(

\Biggl\{

)
\bigr)
\Bigr)
\biggr)

\Biggr\}

\Biggl(

\Biggr)

If you want, you an let TEX hoose the size of delimiter by using the ontrol words

\left and \right before your delimiters. Thus \left[: : :\right will ause the material
to be en losed by bra kets that are appropriately big. Note well: ea h use of a \left
delimiter must have a mat hing \right delimiter (although the delimiters themselves may
be di erent). Hen e $$\left|{a+b \over +d}\right|.$$ gives


a + b


+ d :

40

TEXbook: 148

A TEX intro (Canadian spelling)

Se tion 5: No math anxiety here!

Mathemati al delimiters
(

b
e

k
#
m

\lfloor
\r eil
/
\|
\downarrow
\Updownarrow

. Exer ise 5.23 Typeset bx

)
\{
\rfloor
\langle
\ba kslash
\uparrow
\Downarrow

f

h
n
"
+

 dxe

g
d
i
j
*
l

[
\}
\l eil
\rangle
|
\Uparrow
\updownarrow

5.7 Those spe ial fun tions


There are several types of fun tions that appear frequently in mathemati al text. In
an equation like \sin2 x + os2 x = 1" the trigonometri fun tions \sin" and \ os" are in
roman rather than itali type. This is the usual mathemati al onvention to indi ate that
it is a fun tion being des ribed and not the produ t of three variables. The ontrol words
\sin and \ os will use the right typefa e automati ally. Here is a table of these and some
other spe ial fun tions:

Spe ial mathemati al fun tions


\sin
\ar tan
\limsup
\dim

\ os
\sinh
\liminf
\hom

\tan
\ osh
\log
\ker

\ ot
\tanh
\ln
\max

\se
\ oth
\lg
\min

\ s
\lim
\exp
\arg

\ar sin
\sup
\det
\g d

. Exer ise 5.24 Typeset: sin(2) = 2 sin  os  os(2) = 2 os2  1.


41

\ar os
\inf
\deg
\Pr

TEXbook: 162

A TEX intro (Canadian spelling)

Se tion 5: No math anxiety here!

. Exer ise 5.25 Typeset:


Z

s 2 x dx = ot x + C

sin
lim
=1
!0

. Exer ise 5.26 Typeset:


tan(2) =

sin
lim
= 0:
!1

2 tan 
:
1 tan2 

5.8 Hear ye, hear ye!


There is a parti ular ma ro that is used in almost every mathemati al paper, and is
di erent enough to require a spe ial explanation. This is the \pro laim ma ro. It is used
when stating theorems, orollaries, propositions, and the like. The paragraph following
\pro laim is broken into two parts: the rst part goes up to and in luding the rst period
that is followed by a spa e, and the se ond part is the rest of the paragraph. The idea is
that the rst part should be something like \Theorem 1." or \Corollary B." The se ond
part is the statement of the theorem or orollary. Here is an example:
\pro laim Theorem 1 (H.~G.~Wells). In the ountry of the blind,
the one-eyed man is king.

gives

Theorem 1 (H. G. Wells). In the ountry of the blind, the one-eyed man is king.
The statement of the theorem may ontain mathemati al expressions, of ourse.

42

TEXbook: 202{203

A TEX intro (Canadian spelling)

Se tion 5: No math anxiety here!

. Exer ise 5.27 Typeset:

Theorem (Eu lid). There exist an in nite number of primes.


. Exer ise 5.28 Typeset:

Proposition 1.

p Qn
n

i=1 Xi

 n1 Pni=1 Xi with equality if and only if X1 =    = Xn .

5.9 Matri es
Matri es are typeset using ombinations of the alignment hara ter & and the ontrol
word \ r to indi ate the end of the line. Start with $$\pmatrix{: : :}$$. Into the spa e
between the bra es go the rows of the matrix, ea h one ended by \ r. The entries are
separated by the &. For example the input
$$\pmatrix{
a & b & & d \ r
b & a & +d & -d \ r
0 & 0 & a+b & a-b \ r
0 & 0 & ab & d \ r
}.$$

gives as printed output

a
Bb

0
0

b
d 1
a + d dC:
0 a+b a bA
0 ab
d

The matrix entries in our examples have all been entred within their olumns with a
little spa e on ea h side. They an be made ush right or ush left by inserting \hfill
before or after the entry. Noti e the di eren es between the following example and the
previous one.
$$\pmatrix{
a & b & \hfill & \hfill d \ r
b & a & +d & -d \ r
0 & 0 & a+b & a-b \ r

43

TEXbook: 176{178

A TEX intro (Canadian spelling)

Se tion 5: No math anxiety here!

0 & 0 & ab \hfill & \hfill d \ r


}.$$

gives as printed output


0

a
Bb

0
0
. Exer ise 5.29 Typeset

b
a
0
0


d1
+d dC
a + b a bA:
ab
d

1
B0
I4 =  0
0

0
1
0
0

0
0
1
0

01
0C
0A
1

It's possible to have matri es that use other delimiters. Using \matrix instead of
\pmatrix will leave o the parentheses, so the delimiters must be expli itly in luded using
\left and \right. Here is how we an hange the matrix of our rst example.
$$ \left |
\matrix{
a & b & & d \ r
b & a & +d & -d \ r
0 & 0 & a+b & a-b \ r
0 & 0 & ab & d \ r
}
\right | $$

gives as printed output

b

d
a + d d
0 a + b a b
0 0 ab
d


a

b

0

It's even possible to use \left. and \right. to indi ate that the opening or losing
delimiter is deleted (note the use of the period).

44

A TEX intro (Canadian spelling)

Se tion 5: No math anxiety here!

. Exer ise 5.30 Use a matrix onstru tion to typeset

jxj =

x x0
x x0

This exer ise and more general onstru tions of this type may also be typeset using the

\ ases ma ro.

Sometimes ellipses are used within matri es. The ontrol words \ dots, \vdots, and

\ddots an be used to insert horizontal, verti al, and diagonal dots.

Thus we an use
$$ \left [
\matrix{
aa & \ dots & az \ r
\vdots & \ddots & \vdots \ r
za & \ dots & zz \ r
}
\right $$

to get as printed output

aa    az 3
. . . .. 5
4 ...
.
za    zz
2

Matri es may also be typeset in-line, but they are pretty ugly unless they have a small
number of rows.

5.10 Displayed equations


All of the mathemati s overed so far has identi al input whether it is to be typeset
in-line or displayed. At this point we'll look at some situations that apply to displayed
equations only.
The rst is that of aligning multiline displays. This is done with the alignment hara ter

& and the ontrol words \ r and \eqalign. Starting with $$\eqalign{: : :}$$, the equations
to be aligned are entered with ea h one terminated by \ r. In ea h equation there should be

45

TEXbook: 175

A TEX intro (Canadian spelling)

Se tion 5: No math anxiety here!

one alignment symbol & to indi ate where the alignment should take pla e. This is usually
done at the equal signs, although it is not ne essary to do so. For example

TEXbook: 190{192

$$\eqalign{
a+b &= +d \ r
x &= w + y + z \ r
m + n + o + p &= q \ r
}$$

yields

a+b= +d
x=w+y+z
m+n+o+p=q

Displayed equations an be numbered at either the right or left margin. When the
ontrol word \eqno appears in a displayed equation, everything after the ontrol word is
put at the right margin. Hen e $$ x+y=z. \eqno (1)$$ yields

x + y = z:

(1)

To number an equation at the left margin, use \leqno in pla e of \eqno.


It's possible to number aligned equations by using the ontrol word \eqalignno. The
alignment hara ter & is used to separate the equation from the equation number.
$$\eqalignno{
a+b &= +d & (1) \ r
x &= w + y + z \ r
m + n + o + p &= q & * \ r
}$$

yields

a+b= +d
x=w+y+z
m+n+o+p=q
Use \leqalignno to put the equation numbers on the left.
46

(1)


TEXbook: 192{193

A TEX intro (Canadian spelling)

Se tion 5: No math anxiety here!

Finally, suppose some text needs to appear in the middle of a displayed equation. This
an be done by putting it in an hbox. We will des ribe hboxes in more detail in the next
se tion. For now we want to use them to temporarily resume using ordinary roman type
and to also allow the insertion of spa e between words (remember that all spa es are ignored
when typesetting mathemati s). Hen e $$X=Y \hbox{ if and only if }x=y.$$ will give

X = Y if and only if x = y:
Note arefully the spa es in the hbox.

. Exer ise 5.31 Do some of the hallenge problems on pages 180{181 of The TEXbook.

47

Se tion 6
All in a row

It's not un ommon to want to put a table in the middle of some text. Fortunately TEX
makes it easy to do this. In fa t there are two separate methods of aligning text. The rst is
by using the tabbing environment. This is similar to setting the tab stops on a typewriter.
Ea h line is handled individually, a ording to set tab olumns, but with greater exibility
than that provided by a typewriter. The se ond is the horizontal alignment environment
whi h typesets the whole table at on e using a pres ribed pattern.

6.1 Pi king up the tab


To align material using the tabbing environment, you must rst set the tab positions
using the \settabs ontrol word. Having done this, a line to use these tabs starts with the
ontrol symbol \+ and ends with \ r (remember that the a tual spa ing on lines in the
input le in unimportant).
The easiest way to use the \settabs ontrol word is to put the text into equal olumns.
Using \settabs 4 \ olumns will set the tabs that will produ e four equal olumns. The
tabbing is then done by using the alignment hara ter & to move to the next tab stop. So,
for example,
\settabs 4 \ olumns
\+ British Columbia & Alberta & Saskat hewan & Manitoba \ r
\+ Ontario & Quebe & New Brunswi k & Nova S otia \ r
\+ & Prin e Edward Island & Newfoundland \ r

will produ e the table


British Columbia
Ontario

Alberta
Saskat hewan
Quebe
New Brunswi k
Prin e Edward Island Newfoundland

Manitoba
Nova S otia

Noti e that it is possible to skip over some tab positions, and it is not ne essary to
use all of the tabs in a given line. To make the same table using ve olumns, it is only
ne essary to use \settabs 5 \ olumns to reset the tab stops; then the same three lines
from the last example will produ e:
48

TEXbook: 231

A TEX intro (Canadian spelling)

Se tion 6: All in a row

British Columbia Alberta


Saskat hewan
Manitoba
Ontario
Quebe
New Brunswi k Nova S otia
Prin e Edward Island
Newfoundland
In this example, the olumns are smaller, of ourse. In fa t there are two overlapping
entries in the last row. This is be ause TEX will tab to the next tab position even if (unlike
a typewriter) it means going ba kward on the page.
There is an interesting relationship between grouping and tabbing. The \settabs
values are only appli able to the group in whi h it is de ned, as would be expe ted. Thus
it is possible to temporarily hange the tab settings by grouping within bra es. In addition,
ea h table entry is in a group of its own. Hen e we may make a single entry boldfa e, for
example, by using \bf without bra es. In addition, for any olumn but the last one it is
possible to entre the entry or to align it either on the left or on the right, or to ll a olumn
with a line or dots. Ea h entry has an impli it \hfil at the end so that it will be at the
left of the olumn by default. Adding \hfil at the beginning of the entry will then ause
it to be entred, just as with the \line ontrol word. Adding \hfill to the beginning will
ause the entries to be pushed to the right (\hfill a ts just like \hfil in that it absorbs
ex ess spa e; when both \hfil and \hfill appear, the \hfill takes pre eden e).
\settabs 4 \ olumns
\+ \hfil British Columbia & \hfill Alberta \qquad & \bf Saskat hewan
& Manitoba \ r
\+ \hfil Ontario & \hfill Quebe \qquad & \bf New Brunswi k
& Nova S otia \ r
\+ \hfil --- & \hfill * \qquad & \bf Newfoundland
& Prin e Edward Island \ r
\+ \dotfill && \hrulefill & \ r

will produ e a table with the rst olumn entred, the se ond olumn ush right with
a \qquad of padding, and the third olumn boldfa e. The ontrol words \dotfill and
\hrulefill give alternative olumn entries.
British Columbia
Ontario
|
::::::::::::::::::::::

Alberta
Quebe
*

Saskat hewan
New Brunswi k
Newfoundland

Manitoba
Nova S otia
Prin e Edward Island

. Exer ise 6.1 Take the table of Canadian provin es above and entre ea h entry within
its olumn.
49

A TEX intro (Canadian spelling)

Se tion 6: All in a row

The tab positions an be set with mu h more exibility than just in equal olumns.
The general pattern is to use a sample line of the form \settabs \+ : : : & : : : & : : : \ r.
The spa ing between the alignment hara ters & determines the position of the tabs. For
example, \settabs \+ \hskip 1 in & \hskip 2 in & \hskip 1.5 in & \ r would set
the rst tab one in h from the left margin, the next another two in hes further in, and the
third 1.5 in hes more. It's also possible to use text to determine the distan e between tabs.
So, for example, another possible sample line is \settabs \+ \quad Provin e \quad &
\quad Population \quad & \quad Area \quad & \ r. The tab olumn would then be
just wide enough to a ept the headings with a quad of spa e on ea h side. Here's a more
omplete example:
\settabs \+ \quad Year
& \quad Dividend & \ r
\+ \hfill Year \quad &
\+ \hfill 1971 \quad &
\+ \hfill 2
\quad &
\+ \hfill 3
\quad &
\+ \hfill 4
\quad &
\+ \hfill 5
\quad &

\quad & \quad Pri e \quad


\quad
\quad
\quad
\quad
\quad
\quad

Pri e
41--54
41--54
46--55
40--53
45--52

\quad
\quad
\quad
\quad
\quad
\quad

&
&
&
&
&
&

\quad Dividend \ r
\qquad \$2.60 \ r
\qquad \$2.70 \ r
\qquad \$2.87 \ r
\qquad \$3.24 \ r
\qquad \$3.40 \ r

TEXbook: 247

gives
Year
1971
2
3
4
5

Pri e
41{54
41{54
46{55
40{53
45{52

Dividend
$2.60
$2.70
$2.87
$3.24
$3.40

. Exer ise 6.2 Take the table given above and move it loser to the entre of the page.
. Exer ise 6.3 One way to entre a blo k of text, possibly several lines long, is to use:
$$\vbox{: : :}$$. Use this to entre the table given above. Does the \settabs line need to
be in luded in the \vbox?
. Exer ise 6.4 Improve your last result by putting a line under the olumn heads. The
ontrol word \hrule will insert a horizontal line if introdu ed between two rows of a table.
Now repeat with the ontrol word \strut after the \+ of the line ontaining the olumn
50

A TEX intro (Canadian spelling)

Se tion 6: All in a row

heads. (A \strut e e tively makes the spa ing between lines a little greater. The size an
be altered from the default.) Note the extra spa e that results.

TEXbook: 82

. Exer ise 6.5 Make the following table with de imal alignment, that is, with the de imal
points above ea h other (think of the dollar gure as being right aligned and the ents gure
as being left aligned against the de imal point):
Plums
$1.22
Co ee
1.78
Granola
1.98
Mushrooms
.63
Kiwi fruit
.39
Orange jui e
1.09
Tuna
1.29
Zu hini
.64
Grapes
1.69
Smoked beef
.75
Bro oli
1.09
Total
$12.55
. Exer ise 6.6 Devise a method to make a rough table of ontents by using \settabs and
having entries looking something like:
Getting Started \dotfill & \hfill 1
All Chara ters Great and Small \dotfill & \hfill 9.

6.2 Horizontal alignment with more sophisti ated patterns


The \settabs environment is not di ult to use, and on e the pattern is set, it an be
used repeatedly in di erent portions of the text that follows. It does have some drawba ks,
however. For one, the olumn size must be set before the entries are known. Also, even
though in one ase we wanted the third olumn to be boldfa e, it had to be spe i ed in ea h
line. These problems an be handled more easily by using the \halign environment.
The general pattern in the \halign is as follows:
\halign{ <template line> \ r
<first display line> \ r
<se ond display line> \ r

51

TEXbook: 235{238

A TEX intro (Canadian spelling)

Se tion 6: All in a row

.
.
.
<last display line> \ r
}

Both the template line and the display lines are divided into se tions by the alignment
symbol &. In the template line ea h se tion uses ontrol words in the same manner as does
\line{}. The ontrol word \hfil, for example, an be used to display ush left, ush
right, or entred. Fonts an be hanged using \bf, \it, et . Text may also be entered in
the template line. In addition the spe ial symbol # must appear on e in ea h se tion. Ea h
display line is then set by substituting ea h se tion of the display line into its orresponding
se tion of the template line at the o urren e of the #.
Consider the following example:
\halign{\hskip 2 in $#$& \hfil \quad # \hfil & \qquad $#$
& \hfil \quad # \hfil \ r
\alpha & alpha & \beta & beta \ r
\gamma & gamma & \delta & delta \ r
\epsilon & epsilon & \zeta & zeta \ r
}

The template line indi ates that the rst se tion of the typeset text will always be set two
in hes in from the left and also be set as mathemati s. The se ond se tion will be entred
after adding a quad of spa e on the left. The third and fourth se tions are handled similarly.
Here is the result:

alpha
gamma
 epsilon

beta
delta
zeta

In this ase the rst display line is formed by substituting \alpha for the rst # in the
template line, alpha for the se ond #, \beta for the third and beta for the fourth. The
whole line is then saved for setting. This ontinues until all the lines are a umulated, and
then they are set with ea h olumn being as wide as ne essary to a ept all of its entries (an
impli ation of this a umulation pro ess is that a table with too many entries ould ause
TEX to run out of memory; it's better not to set tables that are more than a page or so
long).
Hen e the template line establishes the pattern for the table entries and the display
lines insert the individual entries.
52

A TEX intro (Canadian spelling)

Se tion 6: All in a row

Sometimes horizontal and verti al lines are used to delimit entries in a table. To put
in horizontal lines, we use \hrule, just as we did in the \settabs environment. However,
we don't want the rule to be aligned a ording to the template, so we use the ontrol word
\noalign. Hen e horizontal lines are inserted by putting \noalign{\hrule}; verti al lines
are inserted by putting \vrule in either the template or the display line. But still all is not
ompletely straightforward. Suppose we take our last example and hange the template to
get verti al lines and also insert horizontal lines.
\halign{\hskip 2in\vrule\quad $#$\quad & \vrule \hfil\quad # \hfil
& \quad \vrule \quad $#$\quad
& \vrule\hfil \quad # \quad \hfil \vrule \ r
\noalign{\hrule}
\alpha & alpha & \beta & beta \ r
\noalign{\hrule}
\gamma & gamma & \delta & delta \ r
\noalign{\hrule}
\epsilon & epsilon & \zeta & zeta \ r
\noalign{\hrule}
}

doesn't give exa tly what we want.

alpha
gamma
epsilon

beta
delta
zeta

There are several de ien ies: the most obvious is the extended horizontal lines, but
also the text looks somewhat squashed into the boxes. In addition, the text has a little extra
spa e on the right rather than being perfe tly entred. As in the \settabs environment,
lines an be made taller by in luding the ontrol word \strut in the template. A further
problem an o ur when the page is set sin e TEX may spread lines apart slightly to improve
the appearan e of the page. This would leave a gap between the verti al lines, so we use the
ontrol word \offinterlineskip within the \halign to avoid this. Finally we an get rid
of the lines sti king out on the left by deleting the \hskip 2 in from the template line. To
move the table to the same position we use \moveright. Finally, we an see how to entre
the text by noting that the extra spa e o urs in the template line after the # where the
text is inserted. Hen e we an improve our result by using
\moveright 2 in
\vbox{\offinterlineskip
\halign{\strut \vrule \quad $#$\quad &\vrule \hfil \quad #\quad \hfil
&\vrule \quad $#$\quad &\vrule \hfil \quad #\quad \hfil \vrule \ r
\noalign{\hrule}

53

TEXbook: 82

A TEX intro (Canadian spelling)

Se tion 6: All in a row

\alpha & alpha & \beta & beta \ r


\noalign{\hrule}
\gamma & gamma & \delta & delta \ r
\noalign{\hrule}
\epsilon & epsilon & \zeta & zeta \ r
\noalign{\hrule}
}}

to get

alpha
gamma
epsilon

beta
delta
zeta

In general, if we want to onstru t a table with boxed entries that is entred on the page,
we an do so by putting the \vbox within a \ enterline{}. But here is a tri k that will
produ e a ni er result. If the \vbox is put in between double dollar signs, it will be typeset
as displayed mathemati s. Of ourse, there is no a tual mathemati s being displayed, but
TEX will put in a little extra spa e above and below the table as is appropriate for a display.
Hen e a entred table with this ni e spa ing may be formed using the following four steps:
(1) put a \vbox between double dollar signs, (2) put an \offinterlineskip and an \halign
within the \vbox, (3) in the \halign put a template line with a \strut in the beginning,
and a \vrule surrounding ea h entry, (4) ea h row of the table should be pre eded and
followed by \noalign{\hrule}.
Here is the pattern to be followed:
$$\vbox{
\offinterlineskip
\halign{
\strut \vrule # & \vrule # & : : : & \vrule # \vrule \ r
\noalign{\hrule}
<first olumn entry> & <se ond olumn entry> & : : : & <last olumn entry> \ r
\noalign{\hrule}

:::

\noalign{\hrule}
<first olumn entry> & <se ond olumn entry> &
\noalign{\hrule}
}
}$$

54

: : : & <last olumn entry> \ r

Se tion 7
Rolling your own

In this se tion we'll reate new ontrol words. The making of these new de nitions, also
alled ma ros, is one of the most powerful te hniques available in TEX. For the rst appli ation of this fa ility, we'll see how a new de nition an save a lot of typing by substituting
short strings for long ones.

7.1 The long and short of it


The ontrol word \def is used to de ne new ontrol words. The simplest form for
doing this is \def\newname{: : :}. Then whenever \newname appears in your input le, it
will be repla ed by whatever is between the bra es in the de nition. Of ourse \newname
must satisfy the onvention for naming ontrol sequen es, that is, it must be a ontrol
word (all letters) or a ontrol symbol (exa tly one nonletter). So, for example, suppose you
write a do ument that ontains the phrase \University of Manitoba" many times. Then
\def\um{University of Manitoba} de nes a new ontrol sequen e \um whi h an then
be used at any time. The senten e I take ourses at the \um. then makes sense. If
the ontrol word exists, your new de nition will repla e it (this in ludes the ontrol words
de ned by TEX, so a little are must be taken in the hoi e of name). Any de nition is,
however, lo al to the group in whi h it is de ned. For example,
\def\um{University of Manitoba}
I took my first ourse at the \um.
{
\def\um{Universit\'e de Montr\'eal}
Then I took my next ourse at the \um.
}
Finally I took my last ourse at the \um.

gives
I took my rst ourse at the University of Manitoba. Then I took my next ourse at
the Universite de Montreal. Finally I took my last ourse at the University of Manitoba.

55

A TEX intro (Canadian spelling)

Se tion 7: Rolling your own

Remember that all spa es after a ontrol word are absorbed; this in ludes the ontrol
words that you de ne. In the previous example, any spa e after \um would be ignored.
However, the spa e after the rst period and the spa e after the rst opening bra e are
di erent; if you look losely at the end of the rst senten e typeset using the example, you'll
see some extra spa e. This an be eliminated by putting a % after the opening bra e to
make the rest of the line a omment. The same holds for the line with the last losing bra e.
Careful ontrol of spa es often alls for the \ ommenting out" of the end of lines in this
manner.
On e a new ontrol sequen e has been de ned, it may be used in new de nitions. This
is one way of making simple form letters. First let's de ne a simple letter.
\def\letter{
\par \noindent
Dear \name,
This is a little note to let you know that your name is \name.
\hskip 2 in Sin erely yours,
\vskip 2\baselineskip
\hskip 2 in The NameNoter
\smallskip \hrule
}

Now this letter uses the ontrol word \name, whi h is unde ned at this point. When
\letter is used, the urrent value of \name will appear in the body of the letter. Hen e
\def\name{Mi hael Bishop}
\letter
\def\name{Mi helle L\'ev\^eque}
\letter

will produ e two opies of the letter, ea h with the orre t name, followed by a horizontal
rule:
Dear Mi hael Bishop,
This is a little note to let you know that your name is Mi hael Bishop.
Sin erely yours,

The NameNoter
56

A TEX intro (Canadian spelling)

Se tion 7: Rolling your own

Dear Mi helle Lev^eque,


This is a little note to let you know that your name is Mi helle Lev^eque.
Sin erely yours,

The NameNoter
We ould have put anything between the bra es in \def\name{: : :}; it ould be several
paragraphs long and use other ontrol sequen es (although in this ontext it would be a
little strange). Of ourse it is possible to use \vfill \eje t as part of the de nition of
\letter to eje t the page when the letter is ompleted.

. Exer ise 7.1 Make a form letter that uses the ontrol words \name, \address, \ ity,
\provin e, and \postal ode.
. Exer ise 7.2 An unnumbered list of items is often made using \item{$\bullet$}. De ne
a ma ro \bitem that does this, and use it for several paragraphs. Now hange ea h bullet
to a dash (note that a simple hange in the ma ro propagates all the ne essary hanges in
all of the paragraphs).
. Exer ise 7.3 Suppose that you are going to have to format several paragraphs in a paper
using \hangindent = 30 pt, \hangafter = 4, and \filbreak (don't worry about what
these ontrol sequen es a tually do; the only important thing for now is that on e they are
set, they remain in e e t for only one paragraph). De ne a single ontrol sequen e \setpar
whi h an then be put in front of ea h paragraph that needs to be so formatted.

7.2 Filling in with parameters


It's possible to use ma ros in mu h greater generality by allowing parameters to be
passed. The idea is somewhat similar to the template line in the \halign environment.
First, let's look at the ase where there is one parameter. In this ase a ontrol sequen e is
de ned by \def\newword#1{: : :}. The symbol #1 may appear between the bra es (several
times) in the de nition of \newword. The material between the bra es a ts like a template.
When \newword{: : :} appears in the text, it will use the de nition of \newword with the
57

A TEX intro (Canadian spelling)

Se tion 7: Rolling your own

material between the bra es inserted into the template at every o urren e of #1 in the
original de nition. The spa ing in the original de nition is ru ial here; there
must be no spa es before the opening bra e.
As an example, we ould use the form letter of the last se tion in the following way:
\def\letter#1{
\par \noindent
Dear #1,
This is a little note to let you know that your name is #1.
\hskip 2 in Sin erely yours,
\vskip 2\baselineskip
\hskip 2 in The NameNoter
\smallskip \hrule
}

Now we an use
\letter{Mi hael Bishop}
\letter{Mi helle L\'ev\^eque}

to get
Dear Mi hael Bishop,
This is a little note to let you know that your name is Mi hael Bishop.
Sin erely yours,

The NameNoter

58

A TEX intro (Canadian spelling)

Se tion 7: Rolling your own

Dear Mi helle Lev^eque,


This is a little note to let you know that your name is Mi helle Lev^eque.
Sin erely yours,

The NameNoter
Now let's de ne \def\displaytext#1{$$\vbox{\hsize = 12 m #1}$$}
as a new ma ro to display text. Then \displaytext{: : :} will ause the material between the bra es to be put in a paragraph with width 12 entimetres
and then entred with some spa e added above and below as is appropriate for
a display. This paragraph was set using this \displaytext ma ro.
The parameter of a ma ro an be no more than one paragraph long. If a new paragraph
is en ountered as part of a parameter, an error will be generated. This is a safety feature,
for otherwise the a idental omission of a losing bra e would ause TEX to eat up the rest
of the le as the parameter.

. Exer ise 7.4 De ne a ma ro \yourgrade so that \yourgrade{89} will ause the following
senten e to be typeset: The grade you re eived is 89%. It should be able to work with any
other per entage, of ourse.
It's not really any harder to use more than one parameter. The form used to de ne a new
ontrol word with two parameters is \def\newword#1#2{: : :}. The de nition between the
bra es may have #1 and #2 o urring in it, perhaps several times. When \newword{: : :}{: : :}
appears in the text, the material between the rst set of bra es repla es #1 in the de nition
and the material between the se ond set of bra es repla es #2 in the de nition. Here is an
example followed by its result:
\def\talks#1#2{#1 talks to #2.}
\talks{John}{Jane}
\talks{Jane}{John}
\talks{John}{me}
\talks{She}{Jane}

59

A TEX intro (Canadian spelling)

Se tion 7: Rolling your own

John talks to Jane. Jane talks to John. John talks to me. She talks to Jane.

. Exer ise 7.5 In a manner similar to the previous exer ise, de ne a ma ro \yourgrade
so that \yourgrade{89}{85} auses the following senten e to be typeset: You re eived a
grade of 89% on your rst exam and a grade of 85% on your se ond exam.
. Exer ise 7.6 Write a ma ro \fra so that \fra {a}{b} will typeset the fra tion ab .
It's important not to put any spa es before the rst bra e in the de nition. If you do,
TEX will interpret the de nition di erently from the way des ribed here. For more than
two parameters, the method of de nition is similar. To de ne a ontrol word with three
parameters, start with \def\newword#1#2#3{: : :}. Then #1, #2 and #3 may o ur between
the bra es. When \newword{: : :}{: : :}{: : :} appears in the text, the material between ea h
set of bra es repla es its orresponding symbol in the de nition of the ontrol word. The
parameters may go up to #9.

7.3 By any other name


Sometimes it's onvenient to be able to give a ontrol word an alternative name. For example, if you prefer a di erent spelling, you might want to all the ontrol word \ enterline
by the name of \ entreline. This an be done by using the \let ontrol word. The use of
\let \ entreline = \ enterline now makes a new (as well as the old) ontrol word available. This an also be used with mathemati al names as with \let \tensor = \otimes.
It is then possible to use
$$ (A \tensor B) (C \tensor D) = AC \tensor BD. $$

to get
(A
B )(C
D) = AC
BD:

. Exer ise 7.7 De ne ontrol sequen es \ll, \ l, and \rl that are equivalent to \leftline,
\ enterline, and \rightline.

60

TEXbook: 206{207

A TEX intro (Canadian spelling)

Se tion 7: Rolling your own

The \let ontrol word allows users to name their own ontrol sequen es. This allows
a personalized set of ontrol sequen es that may be used in pla e of the ones provided by
TEX when desired.

61

Se tion 8
To err is human

In some ways TEX is not ompletely divine. TEX will respond to invalid input by giving
an error message to the s reen if you are using it intera tively and also to the log le.
Be ause TEX is very ompli ated, the a tual point where the error is dete ted may be deep
within the program, so a full report of the error may be rather long and involved. Not only
that, TEX will try to re over from errors, and will report what was done in that pro ess. For
this reason the reading of error messages may be a little di ult for the uninitiated. The
key is to know what is important from your perspe tive and what an be safely ignored. So
let's look at some typi al errors and the messages that they generate.

8.1 The forgotten bye


The rst mistake that we'll look at is one that everyone makes at some time, namely,
the omission of \bye at the end of the le. If you're using TEX intera tively, an asterisk
*

will be printed on the s reen and nothing will happen sin e, having not been told to nish
up, TEX is waiting for input (from your keyboard). Whatever you type in will be appended
to whatever has been input from your les. The usual response is to type \bye<CR>7 sin e
that will nish things up.

8.2 The misspelled or unknown ontrol sequen e


Using a misspelled or other ontrol sequen e unknown to TEX is a ommon error. If
TEX is being run as a bat h job, an error message is printed and the job goes on ignoring
the ontrol sequen e. When using TEX intera tively, it is possible to repair errors (of ourse
this does not hange the original input le, so that must be done when the TEX job is
ompleted). Suppose we have a TEX input le onsisting of the following two lines:
\line{The left side \hfli the right side}
\bye

7 <CR> is the key used to end a line of input. It might be alled the arriage return, enter,
or simply the return key on your terminal. Sometimes it is indi ated by a large left arrow.

62

A TEX intro (Canadian spelling)

Se tion 8: To err is human

The ontrol word should be \hfil, of ourse. Here is the message that would be sent
to your terminal:
! Undefined ontrol sequen e.
l.1 \line{ The left side \hfli
the right side}
?

The rst line starts with ! and gives the error message. Next omes the line number
on whi h the error o urred and the part of the line that was read su essfully. The next
line gives the ontinuation of the line after the error. At this point the question mark means
that TEX is waiting for a response. There are several legal ones:

Responses to TEX error messages


Desired response
Help
Insert
Exit
S roll
Run
Quiet
Carry on

Input to TEX
h<CR>
i<CR>
x<CR>
s<CR>
r<CR>
q<CR>
<CR>

Result

Reason for stopping listed on terminal.


Next line inserted into TEX input le.
Exit from TEX. Completed pages to DVI le.
List message and ontinue after minor errors.
List message and ontinue after any errors.
All terminal listings suppressed.
TEX ontinues as best it an.

In our last example a reasonable response might be to enter h<CR> to get a help message,
then i<CR> to insert more text, (at whi h point TEX responds with insert> and nally
\hfil as the orre t ontrol word. Here is the result:
? h <CR>
The ontrol sequen e at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the orre t
spelling (e.g., `I\hbox'). Otherwise just ontinue,
and I'll forget about whatever was undefined.
? i <CR>
insert>\hfil
[1

The nal [1 means that the rst (and only) page has been ompleted and sent to the
DVI le. The original input le still needs to be xed, of ourse.

63

A TEX intro (Canadian spelling)

Se tion 8: To err is human

8.3 The misnamed font


A misspelled font name is an error similar to the misspelled ontrol sequen e. The
error message is di erent and a little onfusing at rst. Suppose for example the following
appears in your input le:
\font\sf = mss01

It should be mss10, that is, the numbers have been transposed. Here are the error
and help messages:
! Font \sf= mss01 not loadable: Metri (TFM) file not found.
<to be read again>
\par
\bye ->\par
\vfill \supereje t \end
l.2 \bye
? h <CR>
I wasn't able to read the size data for this font,
so I will ignore the font spe ifi ation.
[Wizards an fix TFM files using TFtoPL/PLtoTF.
You might try inserting a different font spe ;
e.g., type `I\font<same font id>=<substitute font name>'.

The TFM (TEX font metri ) le is an auxiliary le that is used by TEX. So this strange
message is just telling you that the font you de ned doesn't exist on your omputer system.

8.4 Mismat hed mathemati s


Another ommon error is to use $ or $$ to start a mathemati al expression and then to
forget the se ond $ or $$ when nished. The text that follows is then treated as mathemati s,
and to make matters worse, if more mathemati s is started by a new $ or $$, it will then
be treated as ordinary text. Needless to say, error messages galore may be generated. TEX
will attempt to orre t the problem by inserting a new $ or $$; in any ase, the problem
is orre ted by the end of the paragraph sin e a new paragraph will automati ally start as
ordinary text.
Consider the following orre t input and its output:
Sin e $f(x) > 0$, $a<b$, and $f(x)$ is ontinuous, we know that
$\int a^b f(x)\,dx >0$.

64

A TEX intro (Canadian spelling)

Se tion 8: To err is human

R
Sin e f (x) > 0, a < b, and f (x) is ontinuous, we know that ab f (x) dx > 0.

If we now leave out the se ond dollar sign in $f(x)$ we then get the following error
and help messages:
! Missing $ inserted.
<inserted text>
$
<to be read again>
\intop
\int ->\intop
\nolimits
l.2 $\int
a^b f(x)\,dx >0$.
? h <CR>
I've inserted a begin-math/end-math symbol sin e I think
you left one out. Pro eed, with fingers rossed.
?

The line starting with ! tells us what has been done. The line starting with l.2 shows
us where we were in the input le when the error o urred. As in our other examples,
the part of the line su essfully read, that is, through \int, appears on one line, and
the ontinuation appears on the next line. The remaining material may seem somewhat
obs ure. These intermediate messages show what was happening further in the guts of the
TEX program when the error o urred. The newer user may ignore them.
Here is what you get as output after TEX tries to re over from the error.
R
Sin e f (x) > 0, a < b, and f (x)is ontinuous; weknowthat ab f (x) dx > 0.

There is a stret h of text that is itali with no spa ing. This is typi al for normal text
being pro essed as mathemati s; if you see this in your output, you have almost ertainly
left out a $ or $$.

8.5 Mismat hed bra es


It's easy to forget or mismat h the losing bra es when making groups. The result may
be a relatively benign error, or it may be atastrophi . Suppose, for example, you have
{\bf A bold title in your text with the losing right bra e omitted. The result will be
65

A TEX intro (Canadian spelling)

Se tion 8: To err is human

the same as if no opening bra e were there; that is, the rest of the paper will be boldfa e if
no other font hanges are made. You will get the following message at the end of the le:
(\end o urred inside a group at level 1)

If you had made the same mistake twi e, then there would be two more opening bra es
than losing bra es, and you would get the message:
(\end o urred inside a group at level 2)

TEX doesn't know that the losing bra e is missing until it rea hes the end of the
input le. Hen e the message doesn't tell you where you went wrong. If the lo ation of
the missing bra e isn't obvious, it's always possible to insert \bye halfway through your
do ument. Running TEX again will ause only the rst half to be pro essed, and if the
error message persists, you will know that the error is in the rst half of the do ument. By
moving the \bye to di erent pla es, the error an be lo alized. Also, looking at the output
often reveals what has gone wrong.
Missing opening bra es are mu h easier to spot. Here is a two line input le and the
resulting error and help messages:
\bf Here is the start}, but there is the finish.
\bye
! Too many }'s.
l.1 \bf Here is the start}
, but there is the finish.
? h <CR>
You've losed more groups than you opened.
Su h booboos are generally harmless, so keep going.

It's quite possible, of ourse, that the line that is supposed to have the missing left
bra e will not be on the line where TEX at hes the error.
A mismat hed bra e in the de nition of a new ontrol sequen e an ause a major error.
Sin e su h a de nition may in lude several paragraphs, it may not be aught by the end
of a paragraph, but, rather will just keep piling more and more text into the un nished
de nition. It's even possible for TEX to run out of memory as it keeps eating up more
text! This is alled a \runaway de nition". Here is a two line input le with a runaway
de nition:

66

TEXbook: 206

A TEX intro (Canadian spelling)

Se tion 8: To err is human

\def\newword{the def
\newword
\bye

Here are the resulting error and help messages:


Runaway definition?
->the def
! Forbidden ontrol sequen e found while s anning definition of \newword.
<inserted text>
}
<to be read again>
\bye
l.3 \bye
? h <CR>
I suspe t you have forgotten a `}', ausing me
to read past where you wanted me to stop.
I'll try to re over; but if the error is serious,
you'd better type `E' or `X' now and fix your file.
? <CR>
No pages of output.

This is obviously a serious error. If it o urs at the beginning of a le (as in the previous
example), there will be no output at all!
If a losing bra e is left out while using a ma ro with parameters, the runaway de nition
will be terminated at the end of the paragraph. So if \def\newword#1{: : :} has been de ned
and you use \newword{: : : without the losing bra e, then at most one paragraph will be
ruined.
In short, when an error o urs, make a note of the line number to see how mu h of
the input le has been read, and also the line starting with an ex lamation point to get a
short des ription of the error. If the error is still not lear, ask TEX for more information
by typing h<CR>. For small errors, TEX an arry on quite a way if you just keep hitting
the <CR>.

67

TEXbook: 205

Se tion 9
Digging a little deeper

In this se tion we look at a few topi s that allow TEX to be used with greater exibility
or e ien y. As the do uments being produ ed get longer, di erent te hniques an help
make their reation easier.

9.1 Big les, little les


TEX an read and write les as it runs. This makes it possible to use les that are smaller
and more onvenient to handle by reating a master le that reads the smaller les in the
proper order. This do ument, for example, onsists of ten se tions plus an introdu tion. In
addition, there are ma ros that are used for all se tions. The ma ros an be put in a le
alled, say, ma ros.tex, the introdu tion an be put in intro.tex, and ea h se tion put
in its own le. The ontrol word \input is then used to read in a le. In general, \input
filename will ause the le alled filename.tex to be read in and pro essed immediately,
just as if the text of filename.tex had been part of the le that read it in. This le may
input other les. In fa t it's often onvenient to make a single le that reads in smaller
pie es, perhaps as follows:
\input
\input
\input
\input
\input
\input
\input
\input
\input
\input
\input
\input

ma ros
intro
se 1
se 2
se 3
se 4
se 5
se 6
se 7
se 8
se 9
se 10

While the text is still being heavily edited, it's possible to pro ess only some of the
les by putting a % at the beginning of ea h line that ontains a le to be skipped (this is
sometimes alled \ ommenting out" the unwanted les).
68

A TEX intro (Canadian spelling)

Se tion 9: Digging a little deeper

The \input ontrol word also allows the use of predesigned ma ros. The ma ros for a
memorandum, for example, might be put in a le alled memo.tex. These ma ros might set
up the right \hsize, \vsize and other parameters, and might stamp the time and date.
On e this has been set up, all memoranda may be started with \input memo to make them
ome out with a ommon format.
Be sure that you don't have the ontrol word \bye in your input le or the TEX program
will stop at that point.

. Exer ise 9.1 Make a TEX input le that reads in a se ond le. Try reading in the se ond
le twi e using the \input ontrol word twi e.

9.2 Larger ma ro pa kages


Designing ma ros that an be used with many types of do uments is obviously useful.
Most universities, for example, have spe i and often ompli ated format requirements for
theses. A olle tion of ma ros, that is, a ma ro pa kage that meets all these spe i ations
ould be somewhat time onsuming to design and ould be quite long. It is possible to use
the \input ommand to use su h a ma ro pa kage, just as it is possible to use it with your
own ma ros. But TEX has a better fa ility for larger pa kages.
A ma ro pa kage an be put in a spe ial form that an be qui kly read by TEX. This
is alled a format le, and the exa t form is of te hni al interest only. The important thing
is it allows TEX to be run with many new ontrol sequen es prede ned. Certain ommands
alled primitives are part of the de nition of TEX.
What we have des ribed in this manual is sometimes alled plain TEX , and onsists of
the TEX primitives plus a set of ma ros in a format le (that is usually in luded in TEX
automati ally) alled plain.fmt. For the urious, any ontrol word an be viewed using
\show. The ommand \show\ enterline will display
> \ enterline=ma ro:
#1->\line {\hss #1\hss }.

on the s reen and in the log le. You an use \show with your own ma ros, too. If you
end up using several ma ro pa kages, you an use the \show ommand to see if a parti ular
ma ro is de ned.

69

A TEX intro (Canadian spelling)

Se tion 9: Digging a little deeper

Many omputer entres have the LaTEX ma ro pa kage. This pa kage allows the user to
reate an index, a table of ontents, and a bibliography automati ally. It also has the ability
to insert some elementary graphi gures su h as ir les, ovals, lines, and arrows. LaTEX
also uses spe ial prede ned les alled style les to set up spe i page parameters. Many
di erent style les are available; some journals will a ept papers on a magneti medium
for dire t pro essing if they are prepared using LaTEX and a designated style le. It is not
di ult to shift from TEX to LaTEX. A user's guide by the author of the ma ro pa kage,
Leslie Lamport, is available: LaTEX: A do ument preparation system8.
The Ameri an Mathemati al So iety uses the AMS -TEX ma ro pa kage for its journals.
It is readily available from that So iety, and papers may be submitted to their journals on
a magneti medium using AMS -TEX. A manual by Mi hael Spivak, The Joy of TEX9 , is
available from the Ameri an Mathemati al So iety.
Other ma ro pa kages exist, and undoubtedly more will be developed. They are usually
of modest ost and an be very e e tive in some ir umstan es. The TEX Users Group
announ es the existen e of new ma ro pa kages in its publi ations.

9.3 Horizontal and verti al lines


Making horizontal and verti al lines is easy using TEX. When typing in text, \hrule
will ause the urrent paragraph to end, will draw a horizontal line whose width is the
urrent value of \hsize, and then will ontinue on with a new paragraph. It's possible to
spe ify the width of the hrule as, for example, with \hrule width 5 m; also you an use
\vskip or \bigskip to put some spa e above or below the hrule. Here is an example:
\parindent = 0 pt \parskip = 12 pt
Here is the text before the hrule.
\bigskip
\hrule width 3 in
And here is some text after the hrule.

that produ es

8 Addison-Wesley, Reading, Massa husetts, 1986, ISBN 0-201-15790-X.


9 Ameri an Mathemati al So iety, 1986, ISBN 0-8218-2999-8

70

A TEX intro (Canadian spelling)

Se tion 9: Digging a little deeper

Here is the text before the hrule.


And here is some text after the hrule.
In fa t this hrule not only has width of three in hes, but also by default has a height
(the amount by whi h the hrule extends above the baseline on whi h the type is being set)
of 0.4 points and a depth (the amount by whi h the hrule extends below the baseline on
whi h the type is being set) of 0 points. Ea h of these parameters an be individually set.
Thus if we hange the last example to say
\hrule width 3 in height 2 pt depth 3 pt we get

Here is the text before the hrule.


And here is some text after the hrule.
The three parameters width, height, and depth may be given in any order.
A vrule may be de ned analogously to an hrule by spe ifying the width, height, and
But, unlike the hrule, the vrule will not automati ally start a new
paragraph when it appears. By default the vrule will be 0.4 points wide, and will be as high
as the line on whi h it is being set. Hen e
depth if desired.

Here is some text before the vrule


\vrule\
and this follows the vrule.

will give
Here is some text before the vrule and this follows the vrule.

. Exer ise 9.2 Make three horizontal lines that are 15 points apart, 3 in hes in length, and
one in h in from the left margin.
Although we usually think of hrules and vrules as horizontal and verti al lines, they
need not ne essarily be used that way. For example:
\noindent
Name: \vrule height 0 pt depth 0.4 pt width 3 in

71

TEXbook: 221{222
TEXbook: 221{222

A TEX intro (Canadian spelling)

Se tion 9: Digging a little deeper

will give
Name:

. Exer ise 9.3 Make the following grid (ea h box is 1 entimetre square):

9.4 Boxes within boxes


We have already seen (in our dis ussion of line shapes) that vboxes and hboxes are
obje ts that may be overfull or underfull. In this se tion we will look at these boxes in a
bit more detail. They may be sta ked or lined up to allow a variety of positions for text on
the page.
An hbox is formed by using \hbox{: : :}. On e the material between the bra es has
been put into an hbox, it is set and an not be further split (this means that material that
must go on one line an be put into an hbox, and it will then remain as one unit). It's
possible to spe ify the size of an hbox. Thus \hbox to 5 m{ ontents of the box} will
produ e an hbox exa tly ve entimetres wide ontaining the typeset text \ ontents of the
box". It's easy to get an underfull or overfull box in this way. An underfull box an be
avoided by using \hfil to absorb the extra spa e. When no dimension is given, an hbox is
formed that is just wide enough to hold the en losed text.
Similarly, vboxes are formed using \vbox{: : :}. What makes these boxes interesting is
that when a vbox ontains hboxes, these hboxes are sta ked one above the other and set as
a unit. Similarly, an hbox an ontain vboxes, whi h will be set in a row. Suppose we take
three hboxes and put them in a vbox:
\vbox{
\hbox{Contents of box 1}
\hbox{Contents of box 2}
\hbox{Contents of box 3}

72

TEXbook: 64{66

A TEX intro (Canadian spelling)

Se tion 9: Digging a little deeper

gives
Contents of box 1
Contents of box 2
Contents of box 3
Now suppose we take another vbox:
\vbox{
\hbox{Contents of box 4}
\hbox{Contents of box 5}
}

These two vboxes an be put into an hbox; this will ause them to be pla ed side by
side. In other words
\hbox{
\vbox{
\hbox{Contents
\hbox{Contents
\hbox{Contents
}
\vbox{
\hbox{Contents
\hbox{Contents
}
}

of box 1}
of box 2}
of box 3}
of box 4}
of box 5}

gives
Contents of box 1
Contents of box 2 Contents of box 4
Contents of box 3 Contents of box 5
Noti e that the two vboxes are aligned so that the bottoms are level; also there is a
little spa e at the beginning of ea h line and also between the vboxes. A tually, the reason
these spa es appear is rather subtle. Unless a line ends in a ontrol word, there is always a
spa e between the last entry in one line and the rst one in the next line. For this reason
the spa e between the vboxes omes from the end of the line ontaining the losing bra e
of the rst vbox. Similarly, the spa e at the beginning of the line is aused by the spa e
73

A TEX intro (Canadian spelling)

Se tion 9: Digging a little deeper

after the opening bra e of the hbox. These spa es an be avoided by \ ommenting out" the
end of the line, that is, by putting a % immediately after the losing bra e of the rst vbox
or the opening bra e of the hbox. If you try to put some vboxes together and a identally
get extra spa e by forgetting to omment out the end of the line, you're in good ompany.
Some very able and experien ed TEX users have done the same thing!
Extra spa e, say one entimetre, an be added by putting an \hskip 1 m between
the vboxes. They an be aligned so that the tops are level by using \vtop instead of \vbox.
Making these two hanges results in:
Contents of box 1
Contents of box 2
Contents of box 3

Contents of box 4
Contents of box 5

We an ombine vboxes, hboxes, vrules, and hrules to get boxed text. How might we
onstru t su h a box? One way is to take the material to be boxed and put it in an hbox
pre eded and followed by a vrule. Then put this in a vbox with hrules above and below it.
This gives us:
\vbox{
\hrule
\hbox{\vrule{} The text to be boxed \vrule}
\hrule
}

whi h results in
The text to be boxed
This produ es boxed material, but there is no margin around it and so it looks very
ramped (of ourse TEX is just giving us what we asked for). We an improve the spa ing
by putting a \strut at the beginning of the hbox to make it a little taller and deeper. This
gives us:
The text to be boxed

. Exer ise 9.4 Why is it that we were for ed to add extra spa e above and below the text
but not before and after it?

74

A TEX intro (Canadian spelling)

Se tion 9: Digging a little deeper

. Exer ise 9.5 Use the method of boxing material to put text entred in a box whi h
extends from the left to the right margin.
. Exer ise 9.6 By sta king nine little boxes, make the following magi square:
6 1 8
7 5 3
2 9 4

. Exer ise 9.7 Noti e that the magi square in the previous exer ise has internal lines that
are twi e as thi k as the outside ones. Also, there is a tiny spa e at the interse tion of the
internal lines. Fix up the magi square so this doesn't happen.
. Exer ise 9.8 Write a ma ro \boxtext#1{: : :} whi h will take the text between the bra es
and put a box around it. Test your ma ro by making up a senten e with every other word
boxed. I'm not quite sure why someone would do this sin e the result is pretty strange.
Note how the baseline and the bottom of the surrounding boxes align.
It's easy to move boxes up, down, left, or right on the page. A \vbox an be moved
to the right one in h by using \moveright 1 in \vbox{: : : }. To move it to the left, use
\moveleft. Similarly, an \hbox an be moved up or down using \raise or \lower.

. Exer ise 9.9 Rewrite the \boxtext ma ro from the previous exer ise so that all of the
text is aligned (hint: by default the depth of a strut is 3.5 points). This would give a senten e like the following: I'm not quite sure why someone would do this sin e the result is
pretty strange.
It's possible to ll a box with either an hrule or with dots. The idea is to use \hrulefill
or \dotfill in the hbox.
\hbox
\hbox
\hbox
\hbox

to
to
to
to

5
5
5
5

in{Getting Started\hrulefill 1}
in{All Chara ters Great and Small\hrulefill 9}
in{The Shape of Things to ome\hrulefill 17}
in{No Math Anxiety Here!\hrulefill 30}

gives
75

A TEX intro (Canadian spelling)

Se tion 9: Digging a little deeper

Getting Started
All Chara ters Great and Small
The Shape of Things to ome
No Math Anxiety Here!

1
9
17
30

If \hrulefill is repla ed by \dotfill we get


Getting Started : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1
All Chara ters Great and Small : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 9
The Shape of Things to ome : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 17
No Math Anxiety Here! : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 30

. Exer ise 9.10 Make a boxed headline appear at the top of the page that is like the one
used in this manual.

76

Se tion 10
Control word list

Here is a list of the ontrol words given in this manual. If you want more detail about
these words than is given here, he k the index of The TEXbook.
Control symbols
\
\,
\=
\%
\
\|

4
34
11
6
10
40

\!
\.
\>
\&
\`

34
11
34
10
11

\"
\/
\#
\{
\~

11
16
10
10
10

\'
\;
\$
\}
\^

11
34
6
10
10

Control words
\AA 12
\ae 12
\approx 37
\arg 41
\bar 36
\biggl 40
\bigl 40
\bigskip 26
\bye 4
\ enterline 26
\ ir 35
\ ot 41
\d 12
\deg 41
\diamond 36
\dotfill 49
\eje t 20
\eqalign 45
\eta 35
\folio 28

\aa 12
\aleph 37
\ar os 41
\ast 36
\baselineskip 22
\Biggl 40
\Bigl 40
\break 26
\ 12
\ entreline 60
\ olumns 48
\ oth 41
\ddag 27
\delta 35
\dim 41
\dots 14
\ell 37
\eqalignno 46
\exists 37
\font 16

\a ute 36
\alpha 35
\ar sin 41
\b 12
\beta 35
\biggr 40
\bigr 40
\breve 36
\ ap 36
\ he k 36
\ os 41
\ s 41
\ddot 36
\Delta 35
\div 36
\downarrow 41
\endinsert 26
\eqno 46
\exp 41
\footline 28

77

\AE 12
\angle 37
\ar tan 41
\ba kslash 37
\bf 16
\Biggr 40
\Bigr 40
\bullet 36
\ dot 36
\ hi 35
\ osh 41
\ up 36
\def 55
\det 41
\dot 36
\Downarrow 41
\epsilon 35
\equiv 37
\flat 37
\footnote 27

A TEX intro (Canadian spelling)


\forall 37
\geq 37
\hang 23
\hbadness 29
\hfill 26
\hrule 71
\hyphenation 30
\inf 41
\iota 35
\j 11
\l 12
\l eil 41
\leq 37
\lfloor 41
\limsup 41
\lower 75
\max 41
\moveright 75
\natural 37
\noindent 22
\O 12
\oe 12
\ominus 36
\overfullrule 29
\par 7
\parskip 22
\Phi 35
\Pr 41
\qquad 34
\rangle 41
\rho 35
\rm 16
\se 41
\Sigma 35
\sinh 41
\ss 12
\subseteq 37
\supseteq 37
\tanh 41
\tensor 60
\tilde 36
\tt 16

Se tion 10: Control word list

\gamma 35
\grave 36
\hangafter 23
\hbox 72
\hfuzz 29
\hrulefill 49
\i 11
\infty 37
\it 16
\kappa 35
\lambda 35
\left 44
\leqalignno 46
\lg 41
\line 26
\magnifi ation 21
\medskip 26
\mu 35
\neg 37
\nopagenumbers 5
\o 12
\offinterlineskip 53
\oplus 36
\overline 39
\parallel 37
\partial 37
\pi 35
\pro laim 42
\quad 34
\r eil 41
\right 44
\root 39
\settabs 48
\sim 37
\sl 16
\star 36
\sum 38
\surd 39
\tau 35
\the 28
\times 36
\u 12

78

\Gamma 35
\H 12
\hangindent 23
\headline 28
\hoffset 20
\hsize 20
\Im 37
\input 68
\item 24
\ker 41
\Lambda 35
\leftline 26
\leqno 46
\lim 38
\ln 41
\magstep 16
\min 41
\nabla 37
\ni 37
\not 36
\odot 36
\omega 35
\otimes 36
\P 27
\parindent 23
\perp 37
\Pi 35
\psi 35
\raggedright 27
\Re 37
\rightline 26
\S 27
\sharp 37
\simeq 37
\smallskip 26
\strut 50
\sup 41
\t 12
\tensor 60
\theta 35
\toleran e 29
\underbar 39

\g d 41
\halign 51
\hat 36
\hfil 27
\hom 41
\hskip 27
\in 37
\int 38
\itemitem 24
\L 12
\langle 41
\leftskip 23
\let 61
\liminf 41
\log 41
\matrix 44
\moveleft 75
\narrower 23
\noalign 52
\nu 35
\OE 12
\Omega 35
\over 37
\pageno 28
\parshape 24
\phi 35
\pmatrix 43
\Psi 35
\raise 75
\rfloor 41
\rightskip 23
s aled 16
\sigma 35
\sin 41
\sqroot 39
\subset 37
\supset 37
\tan 41
\TeX 5
\Theta 35
\topinsert 26
\underline 39

A TEX intro (Canadian spelling)


\uparrow 41
\upsilon 35
\varphi 35
\vbadness 30
\vfill 20
\vsize 20
\widetilde 36

Se tion 10: Control word list

\Uparrow 41
\Upsilon 35
\varrho 35
\vbox 71
\vglue 25
\vtop 74
\xi 35

\updownarrow 41
\v 12
\varsigma 35
\ve 36
\voffset 20
\wedge 36
\Xi 35

79

\Updownarrow 41
\varepsilon 35
\vartheta 35
\vee 36
\vrule 71
\widehat 36
\zeta 35

Se tion 11
I get by with a little help

Many of the exer ises an be answered in several ways. If you like your way better than
the way given below, by all means use it!

I like \TeX!
On e you get the hang of it, \TeX\ is really easy to use.
You just have to master the \TeX ni al aspe ts.

I like TEX! On e you get the hang of it, TEX is really easy to use. You just have to master the TEXni al aspe ts.
Does \AE s hylus understand \OE dipus?

Does s hylus understand dipus?


The smallest internal unit of \TeX{} is about 53.63\AA.

The smallest internal unit of TEX is about 53.63


A.
They took some honey and plenty of money wrapped up in a {\it \$}5 note.

They took some honey and plenty of money wrapped up in a $5 note.


\'El\`eves, refusez vos le\ ons! Jetez vos ha\^\i nes!

 eves, refusez vos le ons! Jetez vos ha^nes!


El

80

A TEX intro (Canadian spelling)

Se tion 11: I get by with a little help

Za\v sto tako polako pijete \v aj?

Zasto tako polako pijete  aj?


Mein Tee ist hei\ss.

Mein Tee ist hei.


Peut-\^etre qu'il pr\'ef\`ere le af\'e gla \'e.

Peut-^etre qu'il prefere le afe gla e.


?`Por qu\'e no bebes vino blan o? !`Porque est\'a avinagrado!

>Por que no bebes vino blan o? <Porque esta avinagrado!


M\'\i\'\j n idee\"en worden niet be\"\i nvloed.

Mn ideeen worden niet benvloed.


Can you take a ferry from \"Oland to \AA land?


Can you take a ferry from Oland
to 
Aland?

T\"urk\ e konu\ san ye\u genler nasillar?

Turk e konusan yegenler nasillar?


I entered the room and---horrors---I saw both my father-in-law and my
mother-in-law.

I entered the room and|horrors|I saw both my father-in-law and my mother-in-law.

81

A TEX intro (Canadian spelling)

Se tion 11: I get by with a little help

The winter of 1484--1485 was one of dis ontent.

The winter of 1484{1485 was one of dis ontent.


His ``thoughtfulness'' was impressive.

His \thoughtfulness" was impressive.


Frank wondered, ``Is this a girl that an't say `No!'?''

Frank wondered, \Is this a girl that an't say `No!'?"


He thought, ``\dots and this goes on forever, perhaps to the last re orded
syllable.''

He thought, \: : : and this goes on forever, perhaps to the last re orded syllable."
Have you seen Ms.~Jones?

Have you seen Ms. Jones?


Prof.~Smith and Dr.~Gold flew from
Halifax N.~S. to Montr\'eal, P.~Q. via Mon ton, N.~B.

Prof. Smith and Dr. Gold ew from Halifax N. S. to Montreal, P. Q. via Mon ton, N. B.
\line{left end \hfil left ta kle \hfil left guard \hfil entre\hfil
right guard \hfil right ta kle \hfil right end}

left end

left ta kle

left guard

entre

82

right guard

right ta kle

right end

A TEX intro (Canadian spelling)

Se tion 11: I get by with a little help

\line{left \hfil \hfil right- entre\hfil right}

left

right- entre

right

\line{\hskip 1 in ONE \hfil TWO \hfil THREE}

ONE

TWO

i{f}f if{}f if{f}

iff iff iff


I started with roman type {\it swit hed to itali type}, and
returned to roman type.

I started with roman type swit hed to itali type, and returned to roman type.
$C(n,r) = n!/(r!\,(n-r)!)$

C (n; r) = n!=(r! (n r)!)


$a+b= -d=xy=w/z$
$$a+b= -d=xy=w/z$$

a + b = d = xy = w=z

a + b = d = xy = w=z

$(fg)' = f'g + fg'$


$$(fg)' = f'g + fg'$$

(fg)0 = f 0 g + fg0

(fg)0 = f 0 g + fg0

83

THREE

A TEX intro (Canadian spelling)

Se tion 11: I get by with a little help

$\alpha\beta=\gamma+\delta$
$$\alpha\beta=\gamma+\delta$$

= +

= +

$\Gamma(n) = (n-1)!$
$$\Gamma(n) = (n-1)!$$

(n) = (n 1)!

(n) = (n 1)!

$x\wedge (y\vee z) = (x\wedge y) \vee (x\wedge z)$

x ^ (y _ z ) = (x ^ y) _ (x ^ z )

$2+4+6+\ dots +2n = n(n+1)$

2 + 4 + 6 +    + 2n = n(n + 1)

$\ve x\ dot \ve y = 0$ if and only if $\ve x \perp \ve y$.

~x  ~y = 0 if and only if ~x ? ~y.

$\ve x\ dot \ve y \not= 0$ if and only if $\ve x \not\perp \ve y$.

~x  ~y 6= 0 if and only if ~x 6? ~y.

$(\forall x\in \Re)(\exists y\in\Re)$ $y>x$.

(8x 2 <)(9y 2 <) y > x.

84

A TEX intro (Canadian spelling)

Se tion 11: I get by with a little help

${a+b\over }\quad {a\over b+ }\quad {1\over a+b+ } \not= {1\over a}+


{1\over b}+{1\over }$.
a
1
1 1 1
a+b

b+ a+b+ 6= a + b + .
What are the points where ${\partial \over \partial x} f(x,y) = {\partial \over
\partial y} f(x,y) = 0$?
 f (x; y ) =  f (x; y ) = 0?
What are the points where x
y
$e^x \quad e^{-x} \quad e^{i\pi}+1=0 \quad x_0 \quad x_0^2
\quad {x_0}^2 \quad 2^{x^x}$.
x
ex e x ei + 1 = 0 x0 x2 x0 2 2x .

$\nabla^2 f(x,y) = {\partial^2 f \over\partial x^2}+ {\partial^2 f \over


\partial y^2}$.
r2 f (x; y) = x2 f2 + y2 f2 .
$\lim_{x\to 0} (1+x)^{1\over x}=e$.
1
limx!0 (1 + x) x = e.
The ardinality of $(-\infty, \infty)$ is $\aleph_1$.

The ardinality of (

1; 1) is 1 .

$\lim_{x\to {0^+}} x^x = 1$.


limx!0+ xx = 1.

85

A TEX intro (Canadian spelling)

Se tion 11: I get by with a little help

$\int_0^1 3x^2\,dx = 1$.

R1

2
0 3x dx = 1.

$\sqrt2 \quad \sqrt {x+y\over x-y} \quad \root 3 \of {10}$ \quad $e^{\sqrt x}$.

p3

x+y
x y

10

p
e x.

$\|x\| = \sqrt{x\ dot x}$.

kxk = px  x.

$\phi(t) = {1 \over \sqrt{2\pi}} \int_0^t e^{-x^2/2}\,dx$.


R
2
(t) = p12 0t e x =2 dx.
$\underline x \quad \overline y \quad \underline{\overline{x+y}}$.

x y x + y.
$\bigl \l eil \lfloor x \rfloor \bigr \r eil \leq \bigl \lfloor \l eil x \r eil
\bigr \rfloor$.


bx  dxe

$\sin(2\theta) = 2\sin\theta\ os\theta


\quad \ os(2\theta) = 2\ os^2\theta - 1 $.

sin(2) = 2 sin  os  os(2) = 2 os2 

1.

86

A TEX intro (Canadian spelling)

Se tion 11: I get by with a little help

$$\int \ s ^2x\, dx = -\ ot x+ C
\qquad \lim_{\alpha\to 0} {\sin\alpha \over \alpha} = 1
\qquad \lim_{\alpha\to \infty} {\sin\alpha \over \alpha} = 0.$$
Z

sin
=1
lim
!0

s 2 x dx = ot x + C

sin
lim
= 0:
!1

$$\tan(2\theta) = {2\tan\theta \over 1-\tan^2\theta}.$$

tan(2) =

2 tan 
:
1 tan2 

\pro laim Theorem (Eu lid). There exist an infinite number of primes.

Theorem (Eu lid). There exist an in nite number of primes.


\pro laim Proposition 1.
$\root n \of {\prod_{i=1}^n X_i} \leq
{1 \over n} \sum_{i=1}^n X_i$ with equality if and only if $X_1=\ dots=X_n$.
pQ
P
Proposition 1. n ni=1 Xi  n1 ni=1 Xi with equality if and only if X1 =    = Xn .

$$ I_4 = \pmatrix{
1 &0 &0 &0 \ r
0 &1 &0 &0 \ r
0 &0 &1 &0 \ r
0 &0 &0 &1 \ r}$$
0

1
B0
I4 =  0
0

0
1
0
0
87

0
0
1
0

01
0C
0A
1

A TEX intro (Canadian spelling)

Se tion 11: I get by with a little help

$$ |x| = \left\{ \matrix{


x & x \ge 0 \ r
-x & x \le 0 \ r} \right.$$

jxj =

x x0
x x0

\settabs \+ \hskip 2 in & \hskip .75in & \hskip 1 m& \ r


\+ &Plums &\hfill\$1&.22 \ r
\+ &Coffee &\hfill1&.78 \ r
\+ &Granola &\hfill1&.98 \ r
\+ &Mushrooms & &.63 \ r
\+ &{Kiwi fruit} & &.39 \ r
\+ &{Orange jui e} &\hfill1&.09 \ r
\+ &Tuna &\hfill1&.29 \ r
\+ &Zu hini & &.64 \ r
\+ &Grapes &\hfill1&.69 \ r
\+ &{Smoked beef} & &.75 \ r
\+ &Bro oli &\hfill\underbar{\ \ 1}&\underbar{.09} \ r
\+ &Total &\hfill \$12&.55 \ r

Plums
$1.22
Co ee
1.78
Granola
1.98
Mushrooms
.63
Kiwi fruit
.39
Orange jui e
1.09
Tuna
1.29
Zu hini
.64
Grapes
1.69
Smoked beef
.75
Bro oli
1.09
Total
$12.55

88

A TEX intro (Canadian spelling)

Se tion 11: I get by with a little help

\settabs \+ \hskip 4.5 in & \ r


\+Getting Started \dotfill &1 \ r
\+All Chara ters Great and Small \dotfill &9 \ r

Getting Started : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1
All Chara ters Great and Small : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : 9
\settabs \+ \hskip 1 m&\hskip 1 m&\hskip 1 m& \ r
\moveright 2 in
\vbox{
\hrule width 3 m
\+ \vrule height 1 m & \vrule height 1 m & \vrule height 1 m
& \vrule height 1 m \ r
\hrule width 3 m
\+ \vrule height 1 m & \vrule height 1 m & \vrule height 1 m
& \vrule height 1 m \ r
\hrule width 3 m
\+ \vrule height 1 m & \vrule height 1 m & \vrule height 1 m
& \vrule height 1 m \ r
\hrule width 3 m
}

\def\boxtext#1{%
\vbox{%
\hrule
\hbox{\strut \vrule{} #1 \vrule}%
\hrule
}%
}
\moveright 2 in \vbox{\offinterlineskip

89

A TEX intro (Canadian spelling)

Se tion 11: I get by with a little help

\hbox{\boxtext{6}\boxtext{1}\boxtext {8}}
\hbox{\boxtext{7}\boxtext{5}\boxtext{3}}
\hbox{\boxtext{2}\boxtext{9}\boxtext{4}}
}

6 1 8
7 5 3
2 9 4

Gentle Intro 1.03 run through TEX on February 14, 1994 at 12:10 P.M.

90

Você também pode gostar