Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
tion to LATEX
Harvey J. Greenberg
University of Colorado at Denver
Mathemati
s Department
PO Box 173364
Denver, CO 80217-3364
hgreenbe
arbon.
udenver.edu
http://www.
udenver.edu/
hgreenbe/
i
Table of Contents
List of Figures
iii
List of Tables
vi
Prefa e
viii
A knowledgements
ix
ix
1 Overview
2 Text
3 Bibliography with
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
BibTEX
3.1 Overview . . . . . . . . . .
3.2 The bib File . . . . . . . .
3.2.1 Main body . . . . .
3.2.2 Web
itations . . .
3.2.3 Additional features
3.3 De
laration and Citation .
Exer
ises . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
7
13
16
23
24
26
27
28
30
30
31
31
36
38
40
42
43
43
44
45
47
49
ii
5 Math Mode
6 Graphi s
8.1
8.2
8.3
8.4
8.5
Your
Your
Your
Your
Your
Own
Own
Own
Own
Own
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
8 Taking Control
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
50
50
53
57
65
67
69
71
75
76
80
80
88
99
102
105
105
107
108
110
110
111
111
113
114
115
119
Closing Remarks
120
Appendix
121
Referen es
128
Index
131
iii
List of Figures
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
2 3
2 3
1
2
4
6
6
7
8
9
9
10
10
12
12
14
15
15
16
16
17
17
17
18
19
21
21
22
22
23
26
26
31
42
46
46
47
48
iv
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
49
53
54
55
55
55
59
59
60
60
61
61
62
63
64
64
65
65
72
72
74
75
81
82
82
83
85
93
93
93
95
98
100
100
105
105
106
107
v
75
76
77
78
79
80
81
82
83
107
108
108
109
111
117
117
118
121
vi
List of Tables
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
8
24
25
25
25
45
47
49
51
51
52
54
56
57
60
66
66
67
90
91
97
113
116
116
122
122
123
123
123
123
124
124
124
124
125
125
vii
37
38
39
40
41
42
43
44
45
46
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
125
126
126
126
126
127
127
128
128
128
viii
Prefa
e
The majority of this book is about using LATEX 2" [2, 10, a des
endant of
LATEX, designed by Leslie Lamport [9, based on TEX, originated by Donald
E. Knuth [8. This is a typesetting program, not a word pro
essor. You
enter some editor that saves plain text les. Then, you type text freely until
you need something spe
ial, su
h as itali
font or a
omplex mathemati
al
expression, like
Z ai +" p
lim
"!0+
ai
1 + (x
(")
)2 dx
It was the desire to have high quality, low
ost publi
ations in mathemati
s and related dis
iplines that
aused Knuth (pronoun
ed Kah-nooth) to
invent TEX (pronoun
ed Tek) in the late 1970's. Originally believing that he
ould write a program in less than a year that
ould typeset do
uments, he
a
tually ended up dening an entire bran
h of resear
h in
omputer s
ien
e.
It was 10 years later that he published his seminal book [8, but he published
arti
les along the way, and he permanently
hanged the way mathemati
al
do
uments are prepared. LATEX (pronoun
ed Lah-tek or Lay-tek) is a
olle
tion of ma
ros built on top of TEX that represents a balan
e between
fun
tionality and ease of use [9, p. xiii. LATEX 2" is the
urrent version,
developed by a team of volunteers: Johannes L. Braams, David P. Carlisle,
Alan Jerey, Frank Mittelba
h, Chris Rowley, and Rainer S
hpf [2.
A
omprehensive
overage of LATEX and the many enhan
ements to it is
given by the The LATEX Companion [5. By
ontrast, this book is designed
to be a su
in
t introdu
tion, omitting many of the things LATEX 2"
an do.
My goal is to oer enough of an introdu
tion that someone not a
quainted
with LATEX (or with TEX)
an write a term paper, thesis, or arti
le, using
LATEX 2" to produ
e high quality results. Exer
ises are provided for guided
instru
tion, whi
h should be just a few
lasses. For one who is well a
quainted
with
omputers, parti
ularly unix, the basi
s that are
overed should take
less than 10 hours, and one
ould do all of the exer
ises. For one who is just
learning how to use a
omputer, it will take longer, espe
ially getting used to
fun
tioning at the
ommand line. In any
ase, the ner points require more
study.
Happy TEXing.
Harvey J. Greenberg
ix
A
knowledgements
AT X Software
Sour
es of L
E
The basi
LATEX software system is available free of
harge for unix systems,
and MiKTeX [13 is available free of
harge for DOS systems. The best
sour
e of these, and additional pa
kages that extend the LATEX
apabilities
(to whi
h I refer in this book), is at the Comprehensive TeX Ar
hive Network
(CTAN) [4, at three host sites (and many mirrors):
1. http://
tan.tug.org/ in Boston, MA, USA,
2. http://www.tex.a
.uk/ in Cambridge, UK, and
3. http://www.dante.de/ in Mainz, Germany (in German).
These all des
ribe how to sear
h and browse the FTP sites for software and
do
uments.
1
1
Overview
You will
reate a le,
alled the LATEX sour
e, whi
h is plain text. To keep
things simple, its sux is .tex, so for example I refer to myfile.tex as a
plain text sour
e le that you
reate. Figure 1 shows the stru
ture of this
le, whi
h I shall des
ribe in greater detail throughout this book.
% This is myfile.tex
% notes to yourself
an go here
\do
ument
lass[options{style}
9
=
;
\end{do ument}
Preamble
\begin{do
ument}
..
.
Body
environment.
latex myfile
1 OVERVIEW
(In an MS Windows system, the
ommand line is the DOS
ommand line,
whi
h you enter by running Start !Programs !MS-DOS Prompt.)
\do
ument
lass{arti
le}
\begin{do
ument}
Hello world.
\end{do
ument}
Case 1. You got messages, but they were not fatal errors.
Among the non-fatal messages you will generally see are warnings like:
save a ba kup
p -p myfile.tex myfile-1.tex
(The -p is to keep the date and time of the sour
e le.) Change -1 to another
qualier ea
h time (e.g., -2 : : : ), so you have a
olle
tion of ba
kups. If
you are running under DOS, use
opy myfile.tex destination, where the
destination is either a: or some ba
kup le name. (If you are familiar with
DOS, nothing more need be said; if not, you need to learn how to
reate,
edit and save plain text les.)
Next you want to view the result. If you are in a unix environment, you
an view the result with the dvi viewer, xdvi. At the
ommand line enter:
xdvi myfile
and it will
ome on your s
reen. (There is more to do if you are working
remotely, in whi
h
ase you must ask someone for help.)
If you are using DOS, the viewer that
omes with MiKTeX [13, a free
software system by Christian S
henk, is
alled YAP. At the DOS
ommand
line you enter:
YAP myfile
You will see various options for viewing and printing.
Under unix, xdvi does not have a print option, so you rst need to
onvert
the dvi le to posts
ript. This is done with the program, dvips. At the
ommand line enter:
dvips myfile -o
(The -o tells the system you want the output to go to a le, rather than
just print; your installation might already have le output as the default,
in whi
h
ase the -o is not needed.) This will result in the
reation of the
posts
ript le myfile.ps. You
an print it in any number of ways, in
luding
the unix
ommand, lpr myfile.ps.
The same
onversion program
an be run under DOS (and
omes with
MiKTeX), and you might want to obtain myfile.ps for a variety of reasons,
in
luding posting it on the web. To view or print a posts
ript le under DOS,
1 OVERVIEW
you
an run a program
alled ghostview. You will need to nd out more
about viewing and printing posts
ript les that suit your parti
ular needs.
Summarizing, you begin by entering a plain text editor. In unix this
ould
be pi
o, ema
s, vi or vim. In DOS you
an use EDIT at the
ommand line,
or you
an use Notepad,Wordpad or MS Word. If you use a word pro
essor,
however, you must take absolutely no advantage of its formatting. You should
even put in hard return
hara
ters (i.e., press Enter at the end of a line
instead of letting the word pro
essor do it for you), and never use tabs.
In MS Word, when saving the le, be sure to spe
ify plain text, and you
must
ontinue to spe
ify the sux as .tex (otherwise, it will use .do
as its
sux). If you want to
he
k that the le is really plain text, enter
EDIT myfile.tex
at the DOS
ommand line and see how the le appears. On
e you have your
sour
e ready to
ompile, enter latex myfile, and if all is well, enter your
dvi viewer. Under unix or DOS use indxdvips to
onvert the dvi le to a
posts
ript (ps) le, whi
h
an be printed. These steps are given in Figure 3.
Exe
ute these
ommands for the sour
e le shown in Figure 2. The result
should be one line of output: Hello World. Congratulations!
reate/edit
myfile.tex
ompile
with
latex
view/print
myfile.dvi
onvert
with
dvips
print/post
myfile.ps
The pt (abbreviation for point) is one of the units of measurement, about
1
A
72 in; other units used in many parts of L TEX are in (in
hes),
m (
entimeters), and em (like the letter m, whi
h is a printer measure equal to the width
of M in the
urrent font).
5
This book is designed for qui
k entry into using LATEX, but do not be
relu
tant to read the last
hapter. It tells you how to dene your own
ommands and how to separate them into an input le that simplies
hanging
things, like notation. I also
annot elaborate just yet on using pa
kages,
indi
ated in Figure 1, ex
ept to say that they are used to fulll some fun
tion, and I shall introdu
e spe
i
pa
kages throughout this book. (One of
the strengths of LATEX is the
ommunity of people who provide pa
kages for
everyone to use at no
ost.) The orientation here is by fun
tion, beginning
with how to write text.
2
Text
2 TEXT
6
\do
ument
lass[12pt{arti
le}
lots
1.1
This is a Se tion
1.2
2
\begin{environment }
..
.
\end{environment }
\begin{
enter}
The text is
entered be
ause I have entered the
enter environment.
Text remains
entered as long as we remain in this environment.
\end{
enter}
\begin{flushleft}
Now we are out of the
entering environment, and have begun the
flushleft environment.
\end{flushleft}
\begin{flushright}
This is another paragraph, but in the flushright environment.
You will have o
asion to use all four paragraph positions.
\end{flushright}
I am ba
k to normal justifi
ation. The added spa
e you see between
the above paragraphs is due to entering those environments.
2 TEXT
)
)
)
)
)
)
)
How
This
This
This
This
This
This
This
it
is
is
is
is
is
is
is
appears
boldfa e.
itali
.
roman.
small
aps.
sans serif.
slanted.
typewriter.
\textbf{\textit{bolditali }}
) bolditali .
Font size
an also be varied at will. Figures 10 and 11 give the sour
e and
result for
ommon variations. Noti
e how the paragraph spa
ing
hanges
to a
ommodate the variation in font size. These size variations
an be
ombined with font styles, su
h as using {\Large\textbf{heading}} for
some heading.
2 TEXT
10
huge
tiny
11
lines. The quotation environment is used for long quotations, having more
than one paragraph (separated by blank lines). The indentation is the same
as the quote, ex
ept the rst line of ea
h new paragraph is indented. (Just
as in the regular text, this
an be overridden by the \noindent
ommand.)
Here is an example that was
reated by putting \begin{quotation} before
the text and \end{quotation} after it.
Computers do not dream, any more than they play. We are
far from
ertain what dreams are good for, but we know what
they indi
ate: a great deal of information pro
essing goes on far
beneath the surfa
e of man's purposive behavior, in ways and
for reasons that are only very indire
tly ree
ted in his overt
a
tivity.
Alan M. Turing
There are reports that many exe
utives make their de
isions
by ipping a
oin or by throwing darts, et
. It is also rumored
that some
ollege professors prepare their grades on su
h a basis.
Sometimes it is important to make a
ompletely `unbiased' de
ision; this ability is o
asionally useful in
omputer algorithms,
for example in situations where a xed de
ision made ea
h time
would
ause the algorithm to run more slowly.
Donald E. Knuth
The quotes are by two pioneers of algorithms, Alan M. Turing and Donald
E. Knuth. Their names appear on the right, after their quote, by skipping a
line and entering \hfill (whi
h means horizontal ll), to make the line ush
right. Here are some other things to noti
e about this example:
There are left and right quotation marks. I used `` '', not " ", to
reate this more stylisti
quotation pun
tuation.
The dash that appears before ea
h name is
reated by three minus
signs, ---. The more minus signs you use, the longer the dash. The
onvention is that one dash is for hyphenation, two are for ranges,
su
h as page numbers, and three are for pun
tuation i.e., use --pre
eding i.e.
There is extra spa
e between the two quotations. This was done with
the \bigskip
ommand.
2 TEXT
12
\smallskip
2.2 Lists
13
The itali
s were spe
ied in the usual way, by en
losing Ba
on's verse
with \textit{ : : : }. (Designed for poetry, ea
h line is a stanza in the verse,
and if a stanza runs long, this form of indentation makes it
lear.) Ba
on's
name appears ush right, again from the \hfill
ommand, but this time
it is on the last line of the verse, rather than a new line. This is a
hieved
simply by not skipping a line after the verse:
\begin{verse}
\textit{Negle
t of mathemati
s ...
} \hfill --- Roger Ba
on
\end{verse}
2.2 Lists
There are three intrinsi
list environments, distinguished by what appears
at the beginning of ea
h item: number, bullet, or your des
ription (perhaps
nothing). To illustrate, here is the use of a des
ription list environment
to itemize steps involved in learning LATEX, whose sour
e is indi
ated by
Figure 14.
le, make paragraphs, vary fonts, and list items are enough to prepare
a basi
do
ument without mathemati
s or tables (like a resume).
Making Tables. LATEX provides a means to make tables with the tabular
environment, and its versatility puts it far ahead of word pro essors.
BibTE X.
Mathemati s. This is a power of LATEX and one reason why it has be ome
Graphi
s. This has progressed a great deal in the past few years thanks to
many people who have provided pa
kages free of
harge.
Other. There are a great many things to learn beyond the simple introdu tion when using LATEX to prepare a thesis, report or arti le.
2 TEXT
14
\begin{des
ription}
\item [Basi
Do
ument Preparation. Knowing how to setup ...
\item [Making Tables. \LaTeX~ provides a means ...
\item [Bibliography. Knowing how to
reate a bibliography ...
\item [Mathemati
s. This is the power of \LaTeX~ and one ...
\item [Graphi
s. This has progressed a great deal in the ...
\item [Other. There are a great many things to learn ...
\end{des
ription}
This is how one item in a des
ription list environment looks with no optional
text at the beginning.
Unlike the verse environment, the rst line goes almost to the left margin,
and the lines extend all the way to the right margin.
Next, Figures 15 and 16 illustrate the itemize list environment, whi
h
prints bullets. Note the indentation of ea
h item and the spa
ing between
items. You see the nesting of two itemize lists, but any type of list
an be
nested within any other type.
2.2 Lists
15
\begin{itemize}
\item This is item 1 and our task has just begun. Blank lines
before an item have no effe
t.
\item This is item 2 and we shall limit to just this few.
A blank line within an item does
reate a new paragraph,
using the indentation of the itemize environment.
\begin{itemize}
\item A se
ond (nested) itemized list
hanges the bullet
and indents another level.
\end{itemize}
\end{itemize}
This is item 1 and our task has just begun. Blank lines
before an item have no ee
t.
This is item 2 and we shall limit to just this few.
A blank line within an item does
reate a new paragraph,
using the indentation of the itemize environment.
2 TEXT
16
\begin{enumerate}
\item This is item 1, and we are having fun.
\item This is item 2, and it's time to number anew.
\begin{enumerate}
\item Ba
k to item 1, but we are not yet done.
\item Two is new.
\begin{enumerate}
\item One again!
\item Two (b) or knot 2b?
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{tabular}
As indi ated, ea h row ends with two ba kslashes, \\. Ea h olumn spe i ation an be left, enter or right, abbreviated by just one hara ter:
17
right
3
Figure 19: A
2 3 Table
We
an draw a horizontal line before any new row by spe
ifying \hline.
To draw a line after the last row, enter \\ \hline (the \\ is simply part
of the syntax and does not add an extra row to the table). The
olumn
spe
i
ations
an have | on either side to indi
ate a verti
al line. Figure 20
illustrates a
ombined use of these options.
How it appears
We
ould draw lines that span some rows and/or
olumns. The way to
vary verti
al line drawing is with the
olumn spe
i
ations: put | only where
you want a verti
al line. The way to vary horizontal line drawing is by using
\
line{rst
ol -last
ol } instead of \hline. This is illustrated in Figure 21.
How it appears
Name Test 1
Bob
67
Sue
72
\begin{tabular}{l|
|}
Name & Test 1 & Test 2 \\ \
line{1-1}
Bob & 67
& 72 \\
Sue & 72
& 67 \\ \
line{2-3}
\end{tabular}
Figure 21: A Table with Partially Spanning Horizontal and Verti al Lines
2 TEXT
18
The entire table uses sans serif font style. This is done by spe
ifying
\textsf{ before entering the tabular environment (and
losing with }
just after it).
Within the tables, fonts are varied: Roman is in the Roman font, spe
ied by \textrm{Roman}, Greek is in itali
, spe
ied by \textit{Greek},
and upper
ase is in small
aps, spe
ied by \texts
{upper
ase}.
A new
olumn spe
i
ation is introdu
ed: p{length }, where any unit
of measure
an be used as the length of the spa
ing. In this example
.3 in
hes is spe
ied. Note that this
ounts as a
olumn, so you see &&
to separate the two tables, ea
h being a
olumn of the main table.
19
Table 1
Obje
t
variable
parameter
onstant
Table 2
Symbols used
lower
ase Roman
Greek
* 1 2
3 4
2 TEXT
20
\begin{tabular}{|p{2in}|l|} \hline
This amount of text is too long to fit on one line of the page.
& This is
olumn 2. \\ \hline
\end{tabular}
\begin{tabular}{|l|l|} \hline
\parbox[t{2in}{This amount of text is too long to fit on
one line of the page.} & This is
olumn 2. \\ \hline
\end{tabular}
They dier only in the pla
ement of the paragraph box, the latter being at
the top to align it with
olumn 2 in the manner shown.
When making a
olumn or parbox small, the spa
ing
an be
ome unsightly due to being justied. This is over
ome with the ushleft environment.
Figures 24 and 25 illustrate this, and note that it
ontains other
ommands
that
an be in any paragraph.
21
\begin{
enter}
\begin{tabular}{ll}
\parbox[t{3in}{\begin{flushleft}
This is
olumn 1, and I might want to display something:
\medskip\
enterline{\fbox{How sweet it is.}}\medskip
This is not the same as
\medskip\fbox{\
enterline{How sweet it is.}}
\end{flushleft} }
& \parbox[t{1in}{\begin{flushleft}\textsf{This is
olumn 2,
whi
h I have put in sans serif font.}
\end{flushleft} }
\end{tabular}
\end{
enter}
This is
olumn
2, whi
h I
have put in
sans serif font.
2 TEXT
22
Average
70.5
70.5
23
\begin{des
ription}
\item [This is option for item.
\end{des
ription}
\begin{des
ription}
\item {[This is not option} for item.
\end{des
ription}
2 TEXT
24
Other fonts
Chara
ter
(Roman)
How you
write it
itali
{}
\{ \}
{}
%$#&_
\
^
~
%$#&_
\
\textba
kslash
\textas
ii
ir
um
^
\textas
iitilde
~
\% \$ \# \& \_
\textregistered
{[ }
large
{}
%$#&_
\
^
~
r
[
\begin{verbatim}
..
.
\end{verbatim}
This is how the sour
e
ode was
reated for the gures, like Figure 26 (p. 22).
Another
lass of spe
ial
hara
ters are letters with a
ents. Table 3 shows
some
ommon examples; a
omplete table is in the Appendix. For example,
write Poin
ar\'{e} to have Poin
ar and G\"{o}del to have Gdel. An
a
ent
ould be applied to any letter, even if it does not relate to some
d.
language for example, \"{b}\~{
}\^{d} ) b
LATEX has a basi
library of a
ents and spe
ial
hara
ters for writing in
languages other than English, whi
h are shown in Appendix Table 29 e.g.,
?`) and \aa). In some
ases, these are not su
ient, parti
ularly if the
entire do
ument is to be in a non-English language. For that purpose there
are some pa
kages (available free of
harge), su
h as Babel [1 (also see [5,
Chapter 9).
2.5 Tabbing
The tabbing environment provides an alternative to the tabular environment
by letting you set your own
olumn tabs. Table 4 shows a simple
ase with
two basi
tabbing
ommands, \= to dene a tab setting, and \> to move
to a tab setting. In addition, \\ ends ea
h row, but unlike the tabular
2.5 Tabbing
25
What you write
\"{a}
\`{e}
\'{i}
\~{o}
\^{u}
)
)
)
)
)
: : : set tab 2
then to 2
skip to 2
\begin{tabbing}
Begin: \=set tab 1\dots \=set tab 2\\
\>skip to 1
\>then to 2\\
\>
\>skip to 2
\end{tabbing}
\begin{tabbing}
1-3 \= sting like a bee \\
4-6-8 \> don't be late \\
\end{tabbing}
\begin{tabbing}
4-6-8 \= don't be late
\kill
1-3 \> sting like a bee \\
4-6-8 \> don't be late
\\
\end{tabbing}
2 TEXT
26
Last eld
Last eld on new line
is
27
break where you want a blank, use the spa
e
hara
ter ~. We would thus
write figure~1 or p.~10.
There are two
ommands to for
e a page break: \pagebreak and \newpage.
The \newpage
ommand follows the analogy with \newline in for
ing a page
break pre
isely at the point it is spe
ied, rather than
ompleting the line as
\pagebreak does. The \nopagebreak
ommand disallows a page break immediately following the next blank line. The \samepage
ommand prevents
a page break within its s
ope. Here is an example that keeps line 1 on the
same page as line 2.
{\samepage
line 1
\nopagebreak
}
line 2
) I insert .3 in
here.
The \hspa
e
ommand has no ee
t at a line boundary, but the \hspa
e*
inserts the spa
e no matter what. For example, the previous
senten
e is written as:
The \verb|\hspa
e|
ommand has no effe
t at a line boundary, but
the \verb|\hspa
e*| \hspa
e*{1in} inserts the spa
e no matter what.
That is why you see the 1 in
h spa
e at the beginning of the se
ond line.
\hspa
e would not insert the 1 in
h, but \hspa
e* does.
Two variations of \hfill are:
\dotfill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
\hrulefill
Analogously, verti
al spa
ing is
ontrolled by \vspa
e, \vspa
e* and
\vfill. The height of one line of normal text is in the keyword \baselineskip ,
2 TEXT
28
so vspa
e{\baselineskip} skips one line at the next new line. The verti
al
spa
e is not added if this goes to the top of a new page; that is what \vspa
e*
does. In parti
ular, at the very beginning of your do
ument, if you want to
make your own title page, you use \vspa
e*{2in} to put a 2 in
h margin at
the top (\vspa
e would not insert the spa
e).
The easiest way to
ontrol line spa
ing throughout your do
ument is to
spe
ify usepa
kage{setspa
e} in your preamble.
This gives you three
ommands:
\singlespa ing
\onehalfspa ing
\doublespa ing
Right after you spe ify one of these, that spa ing will ommen e.
Exer ises.
Submit a printed
opy of both the LATEX sour
e (tex le) and
the asso
iated posts
ript result (ps le). Be sure your name is on ea
h.
1. Write a paragraph in arti
le [and letter style with the following properties:
(a) Ea
h font style in Table 1 is used as one letter in a word that has
more than one letter.
(b) Ea
h font style in Table 1 is used for one
omplete word.
(
) Ea
h font style in Table 1 is used for two
onse
utive
omplete
words.
2. Write two paragraphs in arti
le [and letter style with ea
h of the following properties:
(a) Default indentation on both paragraphs.
(b) No paragraph is indented.
(
) Both paragraphs are indented.
(d) There is added spa
e between paragraphs.
3. Write a paragraph in arti
le style and make a
over page with the
following properties (like the
over page of this do
ument):
29
Your name appears se
ond in letters that are not as large as the
title, but larger than normal size, and it is pre
eded by extra spa
e.
Your e-mail address appears third.
Your web address appears fourth.
Course number and title appears next, with extra spa
e pre
eding
it.
Date appears last, with extra spa
e pre
eding it.
4. Give an enumeration of at least three things you like about mathemati
s. Give the same list without numbers.
5. Produ
e the following table:
Colors
Primary Se
ondary
Red
Green
Blue
Orange
Yellow
Purple
6. Produ
e the following table (in
luding the a
ents and alignments).
Birth Death
Mathemati
ian
Gabrielle Emilie Le Tonnelier
de Breteuil Marquise
du Chtelet
1706 1749
Benjamin Banneker
1731 1806
Sophie Germain
1776 1831
Julius Knig
1849 1913
Rzsa Pter
1905 1977
7. Produ
e the following table.
Player A
1 2
4 5
3
6
Payos ($)
Player B
1
3
5
2
4
6
3 BIBLIOGRAPHY WITH
30
BIBTEX
8. How
an you have an entire table whose
olumns are of xed width?
9. Create a 3-
olumn text su
h that ea
h
olumn is a paragraph of arbitrary length using about 13 of the page width ea
h.
10. Use the tabbing environment to produ
e the following:
apples
integral derivative
grapefruit sum
dieren
e
variables
onstants
11. Use the tabbing environment to produ
e what you see on page 33.
12. Produ
e the following:
rate of mass
net rate of mass
a
umulation
entering the
=
in the
ompartment by
ompartment
onve
tion
Bibliography with
net rate of
+ mass entering
by diusion.
BibTEX
3.1 Overview
It might seem strange to have this se
tion so early, instead of with 7.4. That
is be
ause I require students to produ
e an annotated bibliography early in
the semester, and I want them to use BibT X. So here we are.
BibT X [11 was developed by Oren Ptashnik and is available free of
harge. It reads a plain text le,
alled a bib le (plus one of the les
reated by the latex
ompiler, about whi
h you need not be
on
erned). The
bib le
ontains the bibliographi
database, whi
h
ould extend beyond one
do
ument. The bibtex program that you apply to your sour
e
reates another
le (whi
h you need not examine), from whi
h a se
ond latex
ompilation
auses the bibliography to be
reated. The exe
ution looks like this (same
under unix and DOS):
31
latex myfile
bibtex myfile
latex myfile
You might have to
ompile with latex more times, until you do not have
any unresolved bibliography
itations. On
e this is su
essful, you do not
have to bibtex myfile again until you
hange your bib le or add a
itation.
This added loop is illustrated in Figure 31.
reate/edit
myfile.tex
ompile
with
latex
view/print
myfile.dvi
onvert
with
dvips
print/post
myfile.ps
bibtex
Figure 31: Adding bibtex to the Command Sequen
e
Main body
For purpose of this introdu
tion, suppose your bibliography is in a le
alled
mybiblio.bib, but that name is arbitrary as long as it ends with .bib. We
begin with the most important part of your bib le, whi
h are the entries
you want to in
lude in its database. Ea
h entry has the following form:
type {label ,
eld = "value ",
..
.
3 BIBLIOGRAPHY WITH
32
BIBTEX
arti
le{tex,
author = "Donald E. Knuth",
title
= "The {\TeX} Book",
publisher = "Addison-Wesley Publishing Company",
address = "Reading, MA",
year
= "1989",
edition = "15th",
}
Most authors develop a style to labelling bibliographi
entries. The use
of one keyword is somewhat simplisti
and
ould
ause problems with a
great number of entries be
ause the labels must be unique. We
annot, for
example, have two entries with tex as their label. Here are two styles I have
seen, whi
h you might
onsider:
Form
author .year
author :rst_keyword_in_title
Example
knuth.89
knuth:tex
With two authors, you
an put both of their names; with more than 2,
you
an add et al. (Linguisti
ally, the use of the Latin et al. in formal writing
follows this rule.) In the rst form, if there are two publi
ations by the same
authors in the same year, some people add a, b, : : : after the year (no blank).
In the se
ond form, if there are two publi
ations by the same authors in the
same year, some people add another keyword. You must dis
over what style
works best for you.
Before listing ea
h style (arti
le is one style) and the elds they
an or
must have (author is one eld), here are a few things to note.
The label is arbitrary, but do not use any LATEX spe
ial
hara
ters or
blanks. In the example, the label is spe
ied as tex and it must be
followed by a
omma. Also, labels are
ase-sensitive, so tex is not the
same as TeX.
Ea
h bib entry must have a unique label, so it
an be
ited without
ambiguity in the sour
e le.
33
The order of the elds is arbitrary, and elds are separated by
ommas
(hen
e the
omma after the terminal quote). The last eld does not
require a
omma at the end, but it will not hurt anything, and it gives
exibility if you want to add a eld or
hange the order.
Fields do not have to be on separate lines, but it is more readable that
way.
The eld value an be anything re ognized by LATEX, even mathemati al symbols in math mode.
: : : }.
Remember to put ea
h author's name as rst last or last, rst. If you put
Knuth Donald, the
ompiler will think the rst name is Knuth and the last
name is Donald.
Here is a list of standard entry types with their required elds. What are
optional elds in BibT X are not ne
essarily optional as far as having a
omplete bibliography
itation. For example, the volume and page numbers
of an arti
le are ne
essary to in
lude even though they are optional to satisfy BibT X syntax. (What is ne
essary depends upon the standard one
applies, but most journals require the volume of the journal and the page
numbers for the
ited arti
le.) Fields that are neither required nor optional
are ignored, even if they are valid elds in other types of entries.
34
3 BIBLIOGRAPHY WITH
BIBTEX
month.
in
olle
tion is a part of a book having its own title.
Required elds: author, title, booktitle, publisher, year.
Optional elds: editor, volume or number,
hapter series,
type, pages. address, edition, month.
inpro
eedings is an arti
le in a
onferen
e pro
eedings.
Required elds: author, title, booktitle, year.
Optional elds: editor, volume or number, series, pages,
month, organization, publisher, address.
manual is some te
hni
al do
umentation.
Required elds: author or key (see note below). title.
Optional elds: author, organization, address, edition,
month, year.
mastersthesis is a Master's thesis.
Required elds: author, title, s
hool, year.
Optional elds: type, address, month.
mis
is when nothing else ts.
Required elds: author or key (see note below).
Optional elds: author, title, month, howpublished, year.
phdthesis is a PhD thesis.
Required elds: author, title, s
hool, year.
Optional elds: type, address, month.
pro
eedings
Required elds: title, year.
Optional elds: editor, volume or number, series, publisher,
organization, address, month.
te
hreport is a report published by some institution.
Required elds: author, title, institution, year.
Optional elds: type, number, address, month.
unpublished is a do
ument with an author and title, but not formally
published, even as a te
hni
al report. (Some note of explanation is
required.)
Required elds: author, title, note.
Optional elds: month, year.
In addition to the optional elds listed, whi
h vary by the type of entry,
the note eld is always an option. This lets you enter a note that will appear
at the end of the
itation. To have a
omment that is not printed, enter an
35
When there are multiple authors, we separate them with and (no ommas). For example, [5 in this do ument has the following BibT X entry:
Book{
ompanion,
author
= "Mi
hel Goosens and Frank Mittelba
h and
Alexander Samarin",
title
= "The {\LaTeX} Companion",
publisher = "Addison-Wesley Publishing Company",
address
= "Reading, MA",
year
= "1994",
}
The use of the bra
es in {\LaTeX} is to tell the bibtex program to take
everything inside just as it is written (for the latex program to pro
ess).
Otherwise, the bibtex program might try to pro
ess it itself and produ
e an
unintended result. This applies to a
ents too. In ordinary LATEX, we write
G\"{o}del to produ
e Gdel, but this will not work in BibT X. Instead,
we write G{\"{o}}del, or simply G{\"o}del.
3 BIBLIOGRAPHY WITH
36
BIBTEX
The use of bra
es to for
e a parti
ular result is ne
essary in other instan
es, su
h as writing {F}ourier analysis to for
e the
apital F; otherwise, the bibtex program will produ
e `fourier analysis' (the plain style
produ
es arti
le titles in lower
ase, ex
ept the rst letter of the rst word).
Some authors, however, use this feature inappropriately by putting bra
es
around everything. That defeats one of the primary advantages of using
LATEX and BibT X in the rst pla
e: we want to let the style les determine the nal form, so we
an swit
h styles and use the same sour
e (tex
and bib les).
Here is an example:
book{Strunk,
author = "William Strunk{, Jr.}",
title = "Elements of Style",
publisher = "World Wide Web",
address = "http://www.
olumbia.edu/a
is/bartleby/strunk/",
year
= "1999",
note = "This is the web version of the
lassi
book by
Strunk and White~\
ite{StrunkWhite}",
}
37
parti
ular, ~ is in many urls, and writing it will produ
e a spa
e, not the
tilde. Also, a url
ould be
ome very long, and with latex having no pla
e to
break, you will see a line with lots of spa
es (for justi
ation), followed by
the url. An unsightly line with spa
es
ould also appear after the url. These
di
ulties are over
ome by spe
ifying:
address = "\url{http://www.
olumbia.edu/a
is/bartleby/strunk/}",
For example, this book spe
ies the sans serif font:
\usepa
kage{url}
\renew
ommand\url{\begingroup\urlstyle{sf}\Url}
There are o
asions when we want to referen
e an entire web site. One
example is the LATEX 2" referen
e [2, given by:
mis
{latex2e,
author = "Johannes L. Braams and David P. Carlisle and
Alan Jeffrey and Frank Mittelba
h and Chris Rowley
and Rainer S
h{\" o}pf",
title = "{\LaTeXe} and the {LaTeX}3 Proje
t",
howpublished = "World Wide Web,
\url{http://www.latex-proje
t/org/latex3.html}",
year
= "1994",
}
We have seen several pa
kages so far, and you shall learn more about
pa
kages in 6, where I des
ribe enhan
ements for having graphi
s in LATEX.
However, this is the rst use of \renew
ommand, about whi
h I shall say more
when I des
ribe ways to
ustomize your do
ument in 8.
3 BIBLIOGRAPHY WITH
38
BIBTEX
Then, we
an refer to the string anywhere in the value of a eld by ex
luding the quotes. (That is why we needed the quotes before, when we wrote
literals.)
For example, suppose we dene:
string{kluwer = "Kluwer A
ademi
Publishers"}
Then, we
an enter:
publisher = kluwer,
Note the absen
e of a spa
e between the string values in the title. To ensure
a spa
e, use the spa
e
hara
ter, ~, as a literal:
39
Another useful feature of BibT X is the
rossref eld for
ross referen
ing. For example, suppose we have the following entry (kluwer is a string;
the other values are literals):
Pro
eedings{Byrnes:FAA-89,
editor
= "J.S. Byrnes and Jennifer L. Byrnes",
title
= "Re
ent Advan
es in {F}ourier Analysis and its
Appli
ations: Pro
eedings of the {NATO}
{A}dvan
ed {S}tudy {I}nstitute",
publisher = kluwer,
year
= 1990,
}
If these were the only referen es, the result would appear as follows:
[1
[2
3 BIBLIOGRAPHY WITH
40
BIBTEX
Preamble{ string }
where string is any
on
atenation of literals and strings. Here is an example [11 that is useful for guiding the sorting of referen
es in a spe
ial
ir
umstan
e:
Preamble{ "\new
ommand{\noopsort}[1{}" }
The \new
ommand is something I shall des
ribe more fully in 8. For now,
it is used to dene a
ommand, \noopsort, requiring one argument. Command \noopsort ignores the argument that it re
eives, produ
ing nothing
(indi
ated by {}). Here is how this
an be used.
Suppose there is a 2-volume work by the same authors, originally published 1971, but a se
ond edition of volume 1 is printed in 1973. The bib
entries would have the years in the opposite order than we want be
ause
sorting is rst by the authors, whi
h are the same, then by year. To for
e
the rst volume to sort before the se
ond, we fool the bibtex program with
the following spe
i
ations:
Volume 1
year = "{\noopsort{a}}1973",
Volume 2
year = "{\noopsort{b}}1971",
This fools the bibtex program into thinking the years are a1973 and b1971,
thus putting volume 1 rst. The denition of \noopsort, however, does not
a
tually print the letters, so just the years appear.
\bibliography{mybiblio}
\bibliographystyle{plain}
The rst de
lares the bibliography to be in the bib le, mybiblio.bib.
The se
ond
ommand denes the format style of the bibliography to be
plain, whi
h
omes with every installation of latex. There are other bibliography format styles, in
luding some provided by publishers. Here is a list
of the most basi
ones (in
luded in every installation):
41
3 BIBLIOGRAPHY WITH
42
BIBTEX
Exer ises. Submit a printed opy of the LATEX sour e (tex le), the BibTE X
data (bib le), and the asso
iated posts
ript result (ps le). Be sure your name is
on ea
h.
1. Produ
e a do
ument with one paragraph that
ites three bibliographi
items,
one for ea
h of the following types:
(a) An arti
le in a journal.
(b) An entire book with at least three authors.
(
) A
hapter in a book.
(d) A te
hni
al report.
2. Produ
e a do
ument that lists your entire database, whi
h
onsists of at
least one entry for ea
h of six dierent do
ument types. Further, at least one
entry must have more than two authors.
3. Produ
e a do
ument with one paragraph that
ites three bibliographi
items,
one for ea
h of the following types:
(a) A te
hni
al report on the web.
(b) A book on the web.
(
) An entire web site.
4. Produ
e a do
ument that has only a bibliography
omposed of the following
three entries (in the order shown).
[1
I.M. Ri
h, editor.
1999.
[2
I.M. Ri h, editor.
[3
43
5. Produ
e an annotated bibliography of the following form (note the indentations on left and right margins):
[1
P.R. Halmos,
[2
G. Polya,
1945.
How To Solve It, Prin eton University Press, Prin eton, NJ,
44
\S\ref{subse
:bibfile}
\S\ref{subsubse
:web
ite}
) 3.2
) 3.2.2
) p. 36
) p. 31
For any
ounter, \pageref{
ounter }, gives the page number where its label is
dened, just as \ref{
ounter } gives its value. (Re
all from p. 26 that ~ is used to
have a spa
e without a linebreak, whi
h is an element of good style.)
Equation (6), page 68, was labelled \label{eqn:hessian}, so in this senten
e
I wrote its number by \ref{eqn:hessian} (with parenthesis added) and its page
number by \pageref{eqn:hessian}. In the exer
ise to list what you like about
mathemati
s, I entered the label \label{exer:likeaboutmath} (page 29), whi
h
I
an now referen
e as exer
ise #4 by writing \#\ref{exer:likeaboutmath}.
The
hoi
e of label, su
h as subsubse
:web
ite, is any string you want to use
that does not
ontain embedded blanks or spe
ial
hara
ters used by LATEX. In
my
hoi
e of label, I used the stru
ture prex :name. That is a matter of style,
and I used the prex subse
here. This helps me to distinguish labels for dierent
things. For equations, I use the prex eqn. Some people use this same form but
with dierent prexes, su
h as ss for subse
tion and e for equation. You
an
hoose
any labeling
onvention that is meaningful to you. (If you have a lot of labels and
need to keep tra
k of them by printing ea
h label and
itation in your drafts, see
the showkeys pa
kage at CTAN [4.)
45
\begin{figure}[options
[\
aption{
aption [\label{label }}
..
.
\begin{table}[options
[\
aption{
aption [\label{label }}
..
.
The
aption, if present,
an go at the top or bottom; where you put it is where
it will appear. The label to referen
e a gure or table is put inside the
aption.
(If you put it outside the
aption, as given in [9, it will not be understood, even
though you will get no error message.)
Be
ause gures and tables are not split, their exa
t lo
ation depends upon how
mu
h room there is. For that reason they are
alled oating obje
ts, or oats.
The environment options dene where the oat is to be lo
ated. The four
hoi
es
are shown in Table 6. In this do
ument most tables and gures are spe
ied with
[ht, whi
h means they are to be pla
ed here, the pla
e where it is spe
ied in
the sour
e, if possible. If there is not enough room, it is to be lo
ated at the top
of the following page.
Option
h
t
b
Meaning
Lo
ate here (where the environment is de
lared).
Lo
ate at the top of the next page.
Lo
ate at the bottom of the page (or the next page,
if this page does not have enough room).
Lo
ate on a separate page,
alled a oat page,
whi
h has no text, only gures and tables.
Table 6: Figure and Table Lo
ation Options
The pla
ement of a oat is sometimes a sour
e of frustration. We might spe
ify
[ht and nd the oat in an unexpe
ted pla
e, perhaps on a page by itself. One
ause
ould be an a
umulation of oats that should be
leared at some point
before
ontinuing. This is done with the \
learpage
ommand. This does the
same as \newpage, ex
ept that it also prints all remaining oating obje
ts. It
is also advisable to spe
ify \usepa
kage{float} in the preamble. One of the
enhan
ements is the pla
ement option: [H, whi
h insists that the oat be pla
ed
here (note the
apital H and no other option spe
ied). This option is used in many
pla
es in this book, whi
h is why you sometimes see pages with some blank spa
e
46
in the lower portion, followed by a gure or table. I did this to avoid
onfusion by
having some oat appear pages after it is
ited and dis
ussed.
The table environment is not to be
onfused with the tabular environment.
The latter makes tables, but the table environment does not have to
ontain a
table; it diers from a gure only in its name, and they have separate
ounters.
The gures and tables in this do
ument appear as the form:
Figure
That's it.
As a matter of style, we generally use the gure environment to present what
we usually think of as gures, notably pi
tures, and we generally use the table
environment to present information in tabular form. However, neither of these
onditions is ne
essary for their LATEX environments.
Floats
an be framed, using the \fbox
ommand. For example, Figures 33 and
34 illustrate how to frame a gure with a thi
k border.
\begin{figure}[ht
\begin{
enter}
\setlength{\fboxrule}{3pt} % make border lines thi
k
\setlength{\fboxsep}{.2in} % in
rease distan
e to border
\fbox{ This is a framed figure. }
\end{
enter}
\
aption{Framed Figure with Caption at Bottom \label{fig:fboxbottom}}
\end{figure}
47
48
sets the value of my
ounter to the
urrent page number (value of the intrinsi
ounter, page).
When using a
ounter for some non-intrinsi
sequen
e, we want to be able to
label it for future referen
e. This is done with the \refstep
ounter
ommand,
whi
h also in
rements its value. For example, to in
rement my
ounter by 1 and
establish a label to its value at the pla
e this is done, write
(i), (ii),
:::
This
an be used for intrinsi
ounters too. For example,
onsider the enumerate
list environment, where the types of numerals for the four levels are: arabi
, alph,
roman and Alph. We
an
hange these to be any type we want, su
h as illustrated
in Figures 36 and 37.
\renew
ommand{\theenumi}{\Roman{enumi}}
\renew
ommand{\theenumii}{\Alph{enumii}} %
hanges numeral type
\renew
ommand{\labelenumii}{\theenumii.} %
hanges appearan
e
\begin{enumerate}
\item Introdu
tion
\item Terms and Con
epts
\begin{enumerate}
\item Groups and fields
\item Pi
ni
s and froli
\end{enumerate}
\end{enumerate}
49
I. Introdu
tion
II. Terms and Con
epts
A. Groups and elds
B. Pi
ni
s and froli
Figure 37: Alternative enumerate Symbols Result (Sour
e in Figure 36)
What
hanges
numeral
label
numeral
label
numeral
label
numeral
label
Counter
enumi
enumii
enumiii
enumiv
Command
Exer ises.
Submit a printed
opy of the LATEX sour
e (tex le) and printed
opy of the asso
iated posts
ript result (ps le). Be sure your name is on ea
h.
1. Write a do
ument with at least two pages and two se
tions. Put an enumerated list of items near the beginning of your do
ument, and use the \ref or
\pageref
ommand to referen
e ea
h of the following.
(a) Referen
e 2 by a label that you assign to se
tion 2 (make whatever
label name you like).
(b) Somewhere near the end of your do
ument referen
e the page number
of the rst se
tion.
(
) Referen
e item #2 of your enumerated list.
5 MATH MODE
50
2. In
lude two tables and gures in your do
ument, and referen
e them by label.
Also referen
e the page that they appear.
3. Produ
e Figure 35.
4. Produ
e lists using the enumerate environment with the following appearan
e:
1.
2.
:::
1.1
1.2
:::
:::
2.1
2.2
:::
:::
:::
Math Mode
One
an write mathemati
al expressions by entering math mode, signied by delimiters $ : : : $ or \[ : : : \. The $ delimiter keeps the mathemati
al expression
in the text, like this:
E = m 2 :
x^{ +d}_{a+b}
) x a++db
Operation Symbol
subs
ript
_
supers
ript ^
multiply
\times
divide
\div
51
Example
How it appears What you write
x3
x_3
3
x
x^3
ab
a\times b
ab
a\div b
A\not\subseteq B
x\not\in A\
up B
A\setminus B\not\supset B
What it is
empty set
interse
tion
union
set minus
element in
subset (proper)
subset or equal
superset (proper)
superset or equal
) A 6 B
) x 26 A [ B
) A n B 6 B
How it appears
;
\
[
n
2
xy
5 MATH MODE
52
would remain bold, even when leaving and re-entering. The following illustrates
this, where B [ C is boldfa
e in the rst
ase, and returns to normal style in the
se
ond
ase.
) A B text B [ C
) A B text B [ C
Within math mode, we
an
ontrol the font style of letters with the
ommand,
\mathfont {expression }, where font is one of: {bf,
al, it, normal, rm, sf,
tt} (analogous to the ntextfont
ommand, p. 9). Unlike \boldmath, this applies
only to letters, digits and a
ents, but not to spe
ial mathemati
al symbols. For
example,
) A~ ~1
2
) A~ ~1
2
Font Style
boldfa
e
alligraphi
itali
normal
roman
sans serif
typewriter
Command
\mathbf
\math
al
\mathit
\mathnormal
\mathrm
\mathsf
\mathtt
Example Result
~ ~1
2
A
A~ 1
~
2
~
~
A1
2
A~ ~1
2
A~ ~1
2
~ ~1
2
A
~
A ~1
2
The
alligraphi
style applies only to
apital letters,
ausing unintended results
when applied to other symbols, as shown in Table 11. The
alligraphi
alphabet
looks like this (and it is available only in math mode):
Greek letters are dened only in math mode, and they are spe
ied by spelling
them as keywords. For example, to produ
e
=
53
A=
x2 + y
;
1 + x2+1
5 MATH MODE
54
Operation
How it appears
P
sum
n
X
i=1
R
integral
Z b
a
parentheses
\sum
xi
\sum_{i=1}^n x_i
\int
f (x) dx
()
1+y
fg )
(
bra es
X
i
bra kets
Z 1
0
xi
\int_a^b f(x)\,dx
\left( \right)
\left(\fra
{x}{1+y} \right)
\left\{ \right\}
\left\{\sum_i x_i \right\}
[
f (x) dx
\left[ \right
\left[\int_0^\infty f(x)\,dx\right
55
\[ \sqrt{\fra
{\displaystyle
\prod_{n=1}^N \left( \sum_{i\in I_n} x_i^n\right)}
{\sqrt[3{\displaystyle\sum_{i\in I_\infty} x_i}}
}
\
Appearan e
What to write
in text mode
What to write
in display mode
\fra {x}{2}
\textstyle\fra {x}{2}
\displaystyle\fra {x}{2}
\fra {x}{2}
\max_{x\in X}
\textstyle\max_{x\in X}
\displaystyle\max_{x\in X}
\max_{x\in X}
2
maxx2X
max
x2X
(x 2 A ) x 2 B ) , (A B ):
5 MATH MODE
56
Logi
al Term
existential quantier
universal quantier
negation
disjun
tion
onjun
tion
impli
ation
equivalen
e
su
h that
\forall x
\exists y
\forall x\, \exists y
\forall x\; \exists y
) 8x9y
) 8x 9y
) 8x 9y
(There are other spa
ing
ommands, in
luding negative spa
ing, shown in Appendix Table 36.)
Table 14 shows some relations for ordered sets (besides those on the keyboard:
< = >). Here are some examples:
) ( 1; 0 = fx 3 x 0g
) a j bi bi a j
) 8y fx : x 6 yg 6 A
57
How it appears
6=
xi < 0foralli = 1; : : :
xi < 0 for all i = 1; : : :
xi < 0 for all i = 1; : : :
The rst line points out that blanks mean nothing in math mode, and all letters
are in the math form of itali
(not quite the same as the itali
in text mode). The
use of \mbox is parti
ularly
onvenient in math display mode, whi
h I shall illustrate
in the next se
tion.
\end{array}
The
olumn spe
i
ations and options are the same as in the tabular environment,
but the body is in math mode. The following table has text headers and math
body, so it
an be generated in either of two ways: with the tabular environment,
using the math mode designation for ea
h body entry: $ : : : $, or with the array
environment, using \mbox for ea
h header entry.
Variable Current Value
x
y
1:234567
9:87
Limit
1
12:2
5 MATH MODE
58
This
an be generated by either of the following two ways:
\[\begin{array}{
}
\mbox{Variable} & \mbox{Current Value} & \mbox{Limit} \\ \hline
x
&
1.234567
&
1
\\
y
& -9.87
& -12.2 \\ \hline
\end{array}
\
or
\begin{
enter}
\begin{tabular}{
}
Variable & Current Value & Limit \\ \hline
$x$
& $ 1.234567$ & $ 1
$ \\
$y$
& $-9.87
$ & $-12.2 $ \\ \hline
\end{tabular}
\end{
enter}
x = 5:2
y = 2:5
z = 7:7 (= x + y)
The above was produ
ed by the following use of math display mode (whi
h is
always
entered):
\[ \begin{array}{l
l}
x &=& 5.2 \\
y &=& 2.5 \\
z &=& 7.7 \; (= x+y)
\end{array}
\
The \; spe
ies a spa
e; otherwise, 7.7 (= x+y) ) 7:7(= x + y ).
Another environment is eqnarray. This is like a 3-
olumn array with spe
i
ations {l
l}, as above, but ea
h row is numbered:
x = y
y = z
(1)
(2)
59
\begin{eqnarray}
x &=& y
\label{eqn:xy} \\
y &=& z
\label{eqn:yz}
\end{eqnarray}
The \label statements are to illustrate that we
an referen
e these by writing
(\ref{eqn:xy}) to produ
e (1) and (\ref{eqn:yz}) to produ
e (2). (Note that
\ref gives just the number; parentheses are added.)
The relation need not literally be an equation; anything
ould be used for the
middle
olumn. Further, there are times when we need to use more than one line
for an `equation,' in whi
h
ase we need to suppress the numbering of all but one
of the rows. Figures 43 and 44 give an example. The \nonumber
ommand
auses
no number to be assigned to the rst part of the se
ond equation.
\begin{eqnarray}
x &\mbox{is equal to}& y \\
y & \pre
eq & \fra
{a+b+
+d}{\Psi} + \fra
{e+f+g+h}{\Phi}
+ \nonumber \\
&
& I+K+J+L
\end{eqnarray}
x is equal to y
a+b+
+d e+f +g+h
y
+
+
I +K +J +L
(3)
(4)
5 MATH MODE
60
(ex
ept that
olumn separators (&) are not used in the equation environment).
Analogous to eqnarray*, there is the equation* environment, whi
h suppresses the
equation numbering. To illustrate, Figures 45 and 46 show how to present a matrix
equation. Also, note how x0 is spe
ied. Table 15 shows other ways to denote the
transpose of a ve
tor.
)
)
)
)
)
How it appears
x0
xt
xT
xT
xT
Ax0 =
0
x1
x2
x3
1
A:
61
\[ \left[ \begin{array}{
|
}
\begin{array}{
} A_{11} & A_{12} & A_{13} \\
A_{21} & A_{22} & A_{23}
\end{array}
& 0 \\ \hline
0 & \begin{array}{
} B_{11} & B_{12} \\ B_{21} & B_{22}
\end{array}
\end{array} \right
\
6
6
4
0
B11 B12
B21 B22
3
7
7
5
\fbox{$ \begin{array}{l
l}
\displaystyle\int_0^\infty xe^{-\tau x}\,dx
&=& \displaystyle\fra
{1}{\tau} \\ \\
&=& \displaystyle\oint_a^{b+
} \Psi(x)\,dx
\end{array}
$}
Z
xe
x dx
=
=
1
I
b+
(x) dx
5 MATH MODE
62
an undesirable
lash. This
ould be over
ome by putting a verti
al spa
e
ommand
just after the expression. In parti
ular, putting \vspa
e{.2\baselineskip} after
x = y + z
auses extra verti
al spa
e equal to 20% of the value of \baselineskip,
whi
h is the height of one line of normal text. (In the longrun, it is better to use
parameters, like \baselineskip, rather than absolute measurements for spa
ing,
be
ause the former takes into a
ount the font size, whi
h you might
hange.)
Now
onsider the following
onditional assignment:
f (x) =
8
<
:
1
0
1
if
if
if
x < 0;
x = 0;
x > 0:
63
}|
i:::j + k l
e
x
y ab
| {z }
This dieren
e
has an underbra
e
Figure 50: Horizontal Bra
es Result (Sour
e in Figure 49)
We often need to mix mathemati
al notation and text. We
ould use the
tabular environment and spe
ify in-line math mode where needed (with $), or we
ould use the array environment and use either the \mbox or \parbox (see p. 20) to
enter the text. There are, however, some nuan
es to understand. Figures 51 and
52 show the problem with using \flushleft to make the text within the parbox
ush left. (Try it with the default justify and you will see that the spa
ing gives a
poor appearan
e.) The problem is that \flushleft skips a line, whi
h ruins the
alignment (even though [t is spe
ied). The solution is to use the \raggedright
ommand, as shown in gures 53 and 54. In addition, the \raisbox
ommand is
used to lower the small matrix, giving it some spa
e below the horizontal line.
5 MATH MODE
64
Denition
Example
1 0
2
Covarian e
1
2
X2 = X12
P r8
[X1 = x
for
>
>
<
=
>
>
:
1
4
1
2
1
4
and
for
x=
for
x=
for
x=
1:
65
Denition
Aij = E [(Xi i )(Xj j ),
where fXi g are random
variables, and E [ is the
expe
ted value operator with
i = E (Xi ).
Example
1 0
2 1
0 2
for X2 = X12
P r8
[X1 = x
>
>
<
=
>
>
:
1
4
1
2
1
4
and
for
x=
for
x=
for
x=
1:
5 MATH MODE
66
Fun
tion How it appears
limit
lim inf
log
maximum
tangent
lim
lim inf
log
max
tan
How it appears
textstyle
displaystyle
limn!1 xn
lim x
n!1 n
lim infn#0 log xn limn#inf
log xn
0
maxx2X f (x) max
f (x)
x2X
tan( + )
tan(+)
ln x
ln x
$\mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$
For example, the real line is sometimes denoted by R , rather than <, whi
h is
the LATEX spe
ial symbol, $\Re$. Table 18 shows how \mathbb
an be used for
spe
ifying other numeri
al spa
es.
)
)
)
)
67
How it appears
R
C
Z
Q
What it means
Real values
Complex values
Integer values
Rational values
$\maths r{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$
)A BCDE FG H I J K L M N OPQRS T U V W X Y Z
In parti
ular, L is often used to denote the Lapla
e transform or the Lagrangian,
and H is sometimes used to denote the Hamiltonian. (Compare with \math
al,
H, whi
h is also used by some authors.)
r f (x) =
2
2 f (x)
:
xi xj
(5)
5 MATH MODE
68
\[ \begin{array}{lll}
\nabla^2f(x) &=& \left[ \displaystyle\fra
{\partial^2f(x)}
{\partial x_i \partial x_j}
\right.
\end{array} \
There seems to be some
rowding in this dire
t spe
i
ation. Compare with the
following and see if you
an produ
e it:
2 f (x)
:
f (x) =
xi xj
(6)
There are two integral signs: \int) and \oint) , whi
h are both variable
size symbols. For example, note how the outer integral is large in the following
expression:
R
lim
a !1
H
X (v )
H
xef (x) dx
f (x) dx (v ) dv:
X (v) e
1 Z xn Z xn 1
0
x2
write
69
(urv
vru) dS =
Z Z Z
(ur rv
vr ru) d:
The domains of integration, and the spa
ing of the integral signs, are better with
the following, whi
h is not produ
ed by standard LATEX 2" , but by spe
ifying
\usepa
kage{amsmath} in the preamble (see The LATEX Companion [5, p. 223):
ZZ
(urv
vru) dS =
ZZZ
Note how the domains are
entered on the multiple integrals and the spa
ing of
the integral signs.
\newtheorem{theorem}{Theorem}[se
tion
Then, the theorem was produ
ed by the following LATEX
ode:
\begin{theorem}
For $n > 2$, there is no solution to $x^n + y^n = z^n$ for
\newline $x,y,z\in \LZ_{++}$.
\end{theorem}
Other theorem-like environments
an be dened to have the same properties.
This requires both a keyword, like Theorem, and a unique name for the environment,
like theorem, also used as a
ounter. Here is the syntax:
5 MATH MODE
70
\newtheorem{name }{keyword }[within
The name denes the environment name, and it denes a
ounter, so it must be
dierent from all other environment and
ounter names. The within option denes
the
ounter to be within some other, whi
h
an be intrinsi
or some other
ounter
dened by the \new
ounter
ommand (p. 47) or by some other \newtheorem.
In this do
ument, I dened the theorem environment to be numbered within the
se
tion, so you see Theorem 5.1, rather than Theorem 1. To further illustrate,
here is a
orollary environment:
\newtheorem{
orollary}{Corollary}[theorem
Note that this is within the theorem
ounter, whi
h is valid by having been dened
by its own \newtheorem. Then, the above
orollary was written as:
\newtheorem{axiom}{Axiom}
The Axiom of Choi
e
an then be stated thusly:
Axiom 1 From any (innite) family of sets a new set
an be
reated that
ontains
exa
tly one element from ea
h set in the family.
This was
reated by the following
ode:
5.7 Renements
71
\newtheorem{defn}{definition}[se
tion
Then, in the text:
Denition 5.1
The
ir
le on the sphere.
For more ustomization, the theorem pa kage enables a wide range of variations over the font style (among other things).
5.7 Renements
Mathemati
al delimeters, like parentheses and bra
es, must be varied to en
lose some expressions. Whereas \left and \right
ommands adjust the
size of a mathemati
al delimiter to t the en
losed expression, we
an also
enlarge these delimiters ourselves. One way is to pre
ede math mode with a
size
ommand for example,
{\large(}$E=m
^2${\large)}
) (E = m 2 ).
There are, however, delimiter size
ontrol
ommands, whi
h apply to a single
hara
ter: \big, \Big, \bigg, and \Bigg. For example,
5 MATH MODE
72
$\big(E=m
^2\big)$
) E = m 2
The use of text font environments
omes
lose to the
orresponding math
size, (large$big, : : : , Huge$Bigg), but they are dierent, espe
ially the
thi
knesses. This is more evident with the square and angular bra
kets:
$\Big[E=m
^2\Big$
{\Large[}$E=m
^2${\Large}
) E = m 2
)[E = m 2 .
$\bigg\langleE=m
^2\bigg\rangle$
{\LARGE$\langle$}$E=m
^2${\LARGE$\rangle$}
) E = m
)hE = m 2 i.
(a + b)2 = a2 + 2ab + b2
L M " V = H0
A(x) = fy : (y ) = [a2A (x)g
Figure 56: gather* Environment Result (Sour
e in Figure 55)
5.7 Renements
73
a b
d
by spe -
ifying $\left(\begin{array}{
} a&b \\
&d \end{array}\right)$. An alternative is with the amsmath smallmatrix environment: a
db is obtained
by $\left(\begin{smallmatrix} a&b \\
&d \end{smallmatrix}\right)$.
(Note that there are no
olumn spe
i
ations.) This is not equivalent to
pre
eding the array spe
i
ation
with a text size environment; in parti
ular,
a
b
\s
riptsize produ
es
d . While the letters inside the matrix are approximately the smallmatrix size, the spa
ing and parentheses are not the
same.
The amsmath pa
kage has a
ommand to put dots a
ross any number
of
olumns in an array. Its syntax is \hdotsfor[spa
ing {n}, where spa
ing
determines the spa
ing between the dots, and n is the number of
olumns it
spans. For example,
( )
\left|\begin{array}{
}
1 & 2 & 3 & 4 & 5 \\
\hdotsfor{3}
\\
& \hdotsfor{3} \\
\hdotsfor[2{5} \\
\hdotsfor[.5{5} \\
\end{array}\right|
1 2 3 4 5
:::::::
:::::::
::::::::::
:::::::::::::::::
The \sta
krel
ommand lets us put
hara
ters over a relation: For
def
example, n^+\sta
krel{\mathrm{def}{=}n+1 )n+
n
. With more
generality, the \overset and \underset amsmath
ommands enable us to
put any
hara
ters over or under any
hara
ter. For example,
= +1
$\overset{a}{X}$
$\underset{b}{Y}$
$\overset{a}{\underset{b}{Z}}$
) X
) Yb
a
) Zb
5 MATH MODE
74
X
i2I
j 2J
Aij =
X
i2I
j 2J
Aij
5.8 Grammar
75
A
?
?
y
D
! Bx
! C?
?
y
?
?
! E
!F
5.8 Grammar
When writing mathemati
al expressions, people make some
ommon errors.
The general guide is to treat a mathemati
al expression linguisti
ally. In
English this means that every senten
e has a subje
t and predi
ate,
lauses
are separated by
ommas, and phrases are appropriately pun
tuated. Here
are some of the most
ommon elements of grammar to
onsider.
1. Pun
tuate math display mode. The expression usually needs a
omma or period. For example, note the
olon before the display and
the
omma at its end, whi
h is in
orre
t to omit.
A symmetri
rearrangement of a matrix has the following form:
R = P t MP;
where
P is a permutation matrix.
2. Dene before use. As you read arti
les noti
e that those that are
among the most
onfusing are when the authors used a term that is not
dened until pages later. For example, we might see The distinguishing
property of an abelian group is the
ommutivity : : : But a group had
not yet been dened.
3. Referen
e obje
t is lo
ated after the referen
e. For example, a
gure appears after its rst referen
e. LATEX does this automati
ally,
but you might want to take
ontrol over lo
ating gures.
=
( ) =
( )
5 MATH MODE
76
(
B .'
Exer ises. Submit a printed opy of the LATEX sour e (tex le) and of the
asso
iated posts
ript result (ps le). Be sure your name is on ea
h. (Lookup
spe
ial symbols in the Appendix.)
1. Produ
e ea
h of the following in math display mode.
otherwise.
2. Produ e the following in math display mode with the array environment and/or with the eqnarray* environment.
ln ex = x
sinf + 2g = sin
5.8 Grammar
= Pin=i10 xi ) yn+1
(
) yn
(d)
1
X
f (x) =
(e)
x
(f)
77
n=0
Z x2
a
f (n) (0)
yn = xn
xi0
xn
n!
a2 a3
b2 b3
:
x = y mod n def
= x y = kn for some k = 0; 1; : : :
z }| {
~ 1 + ~ 2
x| 2 {z
+ y}3
8. Produ
e ea
h of the following in line with text (that you
ompose) and
in math display mode.
(a)
(b)
?
A
=
fS 2 S : S 62 S g
p
jF Pj
0
B
B
(
)
a11 a12
a21 a22
CB
BC
1
C
C
A
5 MATH MODE
78
(a) q (G) max
(b)
(
)
2
m(GA )
(G); pA 1 if G 6= ;.
A B
0 C
(0; )T = (0; )
=
p Za
3 ( x 13 + a)2 dx;
3
V=
2 0
xT
xT
xT C
= (0; C T x)T ,
maxf0; f (x)=xj g
r+f (x)j = > f (x)=xj
>
>
>
:
minf0; f (x)=xj g
if xj
= aj
if aj
< xj < bj
if xj
= bj
f (x)
12. Produ
e the following: xj .
x=x
(u +uvv)
1 +
2
where
5.8 Grammar
79
E = m 2
y = Ax !b;
where A is an m n matrix and b is an m-ve
tor. Now suppose
y (! ) is spe
ied and we want to nd x.
u+v
v
u + v.
The remaining exer
ises are more di
ult. You are to produ
e the mathemati
al expressions shown in math display mode.
14. The following is tri
ky to get the evaluation expression,
right size and lo
ation.
= (1=22)v 1=4 + 1:
2
d
f (x + tr+ f (x))
dt
t= 1
15. Note the row and
olumn labels outside the matrix.
2
a b d e
1 1
A = 26
6 1
34 0
4 0
t = 12 to be the
0
1
1
0
0
0
1
1
0
1
0
1
13
0 77
05
1
6 GRAPHICS
80
16. Row pointers:
11
12
A = 21 22
rows in 1
rows in 2 (this arrow is
loser to matrix)
12
22
"
A = 11
21
"
olumns
olumns
in 1
in 2
A = 11
21
"
12
22
"
rows in 1
rows in 2
olumns
olumns
in 1
in 2
Graphi s
81
\fbox{left}$\longrightarrow$\fbox{ enter}$\longrightarrow$\fbox{right}
left
! enter ! right
left
enter
right
The % at the end of the rst line is to avoid having a blank between the
enter box and the $\longrightarrow$ that follows it. The rst optional
argument of this \framebox
ommand is the width of the box, given as 2
m
for ea
h box. The se
ond optional argument is the position of the ins
ribed
text: l = left,
=
enter, and r = right.
We
an make the
ontents of a box obey all paragraph
ontrols in text
mode by the \parbox
ommand. By itself, it lets us sta
k short phrases,
top
like middle (note how the paragraph spa
ing adjusts). Combined with
bottom
\framebox, we
an
reate verti
al diagrams easily, as illustrated in Figures
59 and 60.
\begin{
enter} \parbox{2
m}{
\framebox[2
m{top}
\\ \
enterline{$\downarrow$} \\
\framebox[2
m{middle} \\ \
enterline{$\downarrow$} \\
\framebox[2
m{bottom}
} \end{
enter}
6 GRAPHICS
82
top
middle
bottom
Figure 60: Verti
al Diagram Result (Sour
e in Figure 59)
ontrol over positioning. A basis for this is the pi
ture environment. To
begin, Figure 61 shows a more elaborate
hart, whi
h was
reated by the
pi
ture environment, whose sour
e is shown in Figure 62. Going through its
parts will serve to explain the various
ommands.
top left
m?
enter
a
b
bottom right
ZZ
Z
-~Zoval
( )
ph
83
\put(0,0){\ ir le*{.1}}
The next three
ommands put three dierent kinds of boxes, ea
h beginning at .5 in
hes below the origin (i.e., y
: ). The rst is similar
to \framebox in text mode, but its syntax is dierent. In pi
ture mode it
enables
ontrol over not only the width, but also the height, and this extends
the position options to a se
ond
hara
ter: t = top; b = bottom. The general
form of the \framebox
ommand in the pi
ture environment is as follows:
= 5
In the example shown in Figure 62, the spe
i
ations are width = .7 in
hes
and height = .3 in
hes; the position is
entered be
ause that is the default.
The next \put puts a dashed box, having the same dimensions as the
framed box, with the length of the dash set to .01 in
hes. The next dashed
6 GRAPHICS
84
box has the dash length set equal to .1 in
hes, resulting in fewer dashes to
ompose the box. The box length is set to 1.2 in
hes, and the text is at the
bottom right be
ause of the optional spe
i
ation, [br.
Now we
ome to the \
ir
le spe
i
ation, lo
ated at
oordinates : ;
(from \put), with diameter = .2 in
hes. The 1 inside the
ir
le required another \put, and some trial and error was needed to establish its position. We
know the
enter of the
ir
le is at : ;
, but that is not where we want
to put the ins
ribed text to be
entered. Unlike the box family, we
annot
in
lude the
entering of text within the
ir
le
ommand. The same applies
to the \oval spe
i
ation, followed by putting text that required some trial
and error to lo
ate. The oval, itself, has dimensions : : (in
hes), where
.5 measures the entire width:
( 65 1)
( 65 1)
5 25
'
&
width
$
6
- height
?
%
After the \oval spe
i
ation, I use the \fbox
ommand. This is the same
as I used in text mode, ex
ept here I use it to frame an array, dened as usual
in math mode: the array has three rows and one
olumn, whi
h is
entered.
Now the
ode begins to draw the ve
tors, whi
h are lines with arrow
heads. Both \ve
tor and \line have the same syntax:
\line(x,y ){len }
=0
If x
, the line is verti
al, and len is the amount of
hange above or below
the original point (it does not matter what the magnitude of y is; only its
sign matters). If y
, the line is horizontal, and len is the amount of
hange to the right or left of the original point (it does not matter what the
magnitude of x is; only its sign matters). Otherwise, if x 6
, the a
tual
=0
=0
y
hange in x is still len, and the slope of the line is x . This is undoubtedly
onfusing, so
onsider Figure 63. The new point is determined by moving
y
from (x0 ; y0 ) along the line with slope x until the new x-
oordinate is
y . The a
tual length of
x0 + len. Then, the new y -
oordinate is y0 + len
x
r
2
y
the line segment is len 1 + x .
85
y0 + y
slo
pe
xy
y
y0 + len
x
New
point
Original
point
y0
x0 + len
x0
x0 + x
(
y =
1
1
=0
if yt > y0
otherwise.
( ) = ( + 1 3 + 1 5)
=13
= 13
15
losest we
ould
ome is 45 .
Fixing len = xt x0 , then sear
hing for a nearest slope approximation,
is not ne
essarily the best overall approximation. We
ould setup a leastsquares estimation problem, but trial and error in sele
ting the parameters
tends to be just as e
ient. Either way, we have some work to do.
The rst \ve
tor
ommand in Figure 62 starts at
: ; , whi
h I
al
ulated to be from the top left box to the
enter box.
( 65 1)
86
width
6 GRAPHICS
height
( 1 5)
= 3
= 35
( 3 5 + 3) = ( 3 35)
=1 =0
(0 5)
= 0 ( 3) = 3
( )=( +
(
)
) = ( 1 5)
( )=
( )
=
= 3
( 1 + 3 5) = ( 65 5)
=0 0
65
( 2)
( )=(
+ ) = ( 65 1 ( 5)+ 1) = ( 65 4)
= =4
top left
( nve tor(0,-1){.4}
)=( +
87
) = ( 65 + 1 1) = ( 55 1)
the radius: x1 ; y1
x
r; y
:
:;
: ; , so that is
where we \put the rst arrow. The head is to be ush with the left edge of
the \fbox, and this needs some trial and error. The un
ertainty is the width
of the box; we know only that the
enter of the box was put at ;
, but we
do not know the width of the box. With just a few iterations, the end point
was determined to be x
, so len
x : . The reverse arrow begins at
; , and its slope is
; , whi
h is why we have \ve
tor(-1,0){.55}.
The last ve
tor also required trial and error, due to not having the
orner
of the oval
oordinates. In this
ase, the end points were determined to be
from : ; :
to : ; : . The former was found by trial and error,
but the latter was
omputed by knowing that the bottom right box starts
at ; : and has a width of 1.2, so the midpoint of the bottom edge is at
: ; : . Now the true slope of the line we want is : : , but the restri
tions
do not allow this. The
losest slope we
an have is with
x; y
; ,
whi
h is what is spe
ied. Given this slope, the best
hoi
e of len
an be
found as the average of the deviations:
(0 1)
(0 1)
(1 2 895)
(1 5)
(1 6 5)
=0
( 1 0)
= = 55
(1 6 5)
395
4
( ) = (1 1)
Only boxes
an have ins
ribed text; the
ir
les and ovals require separate \put
ommands, whi
h
an take some trial and error to position.
Some
al
ulations and some trial and error are needed to align obje
ts
and lines.
Moving a portion of the pi
ture
an be tedious, requiring re-
al
ulations
and more eort for the new positions.
There is no dire
t way to
ontrol the size or style of the arrow heads,
and there is very limited
ontrol over line thi
knesses.
These
an make using the pi
ture environment time
onsuming and rather
unpleasant. There is a better way!
6 GRAPHICS
88
6.2 PSTri
ks
PSTri
ks [14 was written by Timothy Van Zandt, and is provided free of
harge. (It is not standard with MiKTeX, but you
an obtain it at CTAN [4.)
In the preamble spe
ify \usepa
kage{pst-all} for the entire system. (You
an use parts, in whi
h
ase you spe
ify the parts you use instead of pst-all
see [14 for loading individual portions.)
One thing you need to know is that not all of the pst results
an be seen
with a dvi viewer. Some require
onverting to posts
ript and viewing
the ps le. This is espe
ially true of
ommands that involve rotations.
PSTri
ks (pst, for short) is designed to over
ome di
ulties with using
the pi
ture environment, some of whi
h were listed above. Here are some of
the features of PSTri
ks that I shall illustrate.
Cir
les and ovals, in addition to boxes,
an have ins
ribed text.
Lines and arrows have the same
ommand, identifying any of a great
variety of arrowheads simply.
Only one
ommand is needed to put lines through a sequen
e of points,
and slopes need not be
al
ulated.
Obje
ts
an be named (as nodes ) and lines and arrows
an be drawn
between them by naming the tail and head, thereby eliminating the
need for
al
ulation or trial and error.
Arrow heads are adjustable.
Shapes are highly variable.
Drawing
urves is simple, in
luding plots of points that
an
ome from
a data le, and Bezier approximations of four points are available.
6.2 PSTri ks
89
All of the pst
ommands have options to override default settings for
relevant parameters. The defaults, themselves,
an be set with the \psset
ommand: \psset{parameter = value [, : : : }. For example, the default unit
of measurement is 1
m, and the default ll
olor is white, but we
an
hange
them by spe
ifying:
\psset{unit=1in,fill
olor=gray}
\psset{unit=1mm,fill
olor=white}.
These
ommands
an be used in the text. For example, we obtain
this oval by writing: : : : we obtain \psovalbox{this oval} : : :
6 GRAPHICS
90
psframe(x0 ; y0 )(x1 ; y1 )
npsframe(0,1)(10,-2)
ps
ir
le(x; y ){r}
nps
ir
le(5,0){2}
psellipse(x; y )(rx ; ry )
npsellipse(3,0)(5,2)
( )
\s
alebox{size}{stu}
\s
alebox{width ,height}{stu}
Here are some examples:
6.2 PSTri ks
91
psframebox{stu}
framebox
\psframebox{framebox}
framebox
\psframebox[framear =.4{framebox}
psshadowbox{stu}
shadow added
\psshadowbox{shadow added}
psdblframebox{stu}
double frame
ps
ir
lebox{stu}
ir
le
psovalbox{stu}
oval
Halving
the
ir
le
Doubling
Tall
\s
alebox{2}{\psframebox{
\textsl{Doubling} }}
\s alebox{1 3}{Tall}
Wide
\s alebox{3 1}{Wide}
Right
Left
Down
6 GRAPHICS
92
One appli
ation is given by the following:
Who is the founder of TEX?
Node C
The sour
e
ode is shown in Figure 64. After entering the
entering environment and setting the default units of measurement, the \rput
ommand
puts a node, with the \rnode
ommand. The name is set to A, and the text
Node A is put there (with no frame). The syntax for \rnode is:
\rnode{name }{stu }
The next two
ommands put nodes named B and C, ea
h en
losed with a
frame. The \n
line
ommand has the same arrow options as \psline, but
with the following syntax:
\n
line{a}{name of node A}{name of node B }
The rst \n
line in Figure 64 draws a plain line from node A to node B.
The [nodesepA=3pt option gives 3 pt separation between the end of the
line and node A. Otherwise, the line would tou
h Node A text, whi
h is not
what we want. The separation is exaggerated to 5 pt in the arrow from
node C to node A. The default value is nodesep=0pt, whi
h is what we
want when the nodes are en
losed boxes, like B and C. In general, node
separation
an be spe
ied for either end point, or for both end points, by
spe
ifying nodesepA=n, nodesepB=n, or nodesep=n, respe
tively. (nodesepA
and nodesepB are keywords and have nothing to do with the names we assign
to our nodes.)
Figure 66 shows a graph that
ould represent any number of things. Its
sour
e, using PSTri
ks, is shown in gure 65. (Try adding one line at a time
and observe ea
h ee
t.)
6.2 PSTri ks
93
\begin{
enter}
\psset{unit=1
m}
\rput( 0, 0){\rnode{A}{Node A}}
\rput(-2,-1){\rnode{B}{\psframebox{Node B}}}
\rput( 2,-1){\rnode{C}{\psovalbox{Node C}}}
\n
line[nodesepA=3pt{A}{B}
\n
line[nodesepA=5pt{<-}{A}{C}
\n
line{<->}{B}{C}
\end{
enter} \vspa
e{.5in}
1/2
2/3
2
4!3
2/4
3!4
loop
Figure 66: Graph Result (Sour
e in Figure 65)
6 GRAPHICS
94
(x0 ; y0) is one point on the parabola, and (x1; y1) is the (unique) point
dy=dx = 0. \parabola* spe
ies lling the parabola. For example,
where
having
\psgrid[subgriddiv=1,griddots=10,gridlabels=7pt(-1,0)(4,4)
\parabola{<->}(4,3)(2,0)
\parabola*[fill
olor=bla
k,showpoints=false(1,1)(2,3)
4
3
2
1
0
-1
b
2
y = ax2 + bx + , where a 6= 0?
Answer: nparabola
(0; )(
2a
4a
b2
+ )
The following shows two
ommands: ps
urve and ps
urve, the latter
being a
losed
urve that joins the last point with the rst.
b
\ps
urve{(->}(0,0)(1,1)(1,-1)(-1,1)(-1,-1)
b
b
\ps urve(0,0)(1,1)(1,-1)(-1,1)(-1,-1)
b
b
The Bezier
urve joins two end points and
omes as
lose as possible to
two intermediate points. The
ommand syntax is:
6.2 PSTri ks
95
\psbezier(0,0)(1,3)(2,1)(3,4)
b
b
+50
15
10
5
0 50
C
B
b
b
60
b
b
70
80
90
100 s ore
\psset{unit=2mm, showpoints=false}
\fileplot[plotstyle=dots{mydata.dat}
\psaxes[Ox=50,Oy=0,Dx=10,Dy=5,dx=10,dy=5,ti
ks=y{<->}(60,17)
\rput[r(60,-2){\large s
ore}
\psline(1,0)(1,6)(10,6)(10,0)
\rput( 5, 8){\textsf{F}}
\psline(11,0)(11,2)(19,2)(19,0) \rput(14, 4){\textsf{D}}
\psline(20,0)(20,11)(29,11)(29,0) \rput(25,13){\textsf{C}}
\psline(30,0)(30,8)(39,8)(39,0) \rput(35,10){\textsf{B}}
\psline(40,0)(40,5)(50,5)(50,0) \rput(45, 7){\textsf{A}}
6 GRAPHICS
96
After setting the units of measurement to 2 mm, the data le is read and
its points plotted with the \fileplot
ommand. (Setting showpoints=false
suppresses plotting the points in the \psline
ommands.) The data le is
plain text and has the following entries:
% This is mydata.dat
5 2 9 4
15 2 18 1
22 6 27 4
30 2 31 1 35 4 39 1
40 2 45 2 50 1
%
%
%
%
%
F
D
C
B
A
=
=
=
=
=
[0,65)
[65,70)
[70,80)
[80,90)
[90,100
The plot, itself, is just the points, spe
ied by plotstyle=dots. There
are other plot styles, su
h as plotstyle=line, and there are 11 dot styles.
Here is one of the alternatives:
\fileplot[dotstyle=+,plotstyle=dots{mydata.dat}
+
+
+
+
+
)
(0 0)
\psaxes[unit=.5 m{->}(4,0)(8,3)
2
1
) 0
0 1 2 3
\psaxes[unit=.5 m{->}(0,0)(-1.1,0)(2.1,2.1)
2
1
)
10 1 2
6.2 PSTri ks
97
(60 2)
6 GRAPHICS
98
b b
bb
bb
nfileplot[plotstyle=dots{mydata.dat}
b
15
10
5
0
50
npsaxes[Ox=50,Oy=0,Dx=10,Dy=5,
b b
60
70
bb
80
bb
90
100
15
10
5
0
50
b b
60
70
bb
80
bb
90
npsline(1,0)(1,6)(10,6)(10,0)
nrput(5,8){ntextsf{F}}
b
100
15
10
5
0
50
Db
60
b
b
70
5
0
50
Db
60
5
0
50
70
5
0
50
bb
90
Db
100
70
60
Db
70
90
bb
80
bb
npsline(20,0)(20,11)(29,11)(29,0)
nrput(25,13){ntextsf{C}}
b
100
npsline(30,0)(30,8)(39,8)(39,0)
nrput(35,10){ntextsf{B}}
B
b
C
b
80
60
15
10
bb
npsline(11,0)(11,2)(19,2)(19,0)
nrput(14,4){ntextsf{D}}
15
10
bb
80
15
10
bb
90
B
b
bb
80
100
A
bb
90
npsline(40,0)(40,5)(50,5)(50,0)
nrput(45,7){ntextsf{A}}
100
99
In this
ase I spe
ied the option, s
ale=.5, whi
h prints the gure half
the size it was produ
ed (in this
ase by MATLAB, by spe
ifying print sin -deps
6 GRAPHICS
100
1
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
8
101
whose do
umentation is at CTAN [4. It has two basi
operations: (1) edit
some string or position in the gure (i.e., the eps le), and (2) translate LATEX
ommands that you put in the gure in the rst pla
e. The do
umentation
gives examples, with eps les produ
ed by MATLAB and xg.
Importing graphi
s is only one of the fun
tions of graphi
x. It
an also
perform s
aling, rotation, and sizing of an arbitrary box. The box
ould
ontain text, pi
tures, or almost any stu. Here are examples:
\resizebox{1in}{!}{\fbox{Open wide}}
\refle
tbox{Refle
t on this}
\rotatebox[origin=
{90}{Lands
ape}
Py
th
W
as
a
sq go
ua ra
re s
?
siht no t
eeR
Lands
ape
Open wide
\rotatebox[origin=rt{45}
{\psframebox{
\begin{tabular}{
}
Was\\Pythagoras\\a square?
\end{tabular}
}
}
These operations are available be
ause the programs that perform them
are used in the \in
ludegraphi
s
ommand. Although it is feasible to
perform the operation after importing a graphi
, it is more e
ient to spe
ify
that option in the \in
ludegraphi
s . Here are some examples:
6 GRAPHICS
102
\in
ludegraphi
s
{protra
tor.eps}
Exer ises. Submit a printed opy of the LATEX sour e (tex le) and printed
opy of the asso
iated posts
ript result (ps le). Be sure your name is on
ea
h.
1. Use the pi
ture environment to draw the smiley fa
e on page 82.
2. Draw the following graph with the pi
ture environment, where \thi
klines
is spe
ied and \unitlength = 1mm
vm
1
vm
4
- v2
vm
3
103
rhombus
6. Make a gure in some system that lets you save it as an eps le (or use
some
onversion program). Then, in
lude it in your do
ument.
7. Use whatever means you prefer (or that your instru
tor requires) to
in
lude ea
h of the following gures in your do
ument. (They were
drawn here with PSTri
ks, but this se
tion did not des
ribe all that is
needed, so you must obtain the PSTri
ks User's Guide [14.)
(a) Graphi
view of Pythagorean Theorem:
leg 2
square
of
leg 2
hy
p
square of
hypotenuse
ot
en
us
leg 1
square of
leg 1
6 GRAPHICS
104
(b) Network with ar
data:
(25; 30)
(45; 10)
(15; 40)
(35; 50)
(15; 30)
(35; 50)
(45; 60)
(25; 20)
y = sin
x
-1
-4
-3
-2
-1
Ja
ob I
(16541705)
Nikolaus
(16621716)
Nikolaus I
(16871759)
Jahann I
(16671748)
Nikolaus II
(16951726)
Daniel
(17001782)
Johann II
(17101790)
Johann III
(17461807)
Jo
ob II
(17591789)
105
7
106
the \do
ument
lass
ommand. For example, the following does this while
spe
ifying 12pt font as another option:
\do
ument
lass[12pt,titlepage{arti
le}
As illustrated in Figure 73, \maketitle puts the third author on a separate line. This is be
ause the added width of author information makes it
too long to t on one line. All three authors would be put on separate lines
if the address information were extended further, or if the names were very
long.
7.2 Abstra t
107
There are times when we want to a
knowledge support for one or more of
the authors. The \thanks
ommand does this by
reating a footnote, using
dierent footnote marks for ea
h one. Figures 74 and 75 illustrate this along
with some variation in the date.
\title{Pie
es of $\pi$\thanks{Renamed.}}
\author{Ar
himedes\thanks{Supported by the army.}\\ Syra
use, Si
ily
\and Pythagoras \\ Samos, Ionia }
\date{210 {\s
b
} (revision of earlier version, 510 {\s
b
})}
Figure 74: Footnotes in the Cover Page Sour e (Result in Figure 75)
Pie
es of 1
Ar
himedes
Syra
use, Si
ily
2
210
Pythagoras
Samos, Ionia
Renamed.
Supported by the army.
Figure 75: Footnotes in the Cover Page Result (Sour e in Figure 74)
7.2 Abstra
t
The abstra
t environment is in all do
ument styles, ex
ept arti
le. To have
it, spe
ify titlepage as an option in \do
ument
lass (even if you do not intend to use \maketitle). This environment is dened to produ
e an abstra
t
108
on a separate page (pla
ed wherever you put the environment spe
i
ation),
with the header: Abstra
t, in boldfa
e and
entered. The abstra
t, itself,
is one paragraph and is printed without indentation. Figures 76 and 77 illustrate this. (Like the
over page, the abstra
t is pla
ed far from the top of
the paper, whi
h is not shown in Figure 77.)
\begin{abstra
t}
This shows that the ratio of the
ir
umferen
e to the diameter
of any
ir
le is the same
onstant value, denoted $\pi$.
We further prove that this
onstant is bounded by
$\fra
{223}{71} < \pi < \fra
{22}{7}$.
\end{abstra
t}
Abstra
t
This shows that the ratio of the
ir
umferen
e to the diameter
of any
ir
le is the same
onstant value, denoted . We further
22
prove that this
onstant is bounded by 223
71 < < 7 .
Figure 77: Making an Abstra
t Result (Sour
e in Figure 76)
109
Figure 78: Some Front Matter Spe
i
ations for This Do
ument
The \pagenumber spe
i
ation
auses the page numbers for the front
matter to be put into Roman numerals. That is why you see the Table
of Contents on page i (rst numbered page, just after the
over). Then, I
de
lare \listoffigures , whi
h is on page v, followed by the list of tables.
Ea
h of these are put on a new page. Just above ea
h de
laration, I use the
\add
ontentsline to add it to the table of
ontents, indi
ated by the to
spe
i
ation. The se
tion parameter tells the latex program to format it
like a se
tion ush left.
The page numbering is reset when we nish the front matter by spe
ifying
\newpage \pagenumbering{arabi
} \pagestyle{headings}
This swit
hes to the Arabi
numerals and initializes the page
ounter.
The same format as the abstra
t
an be used for other front matter that
we want to format the same way. The only
hange we require is another
header name. This is done by re-dening the \abstra
tname parameter
used by the abstra
t environment. The \renew
ommand enables us to do
this. 8 has more to say about using this
ommand to
ustomize many
things. For now,
onsider the following example that illustrates how to have
an A
knowledgements page:
\renew
ommand\abstra
tname{A
knowledgements}
\begin{abstra
t}
I thank my family and friends for all of their support.
I also thank the
ontributors to the Comprehensive \TeX\
Ar
hive Network (CTAN).
\end{abstra
t}
110
Alternatively, we might want something to look like a se
tion (and automati
ally added to the table of
ontents), but we do not want it to have
a se
tion number. This is a
hieved by the \se
tion*
ommand, where the
* suppresses the numbering. For example, \se
tion*{Prefa
e} puts Prefa
e in the same style as any se
tion, but with no number (and the se
tion
ounter remains un
hanged).
7.4 Ba
k Matter
After the main part of the do
ument is nished, we put the bibliography (see 3 and 8.5). We might rst want to have appendi
es that follow the main text. This
ould be done with the appendix environment:
\begin{appendix} : : : \end{appendix}.
The last portion in the ba
k of any book is its index. This
ould also be
desirable in a long report. To make an index, we have three things to put
into our sour
e le:
1. Put \usepa
kage{makeidx} in the preamble.
2. Put \makeindex at the end of the preamble.
3. Put \printindex just before \end{do
ument}.
After a su
essful
ompilation, with all referen
es resolved, enter at the
ommand line:
makeindex myfile
Then,
ompile again. This is analogous to the use of bibtex (p. 31), and is
illustrated in Figure 79.
There are pa
kages to make other ba
k matter: a
ronym makes a list of
a
ronyms, nomen
l makes a list of nomen
lature, and gloss makes a glossary.
These are all easy to install, but they generally do not
ome with a basi
LATEX installation; you get them from CTAN [4. GlossTEX is a pa
kage that
ombines all of these fun
tions, but it requires more steps to install.
Exer ises.
Submit a printed
opy of both the LATEX sour
e (tex le) and
the asso
iated posts
ript result (ps le). Be sure your name is on ea
h.
1. Write an arti
le with a title page and abstra
t. Make the main body
have at least three se
tions: Introdu
tion, Main Results, and Con
lusions.
111
reate/edit
myfile.tex
ompile
with
latex
view/print
myfile.dvi
onvert
with
dvips
print/post
myfile.ps
makeindex
Figure 79: Adding makeindex to the Command Sequen
e
2. Extend exer
ise 1 to have a
knowledgements and referen
es (using
BibT X).
3. Combine exer
ises 1 and 2 and add a table of
ontents showing not only
all se
tions and subse
tions, but also the abstra
t, a
knowledgements
and referen
es.
8
Taking Control
8 TAKING CONTROL
112
( )
and spe
ify \usenul in the do
ument. If you need to use the publisher's,
simply
hange the one line to:
\new
ommand{\usenul}{\nul}
113
(The sux .tex is assumed.) Dierent sour
e les
ould simply input this
same le, so dupli
ation of work is avoided.
What it is
Abstra
t
Appendix
Chapter
Contents
Index
List of Figures
List of Tables
Part
Referen
es
\abstra
tname
\appendixname
\
haptername
\
ontentsname
\indexname
\listfigurename
\listtablename
\partname
\refname for arti
le style
\bibname for book and report styles
8 TAKING CONTROL
114
\makeatletter
\renew
ommand\these
tion{\arabi
\
se
tion}
\makeatother
The pre
eding
ommand, \makeatletter, is to make the
hara
ter a letter.
The su
eeding
ommand, \makeatother, restores to its spe
ial meaning
(\ is for
ertain spa
ing, equal to about 2 spa
es).
=0
\newenvironment{proof}
{\begin{flushleft} \begin{des
ription}
\item \textit{\textbf{Proof:}}~ } % begin proof
{\hfill\rule{2.1mm}{2.1mm}
\end{des
ription}\end{flushleft} } % end proof
Then,
115
\begin{proof}
First, suppose \dots \linebreak
Thus, the theorem follows.
\end{proof}
produ
es:
First, suppose : : :
Thus, the theorem follows.
Proof:
72.27 pt 39 pt
1 in
54 in
11
6.14.295 pt
390 pt
5.396 in
8.5 in
113.025 pt
1.564 in
8 TAKING CONTROL
116
Parameter
\footskip
Current
Settingy
30.0pt
Meaning
spa
e between bottom of body and top of
footer
\headsep
25.0pt
spa
e between bottom of header and top of
body
\headheight
12.0pt
height of header
\hoffset
0.0pt
horizontal oset to add to indentation of
body
\oddsidemargin
17.0pt
extra spa
e added at left (applies only
to odd numbered pages if the style is
two-sided, in whi
h
ase there is also an
nevensidemargin parameter)
\paperheight
794.96999pt height of the paper
\paperwidth
614.295pt width of the paper
\textheight
548.5pt
height of the body
\textwidth
390.0pt
width of the body
\topmargin
17.0pt
spa
e added before the top of the header
\voffset
0.0pt
verti
al oset to add to indentation of body
yPrinted using \theparameter.
Table 23: Margin Parameters
Parameter
\itemsep
\parindent
\parsep
\parskip
Meaning
spa
e added to \parsep between items in a list.
indentation at beginning of paragraph.
spa
e between paragraphs in the same item of a list.
spa
e between paragraphs.
Table 24: Spa
ing Parameters
In the
ase of list parameters, they must be set after entering the list
environment. (Defaults are restored after leaving.) For example, the lists in
2.2 (p. 13) are spa
ed by default values. Here is what happens when we
hange \itemsep:
The default value of \itemsep is 5.0pt plus 2.5pt minus 1.0pt, and I
have saved it by: \setlength{\mylength}{\itemsep}.
117
See the above spa
ing between items. What you see next is with
\setlength{\itemsep}{0pt}.
What you see next is with \setlength{\itemsep}{10pt}.
Next is ba
k to normal by \setlength{\itemsep}{\mylength}.
We are ba
k to normal with \itemsep = 5.0pt plus 2.5pt minus 1.0pt.
Figure 80: Array with Fixed Width Column Sour e (Result in Figure 81)
B xB = bN + 21 bN
B xB > bB + 21 bB
N B =
B + 12
B
N N <
N + 21
N
Figure 81: Array with Fixed Width Column Result (Sour e in Figure 80)
8 TAKING CONTROL
118
npagewidth
1 in +
nvoffset
ntopmargin
nheadheight
ntextheight
nheadsep
header
noddsidemargin
npageheight
ntextwidth
1 in +
body
footer
nhoffset
nfootskip
119
B xB = bN + 21 bN
B xB > bB + 21 bB
N B =
B + 12
B
N N <
N + 21
N
B xB = bN + 12 bN
N B = B + 12 B
N N < N + 21 N
B xB > bB + 21 bB
N B =
B + 12
B
N N <
N + 21
N
B xB = bN + 21 bN
B xB > bB + 21 bB
environment
instead. You will have
omplete
ontrol over the formatting, and there
will be no sorting the list of referen
es will appear in the order you put
them. Instead of the BibT X
ommands, \bibliography{mybiblio} and
\bibliographystyle{plain}, spe
ify the following:
\begin{thebibliography}{n}
\bibitem[what appears {label (that you
ite)} entry
..
.
\end{thebibliography}
where n is the width of the widest label you want to allow. (It works if
you spe
ify 99.) Ea
h \bibitem is an entry, as des
ribed for BibT X in 3
(p. 30), with label the unique identier used by the \
ite
ommand. The
option is an alternative to having the referen
es numbered, and you
an enter
whatever you like.
Here is a
omplete example with two referen
es, whi
h I formatted to
agree with the plain style of BibT X:
\begin{thebibliography}{99}
\bibitem{
ompanion} Mi
hel Goosens, Frank Mittelba
h and Alexander
Samarin, \textit{The \LaTeX\ Companion}, Addison-Wesley
8 TAKING CONTROL
120
These will appear in the do
ument's list of referen
es even if they are not
ited. They
an be
ited in the same way des
ribed in 3: by \
ite{
ompanion}
and \
ite{tex}, respe
tively. When
iting Knuth's book, for example, we
obtain [2 in the text. Alternatively, we
an exer
ise the option:
\bibitem[Knuth, 1989{tex} Donald E. Knuth,
:::
Closing Remarks
Now you know how to write a mathemati
al do
ument in LATEX 2" and you
know there is mu
h more you
an learn to gain renements. Besides what
you
an do yourself to elevate the quality of the results, there are many
pa
kages, available from CTAN [4. Figure 83 shows the preamble used for
APPENDIX
121
%
%
%
%
%
%
%
%
%
%
%
%
%
graphi
s
index
\url{...}
...to write \textbf{\texts
{..}}
verbatim
enable float [H option
like multi
olumn
formerly amstex
ams symbols (\mathbb fonts)
draws
ommutative diagrams
more math symbols (like \maths
r)
bold math fonts (\mathbm)
enables more
ontrol over newtheorem
This
ontains
omplete tables of font information and basi
LATEX
ommands.
It is designed like a referen
e manual for easy lookup, beginning with Table 25, whi
h gives
onversion among three
ommon units of measurement.
APPENDIX
122
pt
in
m
pt
1
.01384 .03515
in 72.27
1
2.54
m 28.45 .3937
1
Table Contents
27
28
29
30
31
32
Math mode 33
34
35
36
37
38
39
40
41
42
43
44
APPENDIX
textbf
tiny
Large
verbatim
123
textit
s
riptsize
LARGE
textrm
footnotesize
huge
texts
small
Huge
textsf
normalsize
underline
texttt
large
verb
bigskip
flushright
medskip
pagebreak
smallskip
vspa
e
enter
hfill
newpage
quotation
tabbing
vspa
e*
enterline
hspa
e
noindent
quote
tabular
learpage
hspa
e*
nolinebreak
raisebox
verse
flushleft
linebreak
nopagebreak
samepage
vfill
\'{a}
\`{e}
\^{i}
\"{o}
\ae
\AE
\L
u
H
oo
\u{u}
\~{n}
\H{H}
\t{oo}
\oe
\OE
\ss
d.
b
: : :
\
{
}
\d{d}
\b{b}
\dots
\aa
\AA
?`
z
v
\.{x}
\={z}
\v{v}
\o
\O
!`
addto
ounter
ref
the
ounter
label
refstep
ounter
value
new
ounter
set
ounter
pageref
step
ounter
APPENDIX
124
abstra
t
appendix
listoffigures
maketitle
subse
tion
tableof
ontents
add
ontentsline
bibliography
listoftables
printindex
subsubse
tion
thanks
addto
ontents
bibliographystyle
makeindex
se
tion
subsubsubse
tion
thebibliography
markright
renew
ommand
markboth
setlength
pagenumbering
thispagestyle
pagestyle
left
al
mathit
mathtt
right
boldmath (set
displaystyle
mathnormal
mbox
textstyle
in text mode)
mathbf
math
al
mathrm
mathsf
overbra
e
overline
underbra
e underline
a \
he
k{a} e
x_ \dot{x}
y
^{ nhat{nimath}
xyz
d nwidehat{xyz}
\breve{e} i \a
ute{i}
\ddot{y}
z \bar{z}
|~ ntilde{njmath}
f nwidetilde{ab
}
ab
o \grave{o}
~v \ve
{v}
~
\hbar
(Note that it is better style to use \imath, rather than i, and \jmath,
rather than j , to avoid the
lash between the a
ent and dot.)
APPENDIX
125
"
\alpha
\beta
#
\gamma
\delta
\epsilon
\varepsilon
\zeta
\eta
\Gamma
\Delta
\Theta
\aleph
`
A : : : Z {nmath
al A
\theta
\vartheta
\iota
\kappa
\lambda
\mu
\nu$
\xi
\Lambda
\Xi
\Pi
\ell
: : : Z}
o
$
%
&
o
\pi
\varpi
\rho
\varrho
\sigma
\varsigm
'
!
\tau
\upsilon
\phi
\varphi
\
hi
\psi
\omega
\Sigma
\Psi
\Upsilon
\Omega
\Phi
<
\Re
\Im
)
)
)
)
)
)
)
)
xy
xy
xy
x y
x
y
xy
xy
xy
no spa
e
thin spa
e
medium spa
e
spa
e = 1em
spa
e = 2em
negative thin spa
e
negative medium spa
e
negative thi
k spa
e
{supers
ript}
{subs
ript}
^{}
_{}
\prime
\infty
\emptyset
APPENDIX
126
n
nU
\pm
\mp
\times
\div
\setminus
\ba
kslash
\biguplus
\
u
^
_T
\
ap
\sq
ap
\wedge
\vee
\big
ap
\bigvee
\bigwedge
W
V
[
t
S
L
F
\
up
\sq
up
\uplus
\oplus
\big
up
\bigoplus
\bigsq
up
\odot
\otimes
\oslash
\ominus
\bigodot
\bigotimes
r
8
\nabla
\forall
\partial
\exists
p
:
\surd
\neg
} \wp
ar
os
s
lg
Pr
ar
sin
det
lim
se
ar
tan
dim
liminf
sin
arg
exp
limsup
sinh
os
g
d
ln
sup
osh
hom
log
tan
ot
inf
max
tanh
oth
ker
min
\equiv
/
2
3
\propto
\in
\ni
v
\leq
\pre
\pre
eq
\ll
\subset
\subseteq
\sqsubseteq
w
\geq
\su
\su
eq
\gg
\supset
\supseteq
\sqsupseteq
6=
'
=
\neq
\sim
\simeq
\
ong
\asymp
\approx
=: \doteq
j= \models
APPENDIX
(
!
)
$
,
7
!
(
)
127
\leftarrow
\Leftarrow
\rightarrow
\Rightarrow
\leftrightarrow
\Leftrightarrow
\mapsto
\hookleftarrow
\leftharpoonup
\leftharpoondown
\rightleftharpoons
(=
!
=)
!
()
7!
,!
*
+
\longleftarrow
\Longleftarrow
\longrightarrow
\Longrightarrow
\longleftrightarrow
\Longleftrightarrow
\longmapsto
\hookrightarrow
\rightharpoonup
\rightharpoondown
"
*
#
+
l
m
%
&
.
-
..
.
4
.
4
./
>
a
\
j
\
ir
\
dots
\vdots
\frown
\triangle
\triangleright
\bigtriangleup
\bowtie
\top
\dashv
\angle
\mid
..
/
5
?
?
`
k
k
\big
ir
\ddots
\bullet
\smile
\diamond
\triangleleft
\bigtriangledown
\perp
\bot
\vdash
\|
\parallel
\uparrow
\Uparrow
\downarrow
\Downarrow
\updownarrow
\Updownarrow
\nearrow
\searrow
\swarrow$
\nwarrow
REFERENCES
128
P
Q
`
\sum
\prod
z}|{
\overbra e{ . }
\ oprod
\overline{ . }
n
d
\fra {n}{d}
()
( )
j
h
\int
p:
\langle
|{z}
\underbra
e{ . }
\underline{ . }
\sqrt{ . }
fg
b
i
\oint
\{ \}
\lfloor
[
\rfloor
\rangle
:::
\dag
\ddag
\ldots
\S
\P
\
opyright
\pounds
Table 45: Spe ial Symbols in Both Text and Math Modes
put(x; y ){stuff }
multiput(x; y )(x; y ){number }{stuff }
line(x; y ){length}
framebox(width; height)[p{text}
ve
tor(x; y ){length} dashbox{dashs ize}(width; height)[p{text}
ir
le{radius)
makebox(width; height)[p{text}
ir
le*{radius)
oval(width; height)[p
linethi
kness{dimension}
REFERENCES
129
[12 Keith Re
kdahl. Using imported graphi
s in LATEX 2" . World Wide Web
site Version 2.0, Comprehensive TEX Ar
hive, CTAN/info/epslatex.ps
(see [4 for repla
ing CTAN), 199597.
130
REFERENCES
Index
nhspa
e, 27
nimath, 124
ninput, 113
njmath, 124
nkill, 25
nlabel, 43, 59
nleft, 62, 128
nlinebreak, 26
nline, 84
nlistoffigures, 108
nlistoftables, 108
nmakebox, 82
nmaketitle, 105
nmathbb, 66
nmaths
r, 67
nmathfont, 52
nmbox, 57, 63, 65
nmedskip, 12
nmulti
olumn, 21, 112
nnew
ommand, 40, 111
nnew
ounter, 47
nnewenvironment, 114
nnewline, 26
nnewpage, 27, 45
nnewtheorem, 69, 70
nno
ite, 41
nnoindent, 11
nnolinebreak, 26
nnopagebreak, 27
noddsidemargin, 115
noverbra
e, 62
noverline, 62
noverset, 73
npagebreak, 27
npagenumbering, 109
nBigg, 71
nBig, 71
naddto
ounter, 47
narraystret
h, 119
nauthor, 105
nbaselineskip, 28, 62
nbibliographystyle, 40
nbibliography, 40
nbigg, 71
nbigskip, 11, 12
nbig, 71
nboldmath, 51
n
dots, 62, 68
n
enterline, 7, 21
n
ite, 41
n
learpage, 45
n
line, 17
ndashbox, 82
ndate, 105
ndisplaystyle, 54, 61
ndo
ument
lass, 1, 106
ndotfill, 27
ndots, 8
ndvips, 3
nensuremath, 112
nfboxrule, 46
nfboxsep, 46
nfbox, 10, 46, 61, 80, 84
nfra
, 53, 67
nframebox, 81, 83
nframe, 10
nhfill, 11, 13, 27
nhline, 17, 60
nhrulefill, 27
nhspa
e*, 26, 27
131
INDEX
132
npageref, 44, 70
npagestyle, 109
nparbox, 20, 21, 81
npartial, 67
nprime, 60
nprod, 53
npsset, 89
nraggedright, 63
nraisebox, 63
nrefstep
ounter, 48
nref, 43, 44, 59, 70
nrenew
ommand, 37, 48, 109, 111
nrenewenvironment, 114
nright, 62, 128
nsamepage, 27
nse
tion*, 110
nse
tion, 5, 6
nset
ounter, 47
nsetlength, 46, 82
nsmallskip, 12
nsqrt, 53
nsta
krel, 73
nstep
ounter, 47
nsubse
tion, 6
nsubsta
k, 74
ntableof
ontents, 108
ntextstyle, 54
ntextwidth, 115
ntextfont, 9
nthanks, 107
ntheenumi, 48
nthe
ounter, 43, 44, 48
ntitle, 105
nunderbra
e, 62
nunderline, 10, 18, 62
nunderset, 73
nunitlength, 82
nurl, 37
INDEX
le
133
Lagrangian, 67
Lapla
e transform, 67
latex
ommand, 2
list environment, 13
des
ription, 13
ghostview, 4
global setting, 49
glossary, 110
graph, 92
Hamiltonian, 67
horizontal ll, 11
jpeg2ps, 99
INDEX
134
enumerate, 15
itemize, 14
lo
al setting, 46
math display mode, 50, 54, 58
matrix equation, 60
message, 2
Overfull : : : , 2
Repeated entry, 41
Underfull : : : , 2
warning, 2
MetaPost, 88
MiKTeX, 3, 88, 99
nodes, 92
pa
kage, ix, 1, 5, 7
a
ronym, 110
algorithm, 121
ams
d, 74
amsmath, 69, 72
amssymb, 66
babel, 24
bibunits, 120
bm, 53
-pas
al, 121
hemsym, 121
fan
yvrb, 121
oat, 45
fonten
, 9
frankenstein, 120
geometry, 115
gloss, 110
glosstex, 110
graphi
x, 99
graphtex, 121
listings, 121
longtable, 22
makeidx, 110
mathrsfs, 67
morevrb, 121
nomen
l, 110
psfrag, 100
pstri
ks, 87, 88
qsymbols, 121
setspa
e, 28
showkeys, 44
theorem, 71
url, 37
wasysym, 121
xypi
, 121
paragraph positions, 7
preamble, 1, 39, 115, 120
quotation marks, 11
se
tion, 5, 6
SIAM, 1
spa
ing, 14
~, 26
horizontal, 27
math mode, 53, 56, 119
verti
al, 12, 27
spe
ial
hara
ter, 1, 14, 17, 23, 27,
32, 50, 114
ntextspe
, 23
in url, 36
spe
ial fun
tion, 65
sta
king, 73
subs
ript, 50
sta
k, 73
subse
tion, 5, 6
supers
ript, 50
tabbing
ommands, 24
table, 16
ti
ks, 97
transpose, 60
INDEX
trigonometri
fun
tions, 65
units of measurement, 4, 18, 82, 89,
92, 96, 121, 122
unix, 3, 4, 30, 99
xdvi, 3
YAP, 3
135