Sei sulla pagina 1di 145

A Simplied Introdu

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/

April 11, 2000

hgreenbe/

i
Table of Contents

List of Figures

iii

List of Tables

vi

Prefa e

viii

A knowledgements

ix

Sour es of LATEX Software

ix

1 Overview

2 Text

2.1 Fonts and Paragraphs .


2.2 Lists . . . . . . . . . .
2.3 Making Tables . . . . .
2.4 Spe ial Chara ters . .
2.5 Tabbing . . . . . . . .
2.6 Line and Page Breaks .
2.7 Spa ing . . . . . . . .
Exer ises . . . . . . . . . . .

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 . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

4 Counters, Labels, and Referen es


4.1 Basi Con epts . .
4.2 Intrinsi Counters .
4.3 Figures and Tables
4.4 Dening Your Own
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

5.1 Mathemati al Symbols . . . . . . . . . .


5.2 Fra tions and Variable Size Fun tionality
5.3 Arrays and Equations . . . . . . . . . . .
5.4 Spe ial Fun tions and Alphabets . . . .
5.5 Derivatives and Integrals . . . . . . . . .
5.6 Theorems and Denitions . . . . . . . .
5.7 Renements . . . . . . . . . . . . . . . .
5.8 Grammar . . . . . . . . . . . . . . . . .
Exer ises . . . . . . . . . . . . . . . . . . . . .

6 Graphi s

6.1 Pi ture Environment


6.2 PSTri ks . . . . . . .
6.3 Importing pi tures .
Exer ises . . . . . . . . . .

7 Making Spe ial Parts

7.1 Cover Page . . . .


7.2 Abstra t . . . . . .
7.3 Other Front Matter
7.4 Ba k Matter . . . .
Exer ises . . . . . . . . .

8.1
8.2
8.3
8.4
8.5

Your
Your
Your
Your
Your

Own
Own
Own
Own
Own

.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

Abbreviations and Commands


Names, Titles and Numbers .
Environments . . . . . . . . .
Margins and Spa ing . . . . .
Bibliography . . . . . . . . .

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

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

The Stru ture of a LATEX Do ument. . . . . . . . . . . . . . .


Your First LATEX Sour e File . . . . . . . . . . . . . . . . . .
Command Sequen e from Sour e to Posts ript . . . . . . . .
An Introdu tory Do ument Sour e (Result in Figure 5) . . .
An Introdu tory Do ument Result (Sour e in Figure 4) . . .
Positioning Paragraphs Sour e (Result in Figure 7) . . . . . .
Positioning Paragraphs Result (Sour e in Figure 6) . . . . . .
Centering Sour e (Result in Figure 9) . . . . . . . . . . . . .
Centering Result (Sour e in Figure 8) . . . . . . . . . . . . .
Some Font Sizes Sour e (Result in Figure 11) . . . . . . . . .
Some Font Sizes Result (Sour e in Figure 10) . . . . . . . . .
Skipping Line Spa es Sour e (Result in Figure 13) . . . . . .
Skipping Line Spa es Result (Sour e in Figure 12) . . . . . .
Des ription List Environment . . . . . . . . . . . . . . . . . .
Itemize List Environment Sour e (Result in Figure 16) . . . .
Itemize List Environment Result (Sour e in Figure 15) . . . .
Enumerate List Environment Sour e (Result in Figure 18) . .
Enumerate List Environment Result (Sour e in Figure 17) . .
A  Table . . . . . . . . . . . . . . . . . . . . . . . . . . .
A  Table with Horizontal and Verti al Lines . . . . . . .
A Table with Partially Spanning Horizontal and Verti al Lines
Nested Tables Sour e (Result in Figure 23) . . . . . . . . . .
Nested Tables Result (Sour e in Figure 22) . . . . . . . . . .
\parbox Sour e (Result in Figure 25) . . . . . . . . . . . . .
\parbox Result (Sour e in Figure 24) . . . . . . . . . . . . .
Multi olumn Sour e (Result in Figure 27) . . . . . . . . . . .
Multi olumn Result (Sour e in Figure 26) . . . . . . . . . . .
Obtaining Bra kets in a Des ription List Environment . . . .
Tabbing Sour e (Result in Figure 30) . . . . . . . . . . . . . .
Tabbing Result (Sour e in Figure 29) . . . . . . . . . . . . . .
Adding bibtex to the Command Sequen e . . . . . . . . . .
A Do ument to Print the Bibliographi Database . . . . . . .
Framed Figure 34 Sour e . . . . . . . . . . . . . . . . . . . .
Framed Figure with Caption at Bottom . . . . . . . . . . . .
Framed Figure with Caption at Top . . . . . . . . . . . . . .
Alternative enumerate Symbols Sour e (Result in Figure 37) .

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

Alternative enumerate Symbols Result (Sour e in Figure 36)


Variable Sizes Sour e (Result in Figure 39) . . . . . . . . .
Variable Sizes Result (Sour e in Figure 38) . . . . . . . . .
\displaystyle Sour e (Result in Figure 41) . . . . . . . .
\displaystyle Result (Sour e in Figure 40) . . . . . . . .
Examples to Compare Text and Display Modes . . . . . . .
eqnarray Environment Sour e (Result in Figure 44) . . . . .
eqnarray Environment Result (Sour e in Figure 43) . . . . .
Matrix Equation Sour e (Result in Figure 46) . . . . . . . .
Matrix Equation Result (Sour e in Figure 45) . . . . . . . .
Nested Arrays Sour e (Result in Figure 48) . . . . . . . . .
Nested Arrays Result (Sour e in Figure 47) . . . . . . . . .
Horizontal Bra es Sour e (Result in Figure 50) . . . . . . .
Horizontal Bra es Result (Sour e in Figure 49) . . . . . . .
\flushleft in parbox Sour e (Result in Figure 52) . . . .
\flushleft in parbox Result (Sour e in Figure 51) . . . .
\raggedright in parbox Sour e (Result in Figure 54) . . .
\raggedright in parbox Result (Sour e in Figure 53) . . .
gather* Environment Sour e (Result in Figure 56) . . . . .
gather* Environment Result (Sour e in Figure 55) . . . . .
Commutative Diagram Sour e (Result in Figure 58) . . . .
Commutative Diagram Result (Sour e in Figure 57) . . . .
Verti al Diagram Sour e (Result in Figure 60) . . . . . . . .
Verti al Diagram Result (Sour e in Figure 59) . . . . . . . .
Variety of Obje ts in Pi ture Environment . . . . . . . . . .
Sour e for Figure 61 . . . . . . . . . . . . . . . . . . . . . .
Line Parameters . . . . . . . . . . . . . . . . . . . . . . . .
PSTri ks Sour e for Conne ting Nodes . . . . . . . . . . . .
Graph Sour e (Result in Figure 66) . . . . . . . . . . . . . .
Graph Result (Sour e in Figure 65) . . . . . . . . . . . . . .
Sour e Code for Drawing Histogram of Test S ores . . . . .
Sequen e of PSTri ks Commands to Draw Histogram . . . .
Applying \in ludegraphi s to Import an eps File . . . . .
Spe ifying Dimensions in \in ludegraphi s . . . . . . . .
Title Page Sour e (Result in Figure 72) . . . . . . . . . . .
Title Page Result (Sour e in Figure 71) . . . . . . . . . . .
Adding Addresses to Authors . . . . . . . . . . . . . . . . .
Footnotes in the Cover Page Sour e (Result in Figure 75) .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

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

Footnotes in the Cover Page Result (Sour e in Figure 74) . .


Making an Abstra t Sour e (Result in Figure 77) . . . . . . .
Making an Abstra t Result (Sour e in Figure 76) . . . . . . .
Some Front Matter Spe i ations for This Do ument . . . . .
Adding makeindex to the Command Sequen e . . . . . . . .
Array with Fixed Width Column Sour e (Result in Figure 81)
Array with Fixed Width Column Result (Sour e in Figure 80)
Do ument Margins . . . . . . . . . . . . . . . . . . . . . . . .
Most of the Preamble for this Do ument . . . . . . . . . . . .

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

Intrinsi Font Styles . . . . . . . . . . . . . . . . . . .


Writing Spe ial Chara ters . . . . . . . . . . . . . . .
Some A ents for Letters . . . . . . . . . . . . . . . .
The Tabbing Environment . . . . . . . . . . . . . . . .
The \kill Tabbing Command . . . . . . . . . . . . .
Figure and Table Lo ation Options . . . . . . . . . . .
Numerals to Print Counters . . . . . . . . . . . . . . .
Default Settings for enumerate Counters . . . . . . . .
Some Mathemati al Operations . . . . . . . . . . . . .
Set Notation . . . . . . . . . . . . . . . . . . . . . . .
The nmathfont Commands . . . . . . . . . . . . . . .
Variable Size Mathemati al Operation Symbols . . . .
Some Symbols in Logi . . . . . . . . . . . . . . . . .
Order Relations . . . . . . . . . . . . . . . . . . . . .
Transpose of a Ve tor . . . . . . . . . . . . . . . . . .
Some Common Mathemati al Fun tions . . . . . . . .
Examples of Mathemati al Fun tions . . . . . . . . . .
Notation Using mathbb Fonts from amssymb Pa kage .
Some Basi Drawing Commands in PSTri ks . . . . .
Boxes in PSTri ks . . . . . . . . . . . . . . . . . . . .
Parameters for \psaxes . . . . . . . . . . . . . . . . .
Intrinsi Name Parameters . . . . . . . . . . . . . . .
Margin Parameters . . . . . . . . . . . . . . . . . . . .
Spa ing Parameters . . . . . . . . . . . . . . . . . . .
Conversions of Common Units of Measurement . . . .
Referen e Tables . . . . . . . . . . . . . . . . . . . . .
Commands/Environments for Text Font Appearan e .
Commands/Environments for Controlling Text Position
Text A ents and Spe ial Symbols . . . . . . . . . . .
Commands for Counters . . . . . . . . . . . . . . . . .
Commands/Environments to Organize Do ument . . .
Commands to Control Do ument Style . . . . . . . . .
Commands to Control Fonts in Math Mode . . . . . .
A ents in Math Mode . . . . . . . . . . . . . . . . . .
Greek and Spe ial Letters . . . . . . . . . . . . . . . .
Spa ing Commands in Math Mode . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

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

Frequently Used Mathemati al Symbols . . . . . .


Binary Operations . . . . . . . . . . . . . . . . . .
Operators and Quantiers . . . . . . . . . . . . . .
Spe ial Fun tions . . . . . . . . . . . . . . . . . . .
Relation Symbols . . . . . . . . . . . . . . . . . . .
Arrows . . . . . . . . . . . . . . . . . . . . . . . .
Dots, Cir les, Triangles and Lines . . . . . . . . . .
Variable Size Symbols . . . . . . . . . . . . . . . .
Spe ial Symbols in Both Text and Math Modes . .
Commands and Parameters in Pi ture Environment

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.

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

The author thanks the many ontributors in the omp.text.tex newsgroup,


parti ularly Donald Arseneau, Herman Bruynin kx, David Carlisle, Robin
Fairbairns, Jonathan Fine, Denis Girou, David Haller, Dan Lue king, Timothy Murphy, Sebastian Rahtz, Axel Rei hert, Thomas Ruedas, Bernd S handl,
Anton S hwaighofer, Mrten Svantesson, and Matt Swift, who were very generous with taking time to answer so many questions on a regular basis. I also
re eived useful omments from people who read an earlier draft that I made
available on the web, notably William Briggs. I espe ially thank Kasper B.
Graversen whose in-depth review has made this version mu h better than my
original. One student, Andrea Dean, provided feedba k that led to several
points of lari ation. Last, but not least, I thank Allen G. Holder, who
taught me LATEX in the rst pla e.

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
=
;


optional spe i ations

\end{do ument}

Preamble

(blank lines do not matter)

 e.g., de laring use of pa kages

\begin{do ument}
..
.

Anything following % is ignored


(used for omments).

Body

This is the do ument

environment.

All that follows is ignored


( ould be used for omments).

Figure 1: The Stru ture of a LATEX Do ument.


In the preamble, there are many options, depending upon the style; the
intrinsi do ument styles are: arti le, book, letter, report, and slides.
Most publishers have their own style, whi h you an obtain free of harge.
Among these are professional so ieties, notably the Ameri an Mathemati al
So iety (amsmath style) and the So iety for Industrial and Applied Mathemati s (siam style).
The fo us throughout this book is on the arti le style. Further, I shall
be using defaults for almost everything, on entrating on getting started
with using LATEX as qui kly as possible. Later, some of the options, like
margin settings and other preamble spe i ations are overed, as well as
more advan ed topi s for ustomizing your do ument.
Are you ready to write your rst LATEX do ument? Copy the sour e le
shown in Figure 2 and name it myfile.tex. Then, at the ommand line,
enter:

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}

Figure 2: Your First LATEX Sour e File


This is alled ompiling your sour e, whi h reates several output les.
The only one you need to be on erned with now is the dvi le, whi h the
latex program ( alled a  ompiler) names myfile.dvi. One of three things
will have o urred:

Case 1. You got messages, but they were not fatal errors.
Among the non-fatal messages you will generally see are warnings like:

Overfull \hbox ...


Overfull \vbox ...
Underfull \hbox ...
Underfull \vbox ...
Do not worry about these.

Case 2. You got a fatal error message.


You must nd and orre t it. This is alled debugging your sour e.
Sometimes the error message tells you what went wrong, su h as missing a bra e ( hara ters { and }, whi h you will ome to know and love),
or some ommand was not re ognized due to being misspelled. Many
times the message is not very informative, so you are advised to ompile often. That way you will know that what you did in the last few
minutes ontains the error.

Case 3. You got no messages.


Something went wrong and you need to ask for help.

save a ba kup

If all went well, the rst thing to do is


by opying your
sour e le to another subdire tory, or to a dierent name. In unix do this by
entering:

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

Figure 3: Command Sequen e from Sour e to Posts ript


Now hange your do ument to spe ify a font size of 12pt (default is 10pt)
by hanging your rst line to the following:
\do ument lass[12pt{arti le}

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

We begin by illustrating the most ommon text formatting, mu h like you


would want in a word pro essor. (The power of LATEX will be evident when
we get to mathemati al expressions, but even some text, espe ially tables,
will demonstrate the superior quality of the LATEX results.) First, onsider
how to make se tions and subse tions in arti le style. Figure 4 is the sour e
that produ es the result in Figure 5, showing how se tions and subse tions
are dened. Note the automati numbering, and how extra spa es and blank
lines have no ee t.

2 TEXT

6
\do ument lass[12pt{arti le}

% We have defined the do ument to be an arti le using 12 point font.


% Blank lines mean nothing here, in the preamble.
\begin{do ument}

% Begin do ument "environment".

\se tion{This is a Se tion}


\subse tion{This is a subse tion}
This is the body of the subse tion.
I an move to a new line anytime, and I an put in
of
blanks
with
no
effe t.

lots

Skipping four lines is the same as skipping one line


--- it starts a new paragraph.
\subse tion{Here is another subse tion}
\se tion{Here is another se tion}
\end{do ument}

Figure 4: An Introdu tory Do ument Sour e (Result in Figure 5)

1.1

This is a Se tion

This is a subse tion

This is the body of the subse tion. I an move to a new line


anytime, and I an put in lots of blanks with no ee t.
Skipping four lines is the same as skipping one line  it starts
a new paragraph.

1.2
2

Here is another subse tion


Here is another se tion

Figure 5: An Introdu tory Do ument Result (Sour e in Figure 4)

2.1 Fonts and Paragraphs

2.1 Fonts and Paragraphs


Figure 6 shows the sour e to produ e dierent paragraph positions: entered,
ush left, ush right, and justied (the default). Note that these are environments, a on ept you need to understand about LATEX. The general form
of an environment uses the following syntax:

\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.

Figure 6: Positioning Paragraphs Sour e (Result in Figure 7)


Instead of the enter environment, you an use the \ enterline ommand; they dier in that the environment skips a line before and after the
paragraph, shown in Figures 8 and 9.
You an also suppress indentation of the rst line of a paragraph with
the \noindent ommand. Here is an example:

\noindent This paragraph is not indented. produ es:


This paragraph is not indented.
Table 1 lists the fonts that are intrinsi in a basi latex installation. (More
fonts are available in pa kages, usually free of harge.) In te hni al writing,
you will have parti ular use for the itali font, as it is used when introdu ing

2 TEXT

The text is entered be ause I have entered the enter


environment. Text remains entered as long as we remain in
this environment.
Now we are out of the entering environment, and have begun
the ushleft environment.
This is another paragraph, but in the ushright environment.
You will have o asion to use all four paragraph positions.
I am ba k to normal justi ation. The added spa e you see
between the above paragraphs is due to entering those environments.
Figure 7: Positioning Paragraphs Result (Sour e in Figure 6)
a new term. For example,

A \textit{group} is defined on a set of elements \dots

)A group is dened on a set of elements : : :


(The )symbol an be read as produ es.) Note the use of the \dots ommand, whi h produ es the ellipsis.

What you write


This is \textbf{boldfa e}.
This is \textit{itali }.
This is \textrm{roman}.
This is \texts {small aps}.
This is \textsf{sans serif}.
This is \textsl{slanted}.
This is \texttt{typewriter}.

)
)
)
)
)
)
)

How
This
This
This
This
This
This
This

Table 1: Intrinsi Font Styles

it
is
is
is
is
is
is
is

appears

boldfa e.

itali .
roman.

small aps.
sans serif.
slanted.
typewriter.

2.1 Fonts and Paragraphs

This pre edes enter environment.


\begin{ enter} This line is entered. \end{ enter}
This ontinues after entering.
This pre edes enterline.
\ enterline{This line is entered.}
This ontinues after entering.

Figure 8: Centering Sour e (Result in Figure 9)


This pre edes enter environment.
This line is entered.
This ontinues after entering.
This pre edes enterline.
This line is entered.
This ontinues after entering.
Figure 9: Centering Result (Sour e in Figure 8)
Some ombinations of font styles an be produ ed. For example,

\textbf{\textit{bolditali }}

) bolditali .

The argument of \textbf is \textit{bolditali }. The general form is


ntextfont {text }, where font is one of {bf, it, rm, s , sf, sl, tt}, as
seen in Table 1.
Not all ombinations are in the basi LATEX 2" installation. In parti ular,
you must put \usepa kage[T1{fonten } in your preamble to obtain:

\textbf{\texts {bold small aps}}

) bold small aps.

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

You an make the text {\large large} or {\Large larger} or


even {\LARGE larger still}. You an also make it {\huge huge}.
You might want to make something {\small small} or
{\footnotesize smaller} or even {\s riptsize smaller still}.
You an make it really {\tiny tiny}.

Figure 10: Some Font Sizes Sour e (Result in Figure 11)

You an make the text

large or larger or even larger still.

huge

You an also make it


. You might want to make something small or smaller or even smaller still. You an make it really
.

tiny

Figure 11: Some Font Sizes Result (Sour e in Figure 10)


The use of bra es to en lose a font size spe i ation is like an environment.
Optionally, we an expli itly use the environment syntax: \begin{size } : : :
\end{size }. For example, \begin{large} This is large.\end{large} produ es the same result as {\large This is large.}. The environment syntax is useful when you want to keep the size for a large blo k of text, and the
bra es format is useful for short phrases. (There is no intrinsi environment
for font styles.)
It is straightforward to underline text  just write \underline{text }.
We an also frame text just by writing \frame{text }. We an give frame
some room around the edges by using \fbox instead. (More on framing in
6, p. 81.) To overline is as straightforward, but learning it must wait until
we enter math mode.
Now onsider ways to indent a blo k of text. Here is an example using the
quote environment, whi h was generated by putting \begin{quote} before
the text and \end{quote} after it:
The onstru tion of the real number system, notably by Dedekind
uts, was motivated by the need to x al ulus, whi h ran into
trouble due to insu ient rigor in dealing with limits.
The quote environment is intended for short quotes, generally one short
paragraph (as above), or a sequen e of one line quotes, separated by blank

2.1 Fonts and Paragraphs

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

Figures 12 and 13 illustrate three levels of skipping: small, medium and


big. Later, we shall look at a way to have a mu h ner range of verti al
spa ing.
This is a first line. \bigskip
The spa e you see is a big skip. \medskip
The spa e you now see is a medium skip.

\smallskip

The spa e you now see is a small skip.


This is just an ordinary line spa e.

Figure 12: Skipping Line Spa es Sour e (Result in Figure 13)

This is a rst line.


The spa e you see is the big skip.
The spa e you now see is a medium skip.
The spa e you now see is a small skip.
This is just an ordinary line spa e.
Figure 13: Skipping Line Spa es Result (Sour e in Figure 12)
The verse environment indents oppositely: lines after the rst. The following was generated by putting \begin{verse} before the text and \end{verse}
after it:

Negle t of mathemati s works injury to all knowledge, sin e he


who is ignorant of it annot know the other s ien es or the
things of this world. And what is worse, men who are thus
ignorant are unable to per eive their own ignoran e and so do
not seek a remedy.
 Roger Ba on

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.

Basi Do ument Preparation. Knowing how to setup the latex sour e

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.

Bibliography. Knowing how to reate a bibliography, in parti ular with

BibTE X.

Mathemati s. This is a power of LATEX and one reason why it has be ome

standard in writing mathemati al papers. I will show you how to do


virtually any mathemati al expression in line with the text, or in math
display mode.

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}

Figure 14: Des ription List Environment


Two new things appear in the example: the use of \LaTeX to produ e
LATEX, and the use of ~ ( alled tilde) to enter a spa e.
Without the
A
tilde, the result would be L TEXprovides, even with a spa e after \LaTeX
in the sour e. (The reason is that a spa e is needed anyway after \LaTeX
(or any keyword) in order to distinguish it ompletely, and one might want a
pun tuation mark, like a omma, following \LaTeX, whi h requires no spa e.)
The text within the square bra kets is an option. If present, as in this
example, it is printed in boldfa e. With no option, the des ription list is one
way to have text indented the opposite of a normal paragraph: the rst line
is at the left and subsequent lines are indented. For example,
\begin{des ription}
\item \textsf{This is how one item in a des ription list
environment looks with no optional text at the beginning.}
\end{des ription}

produ es the following result:

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}

Figure 15: Itemize List Environment Sour e (Result in Figure 16)




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.

 A se ond (nested) itemized list hanges the bullet and


indents another level.

Figure 16: Itemize List Environment Result (Sour e in Figure 15)


Finally, I des ribe the enumerate list environment, where the default
numbering is with Arabi numerals. With nested enumeration, the numbering hanges at ea h level. Figures 17 and 18 illustrate with three levels of
nesting.

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}

Figure 17: Enumerate List Environment Sour e (Result in Figure 18)

1. This is item 1, and we are having fun.


2. This is item 2, and it's time to number anew.
(a) Ba k to item 1, but we are not yet done.
(b) Two is new.
i. One again!
ii. Two (b) or knot 2b?
Figure 18: Enumerate List Environment Result (Sour e in Figure 17)

2.3 Making Tables


A table is made with the tabular environment, whi h has the following syntax:

\begin{tabular}{ olumn spe s } options


rst row spe \\
..
.

last row spe [\\ options

\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:

2.3 Making Tables

17

l, or r, respe tively. In the body of the table, ea h olumn is separated by


&. Figure 19 shows an example of a 2  3 table.
How it appears
left enter
1
2

What you write


\begin{tabular}{l r}
left & enter & right \\
1 & 2
& 3
\end{tabular}

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

What you write

-110 -120.12 -130


210
220.
230
Figure 20: A

\begin{tabular}{|l| |r|} \hline


-110 & 120 & -130 \\ \hline
210 & -220 & 230 \\ \hline
\end{tabular}

2  3 Table with Horizontal and Verti al Lines

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

What you write


Test 2
72
67

\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

We an have tables nested within tables. Figures 22 and 23 illustrate


this, while showing more variation with lines and using various fonts. Here
are some things to note:




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.

The \underline ommand is used to underline Table 1, whi h is olumn


1 of the main table, whereas \ line{3-3} is used to underline all of
olumn 3 of the main table, headed by Table 2.
\textsf{
\begin{tabular}{lp{.3in}l} \\
\underline{Table 1} &&
Table 2 \\ \ line{3-3}
\\
\begin{tabular}{|l |} \hline
Obje t
& Symbols used \\ \hline
variable & lower ase \textrm{Roman} \\
parameter & \textit{Greek}
\\
onstant & \texts {upper ase} \textrm{Roman} \\
\end{tabular}
&& % Begin Table 2
\begin{tabular}{|r |} \hline
* & 1 & 2 \\ \ line{2-2}
& 3 & 4 \\ \ line{1-1}\ line{3-3}
\end{tabular}
\end{tabular}
} % end sf

Figure 22: Nested Tables Sour e (Result in Figure 23)

2.3 Making Tables

19

Table 1
Obje t
variable
parameter
onstant

Table 2
Symbols used
lower ase Roman

Greek

upper ase Roman

* 1 2
3 4

Figure 23: Nested Tables Result (Sour e in Figure 22)


There are times when we want to put a good bit of text into some olumns
of a table. Suppose, for example, we write the following:
\begin{tabular}{|l|l|} \hline
This amount of text is too long to fit on one line of
the page. & This is olumn 2. \\ \hline
\end{tabular}

The result will be to run o the edge of the paper:


This amount of text is too long to t on one line of the page. This is olumn 2.
One solution is to insert new rows and break up the text manually:
\begin{tabular}{|l|l|} \hline
This amount of text is too long to fit on one
& This is olumn 2. \\
line of the page. & \\ \hline
\end{tabular}

This amount of text is too long to t on one This is olumn 2.


line of the page.

Instead, one an assign a xed width to a olumn by spe ifying p{length }.


For example,

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}

This amount of text is too This is olumn 2.


long to t on one line of the
page.

Another is solution is to use the \parbox ommand (short for paragraph


box). This has the form \parbox[option {width }{text }, where the option
is the pla ement: t = top and b = bottom (default is enter). Here are two
examples:
\begin{tabular}{|l|l|} \hline
\parbox{2in}{This amount of text is too long to fit on
one line of the page.} & This is olumn 2. \\ \hline
\end{tabular}

This amount of text is too


long to t on one line of the This is olumn 2.
page.

\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}

This amount of text is too This is olumn 2.


long to t on one line of the
page.

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.

2.3 Making Tables

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}

Figure 24: \parbox Sour e (Result in Figure 25)

This is olumn 1, and I might want to


display something:
How sweet it is.
This is not the same as

This is olumn
2, whi h I
have put in
sans serif font.

How sweet it is.


Figure 25: \parbox Result (Sour e in Figure 24)
Any measurement, su h as the width of a paragraph box, an be determined by some length parameter, rather than a xed onstant. For example,
see exer ise 9 at the end of this hapter and onsider \parbox{.3\linewidth}...
If we want some heading to span several olumns, this is done by the
ommand, \multi olumn{number }{ ol spe }{entry }. The rst argument is
the number of olumns to span (starting where \multi olumn is spe ied).
This must be in the range 1 to however many olumns remain from the
urrent position. The se ond argument is any valid olumn spe i ation,
su h as l, , r, with, or without, a verti al line spe i ation, |, on either

2 TEXT

22

side. Finally, the third argument is the text.


The \multi olumn ommand an also serve to override some olumn
spe i ation. Suppose, for example, we want the olumns to be left justied,
but we want the headers to be entered. Figures 26 and 27 illustrate these
uses of \multi olumn. The rst is used to enter `Test number' over olumns
2 and 3. The line in the sour e begins with & to skip olumn 1, then the
\multi olumn spe ies 2 olumns, entered with verti al lines before and
after. The se ond use simply enters the `Student' header. The last use of
\multi olumn enters `Taken in lass' over olumns 2 and 3. Unlike the rst
use, the verti al line at the end is missing be ause was spe ied instead of
|.
\begin{ enter}
\begin{tabular}{l| | }
& \multi olumn{2}{| |}{Test number} \\
\multi olumn{1}{ |}{Student} &
1 &
2 & Average \\ \hline
Bill
& 67 & 72 & 70.5 \\
Charleetah & 72 & 67 & 70.5 \\ \hline
& \multi olumn{2}{ }{Taken in lass}
\\ \ line{2-3}
\end{tabular}
\end{ enter}

Figure 26: Multi olumn Sour e (Result in Figure 27)


Test number
Student
1
2
Bill
67
72
Charleetah 72
67
Taken in lass

Average
70.5
70.5

Figure 27: Multi olumn Result (Sour e in Figure 26)


Tables that are too long to t on one page ould be broken manually,
but the longtable pa kage enables automati page breaks by the LATEX ompiler. (You obtain the pa kage from CTAN [4.) In the preamble, spe ify
\usepa kage{longtable}. Then, instead of the tabular environment, spe ify the longtable environment, whi h has most of the same options.

2.4 Spe ial Chara ters

23

2.4 Spe ial Chara ters


We have already seen that some hara ters are spe ial, in that they delimit
something. In parti ular, \ delimits every LATEX ommand, and % ends a
line, enabling omments. How do we print su h hara ters? One way is with
the symbol, itself, like \%. Other times a keyword, like \textba kslash, is
needed. The Appendix ontains omplete tables of these (in luding those
I do not over in the hapters). Of parti ular importan e are the bra es,
written as \{ \} to obtain { }. (Re all that the bra es by themselves reate
a lo al environment, like {\large : : : }.)
When using a keyword to spe ify a spe ial hara ter, it appears with
whatever font is a tive. Table 2 illustrates this with ommonly used spe ial hara ters. The bra kets, [ , are dierent be ause they an be entered
dire tly, ex ept when they are used to delimit an option in the syntax, in
whi h ase they an be obtained by en losing them in bra es. One example
is the des ription list environment, illustrated in Figure 28. (Another is in
the tabular environment (page 16), but I omitted a dis ussion of position
options that are spe ied by bra kets.)
How it appears

What you write

This is option for item.

\begin{des ription}
\item [This is option for item.
\end{des ription}

[This is not option for item.

\begin{des ription}
\item {[This is not option} for item.
\end{des ription}

Figure 28: Obtaining Bra kets in a Des ription List Environment


Another way to print the unprintable is with the verbatim environment
or the \verb ommand. Unlike all other ommands, \verb does not use
bra es to delimit its argument. It uses any other hara ter to delimit a
string, whi h an ontain any hara ter ex ept itself. For example, we an
write \verb{}%$#\ to generate the string {}%$#\ (delimited by ), whi h
is printed in typewriter font style. The verbatim environment uses the usual
syntax:

2 TEXT

24
Other fonts

Chara ter
(Roman)

How you
write it

itali

{}

\{ \}

{}

%$#&_
\
^
~

%$#&_
\
\textba kslash
\textas ii ir um
^
\textas iitilde
~
\% \$ \# \& \_

\textregistered

{[ }

large

{}
%$#&_
\
^
~

r
[

Table 2: Writing Spe ial Chara ters

\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}

)
)
)
)
)

What you see

Table 3: Some A ents for Letters


environment, the rst senten e ontinues normally, without extra spa es, so
that the position of the tab is not equivalent to that of a table's olumn.
What you see
Begin: set tab 1
skip to 1

What you write

: : : 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}

Table 4: The Tabbing Environment


Sometimes we do not want to have the longest portion of text rst, yet
it is needed to dene the tab. Table 5 illustrates how this is solved with the
\kill ommand. In the rst tabbing, the lines are in the order we want,
but the tab is set by the shorter string `1-3', making `4-6-8' extend past the
tab. The se ond tabbing puts the longer eld rst, in order to set the tab
orre tly, then spe ies \kill instead of \\ to suppress (or kill) the printing
of the line.
What you see

What you write

1-3 sting like a bee


4-6-8don't be late

\begin{tabbing}
1-3 \= sting like a bee \\
4-6-8 \> don't be late \\
\end{tabbing}

1-3 sting like a bee


4-6-8 don't be late

\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}

Table 5: The \kill Tabbing Command

2 TEXT

26

Figures 29 and 30 illustrate the tabbing environment with xed eld


widths. It rst uses the \hspa e* ommand for horizontal spa ing, then it
uses the name of the last eld to set what follows.
\begin{tabbing}
\= \hspa e*{.5in} \= \hspa e*{2in} \= Last field: \= \kill
\> Field 1 (following tab 1)
\\ \> \> Field 2 on new line \> Last field
\\ \> \>
\> Last field on new line
\end{tabbing}

Figure 29: Tabbing Sour e (Result in Figure 30)

Field 1 (following tab 1)


Field 2 on new line

Last eld
Last eld on new line

Figure 30: Tabbing Result (Sour e in Figure 29)

2.6 Line and Page Breaks


You an ause a new line by entering \linebreak. When text is justied (the
default), this ould result in an undesirable appearan e, like the following:

\textsf{This example is \linebreak extreme.}


)This
example
extreme.

is

The \newline ommand for es a new line without justifying it.

\textsf{Here is the extreme \newline example.}


)Here is the extreme
example.
The \nolinebreak ommand works analogously, preventing a line break,
even if it means extending into the right margin. Also, it is better style to
keep ertain `words' together, su h as `gure 1' or `p. 10'. To prevent a line

2.7 Spa ing

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

2.7 Spa ing


We have already seen the use of ~ to insert one spa e and \hfill to put the
remaining text ush right. The most versatile method to insert horizontal
spa es is with \hspa e and \hspa e*.
These have one argument: the
amount of spa e to be inserted. For example,

I insert .3~in \hspa e{.3in} here.

) 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):




All lines are entered.


The title appears rst in very large letters.

2.7 Spa ing







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):

3.2 The bib File

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

3.2 The bib File


3.2.1

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 ",
..
.

For example, Knuth's book [8 would be entered as follows:

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.

3.2 The bib File




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.

There is a nal } to lose the entry  type {

: : : }.

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.

arti le refers to an arti le from a journal or magazine.


Required elds: author, title, journal, year.
Optional elds: volume, number, pages, month.
book refers to a book with an expli it publisher.
Required elds: author or editor, title, publisher, year.
Optional elds: volume or number, series, address, edition, month.
booklet refers to a bound, printed do ument, but without an expli it
publisher.
Required elds: author or key, title.
Optional elds: author, howpublished, address, month, year.
inbook is a part of a book, su h as a hapter or just some range of pages.
Required elds: author or editor, title, hapter and/or pages,
publisher, year.
Optional elds: volume or number, series, type, address, edition,

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

3.2 The bib File

35

unre ognized eld, su h as omment = "...", (this is ignored with no error


message given).
If a required eld is missing when you ompile, you will get an error
message. Possibly there will be some standard xup, but it is best if you
provide the missing eld value. If a do ument has no author, you must
provide a key for sorting. For example, onsider the following entry for
LATEX 2" [10, whi h has no person as an author. The bibliography will be
sorted with the key, LaTeX2e, used to order this entry relative to author
names. The key will not be printed.
manual{usrguide,
key = "LaTeX2e",
title = "{\LaTeXe} for authors",
type = "World Wide Web site",
institution = "Comprehensive {\TeX} Ar hive",
address = "{CTAN\url{/ma ros/latex/do /usrguide.ps}
(see~\ ite{CTAN} for repla ing CTAN)}",
year = "1995--99",
}

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).

3.2.2 Web itations


When BibT X was developed, the World Wide Web did not exist. Now it
is a major sour e of information. There is no universally a epted standard
for how to referen e web do uments, but here is one way.
If it is a book, use the book type and spe ify:

publisher = "World Wide Web",


address = "url ",

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}",
}

The referen e \ ite{StrunkWhite} presumes there is the entry for the


original publi ation. The use of the bra es in the name is to be sure that
the author appears as intended: William Strunk, Jr. Otherwise, without the
bra es, the omma would signal the bibtex program that `Jr.' is the rst
name of the author, and it would appear as `Jr. William Strunk'.
If the do ument is a te hni al report, use that style but in lude the url
as a note or in the address eld. Eventually, you will run into some di ulty
with writing urls. For one thing, the url ould ontain spe ial hara ters; in

3.2 The bib File

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/}",

The \url spe i ation is not a tually an intrinsi ommand in LATEX; it


is dened in a pa kage. Its main use is to determine where the url an be
broken in order to put it on two lines, if needed. Another feature of the
url pa kage is that \url prints spe ial hara ters, like ~. To have the \url
ommand a tive in your do ument, put the following de laration into your
preamble: \usepa kage{url}. The default font it uses is tt, but you an
hange this to another font with the spe i ation:
\renew ommand\url{\begingroup\urlstyle{font }\Url}

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

3.2.3 Additional features


One element of good style is to be onsistent in your terms, in luding abbreviations and names of publishers. One sometimes sees Kluwer, other times
Kluwer A ademi Publishers, and still other times Kluwer Pub. To help
be onsistent and to save some work in the long run when we write many
dierent do uments and produ e more bib les, we an dene strings with
the entry:
string{name = "string "}

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,

to produ e the publisher value = Kluwer A ademi Publishers. Besides


onsisten y, an advantage is that if some name hanges, we merely hange
the one string value and re ompile.
We an on atenate strings and/or literals with #. For example, suppose
we write
string( mom = "My Mother" )
string( dad = "My Father" )
author = mom,
title = mom # dad,
editor = dad,

Then, the three eld values are equivalent to:


author = "My Mother",
title = "My MotherMy Father",
editor = "My Father",

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:

3.2 The bib File


title

39

= mom # "~" # dad,

The same title as the above is obtained by any of the following:


title = "My Mother " # dad,
title = mom # " My Father",

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,
}

Then, we an have the following entry:


InPro eedings{Artemiadis:FAA-89-311,
rossref = "Byrnes:FAA-89",
author
= "N.K. Art{\'e}miadis",
title
= "Results on the Absolutely Convergent Series
of Fun tions and of Distributions",
pages
= "311--316",
}

If these were the only referen es, the result would appear as follows:

[1

N.K. Artmiadis. Results on the absolutely onvergent series of fun tions


and of distributions. In Byrnes and Byrnes [2, pages 311316.

[2

J.S. Byrnes and Jennifer L. Byrnes, editors.

Re ent Advan es in Fourier


Analysis and its Appli ations: Pro eedings of the NATO Advan ed Study
Institute. Kluwer A ademi Press, 1990.

BibTE X also re ognizes a preamble in our bib les to enable us to dene

some LATEX ommands. The general form is

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.

3.3 De laration and Citation


At the end of your sour e le (where you want the bibliography to appear),
before \end{do ument}, put the following ommands (in either order):

\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):

3.3 De laration and Citation

41

plain is the most ommon be ause it formats entries a ording


to a epted standards. Entries are sorted by the alphabeti al
order of author names, breaking ties with the year of publi ation, and they are labeled with numbers.
abbrv diers from plain by abbreviating names of journals, among
other things (to give a more ompa t bibliography).
alpha diers from plain by iting by labels, rather than numbers.
unsrt diers from plain by sorting entries by the order in whi h
they are ited, rather than by the author names.
We shall use only the plain style here, but know that many other styles have
been written and are available free of harge.
To ite parti ular referen es, the LATEX ommand is \ ite{label [, : : : },
where label is what we put in our bib le entry. For example, [8 is produ ed
by spe ifying \ ite{tex}. You an put more than one itation, separated by
ommas. For example, \ ite{tex,latex} produ es [8, 9 for this do ument.
You an insert some further itation information as an optional input
argument to the \ ite ommand. For example, \ ite[p.~46{latex} produ es [9, p. 46 in this do ument. (In the option, delimited by [ , the ~ is
used to ensure that there is a spa e but no line break when giving the page
number as p. 46 in the itation.)
The rule is that only those bib entries that are ited appear in the nal
do ument. The reason is that we an maintain one large bib le and write
many do uments that use it. There are times when we want to be sure a
parti ular bib entry appears, but we do not want to ite it in the text. This
is done with the \no ite ommand. In parti ular, if we want to have every
entry in our bib le appear, we spe ify \no ite{*}. If we want only some
parti ular list of entries to appear, we use \no ite with their labels, su h as
\no ite{tex} to be sure Knuth's TEX book appears, even if it is not ited
expli itly. Figure 32 shows a omplete sour e le for having all entries in
mybiblio.bib appear, and that is the entire do ument!
We an spe ify more than one bib le, su h as:
\bibliography{mybiblio,another}
The bibtex program will sear h them sequentially for any itation. If we have the
same label in both bib les, the entries must be identi al; otherwise, we will get
a fatal error message, Repeated entry telling us whi h label is repeated. If we
have the same entry with dierent labels, they will appear twi e if both labels are
used (or if we used \no ite{*}).

3 BIBLIOGRAPHY WITH

42

BIBTEX

\do ument lass[12pt{arti le}


\begin{do ument}
\no ite{*}
\bibliographystyle{plain}
\bibliography{mybiblio}
\end{do ument}

Figure 32: A Do ument to Print the Bibliographi Database

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.

Impossible Dreams, volume I. Ma Ta o, se ond edition,

[2

I.M. Ri h, editor.

Impossible Dreams, volume II. Ma Ta o, 1990.

[3

I.M. Smart, U.R. Tu, and V.F. Money.


Volume II of Ri h [2, 1990.

How to Square a Cir le, hapter 1.

43
5. Produ e an annotated bibliography of the following form (note the indentations on left and right margins):

[1

P.R. Halmos,

Naive Set Theory, Van Nostrand, Prin eton, NJ, 1960.

This is a good book, whi h I assign to my Ph.D. students.


The rst 100 pages seem simple. The next 100 reveal la k of
understanding the rst 100.

[2

G. Polya,
1945.

How To Solve It, Prin eton University Press, Prin eton, NJ,

This is a seminal book that arti ulates the problem-solving 


i.e., theorem-proving  pro ess. There are many editions, and
there are modern des endants, su h as : : :

Counters, Labels, and Referen es

4.1 Basi Con epts


A ounter is a numeri al value that refers to something that is being numbered,
su h as pages, se tions, gures, and equations. A label is the identi ation of
a parti ular value, and a referen e is a itation to a label. The LATEX syntax
for labeling a ounter is \label{label }, pla ed where the ounter's value is set,
where label is unique in the do ument. The LATEX syntax for referen ing a label is
\ref{label }. For example, in this book I dened:

\se tion{Bibliography with \Bibtex} \label{se :Bibliography}


Now I an refer to 3 by \S\ref{se :Bibliography}. The hoi e of label is arbitrary, ex ept do not use LATEX spe ial hara ters or blanks, just as the labels in
the bib le entries.
There are times when you just want to produ e the ounter value, without a
label. This is done by \the ounter. For example, \thepage produ es the page
number. On the other hand, if you want to use the ounter's numeri al value as
an argument in a ommand, spe ify \value{ ounter }.
In the next se tion I des ribe intrinsi ounters and illustrate how to label and
referen e them. Then, I shall introdu e the gure and table environments, whi h
have intrinsi ounters asso iated with them.

44

4 COUNTERS, LABELS, AND REFERENCES

4.2 Intrinsi Counters


Anything to whi h LATEX assigns a number has a ounter asso iated with it. Here
I illustrate some of those that are in all do ument styles. Counters that depend
upon the style, like a hapter in a book, an be labelled and referen ed in the same
manner.
You are looking at page 44, whi h I was able to print by writing \thepage.
Similarly, you are reading subse tion 4.2 of se tion 4, whose numbers I ould write
by \thesubse tion\ and \these tion, respe tively.
To illustrate how I an referen e other parts of this do ument, the following
labels were dened (when the subse tion and subsubse tion were rst written):

\subse tion{The bib File} \label{subse :bibfile}


\subsubse tion{Web itations} \label{subsubse :web ite}
Then, I an refer to these as follows:

\S\ref{subse :bibfile}
\S\ref{subsubse :web ite}

) 3.2
) 3.2.2

I an also refer to their page numbers:

p.~\pageref{subsubse :web ite}


p.~\pageref{subse :bibfile}

) 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.)

4.3 Figures and Tables

45

4.3 Figures and Tables


In this se tion I des ribe gure and table environments,
syntax:

\begin{figure}[options
[\ aption{ aption [\label{label }}
..
.

[\ aption{ aption [\label{label }}


\end{figure}

whi h have the same

\begin{table}[options
[\ aption{ aption [\label{label }}
..
.

[\ aption{ aption [\label{label }}


\end{table}

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

4 COUNTERS, LABELS, AND REFERENCES

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

number : aption vs. Table number : aption

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}

Figure 33: Framed Figure 34 Sour e

This is a framed gure.


Figure 34: Framed Figure with Caption at Bottom
The parameter settings have returned to their default values, upon leaving the
gure environment. (This is alled a lo al setting.) Thus, the frame in Figure 35
has thin lines and no extra padding around the border. Also note how the aption
is put at the top (see exer ise 3).

4.4 Dening Your Own

47

Figure 35: Framed Figure with Caption at Top


This is framed with default parameter values.

4.4 Dening Your Own


In the preamble you an dene your own ounter with the \new ounter ommand:

\new ounter{name }[within


where name is the (unique) name of the ounter ( annot be the same as one of
the intrinsi ounter names). The initial value of the ounter is 0. For example,
\new ounter{my ounter} denes a ounter whose name is my ounter. You an
also dene the ounter to be within another ounter. For example,
\new ounter{my ounter}[se tion
denes my ounter to be within the se tion ounter. This will ause the value of
my ounter to be reset to 0 when entering a new se tion. Further, instead of the
printed values being 1, 2, : : : , they will be 1.1, 1.2, : : : within se tion 1; more
generally, the values of my ounter will be of the form s.1, s.2, : : : when printed
within se tion s.
The ounter values are printed in Arabi numerals, but you an spe ify the
type of numeral, shown in Table 7.

What you see


a, b, , d, : : :
A, B, C, D, : : :
1, 2, 3, 4, : : :
i, ii, iii, iv, : : :
I, II, III, IV, : : :

What you write


\alph{my ounter}
\Alph{my ounter}
\arabi {my ounter}
\roman{my ounter}
\Roman{my ounter}

Table 7: Numerals to Print Counters


Counter values an be in remented with the \addto ounter ommand. For
example, \addto ounter{my ounter}{1} adds 1 to the value of my ounter. If we
just want to in rement the ounter by 1, we an spe ify \step ounter{my ounter}.
Counter values an be set to some absolute value with the \set ounter ommand.
For example, \set ounter{my ounter}{5} sets the value of my ounter to 5. This
an also be used to transfer the value of one ounter to another. For example,

\set ounter{my ounter}{\value{page}}

4 COUNTERS, LABELS, AND REFERENCES

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

\refstep ounter{my ounter} \label{mylabel}


Then, we an use \ref{mylabel} and \pageref{mylabel} wherever we like.
The default numeral type is arabi , but you an hange the appearan e to be
any of those listed in Table 7 by applying the \renew ommand to \the ounter. For
example,

\set ounter{my ounter}{0}


\renew ommand{\themy ounter}{\roman{my ounter}}
\step ounter{my ounter} (\themy ounter),
\step ounter{my ounter} (\themy ounter), \dots

(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}

Figure 36: Alternative enumerate Symbols Sour e (Result in Figure 37)


The se ond level, whose ounter is enumii, had its label hanged to what is
spe ied in the sour e: \renew ommand{\labelenumii}{\theenumii.} (the appearan e parameter is \labelenumii). These hanges remain in ee t ( alled a

4.4 Dening Your Own

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

\renew ommand{\theenumi}{\arabi {enumi}}


\renew ommand{\labelenumi}{(\theenumi)}
\renew ommand{\theenumii}{\alph{enumii}}
\renew ommand{\labelenumii}{(\theenumii)}
\renew ommand{\theenumiii}{\roman{enumiii}}
\renew ommand{\labelenumiii}{(\theenumiii)}
\renew ommand{\theenumiv}{\Alph{enumiv}}
\renew ommand{\labelenumiv}{(\theenumiv)}

Table 8: Default Settings for enumerate Counters

global setting ), so we must hange them ba k if we want to restore the defaults,


shown in Table 8.

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:

A onsequen e of Einstein's postulates is that $E = m ^2$.


A onsequen e of Einstein's postulates is that E = m 2 .

The other form is

math display mode, like this:

A onsequen e of Einstein's postulates is that \[E = m ^2.\


A onsequen e of Einstein's postulates is that

E = m 2 :

5.1 Mathemati al Symbols


The example also illustrates the use of the supers ript operator, ^. Table 9 shows
other ommon operations in math mode. (Ea h of the tables in this se tion applies
only to math mode.)
The bra es en lose an expression that an be used to dene a more om2
plex operand. For example, xa+b is written as $x_{a+b}$ and xa is written as
$x^{a^2}$. The order of subs ripts and supers ripts does not matter:
d
x_{a+b}^{ +d} ) x a+
+b

x^{ +d}_{a+b}

) x a++db

5.1 Mathemati al Symbols

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

Table 9: Some Mathemati al Operations


Table 10 shows some set notation. The omplement of A often appears as  A,
produ ed by $\sim A$, but this is not universal notation; some authors use A or
A0 , produ ed by $A^ $ and $A^\prime$, respe tively, and some use A, produ ed
by $\overline{A}$.
Pre eding any symbol by \not puts the line through the symbol, as in the
following examples:

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





What you write


\emptyset
\ ap
\ up
\setminus
\in
\subset
\subseteq
\supset
\supseteq

Table 10: Set Notation


You an ontrol the size of the font by using the usual spe i ation before entering math mode. For example, {\Large $(x\div y) + z$} ) (
)+ . Font
style, however, does not apply to math mode be ause math mode has its own, separate from text mode. You an make math fonts boldfa e by spe ifying \boldmath
before entering math mode. For example, {\boldmath $x^n+y^n=z^n$} ) xn
yn z n . Note that \boldmath is surrounded by the bra es; otherwise, math fonts

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.

\boldmath$A\supset B$ text $B\ up C$


{\boldmath$A\supset B$} text $B\ up C$

) 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,

{\boldmath$\tilde A\times\ve {1}\otimes\overline{2}$}


$\mathbf{\tilde A\times\ve {1}\otimes\overline{2} }$

) A~  ~1
2
) A~  ~1
2

Table 11 illustrates the out ome of ea h font for this expression:


\mathfont {\tilde A\times\ve {1}\otimes\overline{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

Table 11: The nmathfont Commands

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):

ABCDEFGHIJ KLMNOPQRST UVWXYZ :


Write ${\ al P} = A + B$ to produ e P = A + B ; without the bra es, the alligraphi fonts remain in ee t: $\ al P = A + B$ ) P = A + B .

Greek letters are dened only in math mode, and they are spe ied by spelling
them as keywords. For example, to produ e

=

5.2 Fra tions and Variable Size Fun tionality

53

write \[ \alpha - \beta = \Delta - \delta \. As Lamport [9, p. 43 says,


Making Greek letters is as easy as  (or ) (written $\pi$ or $\Pi$). (Not
every Greek letter is in luded  see Appendix Table 35.) The \mathbf does not
make Greek letters boldfa e. We ould use \boldmath to a hieve this, but there
is a pa kage that not only provides the boldfa e font, but also produ es proper
spa ing. In the preamble spe ify \usepa kage{bm}, then \bm{\beta} ) .

5.2 Fra tions and Variable Size Fun tionality


To make fra tions, we ould write $(x+y)/4$ to make (x + y )=4, but if we want
x+y , we use the \fra ommand: $\fra {x+y}{4}$. We an make this appear
4
x+y
larger, as 4 , by pre eding the math mode with \large.
The general form is \fra {numerator }{denominator }, where the numerator
and denominator an be any expression. Here is a more omplex equation in math
display mode:

A=

x2 + y
;
1 + x2+1

written as \[ A = \fra {x^2+y_\alpha}{1+\fra {\eta}{x^2+1}}, \. Note how


the sizes of the fra tions adjust automati ally.
Some mathemati al symbols adjust their size to t the expression. Table 12
shows some of the most ommon of these, and I present more examples below. In
the ase of the integrals, note the use of \, between the integrand and dx. This
inserts a thin spa e ( ompare the results by writing the expression with and without
the \,).
In LATEX, symbols whose size you would want to adapt to expressions are
generally designed to do so. Figures 38 and 39 illustrate this with another example,
whi h uses the \sqrt and \prod fun tions:
\[ \sqrt{\fra {\prod_{n=1}^N \left( \sum_{i\in I_n} x_i^n\right)}
{\sqrt[3{\sum_{i\in I_\infty} x_i}}
}
\

Figure 38: Variable Sizes Sour e (Result in Figure 39)

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

What you write

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

Table 12: Variable Size Mathemati al Operation Symbols


v
u QN

P
n
u
=1
i2In xi
u nq
t
3 P
i2I1 xi

Figure 39: Variable Sizes Result (Sour e in Figure 38)


Noti e that even though it is written in math display mode, the indi es on the
sums and produ t appear as they would in line. LATEX ompilers make judgments
about the layout, but you an for e either of the two styles with the \displaystyle
and \textstyle ommands. Figures 40 and 41 illustrate this.

5.2 Fra tions and Variable Size Fun tionality

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}}
}
\

Figure 40: \displaystyle Sour e (Result in Figure 41)


v
!
u N
uY X
u
xni
u
u n=1 i2I
u s n
u
X
u
xi
t
3
i2I1

Figure 41: \displaystyle Result (Sour e in Figure 40)


In text mode you an for e the display style of pla ing these subs ripts and
supers ripts on fun tions, as well as sizing the expression, as though it were in
display mode. Figure 42 gives more examples to ompare in line text and display
mode, using \textstyle and \displaystyle to override the default form for the
mode. The default is not always predi table; in parti ular, math display mode
does not always use displaystyle.

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

Figure 42: Examples to Compare Text and Display Modes


Table 13 shows symbols used in logi al expressions. For example, to have

(x 2 A ) x 2 B ) , (A  B ):

5 MATH MODE

56

write \[ (x\in A\Rightarrow x\in B) \Leftrightarrow (A\subseteq B). \


To have

8x9y 3 [P (x) ^ Q(y):


write \[ \forall x\exists y\ni [P(x)\wedge Q(y). \

Logi al Term
existential quantier
universal quantier
negation
disjun tion
onjun tion
impli ation
equivalen e
su h that

How it appears What you write


9
\exists
8
\forall
:
\neg
_
\vee
^
\wedge
!
\rightarrow
)
\Rightarrow
,
\Leftrightarrow

\equiv
3
\ni

Table 13: Some Symbols in Logi


The quantiers in this last example seem a bit rowded, so we might want
to add some spa ing between terms. In math mode a full spa e is obtained by
spe ifying \; and a half spa e by \,. Here is how ea h looks:

\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:

(-\infty,0 = \{x\ni x \le 0\}


a_j\pre b_i \equiv b_i \su a_j
\forall y\,\{x: x\not\pre y\}
\not\subset {\ al A}

) ( 1; 0 = fx 3 x  0g
) a j  bi  bi  a j
) 8y fx : x 6 yg 6 A

5.3 Arrays and Equations


Relation
less than or equal
greater than or equal
not equal
pre edes
pre edes or equals
su eeds
su eeds or equals

57
How it appears



6=





What you write


\le
\ge
\ne
\pre
\pre eq
\su
\su eq

Table 14: Order Relations


We have seen how to embed math mode into text, but we an also do the
reverse with the \mbox ommand. Compare ea h of the following:

xi < 0foralli = 1; : : :
xi < 0 for all i = 1; : : :
xi < 0 for all i = 1; : : :

written as $x_i < 0 for all i=1,\dots$


written as $x_i < 0$ for all $i=1,\dots$
written as $x_i < 0 \mbox{ for all } i=1,\dots$

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.

5.3 Arrays and Equations


The array environment is to math mode what tabular environment is to text mode,
and more. It has the form:

\begin{array}{ olumn spe s }options


rst row spe \\
..
.

last row spe [\\ options

\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}

You an align a series of equations to appear this way:

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)

(Another dieren e is that the eqnarray environment uses displaystyle.) We use


the eqnarray environment dire tly (without entering math display mode), so the
above is produ ed by the following:

5.3 Arrays and Equations

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}

Figure 43: eqnarray Environment Sour e (Result in Figure 44)

x is equal to y
a+b+ +d e+f +g+h
y

+
+


I +K +J +L

(3)
(4)

Figure 44: eqnarray Environment Result (Sour e in Figure 43)


There is also an eqnarray* environment, whi h is the same as eqnarray, but
without the equation numbers. There is no apparent advantage to this sin e the
same result an be produ ed by the ordinary array environment, spe ialized to this
olumn spe i ation. It does, however, let us hange our mind easily as to whether
or not to in lude equation numbers by simply adding or removing the * from the
environment spe i ation.
For a single, numbered equation, there is the equation environment. This poses
no parti ular advantage over spe ifying eqnarray and merely entering one row

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.

What you write


x'
x^t
x^T
x^{\mathsf{T}}
x^{\mbox{\tiny $T$}}

)
)
)
)
)

How it appears

x0
xt
xT
xT
xT

Table 15: Transpose of a Ve tor


\begin{equation*}
Ax^\prime = \left[ \begin{array}{rrr}
1.1 & 1.2 & 1.3 \\
21.0 & 22.0 & -2.1 \\
\end{array} \right
\left( \begin{array}{ } x_1 \\ x_2 \\ x_3
\end{array} \right).
\end{equation*}

Figure 45: Matrix Equation Sour e (Result in Figure 46)

Ax0 =

1:1 1:2 1:3


21:0 22:0 2:1

0


x1
x2
x3

1
A:

Figure 46: Matrix Equation Result (Sour e in Figure 45)


Array environments an be nested, as illustrated in Figures 47 and 48. Noti e how the verti al line was drawn by the olumn spe i ation, { | }, and the
horizontal line separating the blo ks is obtained by spe ifying \hline before the
se ond row of the outer array.

5.3 Arrays and Equations

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
\

Figure 47: Nested Arrays Sour e (Result in Figure 48)

A11 A12 A13


A21 A22 A23

6
6
4

0
B11 B12
B21 B22

3
7
7
5

Figure 48: Nested Arrays Result (Sour e in Figure 47)


We an en lose mathemati al expressions in a box, sometimes used for emphasis. For example,

\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

We an use \fbox within math mode, su h as writing $x = \fbox{y} + z$ to


produ e x = y + z . Note how the line height does not adjust to the frame, ausing

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:

produ ed by the following LATEX ode:

\[ f(x) = \left\{ \begin{array}{rll}


-1 & \mbox{if} & x < 0; \\
0 & \mbox{if} & x = 0; \\
1 & \mbox{if} & x > 0.
\end{array}\right.
\
Note the use of \right. after the array. This is be ause \left and \right
must balan e  i.e., there must be an equal number of ea h. It is not ne essary
that the left symbol be related to the right one  i.e., \left\{ does not require
\right\} to balan e; any right symbol will do. The period is not printed in this
ase, used spe i ally for this purpose of balan e.
We have seen the use of \left and \right for bra kets around a matrix. Now
the use of the \left LATEX ommand for onditional assignment raises related uses
of the underbra e and overbra e. Figures 49 and 50 illustrate these, along with
\overline, \underline, \widehat and \widetilde.
\[ \begin{array}{ }
\mbox{This sum has} \\ \mbox{an overbra e} \\
\overbra e{\overline{i\dots j} + \underline{k\ dots l}}
& \underbra e{\widehat{xy} - \widetilde{ab}}
\\ & \mbox{This differen e}
\\ & \mbox{has an underbra e}
\end{array} \

Figure 49: Horizontal Bra es Sour e (Result in Figure 50)

5.3 Arrays and Equations

63

This sum has


an overbra e

}|

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

\renew ommand{\arraystret h}{1.2}


\begin{ enter} \begin{small} \begin{tabular}{lll}
Matrix & Definition & Example \\ \hline
\parbox[t{.9in}{Covarian e}
& \parbox[t{2in}{\flushleft
$A_{ij} = E[(X_i-\mu_i)(X_j-\mu_j)$, where $\{X_i\}$
are random variables, and $E[\ dot$ is the expe ted
value operator with $\mu_i=E(X_i)$. }
& \parbox[t{1.4in}{\s riptsize
$\left[\begin{array}{rrrrr}
\fra {1}{2}&0 \\ 0&\fra {1}{2}
\end{array}\right$
\flushleft for $X_2=X_1^2$ and
$Pr[X_1=x$ \\
$= \left\{ \begin{array}{lll}
\fourth &\mbox{for}& x=-1~ \vspa e{.05in} \\
\half &\mbox{for}& x=~~0~ \vspa e{.05in}\\
\fourth &\mbox{for}& x=~~1.
\end{array}\right.$ } \vspa e{.1in} \\ \hline
\end{tabular} \end{small} \end{flushleft}
\renew ommand{\arraystret h}{1}

Figure 51: \flushleft in parbox Sour e (Result in Figure 52)


Matrix

Denition

Example
1 0 
2

Covarian e

Aij = E [(Xi i )(Xj j ),


where fXi g are random
variables, and E [ is the
expe ted value operator with
i = E (Xi ).

1
2

X2 = X12
P r8
[X1 = x

for

>
>
<
=
>
>
:

1
4
1
2
1
4

and

for

x=

for

x=

for

x=

1:

Figure 52: \flushleft in parbox Result (Sour e in Figure 51)

5.4 Spe ial Fun tions and Alphabets

65

\begin{ enter} \begin{small} \begin{tabular}{lll}


Matrix & Definition & Example \\ \hline
\parbox[t{.9in}{Covarian e}
& \parbox[t{2in}{\raggedright
$A_{ij} = E[(X_i-\mu_i)(X_j-\mu_j)$, where $\{X_i\}$
are random variables, and $E[\ dot$ is the expe ted
value operator with $\mu_i=E(X_i)$. }
& \parbox[t{1.4in}{\s riptsize\raisebox{-.1in}{
$\left[\begin{array}{rrrrr}
\fra {1}{2}&0 \\ 0&\fra {1}{2}
\end{array}\right$}
\flushleft for $X_2=X_1^2$ and
$Pr[X_1=x$ \\
$= \left\{ \begin{array}{lll}
\fourth &\mbox{for}& x=-1~ \vspa e{.05in} \\
\half &\mbox{for}& x=~~0~ \vspa e{.05in}\\
\fourth &\mbox{for}& x=~~1.
\end{array}\right.$ } \vspa e{.1in} \\ \hline
\end{tabular} \end{small} \end{ enter}

Figure 53: \raggedright in parbox Sour e (Result in Figure 54)


Matrix
Covarian e

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:

Figure 54: \raggedright in parbox Result (Sour e in Figure 53)

5.4 Spe ial Fun tions and Alphabets


Math mode re ognizes a olle tion of spe ial fun tions. Table 16 shows some ommon ones. These spe ial fun tions are used to make the sour e learer, rather than
using \mbox to a hieve the same result.
Among the spe ial fun tions are the omplete set of trigonometri fun tions.
For example, we write $\tan\theta = \fra {\sin\theta}{\ os\theta}$ to pro-

5 MATH MODE

66
Fun tion How it appears
limit
lim inf
log
maximum
tangent

lim
lim inf
log
max
tan

What you write


\lim
\liminf
\log
\max
\tan

Table 16: Some Common Mathemati al Fun tions


sin 
du e: tan  = os
 . Appendix Table 40 (p. 126) has a mu h longer list of spe ial
fun tions, as well as the arrows used in some of the examples shown in Table 17.

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

What you write


\lim_{n\rightarrow\infty}x_n
\liminf_{n\downarrow 0}\log\,x_n
\max_{x\in X}f(x)
\fra {\tan(\theta + \pi)}{\ln\,x}

Table 17: Examples of Mathemati al Fun tions


There is also a pa kage of AMS symbols, whi h you de lare in your preamble
with \usepa kage{amssymb}. This gives the following alphabet with the mathbb
font:

$\mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$

) A B C D E F G H IJK L M N O PQ R STUVW XYZ

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.

5.5 Derivatives and Integrals


What you writey
\mathbb{R}
\mathbb{C}
\mathbb{Z}
\mathbb{Q}
yIn math mode.

)
)
)
)

67
How it appears
R
C
Z
Q

What it means
Real values
Complex values
Integer values
Rational values

Table 18: Notation Using mathbb Fonts from amssymb Pa kage


Another alphabet is \maths r, for whi h you spe ify \usepa kage{mathrsfs}
in the preamble. This gives the following alphabet:

$\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.)

5.5 Derivatives and Integrals


We an express a total derivative, df (x)=dx, by writing $df(x)/dx$; or, we an use
(x)
. The partial derivative symbol,  , is written
the \fra ommand to produ e dfdx
\partial, so you an write \partial f(x)/\partial x to produ e f (x)=x, and
f (x)
{\large$\fra {\partial f(x)}{\partial x}$} to produ e x .
The usual notation for the gradient of a fun tion is the nabla, denoted by
the symbol r, (also alled del), whi h is an upside down delta (introdu ed by
Hamilton in 1853). In LATEX it is produ ed by \nabla, and its mathemati al
denition is the ve tor of rst partial derivatives:

rf (x) = (f (x)=x1 ; : : : ; f (x)=xn ):


I leave it as an exer ise to show the LATEX ode that produ ed equation (5).
The Hessian is the matrix of se ond partial derivatives:

r f (x) =
2

This was produ ed by the following ode:

 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

This was obtained by the following ode:

\[ \int_a^b \lim_{\lambda\rightarrow\infty} \left|


\fra {\oint_{X(v)} xe^{\lambda f(x)}\,dx}
{\oint_{X(v)} e^{\lambda f(x)}\,dx}\right|
\,\Phi(v)\,dv .
\
(Note the use of the thin spa e, \,.)
Denite multiple integrals are no problem. To have
Z

1 Z xn Z xn 1
0



x2

H (x1 ; : : : ; xn ) dx1    dxn

write

\[ \int_0^\infty \int_0^{x_n} \int_0^{x_{n-1}} \ dots


\int_0^{x_2} H(x_1,\dots,x_n)\,dx_1\ dots dx_n
\

5.6 Theorems and Denitions

69

However, onsider the following:


Z Z

(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

(ur  rv vr  ru) d:

Note how the domains are entered on the multiple integrals and the spa ing of
the integral signs.

5.6 Theorems and Denitions


The foundations of mathemati s are axioms and rules of inferen e. The rules
reate theorems, whi h are statements whose truths are established relative to the
underlying logi . This is so fundamental that LATEX has the fa ility to dene a
spe ial environment that in ludes a keyword, like Theorem, and a name, whi h
is not only the name of the environment, but is also the name of the asso iated
ounter. Consider the following example:

Theorem 5.1 For n > 2, there is no solution to xn + yn = z n for


x; y; z 2 Z++.
Noti e how  Theorem 5.1 appears, all text is in itali , and we have the
ounter value: \thetheorem=5.1. This was dened in the preamble by:

\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:

Corollary 5.1.1 The sum of ubes annot be a ube.


It was dened in the preamble as follows:

\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:

\begin{ orollary} The sum of ubes annot be a ube.


\end{ orollary}
The following reates an axiom environment that is not within any other
ounter.

\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:

\begin{axiom} \label{axm: hoi e}


From any (infinite) family of sets a new set an be reated
that ontains exa tly one element from ea h set in the family.
\end{axiom}
The label allows us to refer to the Axiom of Choi e as `Axiom 1 on page 70' by
writing Axiom~\ref{axm: hoi e} on page~\pageref{axm: hoi e}.
The environment reated by \newtheorem puts the text in itali s, but this is
generally not desirable for a denition. Consider the following example:

5.7 Renements

71

Denition 5.1 The ir umferen e of a sphere is the ir umferen e of any great


ir le on the sphere.

This was reated by rst entering (in the preamble):

\newtheorem{defn}{definition}[se tion
Then, in the text:

\begin{defn} The ir umferen e of a sphere is the


ir umferen e of any great ir le on the sphere.
\end{defn}
Compare this with the following:

Denition 5.1

The
ir le on the sphere.

ir umferen e of a sphere is the ir umferen e of any great

This was reated by rst entering (in the preamble):

{\theorembodyfont{\rmfamily} \newtheorem{mydefn}{Definition}[se tion}


Then, in the text:

\begin{mydefn} The \textit{ ir umferen e of a sphere} is the


ir umferen e of any great ir le on the sphere.
\end{mydefn}

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.

The remaining renements use the amsmath pa kage (introdu ed on p. 69


for obtaining better multiple integrals).
The gather and gather* environments allow the new line spe i ation,
\\, in math mode. They behave like the eqnarray and eqnarray* environments, respe tively, ex ept the equations are not aligned. Figures 55 and 56
illustrate this. The same result with equation numbers is obtained by the
gather environment.
\begin{gather*}
(a+b)^2 = a^2 + 2ab + b^2 \\
{\ al L} \oplus M^\varepsilon - V = H_0 \\
A(x) = \{y: \phi(y) = \ up_{a\in \ al A} \Psi(x)\}
\end{gather*}

Figure 55: gather* Environment Sour e (Result in Figure 56)

(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


When writing a matrix within text, we ould produ e

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}}$

This an be used to sta k subs ripts:

) X
) Yb
a

) Zb

5 MATH MODE

74

$\displaystyle{\sum_{ \sta krel{ \mbox{\s riptsize$i\in I$} }


{j\in J}
}
} A_{ij}
= \underset{j\in J}
{ \underset{i\in I}{\sum} } A_{ij} $

X
i2I
j 2J

Aij =

X
i2I
j 2J

Aij

Nesting the \underset ommand an be unwieldy; an alternative is the


\substa k ommand:
$\displaystyle\sum_{\substa k{i\in I\\j\in J\\k\in K}} A_{ij}$
X
Aij
i2I
j 2J
k2K

Another pa kage in the ams family is ams d, whi h makes it easy to


draw ommutative diagrams. Figures 57 and 58 illustrate this. (Spe ify
\usepa kage{ams d} in the preamble.) The horizontal arrows are spe ied
by >>> (left to right) with any expression pla ed above or below. The
verti al arrows are spe ied by VVV (down) or AAA (up), with an expression
pla ed to its left or right. All possible horizontal and verti al pla ements are
illustrated.
\[ \begin{CD}
A >a>>
B >>>
C \\
\alpha VV\beta V \gamma AAA VVV\delta \\
D >>d>
E >e>>
F
\end{CD} \

Figure 57: Commutative Diagram Sour e (Result in Figure 58)


There are many more renements, and more pa kages to make things
ni er. Many of these are des ribed in The LATEX Companion [5, Chapter 8,
and you an see an online atalog of pa kages at CTAN [4.

5.8 Grammar

75

A
?
?
y
D

! Bx

! C?

?
y

?
?

! E

!F

Figure 58: Commutative Diagram Result (Sour e in Figure 57)

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.

=

4. An obje t has only one denition. For example, if we write


au bv , we annot later refer to u; v . Sometimes we dene the
omplete obje t,
u; v
au bv , then tell the reader something

( ) =

( )

5 MATH MODE

76

(

like, We shall use k , instead of


uk ; v k , when there is no risk of
onfusion. The overriding prin iple is larity, and it is important that
the reader be told of this.
5. If : : : then : : : is not orre t. Suppose A and C are expressions.
We an write either `If A, C .' or `Suppose A. Then, C .' The rst form
is preferred if A and C are simple expressions. If either A or C are
ompound, the se ond form is learer. The form, `If A, then C .' seems
like it ought to be all right, and the omma is used to larify where
the ante edent (A) ends and the onsequent (C ) begins. In English,
however, this is not orre t.
6. Equivalen e needs ommas. The expression, `A if and only if
should be written as `A if, and only if, B .'

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.

x2 = B 2 4AC implies x =  B 2 4AC .


(b) If Fn+1 = Fn , it follows that 2 Fn+1 = Fn .

x if x  0;
+
( ) x =
(a)

otherwise.

2. Produ e the following in math display mode with the array environment and/or with the eqnarray* environment.

2Fn = Fn+2 2Fn+1 + Fn


= 2Fn Fn+1:
3. Produ e ea h of the following formulas in line with text ( onstru t your
own senten es that ontain them, and in lude proper pun tuation).
(a)
(b)

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!

f (y )dy = 2xf (x2 )

MFe(H2 O)6 = 6MH2O + MFe

4. Produ e the following equation in math display mode.




1:1 1:2 1:3  +  a1


2:1 2:2 2:3
b1

a2 a3
b2 b3

:
 

5. Produ e the expression in the Prefa e.


6. Produ e equations (5) and (6).
7. Produ e ea h of the following expressions:
(a)
(b)

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

9. Produ e ea h of the following formulas in math display mode (with


pun tuation):

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 ,

10. Combine your knowledge of derivatives, onditional assignment (with


array environment), and mathemati al symbols to produ e the following ( alled the trun ated gradient ):
8
>
>
>
>
<

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

11. Produ e the following symbols:


(a) Extended reals: R 1 .
(b) Stri tly positive integers: Z++.
( ) Complex n-ve tors: C n .

(d) Non-negative rational n-ve tors: Q n+ .


f (x)
12. Produ e the following: xj .
x=x

13. What is grammati ally wrong with ea h of the following segments.


(a) A key is how to add velo ities the formula is

(u +uvv)
1 + 2
where

is the velo ity of light.

5.8 Grammar

79

(b) A result of these assumptions is the following equation

E = m 2

Einstein rst noti ed this equivalen e between energy (E ) and


mass (m).
( ) Let x be an n-ve tor and ! a s alar, and dene

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.

(d) Now we onsider adding velo ities.


u

u+v
v

Figure 1. Adding velo ity ve tors:

u + v.

Figure 1 (above) shows how to add velo ities simply as ve tors.


(e) Theorem If

x; y; z 2 Z+ and xn + y n = z n , then n < 3.

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)

17. Column pointers:




12 
22
"

A = 11
21
"

olumns olumns
in 1
in 2

18. Row and olumn pointers:




A = 11
21
"

12 
22
"

rows in 1
rows in 2

olumns olumns
in 1
in 2

Graphi s

Graphi s may be part of a LATEX do ument by one of three ways:


1. Use standard LATEX 2" ommands, notably the pi ture environment;
2. Use a graphi s pa kage to draw within the do ument;
3. Use a pa kage to import some standard graphi s le.
I illustrate ea h, but I do not provide a omplete list of the relevant pa kages
(see CTAN [4 and The LATEX Companion [5).

6.1 Pi ture Environment


If all we want is a series of boxes and arrows, we an do this simply with
\fbox and a long arrow in math mode, as follows:

6.1 Pi ture Environment

81

\fbox{left}$\longrightarrow$\fbox{ enter}$\longrightarrow$\fbox{right}

left

! enter ! right

The \framebox ommand an be used instead of \fbox to produ e the


same result. However, \framebox also has two optional arguments to ontrol
the length of the box and the position of the text within it. For example,
\framebox[2 m[l{left}$\longrightarrow$\framebox[2 m[ { enter}$%
$\longrightarrow$\framebox[2 m[r{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}

Figure 59: Verti al Diagram Sour e (Result in Figure 60)


The box reated by \parbox has its enter aligned with the text, but it
has an optional argument to align its top or bottom with the text. This is
done by spe ifying \parbox[t{width }{text } or \parbox[b{width }{text },
respe tively.
These ommands an be ombined, along with other box ommands, but
there is a need for more versatility, like ovals and diagonal arrows, and more

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 

Figure 61: Variety of Obje ts in Pi ture Environment


The rst ommand begins a enter environment, and I use the \setlength
ommand to set the units of measurement to be 1 in h. This means that when
I spe ify some length = 5, I am spe ifying 5 in hes. The parameter that determines this is \unitlength , and the default for the pi ture environment is
1 pt. Then, we enter the pi ture environment stating that the point of entry
is the origin, indi ated by the oordinates (0,0). (There is an alternative way
to begin the pi ture environment, whi h is not des ribed here.) The lled
ir le shows where (0,0) is in this pi ture.
Every pi ture ommand begins with \put, whi h is ex lusively for the
pi ture environment. The omplete syntax is: \put(x,y ){stu }, where
stu an be text or some pi ture obje t. The x; y oordinates are relative
to where the position is when the pi ture environment is entered. This ould
be at the left margin, as in beginning a paragraph with \noindent; it ould
be a olumn in a table dened within the tabular environment; or ^ it
ould be in the middle of a senten e, just as the smiley fa e appears here (see

( )

ph

6.1 Pi ture Environment

83

\begin{ enter} \setlength{\unitlength}{1in}


\begin{pi ture}(0,0)
\put( 0, 0){\ ir le*{.1}}
\put( 0,-.5){\framebox(.7,.3){ enter} }
\put(-1,-.5){\dashbox{.01}(.7,.3)[tl{top left} }
\put( 1,-.5){\dashbox{.1}(1.2,.3)[br{bottom right} }
\put(-.65, -1){\ ir le{.2}} \put(-.7,-1.05){1}
\put( 1, -1){\oval(.5,.25)} \put(.85,-1.05){oval}
\put(0,-1){\fbox{$\begin{array}{ }a\\b\\ \end{array}$}}
\put(-.3,-.35){\ve tor(1,0){.3}}
\put(-.65,-.5){\ve tor(0,-1){.4}}
\put( .35,-.5){\ve tor(4,-3){.5}}
\put(-.55,-1){\ve tor(1,0){.55}}
\put( 0,-1){\ve tor(-1,0){.55}}
\put(.32,-1){\ve tor(1,0){.43}}
\put(1.2,-.895){\line(1,1){.3975}}
\end{pi ture}
\end{ enter} \vspa e{1in}

Figure 62: Sour e for Figure 61


Exer ise 1).
The rst \put in Figure 62 spe ies the position at the origin, and the
stu is a lled ir le with diameter .1 in hes ( entered at the origin):

\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

\framebox(width ,height )[posn {text }

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

\ve tor(x,y ){len }

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 .

6.1 Pi ture Environment

85

y0 + y
slo

pe

xy

y
y0 + len 
x

New
point

Original
point

y0

x0 + len

x0

x0 + x

Figure 63: Line Parameters


As if this unnatural denition of the line segment were not enough, there
is an important restri tion: x; y must be integer-valued and within
to
6. Suppose our original point is x0 ; y0 , and we want our destination point
to be xt ; yt . If xt x0 , the al ulation is simple: set x
, len jyt y0 j,
and

 
(

y =

1
1

 =0

if yt > y0
otherwise.

If xt 6 x0 , we ould have problems with approximating the results. Suppose,


for example, we want xt ; yt
x0 : ; y0 : . If we we set len
:
to obtain the orre t x- oordinate, how should we set the slope parameters?
Ideally, we would set x
, but the restri tions do not permit this. The
y

( ) = ( + 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

box begins here

width

6 GRAPHICS

height

( 1 5)

In Figure 61 the top left box starts at


; : , and its width is .7, so
the right edge of that box is at x
: . Starting at y
: , the verti al
position hanges by moving up half of the height, so the oordinate where
1
: ; : . That
the arrow begins ( alled its tail ) is
:; :
2:
a ounts for the initial position given by \put(-.3,-.35). The arrow is
to be horizontal, drawn left to right, so x
and y
, as spe ied
with \ve tor(1,0). Finally, we need to determine the length, spe ied as
{.3}. We want the oordinate of the end of the arrow ( alled the head ) to
be ush to the left side of the  enter box. That box begins at ; : ,
so x
:
: . It required these omputations to determine the
omplete pi ture ommand: \put(-.3,-.35){\ve tor(1,0){.3}}.
Now onsider the next \ve tor, whi h is a verti al arrow from the same
box to the ir le below it. The initial position is al ulated simply as the
midpoint of the bottom edge of the box: x; y
x0 12 h; y0 , where the
box starts at x0 ; y0 and h
height. In this ase, x0 ; y0
:; :
and h
: , so we obtain the oordinates of the arrow's tail: xt ; yt
1
: ; , as spe ied. Sin e the arrow is downward,
2: ; :
x
and y < , given by \ve tor(0,-1). The length is determined
by where we want the arrowhead: at the top of the ir le. The ir les y
oordinate is : , whi h is its enter. We must add the radius, whi h is 12 :
sin e .2 is the diameter spe ied by \ ir le{.2}. Thus, the position of the
arrowhead is xh ; yh
xt ; y yt r
: ;
: :
: ; : ,
and we set len j y j : , whi h is what is spe ied:

= 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}

The next arrow is double-headed, so we use two \ve tor ommands to


draw one arrow left to right, then an arrow at the same end points, but drawn
right to left. Further, this involves more al ulations be ause the arrow is
not simply horizontal or verti al. We begin the same way, by omputing the
oordinates of the tail and head. The left end point is at the y - oordinate of
the enter of the ir le, and its x- oordinate is to the right by the length of

6.1 Pi ture Environment

)=( +

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)

len = 12 (:4 + :395) = :3975:


Thus, we spe ify \line(1,1){.3975} to obtain the line shown in Figure 61.
There are pa kages to extend the pi ture environment, and we an plot
urves, alled Bezier approximations, to a set of points. However, I shall
over these in the next se tion with a powerful pa kage alled PSTri ks.
Table 46 (in the Appendix, p. 128) gives the ommands in the pi ture
environment, but here are some things to note:






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.

Another widely distributed pi ture-drawing system is MetaPost [6, 7,


written by John D. Hobby, also provided free of harge. It is more di ult to
learn than PSTri ks, but MetaPost is more open-ended in its design, whi h
makes it potentially more versatile, espe ially on varying the types of le
outputs (PSTri ks is tied to posts ript). In parti ular, pdflatex (not overed
here; see [4) does not work with PSTri ks, but it does with MetaPost.
There are many pa kages [4, typi ally available free of harge, that do
many of the things done by PSTri ks (and some additional things). Many of
these are des ribed in The LATEX Companion [5.

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}

A fundamental ommand in pst is \rput, but unlike the \put ommand


in the pi ture environment, this is not the only way to put obje ts. The
ommands, themselves, an spe ify where to put them. Table 19 gives
some of the ommon ommands to draw obje ts and lines. For those examples, the unit of measurement was set to 1 mm. For ea h ommand,
we an spe ify relevant options as [parameter = value . For example, to
produ e a solid ir le with radius .1 m, entered at the origin, we write
\ps ir le[fillstyle=solid(0,0){.1} (having already set fill olor=gray).
The origin is determined by where you are when issuing a pst ommand;
no environment is entered. Thus, I an put that ir le right here:
All
ommands use the linewidth parameter to ontrol the thi kness of the lines
used in the drawing, and obje ts that ould be made solid, like boxes and
ir les, use the fillstyle parameter. I shall illustrate the ommands in
Table 19 rst, showing the ease and versatility of PSTri ks, then I shall show
some additional shapes and ommands. This is meant to be an introdu tion,
so many features are not presented here. The User's Guide [14 is freely
available and learly written.
In using these ommands, we do want the \rput ommand in order to
put text into various obje ts. The idea of a box is to have some shape en lose
text. PSTri ks extends the re tangle in \framebox by having a variety of
shapes, shown in Table 20. A parameter used by these ommands is the distan e between the border and the text inside, alled framesep=len, where the
default value of len is 3 pt. (As usual, other parameters in lude linewidth,
linestyle, line olor, and fill olor.) The pst gures are drawn after
spe ifying

\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)

Draws re tangle with a orner at

(x0 ; y0) and opposite orner at (x1 ; y1).


Draws ir le entered at (x; y ) with
radius = r.

( )

Draws ellipse entered at x; y with


horizontal radius = rx and
verti al radius = ry

psline{a}(x0 ; y0 ) : : : (xn ; yn) Draws line or arrow, determined by a:


- no arrow; -> forward arrow;
npsline{-}(0,0)(10,0)
<-> double arrow' <- ba kward arrow;
npsline{<->}
(there
are more!), along path given by
(0,0)(5,-2)(1,0)
oordinates.
npsline{|-*}
(0,0)(10,-2)

pspolygon(x0 ; y0 ) : : : (xn ; yn) Draws losed polygon with given


oordinates; same as \psline{-} : : : ,
npspolygon(0,0)
ex ept gure is losed by drawing
(0,-3)(6,-3)
line from (xn ; yn ) to (x0 ; y0 ).
Table 19: Some Basi Drawing Commands in PSTri ks
Boxes need not be en losed (like \makebox), and they an be s aled by
spe ifying one of the following:

\s alebox{size}{stu}
\s alebox{width ,height}{stu}
Here are some examples:

s ales stu keeping the same aspe t ratio


s ales the width and height individually

6.2 PSTri ks

91

psframebox{stu}

Draws re tangle but ould have rounded orners

framebox

\psframebox{framebox}

framebox

\psframebox[framear =.4{framebox}

psshadowbox{stu}

Adds shadow to psframebox

shadow added

\psshadowbox{shadow added}

psdblframebox{stu}
double frame

Draws double frame


\psdblframebox{double frame}

ps ir lebox{stu}
ir le

Draws ir le around stu


\ps ir lebox[linewidth=2pt{ ir le}

psovalbox{stu}
oval

Draws oval around stu


\psovalbox[linestyle=dotted{oval}

Table 20: Boxes in PSTri ks


\s alebox{.5}{\ps ir lebox{
\begin{tabular}{ }
Halving \\ the \\ ir le
\end{tabular} } }

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

There are times when we want to rotate stu. Here is how:


\rotateleft{Left}\rotatedown{Down}
\rotateright{Right}

Down

6 GRAPHICS

92
One appli ation is given by the following:
Who is the founder of TEX?

Who is the founder of \TeX?


\rotatedown{Answer: Donald E. Knuth}

Answer: Donald E. Knuth

So far I have des ribed a variety of shapes, by themselves and as en losures


for boxes. These an be onne ted by \psline, with a great variety of styles,
in luding variations of arrowhead shape. To avoid the tedious al ulations
in lo ating the oordinates of the tail and head, the obje ts being joined an
be referen ed by name. In PSTri ks, the named obje ts are alled nodes.
Consider the following example:
Node A
Node B

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}

Figure 64: PSTri ks Sour e for Conne ting Nodes


\begin{ enter} \psset{unit=1 m}
% Nodes
\ nodeput(-2, 0){1}{1} \ nodeput(0, 0){2}{2}
\ nodeput( 2, 1){3}{3} \ nodeput[doubleline=true( 2,-1){4}{4}
\pnode(-3, 0){1tail} \n line{->}{1tail}{1} % tailess ar into (1)
% Ar s (with labels)
\n line{->}{1}{2} \aput{:U}{1/2} % \aput puts label above ar
\n line{->}{2}{3} \aput{:U}{2/3}
\n line{->}{2}{4} \bput{:U}{2/4} % \bput puts label below ar
\n ar {->}{3}{4} \Aput{\small 3$\rightarrow$4} % \Aput keeps
\n ar {->}{4}{3} \Aput{\small 4$\rightarrow$3} % label horizontal
\n loop[angleB=180,loopsize=.5,arm=.2,linear =.2{->}{3}{3}
\Bput[5pt{loop} % \Bput keeps label horizontal and 5pt is
% the spa e added between label and ar
\n loop[angleA=180,loopsize=.5,arm=.2,linear =.2{<-}{4}{4}
\Bput[5pt{loop}
\end{ enter} \vspa e{1 m}

Figure 65: Graph Sour e (Result in Figure 66)


loop

1/2

2/3
2

4!3

2/4

3!4

loop
Figure 66: Graph Result (Sour e in Figure 65)

6 GRAPHICS

94

Now I des ribe urves that go through, perhaps approximately, given


points. The examples that follow use the following pst settings:
\psset{unit=.5 m,showpoints=true}

(The showpoints=true setting is what auses the points to be in luded in


the pi ture you see.)
We begin with the parabola, whose ommand syntax is:
\parabola{a}(x0 ; y0 )(x1 ; y1 ),

(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

Question: What is the pst ommand to draw the parabola given by

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[parameters {a}(x0 ; y0 )(x1 ; y1 )(x2 ; y2 )(x3 ; y3 )


b
b

\psbezier(0,0)(1,3)(2,1)(3,4)

b
b

We an read data from a le, perhaps produ ed by mathemati al soft






, and
, MATLAB
, Mathemati a
, Maple
, O tave
ware like gnuplot


S-PLUS . The data le just needs pairs of oordinates, whi h an be separated by a omma or just blank and an have parenthesis, bra es, or nothing
around ea h pair. The following histogram was plotted by the sour e ode in
Figure 67, whi h I shall explain. The data le had y = number of students
with test s ore = x
. (The oset of 50 was used in establishing the origin
in the plot.)

+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}}

Figure 67: Sour e Code for Drawing Histogram of Test S ores

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}
+
+
+

+
+

Next, axes are superimposed with the \psaxes ommand:


\psaxes[params {a}(x0 ; y0 )(x1 ; y1 )(x2 ; y2 )

)
(0 0)

where x0 ; y0 is the origin, x1 ; y1 is the Southeast orner, and x2 ; y2 is the


Northwest orner. As in \psline, if x0 ; y0 is absent, the origin is assumed
to be at ; . If x1 ; y1 is absent, it is assumed to be equal to the origin.
Here are some examples:

\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

Note that ti ks are uniformly spa ed on ea h axes. This is suppressed for


the x-axis in Figure 67 by spe ifying the option, ti ks=y. The other parameter settings are des ribed in Table 21. (The default values, dx=dy=0,
ause the spa ing to be equal (approximately) by using Dx\psxunit and
Dy\psyunit, respe tively.)
Horizontal Verti al Default Meaning
Ox=n
Oy=n
0
Label at origin
Dx=n
Dy=n
1
Label in rement
dx=n
dy=n
0
Label spa ing
Table 21: Parameters for \psaxes
The next ommand, rput[r(60,-2){\large s ore} puts s ore in
large font, ush right (indi ated by [r) at the oordinates
; . Thus,
when I superimpose the ommands \fileplot, \psaxes and \rput, we obtain the data plot. The remaining ommands draw the histogram boxes and
put the letter grade above ea h box in sans serif font. Leaving o the s ore,
Figure 68 shows the sequen e of how ea h \psline and \rput adds to the
pi ture. To t the pi ture and the ode next to it, this is s aled (simply, by
spe ifying \psset{unit=1mm}):
We shall stop here, but this does not exhaust the PSTri ks ommands.
See [14 for lots more, in luding many examples.

(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

dx=10,dy=5,ti ks=y{< ->}(60,17)

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

Figure 68: Sequen e of PSTri ks Commands to Draw Histogram

6.3 Importing pi tures

99

6.3 Importing pi tures


The way to import a pi ture into LATEX is to onvert it to en apsulated
posts ript (eps). An ex eptionally lear des ription of this, in luding histori al ontext, is given by Keith Re kdahl [12. (He also goes deeper into
ustomizing pla ements of pi tures in gures.) Many systems that let us
draw gures, and those that plot mathemati al fun tions or data, have an
option to export an eps le. (If you an get a ps le, you ould use \psfig,
or there is a unix onversion utility, \ps2epsi.) On unix, xfig is an ex ellent
system to draw gures, and the export options in lude the eps le format.
A basi plotting system for fun tions and data, for both unix and DOS that
produ es eps les, is gnuplot. This is available free of harge at FTP://ftp.
dartmouth.edu/pub/gnuplot/. O tave extends the apabilities of gnuplot and
is also available free of harge, at http://www. he.wis .edu/o tave/. There



, and
, MATLAB
, Mathemati a
are also ommer ial systems, like Maple


S-PLUS , whi h an produ e eps les of plots.
Another way to obtain an eps le is with onversion. The unix systems
xv and Image Magi k an do this for a large variety of graphi le formats,
in luding bitmap (xbm), gif and jpeg les. There are free onversion systems
on MS Windows, notably jpeg2ps, whi h onverts jpeg les to eps, and
emftoeps, whi h onverts Windows Metales (wmf) to eps.
On e the le is in eps format, we an import it using the Graphi s Bundle [3, written by David P. Carlisle, provided free of harge. It omes with
MiKTeX and basi unix installations. There are two pa kages that provide
essentially the same apabilities but with dierent syntax. One is alled
graphi s, the other is graphi x. Here I use graphi x, as spe ied in the
preamble by \usepa kage{graphi x}.
To in lude an eps le, simply spe ify \in ludegraph s[options {lename }.
For example, Figure 69 shows a gure that was imported with the following
statement:
\begin{ enter}\in ludegraphi s[s ale=.5{sin.eps}\end{ enter}

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

Figure 69: Applying \in ludegraphi s to Import an eps File


after plotting the sin fun tion over the indi ated grid). Figure 70 shows the
same eps le, but with the width and height set as follows:
\begin{ enter} \in ludegraphi s[width=2in,height=1in{sin.eps}
\end{ enter}
1
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
1
8

Figure 70: Spe ifying Dimensions in \in ludegraphi s


For a very large pi ture, we might want to spe ify width=\textwidth,height=!,
and let it ll the entire width of the page. The height spe i ation (!) says
to maintain the aspe t ratio.
If you nd yourself importing eps les but would like to make some
hanges in LATEX, read about the PSfrag pa kage, by Mi hael C. Grant and
David Carlisle, whi h omes with a basi installation (in luding MiKTeX),

6.3 Importing pi tures

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:

Double your fun

\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

\s alebox{2}{Double your fun}

\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}

\in ludegraphi s[width=.25\textwidth,


height=!{protra tor.eps}

\in ludegraphi s[height=.5in,width=!,


angle=90,origin= {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

3. Use PSTri ks to draw Figure 3 (p. 4).

6.3 Importing pi tures

103

4. Use PSTri ks or the pi ture environment to draw the following.

rhombus

5. Use PSTri ks or the pi ture environment to draw the following.

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)

( ) The sin fun tion:

(35; 50)

(45; 60)

(25; 20)

y = sin

x

-1
-4

-3

-2

-1

(d) Bernoulli family tree:


Nikolaus
(16231708)

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

Making Spe ial Parts

7.1 Cover Page


The easiest way to make a over page is with the \maketitle ommand. This
is done in the do ument environment, generally just following \begin{do ument}.
The ne essary parameters are \author and \title, whi h an be dened
anypla e before the \maketitle. Typi ally these are put into the preamble,
or right after \begin{do ument} followed immediately by \maketitle ; it
depends upon your management style. Multiple authors are separated by
\and, su h as in the example shown in Figures 71 and 72. (The jagged
edges in Figure 72 mean that there is more spa e between the title and the
top of the paper.)
Spe ifying \date is optional (\maketitle puts in the urrent date if the
date is not dened). The over page is by itself and is not numbered.
\title{The \LaTeX\ Companion}
\author{Mi hel Goosens \and Frank Mittelba h \and Alexander Samarin}
\date{1994}
\maketitle

Figure 71: Title Page Sour e (Result in Figure 72)

The LATEX Companion


Mi hel Goosens Frank Mittelba h Alexander Samarin
1994
Figure 72: Title Page Result (Sour e in Figure 71)
Sin e arti les often have this information on the rst page of the arti le
(rather than a separate page), titlepage must be spe ied as an option in

7 MAKING SPECIAL PARTS

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}

Addresses, aliations, and other information about ea h author an be


added, using \\ to reate new lines. For example, Figure 73 shows how the
authors appear when the \author denition in Figure 71 is hanged to the
following:
\author{Mi hel Goosens
\\ Geneva, Switzerland
\and Frank Mittelba h \\ Mainz, Germany
\and Alexander Samarin \\ Geneva Switzerland}

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.

The LATEX Companion


Mi hel Goosens
Frank Mittelba h
Geneva, Switzerland
Mainz, Germany
Alexander Samarin
Geneva, Switzerland
1994
Figure 73: Adding Addresses to Authors

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

b (revision of earlier version, 510 b )

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

7 MAKING SPECIAL PARTS

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}

Figure 76: Making an Abstra t Sour e (Result in Figure 77)

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)

7.3 Other Front Matter


The \tableof ontents ommand makes a table of ontents; it is pla ed
wherever you put the ommand, whi h should be right after the over page.
Then, you an in lude lists of gures and tables with the \listoffigures
and \listoftables ommands, respe tively.
The table of ontents generally in ludes numbered parts, like se tions and
subse tions. To in lude other front matter, LATEX provides the \add ontentsline
ommand. For example, the table of ontents in this do ument was obtained
with the spe i ations given in Figure 78.

7.3 Other Front Matter

109

\newpage \pagenumbering{roman} \pagestyle{myheadings}


\tableof ontents \newpage
\add ontentsline{to }{se tion}{List of Figures}
\listoffigures \newpage
\add ontentsline{to }{se tion}{List of Tables}
\listoftables \newpage

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}

7 MAKING SPECIAL PARTS

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

This se tion introdu es you to fundamentals of ustomizing your do ument.


It is still in the ontext of an introdu tion, hoosing only a few of the
things you an hange. A key to these hanges are the \new ommand and
\renew ommand ommands, whi h enable you to dene your own ommands
and hange parameter values of existing ommands.

8.1 Your Own Abbreviations and Commands


The ommand that gives us the ability to make our own has the following
form: \new ommand{\name }[n{whatever }, where n is the number of arguments, and whatever is whatever you want the ommand to do. Here are two
examples simply to abbreviate ommands with long names:
\new ommand{\ul}{\underline}
\new ommand{\m }{\multi olumn}

The rst lets us write \ul{something} to underline something. The se ond

8 TAKING CONTROL

112

lets us write \m {3}{ }{stuff} to enter a multi olumn, in either a tabular


or an array environment, spanning 3 olumns and entered.
The latex ompiler will not let you use a name that is already being used.
For example, if you spe ify \new ommand{\fbox}..., you will get a fatal error
message sin e there is already a \fbox ommand.
A related use is when the ommand requires some lines of ode. Consider
the following example:
\new ommand{\Box}{\mbox{\begin{pi ture}(0,0)
\put( 2,0){\framebox(7,7)}
\end{pi ture} }}

(\mbox is used to ensure text mode). Now \Box )


and, having dened
the \Box ommand, we an use it in other new ommands. For example,
in the preamble
p I spe ied: \new ommand{\ hkbox}{$\Box^\surd\;$} Then,
\ hkbox )
Some ommands are spe i ally for math mode, but we want them to
work in any mode. This is a hieved by the ommand: \ensuremath{math
stu }. For example, onsider \new ommand{\Gs}[1{G_{#1}}. If we are
already in math mode, \Gs{i+j} is repla ed by G_{i+j} to produ e Gi+j ;
otherwise, if \Gs{i+j} is spe ied in text mode, it is repla ed by $G_{i+j}$
to put it into math mode rst. Thus, we an spe ify \Gs{subs ript }, no
matter whi h mode we are in, and obtain the orre t result.
Another reason to have our own ommands is for onsisten y, parti ularly
of notation. Suppose we have a key term, like the null spa e of a matrix.
Some authors write N A , some write nul A, and there are still more symbols
people use. We an hoose one and dene

( )

\new ommand{\nul}{\ensuremath{\math al{N}}}.

Then, we an write \nul(A) to obtain N (A) (and we an be in text or math


mode when we write this). Some publishers have their own notation, so we
must be areful not to override them with ours. A way to do this is to hoose
a dierent name, like mynul, then add to the preamble:
\new ommand{\usenul}{\mynul}

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}

8.2 Your Own Names, Titles and Numbers

113

(where the publisher's ommand name is \nul).


The preamble an be ome very long as we add our ommands, so it
is useful to put them in a separate le, say mydefs.tex (note the .tex
sux). Then, we use the \input ommand to have the latex ompiler read
it wherever it is pla ed. In parti ular, the preamble of this do ument ontains
the ommand:
\input{mydefs}

(The sux .tex is assumed.) Dierent sour e les ould simply input this
same le, so dupli ation of work is avoided.

8.2 Your Own Names, Titles and Numbers


There are times when we prefer some name other than the default. Table 22
shows the ommon names we might want to hange. For example, in this
do ument the Table of Contents was obtained by spe ifying the following
in the preamble:
\renew ommand{\ ontentsname}{Table of Contents}.

What it is
Abstra t
Appendix
Chapter
Contents
Index
List of Figures
List of Tables
Part
Referen es

How it is alled (keyword)

\abstra tname
\appendixname
\ haptername
\ ontentsname
\indexname
\listfigurename
\listtablename
\partname
\refname for arti le style
\bibname for book and report styles

Table 22: Intrinsi Name Parameters


You might want to hange the numbering of some intrinsi ounter. We
saw an example of this in hanging the ounters for enumeration lists (p. 48).
The general form is
\renew ommand{\the ounter }{something }

8 TAKING CONTROL

114

Another example is to hange se tion numbering in a report do ument


style. The rst level of division is assumed to be a hapter, so the numbering
will be hapter.se tion [.subse tion : : : If you have no hapters, it will number
the rst se tion as 0.1. Making the rst level division hapters will over ome
the numbering problem, but the format of hapters is dierent, similar to
a book. Making the do ument lass an arti le will also solve the problem,
sin e the se tion is the rst level division. This might not be appropriate due
to other onsiderations, su h as entering the do ument into a database using
BibT X, where you want it to be ounted as a report, not as an arti le.
The way to do this is as follows:

\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).

8.3 Your Own Environments


The \newenvironment ommand enables us to dene our own environments,
and the \renewenvironment ommand enables us to revise an existing environment. They have the same syntax:
newenvironment{name }[n{begin }{end }
renewenvironment{name }[n{begin }{end }

where name is the name of the environment, n = number of arguments (omit


[0 for n
), begin is what is exe uted upon entering the environment, and
end is what is exe uted upon leaving the environment. For example, the
following reates a proof environment:

=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,

8.4 Your Own Margins and Spa ing

115

\begin{proof}
First, suppose \dots \linebreak
Thus, the theorem follows.
\end{proof}
produ es:
First, suppose : : :
Thus, the theorem follows.

Proof:

8.4 Your Own Margins and Spa ing


The default margins and spa ing are set with purposeful values, and you
will usually not need to hange them. When you do, however, they an
be hanged by setting ertain parameters in the preamble. The margins
of the do ument are ontrolled by the parameters shown in Figure 82 and
des ribed in Table 23. (See Table 25 for onversion fa tors; in parti ular,
1 pt = 72.27 in.)
paper, the urrent settings (shown
For example, if we are using 21 
in Table 23) break down the horizontal parts as follows:

72.27 pt 39 pt
1 in

54 in

begin body stu

11

6.14.295 pt
390 pt
5.396 in
8.5 in

end body stu

113.025 pt
1.564 in

We an in rease the text width by setting \textwidth=length in the


preamble. For example, \textwidth=6in in reases the text width to 6 in hes.
The body expands to the right unless we also hange \oddsidemargin.
Margin settings an be negative; for example, we raise the body 1 in h by
spe ifying \topmargin=-1in in the preamble. This might be a ompanied by
in reasing the text length. The geometry pa kage provides easy spe i ations
for page layout.
The \hspa e* and \vspa e* ommands provide a great deal of ontrol
over horizontal and verti al spa ing, respe tively. We might want some global
settings to make repeated use of these unne essary. Table 24 lists some you
an set with the \setlength ommand, showing their default values (used
in this do ument).

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}.

8.4 Your Own Margins and Spa ing






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.

Figures 80 and 81 show the presentation of an array with a p- olumn to


put horizontal spa e between the other two olumns. Note how ongested it
is, so we want to in rease its verti al spa ing.
\[ \begin{array}{lp{.3in}l}
\,B\,x_B = b_N + \fra {1}{2}\theta\delta b_N
&& \pi_N B = _B + \fra {1}{2}\theta\delta _B \\
B^*x_B > b_B + \fra {1}{2}\theta\delta b_B
&& \pi_N N < _N + \fra {1}{2}\theta\delta _N
\end{array}
\

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

Figure 82: Do ument Margins

nfootskip

8.5 Your Own Bibliography

119

Here is 1.3 line spa ing: \renew ommand{\arraystret h}{1.3}

B xB = bN + 21 bN
B  xB > bB + 21 bB

N B = B + 12  B
N N < N + 21  N

Here is 1.6 line spa ing: \renew ommand{\arraystret h}{1.6}

B xB = bN + 12 bN

N B = B + 12  B

N N < N + 21  N

B  xB > bB + 21 bB

Ba k to default: \renew ommand{\arraystret h}{1}

N B = B + 12  B
N N < N + 21  N

B xB = bN + 21 bN
B  xB > bB + 21 bB

8.5 Your Own Bibliography


You an hoose not to use BibTE X, and use thebibliography

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

Publishing Company, Reading, MA, 1994.


\bibitem{tex} Donald E. Knuth, \textit{The \TeX\ Book},
Addison-Wesley Publishing Company, Reading, MA,
15th edition, 1989.
\end{thebibliography}

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,

:::

in whi h ase \ ite{tex} ) [Knuth, 1989.


Some publishers give you no hoi e, but if you are writing a report and
have ontrol over the formatting, it generally helps the reader to know something about the itation. Thus, [Knuth, 1989 is preferred to [2 be ause
it immediately gives the reader information about the do ument without
having to ip to the bibliography se tion.
With you in ontrol, there is no format monitoring, so ea h entry appears
however you put it, even if there are in onsisten ies in style. This is one
reason it is usually better to use BibT X, even though you lose ontrol
over what appears (i.e., they will be numbers). The bib style le, su h as
plain.bst, applies in either ase. Most installations ome with more than
the basi plain, and its three variations (given on p. 41). Alternative bst les
are a hi ago (from the frankenstein pa kage), apalike and plainnat (from
natbib), whi h give the author and year, su h as [Knuth, 1989 instead of [8.
These pa kages provide even more versatility in how the itations appear (see
[4 or [5, Chapter 13).
If you want to have several bibliographi units in one do ument, su h as
at the end of ea h hapter of a book, use the bibunits pa kage, whi h you
obtain from CTAN [4.

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

this do ument. As you begin to use pa kages, it is ne essary to be ome aware


of updates. You learn about these at CTAN [4.
You will nd other pa kages useful, depending upon your te hni al area.
Here are some pa kages that give you spe ial symbols: hemsym, qsymbols,
wasysym, and xypi . Also, the algorithm pa kage enables an environment
to write sour e ode with standard language elements, and there are others with similar properties or for parti ular programming languages (viz.,
-pas al) and listings)). The graphtex pa kage spe ializes in all sorts of graphs,
in luding those ommonly found in automata theory.
\usepa kage{graphi x,pst-all}
\usepa kage{makeidx}
\usepa kage{url}
\usepa kage[T1{fonten }
\usepa kage{fan yvrb,moreverb}
\usepa kage{float}
\usepa kage{multirow}
\usepa kage{amsmath}
\usepa kage{amssymb}
\usepa kage{ams d}
\usepa kage{mathrsfs}
\usepa kage{bm}
\usepa kage{theorem}

%
%
%
%
%
%
%
%
%
%
%
%
%

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

\renew ommand\ ontentsname{Table of Contents} % Change `Contents'


\renew ommand\url{\begingroup\urlstyle{sf}\Url} % put url in sf font
\input{mydefs} % My ommands and environments
\makeindex
% make myfile.idx (input to makeindex at ommand line)

Figure 83: Most of the Preamble for this Do ument


Appendix

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 25: Conversions of Common Units of Measurement


Table 26 is a guide to how most of the remaining tables are organized.
Afterwards, Table 45 gives spe ial symbols that an be used in either text or
math mode, and Table 46 gives the ommands for the pi ture environment.
Text mode

Table Contents

27
28
29
30
31
32
Math mode 33
34
35
36
37
38
39
40
41
42
43
44

Commands/Environments for Font Appearan e


Commands/Environments for Controlling Position
Text A ents and Symbols
Commands for Counters
Commands/Environments to Organize Do ument
Commands to Control Do ument Style
Commands to Control Fonts in Math Mode
Mathemati al A ents and Symbols
Greek and Spe ial Letters
Spa ing Commands in Math Mode
Frequently Used Mathemati al Symbols
Binary Operations
Operators and Quantiers
Spe ial Fun tions
Relation Symbols
Arrows
Dots Cir les, Triangles and Lines
Variable Size Symbols

Table 26: Referen e Tables

APPENDIX
textbf
tiny
Large
verbatim

123

textit
s riptsize
LARGE

textrm
footnotesize
huge

texts
small
Huge

textsf
normalsize
underline

texttt
large
verb

Table 27: Commands/Environments for Text Font Appearan e

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

Table 28: Commands/Environments for Controlling Text Position

\'{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
!`

Table 29: Text A ents and Spe ial Symbols

addto ounter
ref
the ounter

label
refstep ounter
value

new ounter
set ounter

Table 30: Commands for Counters

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

Table 31: Commands/Environments to Organize Do ument

markright
renew ommand

markboth
setlength

pagenumbering
thispagestyle

pagestyle

Table 32: Commands to Control Do ument Style

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

Table 33: Commands to Control Fonts in Math Mode

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.)

Table 34: A ents in Math Mode

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

Table 35: Greek and Spe ial Letters

What you write


x y
x\,y
x\;y
x\quad y
x\qquad y
x\!y
x\negmedspa e y
x\negthi kspa e y

)
)
)
)
)
)
)
)

What you see

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

Table 36: Spa ing Commands in Math Mode

{supers ript}
{subs ript}

^{}
_{}

\prime

\infty

\emptyset

Table 37: Frequently Used Mathemati al Symbols

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

Table 38: Binary Operations

r
8

\nabla
\forall

 \partial

\exists

p
:

\surd
\neg

} \wp

Table 39: Operators and Quantiers

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

Table 40: Spe ial Fun tions







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

Table 41: Relation Symbols

=: \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
%
&
.
-

Table 42: Arrows


..
.

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

Table 43: Dots, Cir les, Triangles and Lines

\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{ . }

These use nleft and nright

fg
b
i

\oint

\{ \}

\lfloor

[
\rfloor

\rangle

Table 44: Variable Size Symbols

:::

\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}

p 2 fl,r,t,b,lt,lb,rt,rbg. For oval, it is the portion sele ted;


for boxes, p is where the text goes.
Table 46: Commands and Parameters in Pi ture Environment
Referen es

[1 Johannes L. Braams. Babel, a multilingual style-option system for use


with LATEX's standard do ument styles. TUGboat, 12(2):291301, 1991.
Available at CTAN [4.

REFERENCES

129

[2 Johannes L. Braams, David P. Carlisle, Alan Jerey, Frank Mittelba h,


Chris Rowley, and Rainer S hpf. LATEX 2" and the LaTeX3 proje t.
World Wide Web, http://www.latex-proje t.org/latex3.html, 199499.
[3 David P. Carlisle. Pa kages in the `graphi s' bundle. World Wide Web,
CTAN/ma ros/latex/required/graphi s/ (see [4 for repla ing CTAN),
199499.
[4 Comprehensive TEX ar hive (CTAN). UK: ftp.tex.a .uk/tex-ar hive/;
Germany:
ftp.dante.de/tex-ar hive/;
USA: ftp.tug2. s.umb.edu/
tex-ar hive/ . These are host sites, whi h ontain a list of mirror
sites.
[5 Mi hel Goosens, Frank Mittelba h, and Alexander Samarin. The LATEX
Companion. Addison-Wesley Publishing Company, Reading, MA, 1994.
[6 John D. Hobby. A User's Manual for MetaPost. Computing S ien e
Te hni al Report no. 162, AT&T Bell Laboratories, Murray Hill, New
Jersey, 1992. Available at http:// m.bell-labs. om/who/hobby/MetaPost.
html/.
[7 John D. Hobby. Drawing Graphs with MetaPost. Computing S ien e
Te hni al Report no. 164, AT&T Bell Laboratories, Murray Hill, New
Jersey, 1993. Available at http:// m.bell-labs. om/ s/ str/164.ps.gz.
[8 Donald E. Knuth. The TEX Book. Addison-Wesley Publishing Company,
Reading, MA, 15th edition, 1989.
[9 Leslie Lamport. LATEX: A Do ument Preparation System. AddisonWesley Publishing Company, Reading, MA, 1986 (also see 2nd edition,
1994).
[10 LATEX 2" for authors. CTAN/ma ros/latex/do /usrguide.ps (see [4 for
repla ing CTAN), 199599.
[11 Oren Patashnik. BibT Xing. World Wide Web, http://www.ui .edu/
depts/adn/infwww/ps/btxdo .ps, 1988.

[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

[13 Christian S henk. MiKTEX Lo al Guide. World Wide Web, http://


www.miktex.de/, 199899 (version 1.2).
[14 Timothy Van Zandt. PSTri ks: PostS ript ma ros for Generi TeX.
World Wide Web, http://www.tug.org/appli ations/PSTri ks/, 199398.

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

nusepa kage, 28, 45, 66, 67, 69, 88


nvalue, 48
nve tor, 84
nverb, 23
nvfill, 27
nvspa e*, 27
nvspa e, 27, 62
nwidehat, 62
nwidetilde, 62
nn, 16
pdftex, 88
titlepage, 106
a ents, 24
AMS, 1
amsmath, 69
Bezier urve, 94
bibtex program, 30
body, 1
box, 81
olumn spe i ation, 18
ommand line, 1
omment, 23
omments, 1
ompile, 2
onditional assignment, 62
ross referen ing, 39
dash, 11
debugging, 2
derivative, 67
do ument styles, 1
DOS, 3, 4, 30
dvi viewer, 3
emftoeps, 99
environment, 1, 7

INDEX

le

133

abstra t, 107, 109


appendix, 110
array, 57, 60, 63
axiom, 70
enter, 7
orollary, 70
des ription, 13, 23
do ument, 1, 105
enumerate, 15
eqnarray, 58
eqnarray*, 59
equation, 59
gure, 45, 46
ushleft, 7, 20, 21, 63
ushright, 7
gather, 72
gather*, 72
itemize, 14
large, 10
longtable, 22
pi ture, 82
quotation, 11
quote, 10
smallmatrix, 73
tabbing, 24
table, 45, 46
tabular, 16, 23, 46, 63
thebibliography, 119
theorem, 69
verbatim, 23
verse, 12

ps (posts ript), 3, 88, 99


tex, 1, 36
wmf, 99
oat, 45
oat page, 45
oating obje t, 45
font size, 4, 9, 10, 62
font style
bold small aps, 9
boldfa e, 9
boldmath, 51
alligraphi , 52
Greek, 52
itali , 9, 18
math mode, 51, 52, 60, 66
non-English, 24
Roman, 18
sans serif, 9
slanted, 9
small aps, 9, 18
typewriter, 9
underlined, 9
fra tions, 53

bib, 30, 31, 36, 3840


bst (bib style), 40, 120
dvi, 2, 88
eps, 99
jpeg, 99

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

Potrebbero piacerti anche