A Simpliﬁed Introduction to L
A
T
E
X
Harvey J. Greenberg
University of Colorado at Denver
Mathematics Department
PO Box 173364
Denver, CO 802173364
Harvey.Greenberg@cudenver.edu
http://www.cudenver.edu/~hgreenbe/
February 19, 2006
i
Table of Contents
List of Figures iii
List of Tables vi
Preface viii
Acknowledgments ix
Sources of L
A
T
E
X Software ix
1 Overview 1
2 Text 5
2.1 Fonts and Paragraphs . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3 Making Tables . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.4 Special Characters . . . . . . . . . . . . . . . . . . . . . . . . 20
2.5 Tabbing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.6 Line, Page, and Word Breaks . . . . . . . . . . . . . . . . . . 23
2.7 Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3 Bibliography with BibT
E
X 28
3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.2 The bib File . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.2.1 Main body . . . . . . . . . . . . . . . . . . . . . . . . 28
3.2.2 Web citations . . . . . . . . . . . . . . . . . . . . . . . 32
3.2.3 Additional features . . . . . . . . . . . . . . . . . . . . 34
3.3 Declaration and Citation . . . . . . . . . . . . . . . . . . . . . 36
3.4 Some Controls . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4 Counters, Labels, and References 39
4.1 Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . 39
4.2 Intrinsic Counters . . . . . . . . . . . . . . . . . . . . . . . . . 39
4.3 Figures and Tables . . . . . . . . . . . . . . . . . . . . . . . . 40
4.4 Deﬁning Your Own . . . . . . . . . . . . . . . . . . . . . . . . 42
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
ii
5 Math Mode 45
5.1 Mathematical Symbols . . . . . . . . . . . . . . . . . . . . . . 46
5.2 Fractions and Variable Size Functionality . . . . . . . . . . . 48
5.3 Arrays and Equations . . . . . . . . . . . . . . . . . . . . . . 51
5.4 Special Functions and Alphabets . . . . . . . . . . . . . . . . 58
5.5 Derivatives and Integrals . . . . . . . . . . . . . . . . . . . . . 60
5.6 Theorems and Deﬁnitions . . . . . . . . . . . . . . . . . . . . 61
5.7 Reﬁnements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5.8 Grammar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
6 Graphics 71
6.1 Picture Environment . . . . . . . . . . . . . . . . . . . . . . . 71
6.2 PSTricks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.3 Importing pictures . . . . . . . . . . . . . . . . . . . . . . . . 86
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7 Making Special Parts 93
7.1 Cover Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.2 Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
7.3 Other Front Matter . . . . . . . . . . . . . . . . . . . . . . . . 97
7.4 Back Matter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
7.5 Footnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
8 Taking Control 100
8.1 Your Own Abbreviations and Commands . . . . . . . . . . . 100
8.2 Your Own Names, Titles and Numbers . . . . . . . . . . . . . 102
8.3 Your Own Environments . . . . . . . . . . . . . . . . . . . . . 103
8.4 Your Own Margins and Spacing . . . . . . . . . . . . . . . . . 103
8.5 Your Own Output Control . . . . . . . . . . . . . . . . . . . . 108
8.6 Your Own Bibliography . . . . . . . . . . . . . . . . . . . . . 109
Closing Remarks 110
Appendix 111
Some Tips 117
References 119
Index 121
iii
List of Figures
1 The Structure of a L
A
T
E
X Document. . . . . . . . . . . . . . 1
2 Your First L
A
T
E
X Source File . . . . . . . . . . . . . . . . . . 2
3 Command Sequence from Source to Postscript or PDF . . . 4
4 An Introductory Document Source (Result in Figure 5) . . . 5
5 An Introductory Document Result (Source in Figure 4) . . . 6
6 Positioning Paragraphs Source (Result in Figure 7) . . . . . 6
7 Positioning Paragraphs Result (Source in Figure 6) . . . . . 7
8 Centering Source (Result in Figure 9) . . . . . . . . . . . . . 7
9 Centering Result (Source in Figure 8) . . . . . . . . . . . . . 8
10 Some Font Sizes Source (Result in Figure 11) . . . . . . . . . 9
11 Some Font Sizes Result (Source in Figure 10) . . . . . . . . . 9
12 Skipping Line Spaces Source (Result in Figure 13) . . . . . . 11
13 Skipping Line Spaces Result (Source in Figure 12) . . . . . . 11
14 Description List Environment . . . . . . . . . . . . . . . . . . 13
16 Itemize List Environment Result (Source in Figure 15) . . . 13
15 Itemize List Environment Source (Result in Figure 16) . . . 14
17 Enumerate List Environment Source (Result in Figure 18) . 14
18 Enumerate List Environment Result (Source in Figure 17) . 15
19 A 2 3 Table . . . . . . . . . . . . . . . . . . . . . . . . . . 15
20 A 2 3 Table with Horizontal and Vertical Lines . . . . . . . 16
21 A Table with Partially Spanning Horizontal and Vertical Lines 16
22 Nested Tables Source (Result in Figure 23) . . . . . . . . . . 17
23 Nested Tables Result (Source in Figure 22) . . . . . . . . . . 17
24 \parbox Source (Result in Figure 25) . . . . . . . . . . . . . 19
25 \parbox Result (Source in Figure 24) . . . . . . . . . . . . . 19
26 Multicolumn Source (Result in Figure 27) . . . . . . . . . . . 20
27 Multicolumn Result (Source in Figure 26) . . . . . . . . . . . 20
28 Obtaining Brackets in a Description List Environment . . . . 21
29 Tabbing Source (Result in Figure 30) . . . . . . . . . . . . . 23
30 Tabbing Result (Source in Figure 29) . . . . . . . . . . . . . 23
31 Adding bibtex to the Command Sequence . . . . . . . . . . 28
32 A Document to Print the Bibliographic Database . . . . . . 37
33 Framed Figure 34 Source . . . . . . . . . . . . . . . . . . . . 42
34 Framed Figure with Caption at Bottom . . . . . . . . . . . . 42
35 Framed Figure with Caption at Top . . . . . . . . . . . . . . 42
36 Alternative enumerate Symbols Source (Result in Figure 37) 44
37 Alternative enumerate Symbols Result (Source in Figure 36) 44
38 Variable Sizes Source (Result in Figure 39) . . . . . . . . . . 48
39 Variable Sizes Result (Source in Figure 38) . . . . . . . . . . 48
40 \displaystyle Source (Result in Figure 41) . . . . . . . . . 49
41 \displaystyle Result (Source in Figure 40) . . . . . . . . . 50
iv
42 Examples to Compare Text and Display Modes . . . . . . . . 50
43 eqnarray Environment Source (Result in Figure 44) . . . . . . 53
44 eqnarray Environment Result (Source in Figure 43) . . . . . . 53
45 Matrix Equation Source (Result in Figure 46) . . . . . . . . 54
46 Matrix Equation Result (Source in Figure 45) . . . . . . . . 54
47 Nested Arrays Source (Result in Figure 48) . . . . . . . . . . 55
48 Nested Arrays Result (Source in Figure 47) . . . . . . . . . . 55
49 Horizontal Braces Source (Result in Figure 50) . . . . . . . . 56
50 Horizontal Braces Result (Source in Figure 49) . . . . . . . . 56
51 \flushleft in parbox Source (Result in Figure 52) . . . . . 57
52 \flushleft in parbox Result (Source in Figure 51) . . . . . 57
53 \raggedright in parbox Source (Result in Figure 54) . . . . 58
54 \raggedright in parbox Result (Source in Figure 53) . . . . 58
55 gather* Environment Source (Result in Figure 56) . . . . . . 64
56 gather* Environment Result (Source in Figure 55) . . . . . . 64
57 Commutative Diagram Source (Result in Figure 58) . . . . . 66
58 Commutative Diagram Result (Source in Figure 57) . . . . . 66
59 Vertical Diagram Source (Result in Figure 60) . . . . . . . . 72
60 Vertical Diagram Result (Source in Figure 59) . . . . . . . . 72
61 Variety of Objects in Picture Environment . . . . . . . . . . 72
62 Source for Figure 61 . . . . . . . . . . . . . . . . . . . . . . . 73
63 Line Parameters . . . . . . . . . . . . . . . . . . . . . . . . . 75
64 PSTricks Source for Connecting Nodes . . . . . . . . . . . . . 82
65 Graph Source (Result in Figure 66) . . . . . . . . . . . . . . 82
66 Graph Result (Source in Figure 65) . . . . . . . . . . . . . . 83
67 Source Code for Drawing Histogram of Test Scores . . . . . . 84
68 Sequence of PSTricks Commands to Draw Histogram . . . . 87
69 Applying \includegraphics to Import an eps File . . . . . . 88
70 Specifying Dimensions in \includegraphics . . . . . . . . . 88
71 Title Page Source (Result in Figure 72) . . . . . . . . . . . . 93
72 Title Page Result (Source in Figure 71) . . . . . . . . . . . . 93
73 Adding Addresses to Authors . . . . . . . . . . . . . . . . . . 94
74 Footnotes in the Cover Page Source (Result in Figure 75) . . 95
75 Footnotes in the Cover Page Result (Source in Figure 74) . . 95
76 Authors with same footnote (Result in Figure 77) . . . . . . 95
77 Authors with same footnote (Source in Figure 76) . . . . . . 96
78 Making an Abstract Source (Result in Figure 79) . . . . . . . 96
79 Making an Abstract Result (Source in Figure 78) . . . . . . . 97
80 Some Front Matter Speciﬁcations for This Document . . . . 97
81 Adding makeindex to the Command Sequence . . . . . . . . 99
82 Setting a Footnote Source (Result in Figure 83) . . . . . . . 99
83 Setting a Footnote Result (Source in Figure 82) . . . . . . . 99
84 Setting a Footnote Source (Result in Figure 85) . . . . . . . 100
v
85 Setting a Footnote Result (Source in Figure 84) . . . . . . . 100
86 Document Margins . . . . . . . . . . . . . . . . . . . . . . . . 105
87 Varying \itemsep to control item spacing in a list . . . . . . 106
88 Changing the Left Margin of a List (Result in Figure 89) . . 107
89 Changing the Left Margin of a List (Source in Figure 88) . . 107
90 Array with Fixed Width Column Source (Result in Figure 91) 107
91 Array with Fixed Width Column Result (Source in Figure 90) 107
92 \ifthenelse Source (Results in Figure 93) . . . . . . . . . . 108
93 \ifthenelse Results (Source in Figure 92) . . . . . . . . . . 108
94 Most of the Preamble for this Book . . . . . . . . . . . . . . 111
vi
List of Tables
1 Intrinsic Font Styles . . . . . . . . . . . . . . . . . . . . . . . 8
2 Writing Special Characters . . . . . . . . . . . . . . . . . . . 21
3 Some Accents for Letters . . . . . . . . . . . . . . . . . . . . 22
4 The Tabbing Environment . . . . . . . . . . . . . . . . . . . 22
5 The \kill Tabbing Command . . . . . . . . . . . . . . . . . 23
6 Figure and Table Location Options . . . . . . . . . . . . . . 41
7 Numerals to Print Counters . . . . . . . . . . . . . . . . . . . 43
8 Default Settings for enumerate Counters . . . . . . . . . . . . 44
9 Some Mathematical Operations . . . . . . . . . . . . . . . . 46
10 Set Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
11 The `mathfont Commands . . . . . . . . . . . . . . . . . . . 47
12 Variable Size Mathematical Operation Symbols . . . . . . . . 49
13 Some Symbols in Logic . . . . . . . . . . . . . . . . . . . . . 51
14 Order Relations . . . . . . . . . . . . . . . . . . . . . . . . . 51
15 Transpose of a Vector . . . . . . . . . . . . . . . . . . . . . . 54
16 Some Common Mathematical Functions . . . . . . . . . . . . 59
17 Examples of Mathematical Functions . . . . . . . . . . . . . 59
18 Notation Using mathbb Fonts from amssymb Package . . . . 59
19 Some Basic Drawing Commands in PSTricks . . . . . . . . . 79
20 Boxes in PSTricks . . . . . . . . . . . . . . . . . . . . . . . . 80
21 Parameters for \psaxes . . . . . . . . . . . . . . . . . . . . . 86
22 Intrinsic Name Parameters . . . . . . . . . . . . . . . . . . . 102
23 Margin Parameters . . . . . . . . . . . . . . . . . . . . . . . 104
24 Spacing Parameters . . . . . . . . . . . . . . . . . . . . . . . 106
25 Conversions of Common Units of Measurement . . . . . . . . 111
26 Reference Tables . . . . . . . . . . . . . . . . . . . . . . . . . 112
27 Commands/Environments for Text Font Appearance . . . . . 112
28 Commands/Environments for Controlling Text Position . . . 112
29 Text Accents and Special Symbols . . . . . . . . . . . . . . . 113
30 Commands for Counters . . . . . . . . . . . . . . . . . . . . . 113
31 Commands/Environments to Organize Document . . . . . . 113
32 Commands to Control Document Style . . . . . . . . . . . . 113
33 Commands to Control Fonts in Math Mode . . . . . . . . . . 113
34 Accents in Math Mode . . . . . . . . . . . . . . . . . . . . . 114
35 Spacing Commands in Math Mode . . . . . . . . . . . . . . . 114
36 Greek and Special Letters . . . . . . . . . . . . . . . . . . . . 114
37 Frequently Used Mathematical Symbols . . . . . . . . . . . . 115
38 Binary Operations . . . . . . . . . . . . . . . . . . . . . . . . 115
39 Operators and Quantiﬁers . . . . . . . . . . . . . . . . . . . . 115
40 Special Functions . . . . . . . . . . . . . . . . . . . . . . . . 115
41 Relation Symbols . . . . . . . . . . . . . . . . . . . . . . . . 115
vii
42 Arrows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
43 Dots, Circles, Triangles and Lines . . . . . . . . . . . . . . . 116
44 Variable Size Symbols . . . . . . . . . . . . . . . . . . . . . . 117
45 Special Symbols in Both Text and Math Modes . . . . . . . 117
46 Commands and Parameters in Picture Environment . . . . . 117
viii
Preface
The majority of this book is about using L
A
T
E
X2
ε
[2, 10], a descendant of
L
A
T
E
X, designed by Leslie Lamport [9], based on T
E
X, originated by Donald
E. Knuth [8]. This is a typesetting program, not a word processor. You
enter some editor that saves plain text ﬁles. Then, you type text freely until
you need something special, such as italic font or a complex mathematical
expression, like
lim
ε→0
+
a
i
+ε
a
i
1 + (r −j)
2
dr
Φ(ε)
.
It was the desire to have high quality, low cost publications in mathe
matics and related disciplines that caused Knuth (pronounced Kahnooth) to
invent T
E
X (pronounced Tek) in the late 1970’s. Originally believing that he
could write a program in less than a year that could typeset documents, he
actually ended up deﬁning an entire branch of research in computer science.
It was 10 years later that he published his seminal book [8], but he published
articles along the way, and he permanently changed the way mathematical
documents are prepared. L
A
T
E
X (pronounced Lahtek or Laytek) is a col
lection of macros built on top of T
E
X that “represents a balance between
functionality and ease of use” [9, p. xiii]. L
A
T
E
X2
ε
is the current version,
developed by a team of volunteers: Johannes L. Braams, David P. Carlisle,
Alan Jeﬀrey, Frank Mittelbach, Chris Rowley, and Rainer Schöpf [2].
A comprehensive coverage of L
A
T
E
X and the many enhancements to it is
given by the The L
A
T
E
X Companion [5]. By contrast, this book is designed to
be a succinct introduction, omitting many of the things L
A
T
E
X2
ε
can do. My
goal is to oﬀer enough of an introduction that someone not acquainted with
L
A
T
E
X (or with T
E
X) can write a term paper, thesis, or article, using L
A
T
E
X2
ε
to produce high quality results. Exercises are provided for guided instruction,
which should be just a few classes. For one who is well acquainted with
computers, particularly unix, the basics that are covered should take less
than 10 hours, and one could do all of the exercises. For one who is just
learning how to use a computer, it will take longer, especially getting used
to functioning at the command line. In any case, the ﬁner points require
more study.
Happy L
A
T
E
Xing.
— Harvey J. Greenberg
Denver, Colorado
ix
Acknowledgments
The author thanks the many contributors in the comp.text.tex newsgroup,
particularly Donald Arseneau, Herman Bruyninckx, David Carlisle, Robin
Fairbairns, Jonathan Fine, Denis Girou, David Haller, Dan Luecking, Timo
thy Murphy, Sebastian Rahtz, Axel Reichert, Thomas Ruedas, Bernd Schandl,
Anton Schwaighofer, Mårten Svantesson, and Matt Swift, who were very gen
erous with taking time to answer so many questions on a regular basis. I also
received useful comments from people who read an earlier draft that I made
available on the web, notably William Briggs. I especially thank Kasper B.
Graversen whose indepth review has made this version much better than my
original. One student, Andrea Dean, provided feedback that led to several
points of clariﬁcation. Last, but not least, I thank Allen G. Holder, who
taught me L
A
T
E
X in the ﬁrst place.
Sources of L
A
T
E
X Software
The basic L
A
T
E
X software system is available free of charge for unix systems,
and MiKTeX [13] is available free of charge for DOS systems. The best
source of these, and additional packages that extend the L
A
T
E
X capabilities
(to which I refer in this book), is at the Comprehensive TeX Archive Network
(CTAN) [4], at three host sites (and many mirrors):
1. http://ctan.tug.org/ in Boston, MA, USA,
2. http://www.tex.ac.uk/ in Cambridge, UK, and
3. http://www.dante.de/ in Mainz, Germany (in German).
These all describe how to search and browse the FTP sites for software and
documents.
1
1 Overview
You will create a ﬁle, called the L
A
T
E
X source, which is plain text. To keep
things simple, its suﬃx is .tex. For example, I refer to myfile.tex as a
plain text source ﬁle that you create. Figure 1 shows the structure of this
ﬁle, which I shall describe in greater detail throughout this book.
% This is myfile.tex
% notes to yourself can go here
Anything following % is ignored
(used for comments).
\documentclass[ojtion:]{:tnc}
optional speciﬁcations
— e.g., declaring use of packages
Preamble
(blank lines do not matter)
\begin{document}
.
.
.
\end{document}
¸
Body
This is the document environment.
All that follows is ignored
(could be used for comments).
Figure 1: The Structure of a L
A
T
E
X Document.
In the preamble, there are many options, depending upon the style; the
intrinsic document styles are: article, book, letter, report, and slides.
Most publishers have their own style, which they provide for you to down
load. Among these are professional societies, notably the American Mathe
matical Society (amsmath style) and the Society for Industrial and Applied
Mathematics (siam style).
The focus throughout this book is on the article style. Further, I shall
be using defaults for almost everything, concentrating on getting started
with using L
A
T
E
X as quickly as possible. Later, some of the options, like
margin settings and other preamble speciﬁcations are covered, as well as
more advanced topics for customizing your document.
Are you ready to write your ﬁrst L
A
T
E
X document? Copy the source ﬁle
shown in Figure 2 and name it myfile.tex. Then, at the command line,
enter:
latex myfile
(In an MS Windows system, the command line is the DOS command line,
which you enter by running Start−→Programs−→MSDOS Prompt, or by
Start−→Run and entering cmd or command into the window.)
This is called compiling your source, which creates several output ﬁles.
The only one you need to be concerned with now is the dvi ﬁle, which the
2 1 OVERVIEW
\documentclass{article}
\begin{document}
Hello world.
\end{document}
Figure 2: Your First L
A
T
E
X Source File
latex program (called a “compiler”) names myfile.dvi. One of three things
will have occurred:
Case 1. You got messages, but they were not fatal errors.
Among the nonfatal 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 correct it. This is called debugging your source.
Sometimes the error message tells you what went wrong, such as miss
ing a brace (characters { and }, which you will come to know and
love), or some command was not recognized due to being misspelled.
Many times the message is not very informative, so you are advised to
compile often. That way you will know that what you did in the last
few minutes contains the error.
Case 3. You got no messages.
Something went wrong and you need to ask for help.
If all went well, the ﬁrst thing to do is save a backup by copying your
source ﬁle to another subdirectory, or to a diﬀerent name. In unix do this
by entering:
cp p myfile.tex myfile1.tex
(The p is to keep the date and time of the source ﬁle.) Change 1 to another
qualiﬁer each time (e.g., 2 . . . ), so you have a collection of backups. If
you are running under DOS, use copy myfile.tex destination, where the
destination is either a: or some backup ﬁle name. (If you are familiar with
3
DOS, nothing more need be said; if not, you need to learn how to create,
edit, and save plain text ﬁles.)
Next you want to view the result. If you are in a unix environment, you
can view the result with the dvi viewer, xdvi. At the command line enter:
xdvi myfile
and it will come on your screen. (There is more to do if you are working
remotely, in which case you might ask someone for help.)
If you are using DOS, the viewer that comes with MiKTeX [13], a free
software system by Christian Schenk, is called YAP. At the DOS command
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
convert the dvi ﬁle to postscript. This is done with the program, dvips. At
the command 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 which case the o is not needed.) This will result in the creation of the
postscript ﬁle myfile.ps. You can print it by any number of ways, including
the unix command, lpr myfile.ps.
The same conversion program can be run under DOS (and comes with
MiKTeX), and you might want to obtain myfile.ps for a variety of reasons,
including posting it on the web. To view or print a postscript ﬁle under
DOS, you can run a program called ghostview. You will need to ﬁnd out
more about viewing and printing postscript ﬁles that suit your particular
needs.
Summarizing, you begin by entering a plain text editor. In unix this could
be pico, emacs, vi or vim. In DOS you can use EDIT at the command line,
or you can use Notepad, Wordpad or MS Word. If you use a word processor,
however, you must take absolutely no advantage of its formatting. You
should even put in hard return characters (i.e., press Enter at the end of
a line instead of letting the word processor do it for you), and never use
tabs. In MS Word, when saving the ﬁle, be sure to specify plain text, and
you must continue to specify the suﬃx as .tex (otherwise, it will use .doc
as its suﬃx). If you want to check that the ﬁle is really plain text, enter
EDIT myfile.tex
4 1 OVERVIEW
at the DOS command line and see how the ﬁle appears. (There are some
free text editors on the web; use your favorite search engine to ﬁnd them.)
Once you have your source ready to compile, enter latex myfile, and if
all is well, enter your dvi viewer. Under unix or DOS use dvips to convert the
dvi ﬁle to a postscript (ps) ﬁle, which can be printed. You can alternatively
(or also) convert the dvi ﬁle to a pdf ﬁle by the command
dvipdf myfile
These steps are given in Figure 3. Execute these commands for the source
ﬁle shown in Figure 2. The result should be one line of output: Hello World.
Congratulations!
myfile.tex myfile.dvi myfile.ps
create/edit view/print print/post
compile
latex
convert
dvips
myfile.pdf dvipdf
Figure 3: Command Sequence from Source to Postscript or PDF
Now change your document to specify a font size of 12pt (default is 10pt)
by changing your ﬁrst line to the following:
\documentclass[12pt]{article}
The “pt” (abbreviation for “point”) is one of the units of measurement, about
1
72
in; other units used in many parts of L
A
T
E
X are in (inches), cm (centime
ters), and em (like the letter m, which is a printer measure equal to the width
of M in the current font).
This book is designed for quick entry into using L
A
T
E
X, but do not be
reluctant to read the last chapter. It tells you how to deﬁne your own com
mands and how to separate them into an input ﬁle that simpliﬁes changing
things, like notation. I also cannot elaborate just yet on “using packages,”
indicated in Figure 1, except to say that they are used to fulﬁll some func
tion, and I shall introduce speciﬁc packages throughout this book. (One of
the strengths of L
A
T
E
X is the community of people who provide packages for
everyone to use at no cost.) The orientation here is by function, beginning
with how to write text.
5
2 Text
We begin by illustrating the most common text formatting, much like you
would want in a word processor. (The power of L
A
T
E
X will be evident when
we get to mathematical expressions, but even some text, especially tables,
will demonstrate the superior quality of the L
A
T
E
X results.) First, consider
how to make sections and subsections in article style. Figure 4 is the source
that produces the result in Figure 5, showing how sections and subsections
are deﬁned. Note the automatic numbering, and how extra spaces and blank
lines have no eﬀect.
\documentclass[12pt]{article}
% We have defined the document to be an article using 12 point font.
% Blank lines mean nothing here, in the preamble.
\begin{document} % Begin document "environment".
\section{This is a Section}
\subsection{This is a subsection}
This is the body of the subsection.
I can move to a new line anytime, and I can put in lots
of blanks with no effect.
Skipping four lines is the same as skipping one line
 it starts a new paragraph.
\subsection{Here is another subsection}
\section{Here is another section}
\end{document}
Figure 4: An Introductory Document Source (Result in Figure 5)
6 2 TEXT
1 This is a Section
1.1 This is a subsection
This is the body of the subsection. I can move to a new line
anytime, and I can put in lots of blanks with no eﬀect.
Skipping four lines is the same as skipping one line — it starts
a new paragraph.
1.2 Here is another subsection
2 Here is another section
Figure 5: An Introductory Document Result (Source in Figure 4)
2.1 Fonts and Paragraphs
Figure 6 shows the source to produce diﬀerent paragraph positions: cen
tered, ﬂush left, ﬂush right, and justiﬁed (the default). Note that these are
environments, a concept you need to understand about L
A
T
E
X. The general
form of an environment uses the following syntax:
\begin{environment}
.
.
.
\end{environment}
\begin{center}
The text is centered because I have entered the center environment.
Text remains centered as long as we remain in this environment.
\end{center}
\begin{flushleft}
Now we are out of the centering environment, and have begun the
flushleft environment.
\end{flushleft}
\begin{flushright}
This is another paragraph, but in the flushright environment.
You will have occasion to use all four paragraph positions.
\end{flushright}
I am back to normal justification. The added space you see between
the above paragraphs is due to entering those environments.
Figure 6: Positioning Paragraphs Source (Result in Figure 7)
2.1 Fonts and Paragraphs 7
The text is centered because I have entered the center
environment. Text remains centered as long as we remain in
this environment.
Now we are out of the centering environment, and have begun
the ﬂushleft environment.
This is another paragraph, but in the ﬂushright environment.
You will have occasion to use all four paragraph positions.
I am back to normal justiﬁcation. The added space you see
between the above paragraphs is due to entering those environ
ments.
Figure 7: Positioning Paragraphs Result (Source in Figure 6)
Instead of the center environment, you can use the \centerline com
mand; they diﬀer in that the environment skips a line before and after the
paragraph, shown in Figures 8 and 9.
This precedes center environment.
\begin{center} This line is centered. \end{center}
This continues after centering.
This precedes centerline.
\centerline{This line is centered.}
This continues after centering.
Figure 8: Centering Source (Result in Figure 9)
8 2 TEXT
This precedes center environment.
This line is centered.
This continues after centering.
This precedes centerline.
This line is centered.
This continues after centering.
Figure 9: Centering Result (Source in Figure 8)
You can also suppress indentation of the ﬁrst line of a paragraph with
the \noindent command. Here is an example:
\noindent This paragraph is not indented. produces:
This paragraph is not indented.
Table 1 lists the fonts that are intrinsic in a basic latex installation. (More
fonts are available in packages, usually free of charge.) In technical writing,
you will have particular use for the italic font, as it is used when introducing
a new term. For example,
A \textit{group} is defined on a set of elements \dots
⇒A group is deﬁned on a set of elements . . .
(The ⇒ symbol can be read as “produces.”) Note the use of the \dots
command, which produces the ellipsis.
Table 1: Intrinsic Font Styles
What you write How it appears
This is \textbf{boldface}. ⇒ This is boldface.
This is \textit{italic}. ⇒ This is italic.
This is \textrm{roman}. ⇒ This is roman.
This is \textsc{small caps}. ⇒ This is small caps.
This is \textsf{sans serif}. ⇒ This is sans serif.
This is \textsl{slanted}. ⇒ This is slanted.
This is \texttt{typewriter}. ⇒ This is typewriter.
Some combinations of font styles can be produced. For example,
\textbf{\textit{bolditalic}} ⇒ bolditalic.
The argument of \textbf is \textit{bolditalic}. The general form is
`textfont{text}, where font is one of {bf, it, rm, sc, sf, sl, tt}, as
seen in Table 1.
2.1 Fonts and Paragraphs 9
Not all combinations are in the basic L
A
T
E
X2
ε
installation. In particular,
you must put \usepackage[T1]{fontenc} in your preamble to obtain:
\textbf{\textsc{bold small caps}} ⇒ bold small caps.
Font size can also be varied at will. Figures 10 and 11 give the source and
result for common variations. Notice how the paragraph spacing changes
to accommodate the variation in font size. These size variations can be
combined with font styles, such as using {\Large\textbf{heading}} for
some heading.
You can make the text {\large large} or {\Large larger} or
even {\LARGE larger still}. You can also make it {\huge huge}.
You might want to make something {\small small} or
{\footnotesize smaller} or even {\scriptsize smaller still}.
You can make it really {\tiny tiny}.
Figure 10: Some Font Sizes Source (Result in Figure 11)
You can make the text large or larger or even larger still.
You can also make it huge. You might want to make some
thing small or smaller or even smaller still. You can make it really
tiny.
Figure 11: Some Font Sizes Result (Source in Figure 10)
The use of braces to enclose a font size speciﬁcation is like an environ
ment. Optionally, we can explicitly use the environment syntax: \begin{size}
. . . \end{size}. For example, \begin{large} This is large.\end{large}
produces the same result as {\large This is large.}. The environment
syntax is useful when you want to keep the size for a large block of text,
and the braces format is useful for short phrases. (There is no intrinsic
environment for font styles.)
It is straightforward to underline text — just write \underline{text}.
We can also frame text just by writing \frame{text}. We can give frame
some room around the edges by using \fbox instead. (More on framing in
§6, p. 71.) To overline is as straightforward, but learning it must wait until
we enter math mode.
Now consider ways to indent a block of text. Here is an example using the
quote environment, which was generated by putting \begin{quote} before
the text and \end{quote} after it:
10 2 TEXT
The construction of the real number system, notably by Dedekind
cuts, was motivated by the need to ﬁx calculus, which ran into
trouble due to insuﬃcient rigor in dealing with limits.
The quote environment is intended for short quotes, generally one short
paragraph (as above), or a sequence of one line quotes, separated by blank
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, except the ﬁrst line of each new paragraph is indented. (Just
as in the regular text, this can be overridden by the \noindent command.)
Here is an example that was created 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 certain what dreams are good for, but we know what
they indicate: a great deal of information processing goes on far
beneath the surface of man’s purposive behavior, in ways and
for reasons that are only very indirectly reﬂected in his overt
activity.”
— Alan M. Turing
“There are reports that many executives make their decisions
by ﬂipping a coin or by throwing darts, etc. It is also rumored
that some college professors prepare their grades on such a basis.
Sometimes it is important to make a completely ‘unbiased’ de
cision; this ability is occasionally useful in computer algorithms,
for example in situations where a ﬁxed decision made each time
would cause 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 (which means horizontal ﬁll), to make the line
ﬂush right. Here are some other things to notice about this example:
• There are left and right quotation marks. I used ‘‘ ’’, not " ", to
create this more stylistic quotation punctuation.
• The dash that appears before each name is created by three minus
signs, . The more minus signs you use, the longer the dash. The
convention is that one dash is for hyphenation, two are for ranges,
such as page numbers, and three are for punctuation — i.e., use 
preceding “i.e.”
2.1 Fonts and Paragraphs 11
• There is extra space between the two quotations. This was done with
the \bigskip command.
Figures 12 and 13 illustrate three levels of skipping: small, medium and
big. Later, we shall look at a way to have a much ﬁner range of vertical
spacing.
This is a first line. \bigskip
The space you see above is a big skip. \medskip
The space you see just above is a medium skip. \smallskip
The space you now see just above is a small skip.
This is just an ordinary line space.
Figure 12: Skipping Line Spaces Source (Result in Figure 13)
This is a ﬁrst line.
The space you see above is a big skip.
The space you see just above is a medium skip.
The space you now see just above is a small skip.
This is just an ordinary line space.
Figure 13: Skipping Line Spaces Result (Source in Figure 12)
The verse environment indents oppositely: lines after the ﬁrst. The fol
lowing was generated by putting \begin{verse} before the text and \end{verse}
after it:
Neglect of mathematics works injury to all knowledge, since he
who is ignorant of it cannot know the other sciences or the
things of this world. And what is worse, men who are thus
ignorant are unable to perceive their own ignorance and so do
not seek a remedy. — Roger Bacon
The italics were speciﬁed in the usual way, by enclosing Bacon’s verse
with \textit{. . . }. (Designed for poetry, each line is a stanza in the verse,
12 2 TEXT
and if a stanza runs long, this form of indentation makes it clear.) Bacon’s
name appears ﬂush right, again from the \hfill command, but this time it
is on the last line of the verse, rather than a new line. This is achieved by
not skipping a line after the verse:
\begin{verse}
\textit{Neglect of mathematics ...
} \hfill  Roger Bacon
\end{verse}
2.2 Lists
There are three intrinsic list environments, distinguished by what appears
at the beginning of each item: number, bullet, or your description (perhaps
nothing). To illustrate, here is the use of a description list environment
to itemize steps involved in learning L
A
T
E
X, whose source is indicated by
Figure 14.
Basic Document Preparation. Knowing how to setup the latex source
ﬁle, make paragraphs, vary fonts, and list items are enough to prepare
a basic document without mathematics or tables (like a resume).
Making Tables. L
A
T
E
X provides a means to make tables with the tabular
environment, and its versatility puts it far ahead of word processors.
Bibliography. Knowing how to create a bibliography, in particular with
BibT
E
X.
Mathematics. This is a power of L
A
T
E
X and one reason why it has become
standard in writing mathematical papers. I will show you how to do
virtually any mathematical expression in line with the text, or in math
display mode.
Graphics. This has progressed a great deal in the past few years thanks to
many people who have provided packages free of charge.
Other. There are a great many things to learn beyond the simple introduc
tion when using L
A
T
E
X to prepare a thesis, report or article.
Two new things appear in the example: the use of \LaTeX to produce
L
A
T
E
X, and the use of ~ (called “tilde”) to enter a space. Without the
tilde, the result would be L
A
T
E
Xprovides, even with a space after \LaTeX in
the source. (The reason is that a space (or some delimiter) is needed after
\LaTeX (or any keyword) in order to distinguish it completely, and one might
want a punctuation mark, like a comma, following \LaTeX, which requires
no space.)
2.2 Lists 13
\begin{description}
\item [Basic Document Preparation.] Knowing how to setup ...
\item [Making Tables.] \LaTeX~ provides a means ...
\item [Bibliography.] Knowing how to create a bibliography ...
\item [Mathematics.] This is the power of \LaTeX~ and one ...
\item [Graphics.] This has progressed a great deal in the ...
\item [Other.] There are a great many things to learn ...
\end{description}
Figure 14: Description List Environment
The text within the square brackets is an option. If present, as in this
example, it is printed in boldface. With no option, the description 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{description}
\item \textsf{This is how one item in a description list
environment looks with no optional text at the beginning.}
\end{description}
produces the following result:
This is how one item in a description 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, which
prints bullets. Note the indentation of each item and the spacing between
items. You see the nesting of two itemize lists, but any type of list can be
nested within any other type.
• This is item 1 and our task has just begun. Blank lines
before an item have no eﬀect.
• This is item 2 and we shall limit to just this few.
A blank line within an item does create a new paragraph,
using the indentation of the itemize environment.
– A second (nested) itemized list changes the bullet and
indents another level.
Figure 16: Itemize List Environment Result (Source in Figure 15)
14 2 TEXT
\begin{itemize}
\item This is item 1 and our task has just begun. Blank lines
before an item have no effect.
\item This is item 2 and we shall limit to just this few.
A blank line within an item does create a new paragraph,
using the indentation of the itemize environment.
\begin{itemize}
\item A second (nested) itemized list changes the bullet
and indents another level.
\end{itemize}
\end{itemize}
Figure 15: Itemize List Environment Source (Result in Figure 16)
Finally, I describe the enumerate list environment, where the default
numbering is with Arabic numerals. With nested enumeration, the number
ing changes at each level. Figures 17 and 18 illustrate with three levels of
nesting.
\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 Back 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 Source (Result in Figure 18)
2.3 Making Tables 15
1. This is item 1, and we are having fun.
2. This is item 2, and it’s time to number anew.
(a) Back 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 (Source in Figure 17)
2.3 Making Tables
A table is made with the tabular environment, which has the following
syntax:
\begin{tabular}{column specs} options
ﬁrst row spec \\
.
.
.
last row spec [\\ options]
\end{tabular}
As indicated, each row ends with two backslashes, \\. Each column spec
iﬁcation can be left, center or right, abbreviated by just one character:
l, c or r, respectively. In the body of the table, each column is separated by
&. Figure 19 shows an example of a 2 3 table.
How it appears What you write
left center right
1 2 3
\begin{tabular}{lcr}
left & center & right \\
1 & 2 & 3
\end{tabular}
Figure 19: A 2 3 Table
We can draw a horizontal line before any new row by specifying \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 column
speciﬁcations can have  on either side to indicate a vertical line. Figure 20
illustrates a combined use of these options.
We could draw lines that span some rows and/or columns. The way to
vary vertical line drawing is with the column speciﬁcations: put  only where
you want a vertical line. The way to vary horizontal line drawing is by using
16 2 TEXT
How it appears What you write
110 120.12 130
210 220. 230
\begin{tabular}{lcr} \hline
110 & 120 & 130 \\ \hline
210 & 220 & 230 \\ \hline
\end{tabular}
Figure 20: A 2 3 Table with Horizontal and Vertical Lines
\cline{ﬁrst col last col } instead of \hline. This is illustrated in Figure 21.
How it appears What you write
Name Test 1 Test 2
Bob 67 72
Sue 72 67
\begin{tabular}{lcc}
Name & Test 1 & Test 2 \\ \cline{11}
Bob & 67 & 72 \\
Sue & 72 & 67 \\ \cline{23}
\end{tabular}
Figure 21: A Table with Partially Spanning Horizontal and Vertical Lines
We can 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 specifying
\textsf{ before entering the tabular environment (and closing with }
just after it).
• Within the tables, fonts are varied: Roman is in the Roman font, speci
ﬁed by \textrm{Roman}, Greek is in italic, speciﬁed by \textit{Greek},
and upper case is in small caps, speciﬁed by \textsc{upper case}.
• A new column speciﬁcation is introduced: p{length}, where any unit
of measure can be used as the length of the spacing. In this example
.3 inches is speciﬁed. Note that this counts as a column, so you see &&
to separate the two tables, each being a column of the main table.
• The \underline command is used to underline Table 1, which is col
umn 1 of the main table, whereas \cline{33} is used to underline all
of column 3 of the main table, headed by Table 2.
There are times when we want to put a good bit of text into some columns
2.3 Making Tables 17
\textsf{
\begin{tabular}{lp{.3in}l} \\
\underline{Table 1} && Table 2 \\ \cline{33}
\\
\begin{tabular}{lc} \hline
Object & Symbols used \\ \hline
variable & lower case \textrm{Roman} \\
parameter & \textit{Greek} \\
constant & \textsc{upper case} \textrm{Roman} \\
\end{tabular}
&& % Begin Table 2
\begin{tabular}{rcc} \hline
* & 1 & 2 \\ \cline{22}
& 3 & 4 \\ \cline{11}\cline{33}
\end{tabular}
\end{tabular}
} % end sf
Figure 22: Nested Tables Source (Result in Figure 23)
Table 1 Table 2
Object Symbols used
variable lower case Roman
parameter Greek
constant upper case Roman
* 1 2
3 4
Figure 23: Nested Tables Result (Source in Figure 22)
of a table. Suppose, for example, we write the following:
\begin{tabular}{ll} \hline
This amount of text is too long to fit on one line of
the page. & This is column 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 column 2.
One solution is to insert new rows and break up the text manually:
18 2 TEXT
\begin{tabular}{ll} \hline
This amount of text is too long to fit on one
& This is column 2. \\
line of the page. & \\ \hline
\end{tabular}
⇒
This amount of text is too long to ﬁt on one This is column 2.
line of the page.
Instead, one can assign a ﬁxed width to a column by specifying p{length}.
For example,
\begin{tabular}{p{2in}l} \hline
This amount of text is too long to fit on one line of the page.
& This is column 2. \\ \hline
\end{tabular}
⇒
This amount of text is too long
to ﬁt on one line of the page.
This is column 2.
Another solution is to use the \parbox command (short for “paragraph
box”). This has the form \parbox[option]{width}{text}, where the option
is the placement: t = top and b = bottom (default is center). Here are two
examples:
\begin{tabular}{ll} \hline
\parbox{2in}{This amount of text is too long to fit on
one line of the page.} & This is column 2. \\ \hline
\end{tabular}
⇒
This amount of text is too long
to ﬁt on one line of the page.
This is column 2.
\begin{tabular}{ll} \hline
\parbox[t]{2in}{This amount of text is too long to fit on
one line of the page.} & This is column 2. \\ \hline
\end{tabular}
⇒
This amount of text is too long
to ﬁt on one line of the page.
This is column 2.
They diﬀer only in the placement of the paragraph box, the latter being at
the top to align it with column 2 in the manner shown.
When making a column or parbox small, the spacing can become un
sightly due to being justiﬁed. This is overcome with the ﬂushleft environ
ment. Figures 24 and 25 illustrate this, and note that it contains other
commands that can be in any paragraph.
2.3 Making Tables 19
\begin{center}
\begin{tabular}{ll}
\parbox[t]{3in}{\begin{flushleft}
This is column 1, and I might want to display something:
\medskip\centerline{\fbox{How sweet it is.}}\medskip
This is not the same as
\medskip\fbox{\centerline{How sweet it is.}}
\end{flushleft} }
& \parbox[t]{1in}{\begin{flushleft}\textsf{This is column 2,
which I have put in sans serif font.}
\end{flushleft} }
\end{tabular}
\end{center}
Figure 24: \parbox Source (Result in Figure 25)
This is column 1, and I might want to
display something:
How sweet it is.
This is not the same as
How sweet it is.
This is column
2, which I have
put in sans serif
font.
Figure 25: \parbox Result (Source in Figure 24)
Any measurement, such as the width of a paragraph box, can be deter
mined by some length parameter, rather than a ﬁxed constant. For example,
see exercise 9 at the end of this chapter and consider \parbox{.3\linewidth}...
If we want some heading to span several columns, this is done by the
command, \multicolumn{number}{col spec}{entry}. The ﬁrst argument is
the number of columns to span (starting where \multicolumn is speciﬁed).
This must be in the range 1 to however many columns remain from the
current position. The second argument is any valid column speciﬁcation,
such as l, c, r, with, or without, a vertical line speciﬁcation, , on either
side. Finally, the third argument is the text.
The \multicolumn command can also serve to override some column
speciﬁcation. Suppose, for example, we want the columns to be left justiﬁed,
but we want the headers to be centered. Figures 26 and 27 illustrate these
uses of \multicolumn. The ﬁrst is used to center ‘Test number’ over columns
2 and 3. The line in the source begins with & to skip column 1, then the
20 2 TEXT
\multicolumn speciﬁes 2 columns, centered with vertical lines before and
after. The second use simply centers the ‘Student’ header. The last use of
\multicolumn centers ‘Taken in class’ over columns 2 and 3. Unlike the ﬁrst
use, the vertical line at the end is missing because c was speciﬁed instead of
c.
\begin{center}
\begin{tabular}{lccc}
& \multicolumn{2}{c}{Test number} \\
\multicolumn{1}{c}{Student} & 1 & 2 & Average \\ \hline
Bill & 67 & 72 & 70.5 \\
Charleetah & 72 & 67 & 70.5 \\ \hline
& \multicolumn{2}{c}{Taken in class} \\ \cline{23}
\end{tabular}
\end{center}
Figure 26: Multicolumn Source (Result in Figure 27)
Test number
Student 1 2 Average
Bill 67 72 70.5
Charleetah 72 67 70.5
Taken in class
Figure 27: Multicolumn Result (Source in Figure 26)
Tables that are too long to ﬁt on one page could be broken manually,
but the longtable package enables automatic page breaks by the L
A
T
E
X com
piler. (You obtain the package from CTAN [4].) In the preamble, specify
\usepackage{longtable}. Then, instead of the tabular environment, specify
the longtable environment, which has most of the same options.
2.4 Special Characters
We have already seen that some characters are special, in that they delimit
something. In particular, \ delimits every L
A
T
E
X command, and % ends a
line, enabling comments. How do we print such characters? One way is with
the symbol, itself, like \%. Other times a keyword, like \textbackslash, is
needed. The Appendix contains complete tables of these special characters
(including those I do not cover explicitly in the chapters). Of particular
importance are the braces, written as \{ \} to obtain { }. (Recall that the
braces by themselves create a local environment, like {\large. . . }.)
When using a keyword to specify a special character, it appears with
whatever font is active. Table 2 (next page) illustrates this with commonly
2.4 Special Characters 21
used special characters. The brackets, [ ], are diﬀerent because they can
be entered directly, except when they are used to delimit an option in the
syntax, in which case they can be obtained by enclosing them in braces.
One example is the description list environment, illustrated in Figure 28.
(Another is in the tabular environment (page 15), but I omitted a discussion
of position options that are speciﬁed by brackets.)
How it appears What you write
This is option for item.
\begin{description}
\item [This is option] for item.
\end{description}
[This is not option] for item.
\begin{description}
\item {[This is not option]} for item.
\end{description}
Figure 28: Obtaining Brackets in a Description List Environment
Table 2: Writing Special Characters
Character How you
Other fonts
(Roman) write it italic large
{ } \{ \} { } { }
% $ # & _ \% \$ \# \& \_ % $ # & _ % $ # & _
\ \textbackslash \ \
^ \textasciicircum ^ ^
~ \textasciitilde ~ ~
r ( \textregistered r ( r (
[ ] {[ ]} [ ] [ ]
Another way to print the unprintable is with the verbatim environment
or the \verb command. Unlike all other commands, \verb does not use
braces to delimit its argument. It uses any other character to delimit a
string, which can contain any character except itself. For example, we can
write \verb@{}%$#\@ to generate the string {}%$#\ (delimited by @), which
is printed in typewriter font style. The verbatim environment uses the usual
syntax:
\begin{verbatim}
.
.
.
\end{verbatim}
22 2 TEXT
This is how the source code was created for the ﬁgures, like Figure 26 (p. 20).
Another class of special characters are letters with accents. Table 3 shows
some common examples; a complete table is in the Appendix. For example,
write Poincar\’{e} to have Poincaré and G\"{o}del to have Gödel. An
accent could be applied to any letter, even if it does not relate to some
language — for example, \"{b}\~{c}\^{d} ⇒
¨
b˜c
ˆ
d.
L
A
T
E
X has a basic library of accents and special characters for writing in
languages other than English, some of which are shown in Appendix Table 29
— e.g., ?‘⇒¿ and \aa⇒å. In some cases, these are not suﬃcient, particularly
if the entire document is to be in a nonEnglish language. For that purpose
there are some packages, such as Babel [1] (also see [5, Chapter 9]).
Table 3: Some Accents for Letters
What you write What you see
\"{a} ⇒ ä
\‘{e} ⇒ è
\’{i} ⇒ í
\~{o} ⇒ õ
\^{u} ⇒ û
2.5 Tabbing
The tabbing environment provides an alternative to the tabular environment
by letting you set your own column tabs. Table 4 shows a simple case with
two basic tabbing commands, \= to deﬁne a tab setting, and \> to move
to a tab setting. In addition, \\ ends each row, but unlike the tabular
environment, the ﬁrst sentence continues normally, without extra spaces, so
that the position of the tab is not equivalent to that of a table’s column.
Table 4: The Tabbing Environment
What you see What you write
Begin: set tab 1. . . set tab 2
skip to 1 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}
Sometimes we do not want to have the longest portion of text ﬁrst, yet
it is needed to deﬁne the tab. Table 5 illustrates how this is solved with the
2.6 Line, Page, and Word Breaks 23
\kill command. In the ﬁrst tabbing, the lines are in the order we want,
but the tab is set by the shorter string ‘13’, making ‘468’ extend past
the tab. The second tabbing puts the longer ﬁeld ﬁrst, in order to set the
tab correctly, then speciﬁes \kill instead of \\ to suppress (or “kill”) the
printing of the line.
Table 5: The \kill Tabbing Command
What you see What you write
13 sting like a bee
468 don’t be late
\begin{tabbing}
13 \= sting like a bee \\
468 \> don’t be late \\
\end{tabbing}
13 sting like a bee
468 don’t be late
\begin{tabbing}
468 \= don’t be late \kill
13 \> sting like a bee \\
468 \> don’t be late \\
\end{tabbing}
Figures 29 and 30 illustrate the tabbing environment with ﬁxed ﬁeld
widths. It ﬁrst uses the \hspace* command for horizontal spacing, then it
uses the name of the last ﬁeld to set what follows.
\begin{tabbing}
\= \hspace*{.5in} \= \hspace*{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 Source (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 (Source in Figure 29)
2.6 Line, Page, and Word Breaks
You can cause a new line by entering \linebreak. When text is justiﬁed (the
default), this could result in an undesirable appearance, like the following:
24 2 TEXT
\textsf{This example is \linebreak extreme.}
⇒This example is
extreme.
The \newline command forces a new line without justifying it.
\textsf{Here is the extreme \newline example.}
⇒Here is the extreme
example.
The \nolinebreak command works analogously, preventing a line break,
even if it means extending into the right margin. Also, it is better style to
keep certain ‘words’ together, such as ‘ﬁgure 1’ or ‘p. 10’. To prevent a line
break where you want a blank, use the space character ~. We would thus
write figure~1 or p.~10.
There are two commands to force a page break: \pagebreak and \newpage.
The \newpage command follows the analogy with \newline in forcing a page
break precisely at the point it is speciﬁed, rather than completing the line as
\pagebreak does. The \nopagebreak command disallows a page break im
mediately following the next blank line. The \samepage command prevents
a page break within its scope. Here is an example that keeps line 1 on the
same page as line 2.
{\samepage
line 1
\nopagebreak
line 2
}
Word breaks are hyphenations that L
A
T
E
X does for you. Sometimes,
however, you want to suppress hyphenation. This can be done by specifying
\usepackage{hyphenat} in the preamble. (You might have to download
the package from CTAN [4], and follow the simple installation instructions.)
Then, to suppress hyphenation, you specify the \nohyphens command. For
example, the ﬁrst sentence of this paragraph has a hyphen; to suppress it,
enter:
\nohyphens{Word breaks are hyphenations that \LaTeX\ does for you.
Sometimes, however, you want to suppress hyphenation.}
Then, you obtain the following:
Word breaks are hyphenations that L
A
T
E
X does for you. Sometimes,
however, you want to suppress hyphenation.
2.7 Spacing 25
2.7 Spacing
We have already seen the use of ~ to insert one space and \hfill to put the
remaining text ﬂush right. The most versatile method to insert horizontal
spaces is with \hspace and \hspace*. These have one argument: the
amount of space to be inserted. For example,
I insert .3~in \hspace{.3in} here. ⇒ I insert .3 in here.
The \hspace command has no eﬀect at a line boundary, but the \hspace*
inserts the space no matter what. For example, the previous
sentence is written as:
The \verb\hspace command has no effect at a line boundary, but
the \verb\hspace* \hspace*{1in} inserts the space no matter what.
That is why you see the 1 inch space at the beginning of the second line.
\hspace would not insert the 1 inch, but \hspace* does.
Two variations of \hfill are:
\dotfill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
\hrulefill
Analogously, vertical spacing is controlled by \vspace, \vspace* and
\vfill. The height of one line of normal text is in the keyword \baselineskip,
so vspace{\baselineskip} skips one line at the next new line. The verti
cal space is not added if this goes to the top of a new page; that is what
\vspace* does. In particular, at the very beginning of your document, if you
want to make your own title page, you use \vspace*{2in} to put a 2 inch
margin at the top (\vspace would not insert the space).
The easiest way to control line spacing throughout your document is to
specify usepackage{setspace} in your preamble. This gives you three
commands:
\singlespacing \onehalfspacing \doublespacing
Right after you specify one of these, that spacing will commence.
You can, however, specify \renewcommand{\baselinestretch}{1.2}
to increase the spacing modestly (actual increase depends upon the font
size). This acts like renewing the \arraystretch setting and remains in
eﬀect until changed. However, one diﬀerence is that you need to change font
size before this change goes into eﬀect. You could write
\renewcommand{\baselinestretch}{1.2}\small\normalsize
Exercises. Submit a printed copy of both the L
A
T
E
X source (tex ﬁle) and
the associated postscript result (ps ﬁle). Be sure your name is on each.
1. Write a paragraph in article [and letter] style with the following prop
erties:
26 2 TEXT
(a) Each font style in Table 1 is used as one letter in a word that has
more than one letter.
(b) Each font style in Table 1 is used for one complete word.
(c) Each font style in Table 1 is used for two consecutive complete
words.
2. Write two paragraphs in article [and letter] style with each of the fol
lowing properties:
(a) Default indentation on both paragraphs.
(b) No paragraph is indented.
(c) Both paragraphs are indented.
(d) There is added space between paragraphs.
3. Write a paragraph in article style and make a cover page with the
following properties (like the cover page of this document):
• All lines are centered.
• The title appears ﬁrst in very large letters.
• Your name appears second in letters that are not as large as the
title, but larger than normal size, and it is preceded by extra
space.
• Your email address appears third.
• Your web address appears fourth.
• Course number and title appears next, with extra space preceding
it.
• Date appears last, with extra space preceding it.
4. Give an enumeration of at least three things you like about mathemat
ics. Give the same list without numbers.
5. Produce the following table:
Colors
Primary Secondary
Red Green
Blue Orange
Yellow Purple
6. Produce the following table (including the accents and alignments).
2.7 Spacing 27
Mathematician Birth Death
Gabrielle Emilie Le Tonnelier
de Breteuil Marquise
du Châtelet 1706 1749
Benjamin Banneker 1731 1806
Sophie Germain 1776 1831
Julius König 1849 1913
Rózsa Péter 1905 1977
7. Produce the following table.
Payoﬀs ($)
Player A Player B
1 2 3
4 5 6
1 2
3 4
5 6
8. How can you have an entire table whose columns are of ﬁxed width?
9. Create a 3column text such that each column is a paragraph of arbi
trary length using about
1
3
of the page width each.
10. Use the tabbing environment to produce the following:
apples integral derivative
grapefruit sum diﬀerence
variables constants
11. Use the tabbing environment to produce what you see on page 30.
12. Produce the following:
rate of mass
accumulation
in the
compartment
=
net rate of mass
entering the
compartment by
convection
+
net rate of
mass entering
by diﬀusion.
28 3 BIBLIOGRAPHY WITH BIBT
E
X
3 Bibliography with BibT
E
X
3.1 Overview
It might seem strange to have this section so early, instead of with §7.4. That
is because I require students to produce an annotated bibliography early in
the semester, and I want them to use BibT
E
X. So here we are.
BibT
E
X [11] was developed by Oren Ptashnik and is available free of
charge. It reads a plain text ﬁle, called a bib ﬁle (plus one of the ﬁles
created by the latex compiler, about which you need not be concerned). The
bib ﬁle contains the bibliographic database, which could extend beyond one
document. The bibtex program that you apply to your source creates another
ﬁle (which you need not examine), from which a second latex compilation
causes the bibliography to be created. The execution looks like this (same
under unix and DOS):
latex myfile
bibtex myfile
latex myfile
You might have to compile with latex more times, until you do not have
any “unresolved” bibliography citations. Once this is successful, you do not
have to bibtex myfile again until you change your bib ﬁle or add a citation.
This added loop is illustrated in Figure 31.
myfile.tex myfile.dvi myfile.ps
create/edit view/print print/post
compile
latex
convert
dvips
bibtex
myfile.pdf dvipdf
Figure 31: Adding bibtex to the Command Sequence
3.2 The bib File
3.2.1 Main body
For purpose of this introduction, suppose your bibliography is in a ﬁle called
mybiblio.bib, but that name is arbitrary as long as it ends with .bib. We
3.2 The bib File 29
begin with the most important part of your bib ﬁle, which are the entries
you want to include in its database. Each entry has the following form:
@type {label ,
ﬁeld = "value",
.
.
.
}
For example, Knuth’s book [8] would be entered as follows:
@article{tex,
author = "Donald E. Knuth",
title = "The {\TeX} Book",
publisher = "AddisonWesley Publishing Company",
address = "Reading, MA",
year = "1989",
edition = "15th",
}
Most authors develop a style to labeling bibliographic entries. The use
of one keyword is somewhat simplistic and could cause problems with a
great number of entries because the labels must be unique. We cannot, for
example, have two entries with tex as their label. Here are two styles I have
seen, which you might consider:
Form Example
author.year knuth.89
author:ﬁrst_keyword_in_title knuth:tex
With two authors, you can put both of their names; with more than 2,
you can add et al. (Linguistically, the use of the Latin et al. in formal writing
follows this rule.) In the ﬁrst form, if there are two publications by the same
authors in the same year, some people add a, b, . . . after the year (no blank).
In the second form, if there are two publications by the same authors in the
same year, some people add another keyword. You must discover what style
works best for you.
Before listing each style (article is one style) and the ﬁelds they can or
must have (author is one ﬁeld), here are a few things to note.
• The label is arbitrary, but do not use any L
A
T
E
X special characters or
blanks. In the example, the label is speciﬁed as tex and it must be
followed by a comma. Also, labels are casesensitive, so tex is not the
same as TeX.
• Each bib entry must have a unique label, so it can be cited without
ambiguity in the source ﬁle.
30 3 BIBLIOGRAPHY WITH BIBT
E
X
• The order of the ﬁelds is arbitrary, and ﬁelds are separated by commas
(hence the comma after the terminal quote). The last ﬁeld does not
require a comma at the end, but it will not hurt anything, and it gives
ﬂexibility if you want to add a ﬁeld or change the order.
• Fields do not have to be on separate lines, but it is more readable that
way.
• The ﬁeld value can be anything recognized by L
A
T
E
X, even mathemat
ical symbols in math mode.
• There is a ﬁnal } to close the entry — @type{ . . . }.
Remember to put each author’s name as ﬁrst last or last, ﬁrst. If you
put Knuth Donald, the compiler 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
E
X are not necessarily optional as far as having a
complete bibliography citation. For example, the volume and page numbers
of an article are necessary to include even though they are optional to sat
isfy BibT
E
X syntax. (What is “necessary” depends upon the standard one
applies, but most journals require the volume of the journal and the page
numbers for the cited article.) Fields that are neither required nor optional
are ignored, even if they are valid ﬁelds in other types of entries.
article refers to an article from a journal or magazine.
Required ﬁelds: author, title, journal, year.
Optional ﬁelds: volume, number, pages, month.
book refers to a book with an explicit publisher.
Required ﬁelds: author or editor, title, publisher, year.
Optional ﬁelds: volume or number, series, address, edition, month.
booklet refers to a bound, printed document, but without an explicit
publisher.
Required ﬁelds: author or key, title.
Optional ﬁelds: author, howpublished, address, month, year.
inbook is a part of a book, such as a chapter or just some range of pages.
Required ﬁelds: author or editor, title, chapter and/or pages,
publisher, year.
Optional ﬁelds: volume or number, series, type, address, edition,
month.
incollection is a part of a book having its own title.
Required ﬁelds: author, title, booktitle, publisher, year.
Optional ﬁelds: editor, volume or number, chapter series,
type, pages. address, edition, month.
3.2 The bib File 31
inproceedings is an article in a conference proceedings.
Required ﬁelds: author, title, booktitle, year.
Optional ﬁelds: editor, volume or number, series, pages,
month, organization, publisher, address.
manual is some technical documentation.
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, school, year.
Optional ﬁelds: type, address, month.
misc 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, school, year.
Optional ﬁelds: type, address, month.
proceedings
Required ﬁelds: title, year.
Optional ﬁelds: editor, volume or number, series, publisher,
organization, address, month.
techreport is a report published by some institution.
Required ﬁelds: author, title, institution, year.
Optional ﬁelds: type, number, address, month.
unpublished is a document with an author and title, but not formally
published, even as a technical report. (Some note of explanation is
required.)
Required ﬁelds: author, title, note.
Optional ﬁelds: month, year.
In addition to the optional ﬁelds listed, which 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 citation. To have a comment that is not printed, enter an
unrecognized ﬁeld, such as comment = "...", (this is ignored with no error
message given).
If a required ﬁeld is missing when you compile, 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 document has no author, you must
provide a key for sorting. For example, consider the following entry for
L
A
T
E
X2
ε
[10], which has no person as an author. The bibliography will be
sorted with the key, LaTeX2e, used to order this entry relative to author
32 3 BIBLIOGRAPHY WITH BIBT
E
X
names. The key will not be printed.
@manual{usrguide,
key = "LaTeX2e",
title = "{\LaTeXe} for authors",
type = "World Wide Web site",
institution = "Comprehensive {\TeX} Archive",
address = "{CTAN\url{/macros/latex/doc/usrguide.ps}
(see~\cite{CTAN} for replacing CTAN)}",
year = "199599",
}
When there are multiple authors, we separate them with and (no com
mas). For example, [5] in this document has the following BibT
E
X entry:
@Book{companion,
author = "Michel Goosens and Frank Mittelbach and
Alexander Samarin",
title = "The {\LaTeX} Companion",
publisher = "AddisonWesley Publishing Company",
address = "Reading, MA",
year = "1994",
}
The use of the braces in {\LaTeX} is to tell the bibtex program to take
everything inside just as it is written (for the latex program to process).
Otherwise, the bibtex program might try to process it itself and produce an
unintended result. This applies to accents too. In ordinary L
A
T
E
X, we write
G\"{o}del to produce Gödel, but this will not work in BibT
E
X. Instead,
we write G{\"{o}}del, or simply G{\"o}del.
The use of braces to force a particular result is necessary in other in
stances, such as writing {F}ourier analysis to force the capital F; oth
erwise, the bibtex program will produce ‘fourier analysis’ (the plain style
produces article titles in lower case, except the ﬁrst letter of the ﬁrst word).
Some authors, however, use this feature inappropriately by putting braces
around everything. That defeats one of the primary advantages of using
L
A
T
E
X and BibT
E
X in the ﬁrst place: we want to let the style ﬁles deter
mine the ﬁnal form, so we can switch styles and use the same source (tex
and bib ﬁles).
3.2.2 Web citations
When BibT
E
X was developed, the World Wide Web did not exist. Now it
is a major source of information. There is no universally accepted standard
for how to reference web documents, but here is one way.
If it is a book, use the book type and specify:
3.2 The bib File 33
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.columbia.edu/acis/bartleby/strunk/",
year = "1999",
note = "This is the web version of the classic book by
Strunk and White~\cite{StrunkWhite}",
}
The reference \cite{StrunkWhite} presumes there is the entry for the
original publication. The use of the braces in the name is to be sure that
the author appears as intended: William Strunk, Jr. Otherwise, without the
braces, the comma would signal the bibtex program that ‘Jr.’ is the ﬁrst
name of the author, and it would appear as ‘Jr. William Strunk’.
If the document is a technical report, use that style but include the url
as a note or in the address ﬁeld. Eventually, you will run into some diﬃculty
with writing urls. For one thing, the url could contain special characters; in
particular, ~ is in many urls, and writing it will produce a space, not the
tilde. Also, a url could become very long, and with latex having no place to
break, you will see a line with lots of spaces (for justiﬁcation), followed by
the url. An unsightly line with spaces could also appear after the url. These
diﬃculties are overcome by specifying:
address = "\url{http://www.columbia.edu/acis/bartleby/strunk/}",
The \url speciﬁcation is not actually an intrinsic command in L
A
T
E
X;
it is deﬁned in a package. Its main use is to determine where the url can
be broken in order to put it on two lines, if needed. Another feature of
the url package is that \url prints special characters, like ~. To have the
\url command active in your document, put the following declaration into
your preamble: \usepackage{url}. The default font it uses is tt, but
you can change this to TimesRoman or sans serif font with the speciﬁcation:
\urlstyle{rm} or \urlstyle{sf}, respectively.
There are occasions when we want to reference an entire web site. One
example is the L
A
T
E
X2
ε
reference [2], given by:
@misc{latex2e,
author = "Johannes L. Braams and David P. Carlisle and
Alan Jeffrey and Frank Mittelbach and Chris Rowley
and Rainer Sch{\" o}pf",
title = "{\LaTeXe} and the {LaTeX}3 Project",
34 3 BIBLIOGRAPHY WITH BIBT
E
X
howpublished = "World Wide Web,
\url{http://www.latexproject/org/latex3.html}",
year = "1994",
}
We have seen several packages so far, and you shall learn more about
packages in §6, where I describe enhancements for having graphics in L
A
T
E
X.
However, this is the ﬁrst use of \renewcommand, about which I shall say more
when I describe ways to customize your document in §??.
3.2.3 Additional features
One element of good style is to be consistent in your terms, including abbre
viations and names of publishers. One sometimes sees “Kluwer,” other times
“Kluwer Academic Publishers,” and still other times “Kluwer Pub.” To help
be consistent and to save some work in the long run when we write many
diﬀerent documents and produce more bib ﬁles, we can deﬁne strings with
the entry:
@string{name = "string"}
Then, we can refer to the string anywhere in the value of a ﬁeld by excluding
the quotes. (That is why we needed the quotes before, when we wrote
literals.)
For example, suppose we deﬁne:
@string{kluwer = "Kluwer Academic Publishers"}
Then, we can enter:
publisher = kluwer,
to produce the publisher value = “Kluwer Academic Publishers.” Besides
consistency, an advantage is that if some name changes, we merely change
the one string value and recompile.
We can concatenate 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",
3.2 The bib File 35
Note the absence of a space between the string values in the title. To ensure
a space, use the space character, ~, as a literal:
title = 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
E
X is the crossref ﬁeld for cross refer
encing. For example, suppose we have the following entry (kluwer is a string;
the other values are literals):
@Proceedings{Byrnes:FAA89,
editor = "J.S. Byrnes and Jennifer L. Byrnes",
title = "Recent Advances in {F}ourier Analysis and its
Applications: Proceedings of the {NATO}
{A}dvanced {S}tudy {I}nstitute",
publisher = kluwer,
year = 1990,
}
Then, we can have the following entry:
@InProceedings{Artemiadis:FAA89311,
crossref = "Byrnes:FAA89",
author = "N.K. Art{\’e}miadis",
title = "Results on the Absolutely Convergent Series
of Functions and of Distributions",
pages = "311316",
}
If these were the only references, the result would appear as follows:
[1] N.K. Artémiadis. Results on the absolutely convergent series of functions
and of distributions. In Byrnes and Byrnes [2], pages 311–316.
[2] J.S. Byrnes and Jennifer L. Byrnes, editors. Recent Advances in Fourier
Analysis and its Applications: Proceedings of the NATO Advanced Study
Institute. Kluwer Academic Press, 1990.
BibT
E
X also recognizes a preamble in our bib ﬁles to enable us to deﬁne
some L
A
T
E
X commands. The general form is
@Preamble{ string }
where string is any concatenation of literals and strings. Here is an ex
ample [11] that is useful for guiding the sorting of references in a special
circumstance:
36 3 BIBLIOGRAPHY WITH BIBT
E
X
@Preamble{ "\newcommand{\noopsort}[1]{}" }
The \newcommand is something I shall describe more fully in §??. For
now, it is used to deﬁne a command, \noopsort, requiring one argument.
Command \noopsort ignores the argument that it receives, producing noth
ing (indicated by {}). Here is how this can be used.
Suppose there is a 2volume work by the same authors, originally pub
lished 1971, but a second edition of volume 1 is printed in 1973. The bib
entries would have the years in the opposite order than we want because
sorting is ﬁrst by the authors, which are the same, then by year. To force
the ﬁrst volume to sort before the second, we fool the bibtex program with
the following speciﬁcations:
Volume 1 Volume 2
year = "{\noopsort{a}}1973", year = "{\noopsort{b}}1971",
This fools the bibtex program into thinking the years are a1973 and b1971,
thus putting volume 1 ﬁrst. The deﬁnition of \noopsort, however, does not
actually print the letters, so just the years appear.
3.3 Declaration and Citation
At the end of your source ﬁle (where you want the bibliography to appear),
before \end{document}, put the following commands (in either order):
\bibliography{mybiblio}
\bibliographystyle{plain}
The ﬁrst declares the bibliography to be in the bib ﬁle, mybiblio.bib.
The second command deﬁnes the format style of the bibliography to
be plain, which comes with every installation of latex. There are other
bibliography format styles, including some provided by publishers. Here is
a list of the most basic ones (included in every installation):
plain is the most common because it formats entries according
to accepted standards. Entries are sorted by the alphabetical
order of author names, breaking ties with the year of publi
cation, and they are labeled with numbers.
abbrv diﬀers from plain by abbreviating names of journals,
among other things (to give a more compact bibliography).
alpha diﬀers from plain by citing by labels, rather than num
bers.
unsrt diﬀers from plain by sorting entries by the order in which
they are cited, rather than by the author names.
3.4 Some Controls 37
We shall use only the plain style here, but know that many other styles
have been written and are available free of charge.
To cite particular references, the L
A
T
E
X command is \cite{label [,. . . ]},
where label is what we put in our bib ﬁle entry. For example, [8] is produced
by specifying \cite{tex}. You can put more than one citation, separated by
commas. For example, \cite{tex,latex} produces [8, 9] for this document.
You can insert some further citation information as an optional input
argument to the \cite command. For example, \cite[p.~46]{latex} pro
duces [9, p. 46] in this document. (In the option, delimited by [ ], the ~ is
used to ensure that there is a space but no line break when giving the page
number as “p. 46” in the citation.)
The rule is that only those bib entries that are cited appear in the ﬁnal
document. The reason is that we can maintain one large bib ﬁle and write
many documents that use it. There are times when we want to be sure a
particular bib entry appears, but we do not want to cite it in the text. This
is done with the \nocite command. In particular, if we want to have every
entry in our bib ﬁle appear, we specify \nocite{*}. If we want only some
particular list of entries to appear, we use \nocite with their labels, such as
\nocite{tex} to be sure Knuth’s T
E
X book appears, even if it is not cited
explicitly. Figure 32 shows a complete source ﬁle for having all entries in
mybiblio.bib appear, and that is the entire document!
\documentclass[12pt]{article}
\begin{document}
\nocite{*}
\bibliographystyle{plain}
\bibliography{mybiblio}
\end{document}
Figure 32: A Document to Print the Bibliographic Database
We can specify more than one bib ﬁle, such as:
\bibliography{mybiblio,another}
The bibtex program will search them sequentially for any citation. If we have the
same label in both bib ﬁles, the entries must be identical; otherwise, we will get
a fatal error message, Repeated entry– telling us which label is repeated. If we
have the same entry with diﬀerent labels, they will appear twice if both labels are
used (or if we used \nocite{*}).
3.4 Some Controls
You might want to have the bibliography singlespaced, even if the main document
is spaced diﬀerently. Just before the \bibliography statement, put
\renewcommand{\baselinestretch}{1} \selectfont
38 3 BIBLIOGRAPHY WITH BIBT
E
X
The \selectfont command is needed to activate the change in \baselinestretch.
If you also want to change the font size (or style), that will do. Thus, you could
specify
\renewcommand{\baselinestretch}{1} \small
to have the bibliography set in small font size (and single spaced); \selectfont is
not needed.
You can change the heading put by bibtex. The default is Bibliography, but
you might want to have it be References. You do this by specifying (sometime
before the bibliography):
\renewcommand{\refname}{References} for article style
\renewcommand{\bibname}{References} for book and report styles
You can have more than one bibliography by using the bibunits package, which
is available at CTAN [4]. This will let you put diﬀerent bibliographies throughout
your document, and you can change the properties, such as the heading.
Exercises. Submit a printed copy of the L
A
T
E
X source (tex ﬁle), the BibT
E
X
data (bib ﬁle), and the associated postscript result (ps ﬁle). Be sure your name is
on each.
1. Produce a document with one paragraph that cites three bibliographic items,
one for each of the following types:
(a) An article in a journal.
(b) An entire book with at least three authors.
(c) A chapter in a book.
(d) A technical report.
2. Produce a document that lists your entire database, which consists of at least
one entry for each of six diﬀerent document types. Further, at least one entry
must have more than two authors.
3. Produce a document with one paragraph that cites three bibliographic items,
one for each of the following types:
(a) A technical report on the web.
(b) A book on the web.
(c) An entire web site.
4. Produce a document that has only a bibliography composed of the following
three entries (in the order shown).
[1] I.M. Rich, editor. Impossible Dreams, volume I. MacTaco, second edition,
1999.
[2] I.M. Rich, editor. Impossible Dreams, volume II. MacTaco, 1990.
[3] I.M. Smart, U.R. Tu, and V.F. Money. How to Square a Circle, chapter 1.
Volume II of Rich [2], 1990.
39
5. Produce an annotated bibliography of the following form (note the indenta
tions on left and right margins):
[1] P.R. Halmos, Naive Set Theory, Van Nostrand, Princeton, NJ, 1960.
This is a good book, which I assign to my Ph.D. students. The ﬁrst
100 pages seem simple. The next 100 reveal lack of understanding
the ﬁrst 100.
[2] G. Polya, How To Solve It, Princeton University Press, Princeton, NJ,
1945.
This is a seminal book that articulates the problemsolving — i.e.,
theoremproving — process. There are many editions, and there are
modern descendants, such as . . .
4 Counters, Labels, and References
4.1 Basic Concepts
A counter is a numerical value that refers to something that is being numbered,
such as pages, sections, ﬁgures, and equations. A label is the identiﬁcation of
a particular value, and a reference is a citation to a label. The L
A
T
E
X syntax
for labeling a counter is \label{label }, placed where the counter’s value is set,
where label is unique in the document. The L
A
T
E
X syntax for referencing a label is
\ref{label }. For example, in this book I deﬁned:
\section{Bibliography with \Bibtex} \label{sec:Bibliography}
Now I can refer to §3 by \S\ref{sec:Bibliography}. The choice of label is ar
bitrary, except do not use L
A
T
E
X special characters or blanks, just as the labels in
the bib ﬁle entries.
There are times when you just want to produce the counter value, without a
label. This is done by \thecounter. For example, \thepage produces the page
number. On the other hand, if you want to use the counter’s numerical value as an
argument in a command, specify \value{counter}.
In the next section I describe intrinsic counters and illustrate how to label and
reference them. Then, I shall introduce the ﬁgure and table environments, which
have intrinsic counters associated with them.
4.2 Intrinsic Counters
Anything to which L
A
T
E
X assigns a number has a counter associated with it. Here
I illustrate some of those that are in all document styles. Counters that depend
upon the style, like a chapter in a book, can be labelled and referenced in the same
manner.
You are looking at page 39, which I was able to print by writing \thepage.
Similarly, you are reading subsection 4.2 of section 4, whose numbers I could write
by \thesubsection\ and \thesection, respectively.
To illustrate how I can reference other parts of this document, the following
labels were deﬁned (when the subsection and subsubsection were ﬁrst written):
40 4 COUNTERS, LABELS, AND REFERENCES
\subsection{The bib File} \label{subsec:bibfile}
\subsubsection{Web citations} \label{subsubsec:webcite}
Then, I can refer to these as follows:
\S\ref{subsec:bibfile} ⇒ §3.2
\S\ref{subsubsec:webcite} ⇒ §3.2.2
I can also refer to their page numbers:
p.~\pageref{subsubsec:webcite} ⇒ p. 32
p.~\pageref{subsec:bibfile} ⇒ p. 28
For any counter, \pageref{counter}, gives the page number where its label is
deﬁned, just as \ref{counter} gives its value. (Recall from p. 24 that ~ is used to
have a space without a linebreak, which is an element of good style.)
Equation (6), page 60, was labelled \label{eqn:hessian}, so in this sentence
I wrote its number by \ref{eqn:hessian} (with parenthesis added) and its page
number by \pageref{eqn:hessian}. In the exercise to list what you like about
mathematics, I entered the label \label{exer:likeaboutmath} (page 26), which
I can now reference as exercise #4 by writing \#\ref{exer:likeaboutmath}.
The choice of label, such as subsubsec:webcite, is any string you want to use
that does not contain embedded blanks or special characters used by L
A
T
E
X. In
my choice of label, I used the structure preﬁx:name. That is a matter of style,
and I used the preﬁx subsec here. This helps me to distinguish labels for diﬀerent
things. For equations, I use the preﬁx eqn. Some people use this same form but
with diﬀerent preﬁxes, such as ss for subsection and e for equation. You can choose
any labeling convention that is meaningful to you. (If you have a lot of labels and
need to keep track of them by printing each label and citation in your drafts, see
the showkeys package at CTAN [4].)
4.3 Figures and Tables
In this section I describe ﬁgure and table environments, which have the same
syntax:
\begin{figure}[options] \begin{table}[options]
[\caption{caption[\label{label }]}] [\caption{caption[\label{label }]}]
.
.
.
.
.
.
[\caption{caption[\label{label }]}] [\caption{caption[\label{label }]}]
\end{figure} \end{table}
The caption, if present, can go at the top or bottom; where you put it is where
it will appear. The label to reference a ﬁgure or table is put inside the caption.
(If you put it outside the caption, as given in [9], it will not be understood, even
though you will get no error message.)
Because ﬁgures and tables are not split, their exact location depends upon how
much room there is. For that reason they are called “ﬂoating objects,” or ﬂoats.
The environment options deﬁne where the ﬂoat is to be located. The four choices
4.3 Figures and Tables 41
are shown in Table 6. In this document most tables and ﬁgures are speciﬁed with
[ht], which means they are to be placed “here,” the place where it is speciﬁed in
the source, if possible. If there is not enough room, it is to be located at the top of
the following page.
Table 6: Figure and Table Location Options
Option Meaning
h Locate here (where the environment is declared).
t Locate at the top of the next page.
b Locate at the bottom of the page (or the next page,
if this page does not have enough room).
p Locate on a separate page, called a ﬂoat page,
which has no text, only ﬁgures and tables.
The placement of a ﬂoat is sometimes a source of frustration. We might specify
[ht] and ﬁnd the ﬂoat in an unexpected place, perhaps on a page by itself. One
cause could be an accumulation of ﬂoats that should be cleared at some point
before continuing. This is done with the \clearpage command. This does the
same as \newpage, except that it also prints all remaining ﬂoating objects. It
is also advisable to specify \usepackage{float} in the preamble. One of the
enhancements is the placement option: [H], which insists that the ﬂoat be placed
here (note the capital H and no other option speciﬁed). This option is used in many
places in this book, which is why you sometimes see pages with some blank space
in the lower portion, followed by a ﬁgure or table. I did this to avoid confusion by
having some ﬂoat appear pages after it is cited and discussed.
The table environment is not to be confused with the tabular environment. The
latter makes tables, but the table environment does not have to contain a table; it
diﬀers from a ﬁgure only in its name, and they have separate counters. The ﬁgures
and tables in this document appear as the form:
Figure number : caption vs. Table number : caption
That’s it.
As a matter of style, we generally use the ﬁgure environment to present what
we usually think of as ﬁgures, notably pictures, and we generally use the table
environment to present information in tabular form. However, neither of these
conditions is necessary for their L
A
T
E
X environments.
Floats can be framed, using the \fbox command. For example, Figures 33 and
34 illustrate how to frame a ﬁgure with a thick border.
42 4 COUNTERS, LABELS, AND REFERENCES
\begin{figure}[ht]
\begin{center}
\setlength{\fboxrule}{3pt} % make border lines thick
\setlength{\fboxsep}{.2in} % increase distance to border
\fbox{ This is a framed figure. }
\end{center}
\caption{Framed Figure with Caption at Bottom \label{fig:fboxbottom}}
\end{figure}
Figure 33: Framed Figure 34 Source
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 called a local setting.) Thus, the frame in Figure 35
has thin lines and no extra padding around the border. Also note how the caption
is put at the top (see exercise 3).
Figure 35: Framed Figure with Caption at Top
This is framed with default parameter values.
4.4 Deﬁning Your Own
In the preamble you can deﬁne your own counter with the \newcounter command:
\newcounter{name}[within]
where name is the (unique) name of the counter (cannot be the same as one of
the intrinsic counter names). The initial value of the counter is 0. For example,
\newcounter{mycounter} deﬁnes a counter whose name is mycounter. You can
also deﬁne the counter to be within another counter. For example,
\newcounter{mycounter}[section]
deﬁnes mycounter to be within the section counter. This will cause the value of
mycounter to be reset to 0 when entering a new section. Further, instead of the
printed values being 1, 2, . . . , they will be 1.1, 1.2, . . . within section 1; more
generally, the values of mycounter will be of the form :.1, :.2, . . . when printed
within section :.
The counter values are printed in Arabic numerals, but you can specify the type
of numeral, shown in Table 7.
4.4 Deﬁning Your Own 43
Table 7: Numerals to Print Counters
What you see What you write
a, b, c, d, . . . \alph{mycounter}
A, B, C, D, . . . \Alph{mycounter}
1, 2, 3, 4, . . . \arabic{mycounter}
i, ii, iii, iv, . . . \roman{mycounter}
I, II, III, IV, . . . \Roman{mycounter}
Counter values can be incremented with the \addtocounter command. For
example, \addtocounter{mycounter}{1} adds 1 to the value of mycounter. If we
just want to increment the counter by 1, we can specify \stepcounter{mycounter}.
Counter values can be set to some absolute value with the \setcounter command.
For example, \setcounter{mycounter}{5} sets the value of mycounter to 5. This
can also be used to transfer the value of one counter to another. For example,
\setcounter{mycounter}{\value{page}}
sets the value of mycounter to the current page number (value of the intrinsic
counter, page).
When using a counter for some nonintrinsic sequence, we want to be able to
label it for future reference. This is done with the \refstepcounter command,
which also increments its value. For example, to increment mycounter by 1 and
establish a label to its value at the place this is done, write
\refstepcounter{mycounter} \label{mylabel}
Then, we can use \ref{mylabel} and \pageref{mylabel} wherever we like.
The default numeral type is arabic, but you can change the appearance to be
any of those listed in Table 7 by applying the \renewcommand to \thecounter. For
example,
\setcounter{mycounter}{0}
\renewcommand{\themycounter}{\roman{mycounter}}
\stepcounter{mycounter} (\themycounter),
\stepcounter{mycounter} (\themycounter), \dots
⇒ (i), (ii), . . .
This can be used for intrinsic counters too. For example, consider the enumerate
list environment, where the types of numerals for the four levels are: arabic, alph,
roman and Alph. We can change these to be any type we want, such as illustrated
in Figures 36 and 37.
The second level, whose counter is enumii, had its label changed to what is
speciﬁed in the source: \renewcommand{\labelenumii}{\theenumii.} (the “ap
pearance” parameter is \labelenumii). These changes remain in eﬀect (called a
global setting), so we must change them back if we want to restore the defaults,
shown in Table 8.
44 4 COUNTERS, LABELS, AND REFERENCES
\renewcommand{\theenumi}{\Roman{enumi}}
\renewcommand{\theenumii}{\Alph{enumii}} % changes numeral type
\renewcommand{\labelenumii}{\theenumii.} % changes appearance
\begin{enumerate}
\item Introduction
\item Terms and Concepts
\begin{enumerate}
\item Groups and fields
\item Picnics and frolic
\end{enumerate}
\end{enumerate}
Figure 36: Alternative enumerate Symbols Source (Result in Figure 37)
I. Introduction
II. Terms and Concepts
A. Groups and ﬁelds
B. Picnics and frolic
Figure 37: Alternative enumerate Symbols Result (Source in Figure 36)
Table 8: Default Settings for enumerate Counters
What
Counter changes Command
enumi numeral \renewcommand{\theenumi}{\arabic{enumi}}
label \renewcommand{\labelenumi}{(\theenumi)}
enumii numeral \renewcommand{\theenumii}{\alph{enumii}}
label \renewcommand{\labelenumii}{(\theenumii)}
enumiii numeral \renewcommand{\theenumiii}{\roman{enumiii}}
label \renewcommand{\labelenumiii}{(\theenumiii)}
enumiv numeral \renewcommand{\theenumiv}{\Alph{enumiv}}
label \renewcommand{\labelenumiv}{(\theenumiv)}
Exercises. Submit a printed copy of the L
A
T
E
X source (tex ﬁle) and printed copy
of the associated postscript result (ps ﬁle). Be sure your name is on each.
1. Write a document with at least two pages and two sections. Put an enumer
ated list of items near the beginning of your document, and use the \ref or
\pageref command to reference each of the following.
(a) Reference §2 by a label that you assign to section 2 (make whatever
45
label name you like).
(b) Somewhere near the end of your document reference the page number
of the ﬁrst section.
(c) Reference item #2 of your enumerated list.
2. Include two tables and ﬁgures in your document, and reference them by label.
Also reference the page that they appear.
3. Produce Figure 35.
4. Produce lists using the enumerate environment with the following appear
ance:
1. . . .
1.1 . . .
1.2 . . .
2. . . .
2.1 . . .
2.2 . . .
5. Produce two numbered lists such that the second starts its numbering where
the ﬁrst leaves oﬀ. For example, produce the following:
1. List 1, item 1
2. List 1, item 2
Now we are out of list 1 . . . begin list 2.
3. List 2, item 1
4. List 2, item 2
5 Math Mode
One can write mathematical expressions by entering math mode, signiﬁed by de
limiters $. . . $ or \[. . . \]. The $ delimiter keeps the mathematical expression in
the text, like this:
A consequence of Einstein’s postulates is that $E = mc^2$.
⇒ A consequence of Einstein’s postulates is that 1 = :c
2
.
The other form is math display mode, like this:
A consequence of Einstein’s postulates is that \[E = mc^2.\]
⇒ A consequence of Einstein’s postulates is that
1 = :c
2
.
46 5 MATH MODE
Table 9: Some Mathematical Operations
Example
Operation Symbol How it appears What you write
subscript _ r
3
x_3
superscript ^ r
3
x^3
multiply \times o / a\times b
divide \div o ÷/ a\div b
5.1 Mathematical Symbols
The example also illustrates the use of the superscript operator, ^. Table 9 shows
other common operations in math mode. (Each of the tables in this section applies
only to math mode.)
The braces enclose an expression that can be used to deﬁne a more com
plex operand. For example, r
a+b
is written as $x_{a+b}$ and r
a
2
is written as
$x^{a^2}$. The order of subscripts and superscripts does not matter:
x_{a+b}^{c+d} ⇒ r
c+d
a+b
x^{c+d}_{a+b} ⇒ r
c+d
a+b
Table 10 shows some set notation. The complement of ¹ often appears as ∼ ¹,
produced by $\sim A$, but this is not universal notation; some authors use ¹
c
or
¹
, produced by $A^c$ and $A^\prime$, respectively, and some use ¹, produced
by $\overline{A}$.
Preceding any symbol by \not puts the line through the symbol, as in the
following examples:
A\not\subseteq B ⇒ ¹ ⊆ 1
x\not\in A\cup B ⇒ r ∈ ¹∪ 1
A\setminus B\not\supset B ⇒ ¹` 1 ⊃ 1
Table 10: Set Notation
What it is How it appears What you write
empty set ∅ \emptyset
intersection ∩ \cap
union ∪ \cup
set minus ` \setminus
element in ∈ \in
subset (proper) ⊂ \subset
subset or equal ⊆ \subseteq
superset (proper) ⊃ \supset
superset or equal ⊇ \supseteq
5.1 Mathematical Symbols 47
You can control the size of the font by using the usual speciﬁcation before enter
ing math mode. For example, {\Large $(x\div y) + z$} ⇒(x÷y)+z. Font
style, however, does not apply to math mode because math mode has its own, sep
arate from text mode. You can make math fonts boldface by specifying \boldmath
before entering math mode. For example, {\boldmath $x^n+y^n=z^n$} ⇒ x
n
+
y
n
= z
n
. Note that \boldmath is surrounded by the braces; otherwise, math fonts
would remain bold, even when leaving and reentering. The following illustrates
this, where 1 ∪ C is boldface in the ﬁrst case, and returns to normal style in the
second case.
\boldmath$A\supset B$ text $B\cup C$ ⇒ A ⊃ B text B ∪ C
{\boldmath$A\supset B$} text $B\cup C$ ⇒ A ⊃ B text 1 ∪ C
Within math mode, we can control the font style of letters with the command,
\mathfont{expression}, where font is one of: {bf, cal, it, normal, rm, sf,
tt} (analogous to the `textfont command, p. 8). Unlike \boldmath, this applies
only to letters, digits and accents, but not to special mathematical symbols. For
example,
{\boldmath$\tilde A\times\vec{1}\otimes\overline{2}$} ⇒
˜
A×
1 ⊗2
$\mathbf{\tilde A\times\vec{1}\otimes\overline{2} }$ ⇒
˜
A
˜
1 ⊗2
Table 11 illustrates the outcome of each font for this expression:
\mathfont{\tilde A\times\vec{1}\otimes\overline{2}}
Table 11: The `mathfont Commands
Font Style Command Example Result
boldface \mathbf
˜
A
˜
1 ⊗2
calligraphic \mathcal
˜
/ ∞⊗∈
italic \mathit
˜
A
˜
1 ⊗2
normal \mathnormal
˜
¹1 ⊗:
roman \mathrm
˜
A
˜
1 ⊗2
sans serif \mathsf
˜
A
˜
1 ⊗2
typewriter \mathtt
~
A
~
1 ⊗2
The calligraphic style applies only to capital letters, causing unintended results
when applied to other symbols, as shown in Table 11. The calligraphic alphabet
looks like this (and it is available only in math mode):
/B(TcT(H1./L´^O{O1oT 1¼A\Z.
Write ${\cal P} = A + B$ to produce { = ¹ + 1; without the braces, the calli
graphic fonts remain in eﬀect: $\cal P = A + B$ ⇒ { = /+B.
Greek letters are deﬁned only in math mode, and they are speciﬁed by spelling
them as keywords. For example, to produce
α −β = ∆−δ
48 5 MATH MODE
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 included — see Appendix Table 36.) The \mathbf does not make
Greek letters boldface. We could use \boldmath to achieve this, but there is a
package that not only provides the boldface font, but also produces proper spacing.
In the preamble specify \usepackage{bm}, then \bm{\beta} ⇒β.
5.2 Fractions and Variable Size Functionality
To make fractions, we could write $(x+y)/4$ to make (r + n)´4, but if we want
x+y
4
, we use the \frac command: $\frac{x+y}{4}$. We can make this appear
larger, as
x+y
4
, by preceding the math mode with \large.
The general form is \frac{numerator}{denominator}, where the numerator
and denominator can be any expression. Here is a more complex equation in math
display mode:
¹ =
r
2
+ n
α
1 +
η
x
2
+1
.
written as \[ A = \frac{x^2+y_\alpha}{1+\frac{\eta}{x^2+1}}, \]. Note how
the sizes of the fractions adjust automatically.
Some mathematical symbols adjust their size to ﬁt the expression. Table 12
shows some of the most common of these, and I present more examples below. In
the case of the integrals, note the use of \, between the integrand and dr. This
inserts a thin space (compare the results by writing the expression with and without
the \,).
In L
A
T
E
X, symbols whose size you would want to adapt to expressions are gen
erally designed to do so. Figures 38 and 39 illustrate this with another example,
which uses the \sqrt and \prod functions:
\[ \sqrt{\frac{\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 Source (Result in Figure 39)
¸
N
n=1
¸
i∈I
n
r
n
i
3
¸
i∈I
∞
r
i
Figure 39: Variable Sizes Result (Source in Figure 38)
Notice that even though it is written in math display mode, the indices on the
sums and product appear as they would in line. L
A
T
E
X compilers make judgments
about the layout, but you can force either of the two styles with the \displaystyle
and \textstyle commands. Figures 40 and 41 illustrate this.
5.2 Fractions and Variable Size Functionality 49
Table 12: Variable Size Mathematical Operation Symbols
Operation How it appears What you write
sum
¸
\sum
n
¸
i=1
r
i
\sum_{i=1}^n x_i
integral
\int
b
a
1(r) dr \int_a^b f(x)\,dx
parentheses () \left( \right)
r
1 + n
\left(\frac{x}{1+y} \right)
braces ¦¦ \left\{ \right\}
¸
i
r
i
¸
\left\{\sum_i x_i \right\}
brackets [] \left[ \right]
¸
∞
0
1(r) dr
\left[\int_0^\infty f(x)\,dx\right]
\[ \sqrt{\frac{\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 Source (Result in Figure 41)
In text mode you can force the display style of placing these subscripts and
superscripts on functions, as well as sizing the expression, as though it were in
display mode. Figure 42 gives more examples to compare in line text and display
mode, using \textstyle and \displaystyle to override the default form for the
mode. The “default” is not always predictable; in particular, math display mode
does not always use displaystyle.
50 5 MATH MODE
N
¸
n=1
¸
i∈I
n
r
n
i
3
¸
i∈I
∞
r
i
Figure 41: \displaystyle Result (Source in Figure 40)
What to write What to write
Appearance in text mode in display mode
x
2
\frac{x}{2} \textstyle\frac{x}{2}
r
2
\displaystyle\frac{x}{2} \frac{x}{2}
max
x∈X
\max_{x\in X} \textstyle\max_{x\in X}
max
x∈X
\displaystyle\max_{x\in X} \max_{x\in X}
Figure 42: Examples to Compare Text and Display Modes
Table 13 shows symbols used in logical expressions. For example, to have
(r ∈ ¹ ⇒r ∈ 1) ⇔(¹ ⊆ 1).
write \[ (x\in A\Rightarrow x\in B) \Leftrightarrow (A\subseteq B). \]
To have
∀r∃n ÷ [1(r) ∧ Q(n)].
write \[ \forall x\exists y\ni [P(x)\wedge Q(y)]. \]
The quantiﬁers in this last example seem a bit crowded, so we might want
to add some spacing between terms. In math mode a full space is obtained by
specifying \; and a half space by \,. Here is how each looks:
\forall x \exists y ⇒ ∀r∃n
\forall x\, \exists y ⇒ ∀r∃n
\forall x\; \exists y ⇒ ∀r ∃n
(There are other spacing commands, including negative spacing, shown in Appendix
Table 35.)
Table 14 shows some relations for ordered sets (besides those on the keyboard:
< = >). Here are some examples:
(\infty,0] = \{x\ni x \le 0\} ⇒ (−∞. 0] = ¦r ÷ r ≤ 0¦
a_j\prec b_i \equiv b_i \succ a_j ⇒ o
j
≺ /
i
≡ /
i
~ o
j
\forall y\,\{x: x\not\prec y\}
\not\subset {\cal A} ⇒ ∀n ¦r : r ≺ n¦ ⊂ /
5.3 Arrays and Equations 51
Table 13: Some Symbols in Logic
Logical Term How it appears What you write
existential quantiﬁer ∃ \exists
universal quantiﬁer ∀ \forall
negation \neg
disjunction ∨ \vee
conjunction ∧ \wedge
implication → \rightarrow
⇒ \Rightarrow
equivalence ⇔ \Leftrightarrow
≡ \equiv
such that ÷ \ni
Table 14: Order Relations
Relation How it appears What you write
less than or equal ≤ \le
greater than or equal ≥ \ge
not equal = \ne
precedes ≺ \prec
precedes or equals _ \preceq
succeeds ~ \succ
succeeds or equals _ \succeq
We have seen how to embed math mode into text, but we can also do the reverse
with the \mbox command. Compare each of the following:
r
i
< 01o:oi = 1. . . . written as $x_i < 0 for all i=1,\dots$
r
i
< 0 for all i = 1. . . . written as $x_i < 0$ for all $i=1,\dots$
r
i
< 0 for all i = 1. . . . 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 italic (not quite the same as the italic in text mode). The
use of \mbox is particularly convenient in math display mode, which I shall illustrate
in the next section.
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:
52 5 MATH MODE
\begin{array}{column specs}options
ﬁrst row spec \\
.
.
.
last row spec [\\ options]
\end{array}
The column speciﬁcations 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 can be generated in either of two ways: with the tabular environment,
using the math mode designation for each body entry: $. . . $, or with the array
environment, using \mbox for each header entry.
Variable Current Value Limit
r 1.234567 1
n −9.87 −12.2
This can be generated by either of the following two ways:
\[\begin{array}{ccc}
\mbox{Variable} & \mbox{Current Value} & \mbox{Limit} \\ \hline
x & 1.234567 & 1 \\
y & 9.87 & 12.2 \\ \hline
\end{array}
\]
or
\begin{center}
\begin{tabular}{ccc}
Variable & Current Value & Limit \\ \hline
$x$ & $ 1.234567$ & $ 1 $ \\
$y$ & $9.87 $ & $12.2 $ \\ \hline
\end{tabular}
\end{center}
You can align a series of equations to appear this way:
r = 5.2
n = 2.5
. = 7.7 (= r + n)
The above was produced by the following use of math display mode (which is always
centered):
\[ \begin{array}{lcl}
x &=& 5.2 \\
y &=& 2.5 \\
z &=& 7.7 \; (= x+y)
\end{array}
\]
The \; speciﬁes a space; otherwise, 7.7 (= x+y) ⇒ 7.7(= r + n).
5.3 Arrays and Equations 53
Another environment is eqnarray. This is like a 3column array with speciﬁca
tions {lcl}, as above, but each row is numbered:
r = n (1)
n = . (2)
(Another diﬀerence is that the eqnarray environment uses displaystyle.) We use
the eqnarray environment directly (without entering math display mode), so the
above is produced by the following:
\begin{eqnarray}
x &=& y \label{eqn:xy} \\
y &=& z \label{eqn:yz}
\end{eqnarray}
The \label statements are to illustrate that we can reference these by writing
(\ref{eqn:xy}) to produce (1) and (\ref{eqn:yz}) to produce (2). (Note that
\ref gives just the number; parentheses are added.)
The relation need not literally be an equation; anything could be used for the
middle column. Further, there are times when we need to use more than one line
for an ‘equation,’ in which case we need to suppress the numbering of all but one
of the rows. Figures 43 and 44 give an example. The \nonumber command causes
no number to be assigned to the ﬁrst part of the second equation.
\begin{eqnarray}
x &\mbox{is equal to}& y \\
y & \preceq & \frac{a+b+c+d}{\Psi} + \frac{e+f+g+h}{\Phi}
+ \nonumber \\
& & I+K+J+L
\end{eqnarray}
Figure 43: eqnarray Environment Source (Result in Figure 44)
r is equal to n (3)
n _
o + / + c + d
Ψ
+
c + 1 + o + /
Φ
+
1 + 1 + J + 1 (4)
Figure 44: eqnarray Environment Result (Source in Figure 43)
There is also an eqnarray* environment, which is the same as eqnarray, but
without the equation numbers. There is no apparent advantage to this since the
same result can be produced by the ordinary array environment, specialized to this
column speciﬁcation. It does, however, let us change our mind easily as to whether
or not to include equation numbers by simply adding or removing the * from the
environment speciﬁcation.
54 5 MATH MODE
For a single, numbered equation, there is the equation environment. This poses
no particular advantage over specifying eqnarray and merely entering one row
(except that column separators (&) are not used in the equation environment).
Analogous to eqnarray*, there is the equation* environment, which suppresses the
equation numbering. To illustrate, Figures 45 and 46 show how to present a matrix
equation. Also, note how r
is speciﬁed. Table 15 shows other ways to denote the
transpose of a vector.
Table 15: Transpose of a Vector
What you write How it appears
x’ ⇒ r
x^t ⇒ r
t
x^T ⇒ r
T
x^{\mathsf{T}} ⇒ r
T
x^{\mbox{\tiny $T$}} ⇒ r
T
\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}{cc} x_1 \\ x_2 \\ x_3
\end{array} \right).
\end{equation*}
Figure 45: Matrix Equation Source (Result in Figure 46)
¹r
=
¸
1.1 1.2 1.3
21.0 22.0 −2.1
¸
r
1
r
2
r
3
.
Figure 46: Matrix Equation Result (Source in Figure 45)
Array environments can be nested, as illustrated in Figures 47 and 48. Notice
how the vertical line was drawn by the column speciﬁcation, {cc}, and the hori
zontal line separating the blocks is obtained by specifying \hline before the second
row of the outer array.
5.3 Arrays and Equations 55
\[ \left[ \begin{array}{cc}
\begin{array}{ccc} A_{11} & A_{12} & A_{13} \\
A_{21} & A_{22} & A_{23}
\end{array}
& 0 \\ \hline
0 & \begin{array}{cc} B_{11} & B_{12} \\ B_{21} & B_{22}
\end{array}
\end{array} \right]
\]
Figure 47: Nested Arrays Source (Result in Figure 48)
¹
11
¹
12
¹
13
¹
21
¹
22
¹
23
0
0
1
11
1
12
1
21
1
22
¸
¸
¸
¸
Figure 48: Nested Arrays Result (Source in Figure 47)
We can enclose mathematical expressions in a box, sometimes used for empha
sis. For example,
\fbox{$ \begin{array}{lcl}
\displaystyle\int_0^\infty xe^{\tau x}\,dx
&=& \displaystyle\frac{1}{\tau} \\ \\
&=& \displaystyle\oint_a^{b+c} \Psi(x)\,dx
\end{array}
$}
⇒
∞
0
rc
−τx
dr =
1
τ
=
b+c
a
Ψ(r) dr
We can use \fbox within math mode, such as writing $x = \fbox{y} + z$ to
produce r = y +.. Note how the line height does not adjust to the frame, causing
an undesirable clash. This could be overcome by putting a vertical space command
just after the expression. In particular, putting \vspace{.2\baselineskip} after
r = y +. causes extra vertical space equal to 20% of the value of \baselineskip,
which 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 spacing,
because the former takes into account the font size, which you might change.)
56 5 MATH MODE
Now consider the following conditional assignment:
1(r) =
−1 if r < 0;
0 if r = 0;
1 if r 0.
produced by the following L
A
T
E
X code:
\[ 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 because \left and \right
must balance — i.e., there must be an equal number of each. It is not necessary
that the left symbol be related to the right one — i.e., \left\{ does not require
\right\} to balance; any right symbol will do. The period is not printed in this
case, used speciﬁcally for this purpose of balance.
We have seen the use of \left and \right for brackets around a matrix. Now
the use of the \left L
A
T
E
X command for conditional assignment raises related uses
of the underbrace and overbrace. Figures 49 and 50 illustrate these, along with
\overline, \underline, \widehat and \widetilde.
\[ \begin{array}{cc}
\mbox{This sum has} \\ \mbox{an overbrace} \\
\overbrace{\overline{i\dots j} + \underline{k\cdots l}}
& \underbrace{\widehat{xy}  \widetilde{ab}}
\\ & \mbox{This difference}
\\ & \mbox{has an underbrace}
\end{array} \]
Figure 49: Horizontal Braces Source (Result in Figure 50)
This sum has
an overbrace
. .. .
i . . . , + /  ´ rn −
¯
o/
. .. .
This diﬀerence
has an underbrace
Figure 50: Horizontal Braces Result (Source in Figure 49)
We often need to mix mathematical notation and text. We could use the
tabular environment and specify inline math mode where needed (with $), or we
5.3 Arrays and Equations 57
could use the array environment and use either the \mbox or \parbox (see p. 18)
to enter the text. There are, however, some nuances 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 spacing gives a
poor appearance.) The problem is that \flushleft skips a line, which ruins the
alignment (even though [t] is speciﬁed). The solution is to use the \raggedright
command, as shown in ﬁgures 53 and 54. In addition, the \raisebox command is
used to lower the small matrix, giving it some space below the horizontal line.
\renewcommand{\arraystretch}{1.2}
\begin{center} \begin{small} \begin{tabular}{lll}
Matrix & Definition & Example \\ \hline
\parbox[t]{.9in}{Covariance}
& \parbox[t]{2in}{\flushleft
$A_{ij} = E[(X_i\mu_i)(X_j\mu_j)]$, where $\{X_i\}$
are random variables, and $E[\cdot]$ is the expected
value operator with $\mu_i=E(X_i)$. }
& \parbox[t]{1.4in}{\scriptsize
$\left[\begin{array}{rrrrr}
\frac{1}{2}&0 \\ 0&\frac{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~ \vspace{.05in} \\
\half &\mbox{for}& x=~~0~ \vspace{.05in}\\
\fourth &\mbox{for}& x=~~1.
\end{array}\right.$ } \vspace{.1in} \\ \hline
\end{tabular} \end{small} \end{flushleft}
\renewcommand{\arraystretch}{1}
Figure 51: \flushleft in parbox Source (Result in Figure 52)
Matrix Deﬁnition Example
Covariance
¹
ij
= 1[(A
i
−j
i
)(A
j
−j
j
)],
where ¦A
i
¦ are random
variables, and 1[] is the
expected value operator with
j
i
= 1(A
i
).
1
2
0
0
1
2
for X
2
= X
2
1
and
Pr[X
1
= x]
=
1
4
for x = −1
1
2
for x = 0
1
4
for x = 1.
Figure 52: \flushleft in parbox Result (Source in Figure 51)
58 5 MATH MODE
\begin{center} \begin{small} \begin{tabular}{lll}
Matrix & Definition & Example \\ \hline
\parbox[t]{.9in}{Covariance}
& \parbox[t]{2in}{\raggedright
$A_{ij} = E[(X_i\mu_i)(X_j\mu_j)]$, where $\{X_i\}$
are random variables, and $E[\cdot]$ is the expected
value operator with $\mu_i=E(X_i)$. }
& \parbox[t]{1.4in}{\scriptsize\raisebox{.1in}{
$\left[\begin{array}{rrrrr}
\frac{1}{2}&0 \\ 0&\frac{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~ \vspace{.05in} \\
\half &\mbox{for}& x=~~0~ \vspace{.05in}\\
\fourth &\mbox{for}& x=~~1.
\end{array}\right.$ } \vspace{.1in} \\ \hline
\end{tabular} \end{small} \end{center}
Figure 53: \raggedright in parbox Source (Result in Figure 54)
Matrix Deﬁnition Example
Covariance ¹
ij
= 1[(A
i
−j
i
)(A
j
−j
j
)],
where ¦A
i
¦ are random
variables, and 1[] is the
expected value operator with
j
i
= 1(A
i
).
1
2
0
0
1
2
for X
2
= X
2
1
and
Pr[X
1
= x]
=
1
4
for x = −1
1
2
for x = 0
1
4
for x = 1.
Figure 54: \raggedright in parbox Result (Source in Figure 53)
5.4 Special Functions and Alphabets
Math mode recognizes a collection of special functions. Table 16 shows some com
mon ones. These special functions are used to make the source clearer, rather than
using \mbox to achieve the same result.
Among the special functions are the complete set of trigonometric functions.
For example, we write $\tan\theta = \frac{\sin\theta}{\cos\theta}$ to pro
duce: tan θ =
sin θ
cos θ
. Appendix Table 40 (p. 115) has a much longer list of special
functions, as well as the arrows used in some of the examples shown in Table 17.
There is also a package of AMS symbols, which you declare in your preamble
with \usepackage{amssymb}. This gives the following alphabet with the mathbb
font:
$\mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$
⇒ ABCDEFGHIJKLMNOPQRSTUVWXYZ
5.4 Special Functions and Alphabets 59
Table 16: Some Common Mathematical Functions
Function How it appears What you write
limit lim \lim
lim inf liminf \liminf
log log \log
maximum max \max
tangent tan \tan
Table 17: Examples of Mathematical Functions
How it appears
textstyle displaystyle What you write
lim
n→∞
r
n
lim
n→∞
r
n
\lim_{n\rightarrow\infty}x_n
liminf
n↓0
log r
n
liminf
n↓0
log r
n
\liminf_{n\downarrow 0}\log\,x_n
max
x∈X
1(r) max
x∈X
1(r) \max_{x\in X}f(x)
tan(θ+π)
ln x
tan(θ + π)
ln r
\frac{\tan(\theta + \pi)}{\ln\,x}
For example, the real line is sometimes denoted by R, rather than 1, which is
the L
A
T
E
X special symbol, $\Re$. Table 18 shows how \mathbb can be used for
specifying other numerical spaces.
Table 18: Notation Using mathbb Fonts from amssymb Package
What you write
†
How it appears What it means
\mathbb{R} ⇒ R Real values
\mathbb{C} ⇒ C Complex values
\mathbb{Z} ⇒ Z Integer values
\mathbb{Q} ⇒ Q Rational values
†
In math mode.
Another alphabet is \mathscr, for which you specify \usepackage{mathrsfs}
in the preamble. This gives the following alphabet:
$\mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$
⇒ABCDE FGH IJK LMN OPQRST U V W XY Z
In particular, L is often used to denote the Laplace transform or the Lagrangian,
60 5 MATH MODE
and H is sometimes used to denote the Hamiltonian. (Compare with \mathcal,
H, which is also used by some authors.)
5.5 Derivatives and Integrals
We can express a total derivative, d1(r)´dr, by writing $df(x)/dx$; or, we can use
the \frac command to produce
df(x)
dx
. The partial derivative symbol, ∂, is written
\partial, so you can write \partial f(x)/\partial x to produce ∂1(r)´∂r, and
{\large$\frac{\partial f(x)}{\partial x}$} to produce
∂f(x)
∂x
.
The usual notation for the gradient of a function is the nabla, denoted by
the symbol ∇, (also called “del”), which is an upside down delta (introduced by
Hamilton in 1853). In L
A
T
E
X it is produced by \nabla, and its mathematical
deﬁnition is the vector of ﬁrst partial derivatives:
∇1(r) = (∂1(r)´∂r
1
. . . . . ∂1(r)´∂r
n
). (5)
I leave it as an exercise to show the L
A
T
E
X code that produced equation (5).
The Hessian is the matrix of second partial derivatives:
∇
2
1(r) =
¸
∂
2
1(r)
∂r
i
∂r
j
.
This was produced by the following code:
\[ \begin{array}{lll}
\nabla^2f(x) &=& \left[ \displaystyle \frac{\partial^2f(x)}
{\partial x_i \partial x_j}
\right].
\end{array}
\]
There seems to be some crowding in this direct speciﬁcation. Compare with the
following and see if you can produce it:
∇
2
1(r) =
¸
∂
2
1(r)
∂r
i
∂r
j
. (6)
There are two integral signs: \int⇒
and \oint⇒
, which are both variable
size symbols. For example, note how the outer integral is large in the following
expression:
b
a
lim
λ→∞
X(v)
rc
λf(x)
dr
X(v)
c
λf(x)
dr
Φ(·) d·.
This was obtained by the following code:
\[ \int_a^b \lim_{\lambda\rightarrow\infty} \left
\frac{\oint_{X(v)} xe^{\lambda f(x)}\,dx}
{\oint_{X(v)} e^{\lambda f(x)}\,dx}\right
\,\Phi(v)\,dv .
\]
5.6 Theorems and Deﬁnitions 61
(Note the use of the thin space, \,.)
Deﬁnite multiple integrals are no problem. To have
∞
0
x
n
0
x
n−1
0
x
2
0
H(r
1
. . . . . r
n
) dr
1
dr
n
write
\[ \int_0^\infty \int_0^{x_n} \int_0^{x_{n1}} \cdots
\int_0^{x_2} H(x_1,\dots,x_n)\,dx_1\cdots dx_n
\]
However, consider the following:
S
(n∇· −·∇n) do =
τ
(n∇ ∇· −·∇ ∇n) dτ.
The domains of integration, and the spacing of the integral signs, are better with
the following, which is not produced by standard L
A
T
E
X2
ε
, but by specifying
\usepackage{amsmath} in the preamble (see The L
A
T
E
X Companion [5, p. 223]):
S
(n∇· −·∇n) do =
τ
(n∇ ∇· −·∇ ∇n) dτ.
Note how the domains are centered on the multiple integrals and the spacing of the
integral signs.
5.6 Theorems and Deﬁnitions
The foundations of mathematics are axioms and rules of inference. The rules
create theorems, which are statements whose truths are established relative to the
underlying logic. This is so fundamental that L
A
T
E
X has the facility to deﬁne a
special environment that includes a keyword, like “Theorem,” and a name, which
is not only the name of the environment, but is also the name of the associated
counter. Consider the following example:
Theorem 5.1 For n 2, there is no solution to r
n
+ n
n
= .
n
for
r. n. . ∈ Z
++
.
Notice how “Theorem 5.1” appears, all text is in italic, and we have the
counter value: \thetheorem=5.1. This was deﬁned in the preamble by:
\newtheorem{theorem}{Theorem}[section]
Then, the theorem was produced by the following L
A
T
E
X code:
\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}
62 5 MATH MODE
Other theoremlike environments can be deﬁned 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 counter. Here is the syntax:
\newtheorem{name}{keyword}[within]
The name deﬁnes the environment name, and it deﬁnes a counter, so it must be
diﬀerent from all other environment and counter names. The within option deﬁnes
the counter to be within some other, which can be intrinsic or some other counter
deﬁned by the \newcounter command (p. 42) or by some other \newtheorem.
In this document, I deﬁned the theorem environment to be numbered within the
section, so you see Theorem 5.1, rather than Theorem 1. To further illustrate,
here is a corollary environment:
Corollary 5.1.1 The sum of cubes cannot be a cube.
It was deﬁned in the preamble as follows:
\newtheorem{corollary}{Corollary}[theorem]
Note that this is within the theorem counter, which is valid by having been deﬁned
by its own \newtheorem. Then, the above corollary was written as:
\begin{corollary} The sum of cubes cannot be a cube.
\end{corollary}
The following creates an axiom environment that is not within any other counter.
\newtheorem{axiom}{Axiom}
The “Axiom of Choice” can then be stated thusly:
Axiom 1 From any (inﬁnite) family of sets a new set can be created that contains
exactly one element from each set in the family.
This was created by the following code:
\begin{axiom} \label{axm:choice}
From any (infinite) family of sets a new set can be created
that contains exactly one element from each set in the family.
\end{axiom}
The label allows us to refer to the Axiom of Choice as ‘Axiom 1 on page 62’ by
writing Axiom~\ref{axm:choice} on page~\pageref{axm:choice}.
The environment created by \newtheorem puts the text in italics, but this is
generally not desirable for a deﬁnition. Consider the following example:
Deﬁnition 5.1 The circumference of a sphere is the circumference of any great
circle on the sphere.
This was created by ﬁrst entering (in the preamble):
5.7 Reﬁnements 63
\newtheorem{defn}{Definition}[section]
Then, in the text:
\begin{defn} The circumference of a sphere is the
circumference of any great circle on the sphere.
\end{defn}
Compare this with the following:
Deﬁnition 5.1 The circumference of a sphere is the circumference of any great
circle on the sphere.
This was created by ﬁrst entering (in the preamble):
{\theorembodyfont{\rmfamily} \newtheorem{mydefn}{Definition}[section]}
Then, in the text:
\begin{mydefn} The \textit{circumference of a sphere} is the
circumference of any great circle on the sphere.
\end{mydefn}
For more customization, the theorem package enables a wide range of varia
tions over the font style (among other things).
5.7 Reﬁnements
Mathematical delimiters, like parentheses and braces, must be varied to en
close some expressions. Whereas \left and \right commands adjust the
size of a mathematical delimiter to ﬁt the enclosed expression, we can also
enlarge these delimiters ourselves. One way is with a size command — for
example,
{\large(}$E=mc^2${\large)} ⇒ (1 = :c
2
).
There are, however, delimiter size control commands, which apply to a single
character: \big, \Big, \bigg, and \Bigg. For example,
$\big(E=mc^2\big)$ ⇒
1 = :c
2
.
The use of text font environments comes close to the corresponding math
size, (large↔big, . . . , Huge↔Bigg), but they are diﬀerent, especially the
thicknesses. This is more evident with the square and angular brackets:
$\Big[E=mc^2\Big]$ ⇒
1 = :c
2
.
{\Large[}$E=mc^2${\Large]} ⇒[1 = :c
2
].
$\bigg\langleE=mc^2\bigg\rangle$ ⇒
1 = :c
2
.
64 5 MATH MODE
{\LARGE$\langle$}$E=mc^2${\LARGE$\rangle$} ⇒'1 = :c
2
`.
The remaining reﬁnements use the amsmath package (introduced on p. 61
for obtaining better multiple integrals).
The gather and gather* environments allow the new line speciﬁcation,
\\, in math mode. They behave like the eqnarray and eqnarray* environ
ments, respectively, except 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 \\
{\cal L} \oplus M^\varepsilon  V = H_0 \\
A(x) = \{y: \phi(y) = \cup_{a\in \cal A} \Psi(x)\}
\end{gather*}
Figure 55: gather* Environment Source (Result in Figure 56)
(o + /)
2
= o
2
+ 2o/ + /
2
L ⊕`
ε
−\ = H
0
¹(r) = ¦n : φ(n) = ∪
a∈A
Ψ(r)¦
Figure 56: gather* Environment Result (Source in Figure 55)
When writing a matrix within text, we could produce
o /
c d
by spec
ifying $\left(\begin{array}{cc} a&b \\ c&d \end{array}\right)$. An al
ternative is with the amsmath smallmatrix environment:
a b
c d
is obtained
by $\left(\begin{smallmatrix} a&b \\ c&d \end{smallmatrix}\right)$.
(Note that there are no column speciﬁcations.) This is not equivalent to
preceding the array speciﬁcation with a text size environment; in particular,
\scriptsize produces
a b
c d
. While the letters inside the matrix are ap
proximately the smallmatrix size, the spacing and parentheses are not the
same.
The amsmath package has a command to put dots across any number
of columns in an array. Its syntax is \hdotsfor[spacing]{n}, where spacing
determines the spacing between the dots, and n is the number of columns it
spans. For example,
5.7 Reﬁnements 65
\left\begin{array}{ccccc}
1 & 2 & 3 & 4 & 5 \\
\hdotsfor{3} \\
& \hdotsfor{3} \\
\hdotsfor[2]{5} \\
\hdotsfor[.5]{5} \\
\end{array}\right
1 2 3 4 5
. . . . . . . .
. . . . . . . .
. . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
The \stackrel command lets us put characters over a relation: For
example, n^+\stackrel{\mathrm{def}{=}n+1 ⇒ n
+
def
= n + 1. With more
generality, the \overset and \underset amsmath commands enable us to
put any characters over or under any character. For example,
$\overset{a}{X}$ ⇒
a
A
$\underset{b}{Y}$ ⇒ Y
b
$\overset{a}{\underset{b}{Z}}$ ⇒
a
7
b
This can be used to stack subscripts:
$\displaystyle{\sum_{ \stackrel{ \mbox{\scriptsize$i\in I$} }
{j\in J}
} } A_{ij}
= \underset{j\in J}
{ \underset{i\in I}{\sum} } A_{ij} $
⇒
¸
i ∈ I
j∈J
¹
ij
=
¸
i∈I
j∈J
¹
ij
Nesting the \underset command can be unwieldy, but you can use the
smallmatrix environment or the \substack command:
$\displaystyle\sum_{\substack{i\in I\\j\in J\\k\in K}} A_{ij}
= \underset{\begin{smallmatrix} i\in I\\j\in J\\k\in K
\end{smallmatrix}} {\sum} A_{ij}$
⇒
¸
i∈I
j∈J
k∈K
¹
ij
=
¸
i∈I
j∈J
k∈K
¹
ij
Another package in the ams family is amscd, which makes it easy to
draw commutative diagrams. Figures 57 and 58 illustrate this. (Specify
\usepackage{amscd} in the preamble.) The horizontal arrows are speciﬁed
by @>>> (left to right) with any expression placed above or below. The
66 5 MATH MODE
vertical arrows are speciﬁed by @VVV (down) or @AAA (up), with an expression
placed to its left or right. All possible horizontal and vertical placements 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 Source (Result in Figure 58)
¹
a
−−−−→ 1 −−−−→ C
α
β γ
¸
δ
1 −−−−→
d
1
e
−−−−→ 1
Figure 58: Commutative Diagram Result (Source in Figure 57)
There are many more reﬁnements, and more packages to make things
nicer. Many of these are described in The L
A
T
E
X Companion [5, Chapter 8],
and you can see an online catalog of packages at CTAN [4].
5.8 Grammar
When writing mathematical expressions, people make some common errors.
The general guide is to treat a mathematical expression linguistically. In
English this means that every sentence has a subject and predicate, clauses
are separated by commas, and phrases are appropriately punctuated. Here
are some of the most common elements of grammar to consider.
1. Punctuate math display mode. The expression usually needs a
comma or period. For example, note the colon before the display and
the comma at its end, which is incorrect to omit.
A symmetric rearrangement of a matrix has the following form:
1 = 1
t
`1.
where 1 is a permutation matrix.
2. Deﬁne before use. As you read articles notice that those that are
among the most confusing are when the authors used a term that is
not deﬁned until pages later. For example, we might see “The distin
guishing property of an abelian group is the commutivity . . . ” But a
group had not yet been deﬁned.
5.8 Grammar 67
3. Reference object is located after the reference. For example, a
ﬁgure appears after its ﬁrst reference. L
A
T
E
X does this automatically,
but you might want to take control over locating ﬁgures.
4. An object has only one deﬁnition. For example, if we write Φ =
on + /·, we cannot later refer to Φ(n. ·). Sometimes we deﬁne the
complete object, Φ(n. ·) = on + /·, then tell the reader something
like, “We shall use Φ
k
, instead of Φ(n
k
. ·
k
), when there is no risk of
confusion.” The overriding principle is clarity, and it is important that
the reader be told of this.
5. If . . . then . . . is not correct. Suppose ¹ and C are expressions. We
can write either ‘If ¹, C.’ or ‘Suppose ¹. Then, C.’ The ﬁrst form
is preferred if ¹ and C are simple expressions. If either ¹ or C are
compound, the second form is clearer. The form, ‘If ¹, then C.’ seems
like it ought to be all right, and the comma is used to clarify where
the antecedent (¹) ends and the consequent (C) begins. In English,
however, this is not correct.
6. Equivalence needs commas. The expression, ‘¹ if and only if 1.’
should be written as ‘¹ if, and only if, 1.’
Exercises. Submit a printed copy of the L
A
T
E
X source (tex ﬁle) and of the
associated postscript result (ps ﬁle). Be sure your name is on each. (Lookup
special symbols in the Appendix.)
1. Produce each of the following in math display mode.
(a) r
2
= 1
2
−4¹C implies r = ±
√
1
2
−4¹C.
(b) If ∆1
n+1
= 1
n
, it follows that ∆
2
1
n+1
= ∆1
n
.
(c) r
+
=
r if r ≥ 0;
0 otherwise.
2. Produce the following in math display mode with the array environ
ment and/or with the eqnarray* environment.
∆
2
1
n
= 1
n+2
−21
n+1
+ 1
n
= 21
n
−1
n+1
.
3. Produce each of the following formulas in line with text (construct your
own sentences that contain them, and include proper punctuation).
(a) ln c
x
= r
(b) sin¦θ + 2π¦ = sin θ
68 5 MATH MODE
(c) n
n
=
¸
n−1
i=i
0
r
i
⇒n
n+1
−n
n
= r
n
−r
i
0
(d) 1(r) =
∞
¸
n=0
1
(n)
(0)
r
n
n!
(e)
∂
∂r
x
2
a
1(n)dn = 2r1(r
2
)
(f) ´
Fe(H
2
O)
6
= 6´
H
2
O
+´
Fe
4. Produce the following equation in math display mode.
¸
1.1 −1.2 −1.3
−2.1 2.2 2.3
+
¸
o
1
o
2
o
3
/
1
/
2
/
3
=
¸
α −β γ
−δ λ θ
.
5. Produce the expression in the Preface.
6. Produce equations (5) and (6).
7. Produce each of the following expressions:
(a) r = n mod n
def
= r −n = /n for some / = 0. 1. . . .
(b)
. .. .
α
1
+
β
2
− x
2
+y
3
. .. .
8. Produce each of the following in line with text (that you compose) and
in math display mode.
(a) /
?
= ¦o ∈ o : o ∈ o¦
(b)
[T {[ ≤ π
(c)
¸
¸
¸
o
11
o
12
o
21
o
22
(B
1C
9. Produce each of the following formulas in math display mode (with
punctuation):
(a) c
∗
(G) ≥ max
∆(G).
2:(G
A
)
√
¹−1
if G = ∅.
(b) (0. r
T
)T = (0. r
T
)
¹ 1
0 C
=
0
r
T
C
= (0. C
T
r)
T
,
(c) \ =
3
√
3
2
a
0
(−r
1
3
+ o)
2
dr;
5.8 Grammar 69
10. Combine your knowledge of derivatives, conditional assignment (with
array environment), and mathematical symbols to produce the follow
ing (called the truncated gradient):
∇
+
1(r)
j
=
max¦0. ∂1(r)´∂r
j
¦ if r
j
= o
j
∂1(r)´∂r
j
if o
j
< r
j
< /
j
min¦0. ∂1(r)´∂r
j
¦ if r
j
= /
j
11. Produce the following symbols:
(a) Extended reals: R
∞
.
(b) Strictly positive integers: Z
++
.
(c) Complex nvectors: C
n
.
(d) Nonnegative rational nvectors: Q
n
+
.
12. Produce the following:
∂f(x)
∂x
j
x=¯ x
.
13. Produce the following:
Deﬁnition 1 A matrix is singular if its determinate is zero.
Deﬁnition 2 A matrix is nonsingular if it is not singular.
Theorem 1 Every nonsquare matrix has an inverse.
Proof: The determinate of a nonsquare matrix cannot be zero
because it is not deﬁned. Therefore, the matrix is nonsingular.
This implies it has an inverse.
14. What is grammatically wrong with each of the following segments.
(a) A key is how to add velocities the formula is
(n + ·)
1 +
n·
c
2
where c is the velocity of light.
(b) A result of these assumptions is the following equation
1 = :c
2
Einstein ﬁrst noticed this equivalence between energy (1) and
mass (:).
70 5 MATH MODE
(c) Let r be an nvector and ω a scalar, and deﬁne
n = ¹r −ω/.
where ¹ is an : n matrix and / is an :vector. Now suppose
n(ω) is speciﬁed and we want to ﬁnd r.
(d) Now we consider adding velocities.
v
u+v
u
Figure 1. Adding velocity vectors: n + ·.
Figure 1 (above) shows how to add velocities simply as vectors.
(e) Theorem If r. n. . ∈ Z
+
and r
n
+ n
n
= .
n
, then n < 3.
The remaining exercises are more diﬃcult. You are to produce the mathe
matical expressions shown in math display mode.
15. The following is tricky to get the evaluation expression, t =
1
2
to be
the right size and location.
d
dt
1(r + t∇
+
1(r))
t =
1
2
= −
2·
(1´2)
1/4
+ 1.
16. Note the row and column labels outside the matrix.
¹ =
o / c d c
1
2
3
4
1 0 0 0 1
1 1 0 1 0
0 1 1 0 0
0 0 1 1 1
¸
¸
¸
¸
17. Row pointers:
¹ =
¸
11 12
21 22
←rows in 1
←rows in 2 (this arrow is closer to matrix)
18. Column pointers:
¹ =
¸
11 12
21 22
↑ ↑
columns columns
in 1 in 2
71
19. Row and column pointers:
¹ =
¸
11 12
21 22
←rows in 1
←rows in 2
↑ ↑
columns columns
in 1 in 2
6 Graphics
Graphics may be part of a L
A
T
E
X document by one of three ways:
1. Use standard L
A
T
E
X2
ε
commands, notably the picture environment;
2. Use a graphics package to draw within the document;
3. Use a package to import some standard graphics ﬁle.
I illustrate each, but I do not provide a complete list of the relevant packages
(see CTAN [4] and The L
A
T
E
X Companion [5]).
6.1 Picture Environment
If all we want is a series of boxes and arrows, we can do this simply with
\fbox and a long arrow in math mode, as follows:
\fbox{left}$\longrightarrow$\fbox{center}$\longrightarrow$\fbox{right}
⇒ left −→ center −→ right
The \framebox command can be used instead of \fbox to produce the
same result. However, \framebox also has two optional arguments to control
the length of the box and the position of the text within it. For example,
\framebox[2cm][l]{left}$\longrightarrow$\framebox[2cm][c]{center}$%
$\longrightarrow$\framebox[2cm][r]{right}
⇒ left −→ center −→ right
The % at the end of the ﬁrst line is to avoid having a blank between the
center box and the $\longrightarrow$ that follows it. The ﬁrst optional
argument of this \framebox command is the width of the box, given as 2 cm
for each box. The second optional argument is the position of the inscribed
text: l = left, c = center, and r = right.
We can make the contents of a box obey all paragraph controls in text
mode by the \parbox command. By itself, it lets us stack short phrases,
72 6 GRAPHICS
like
top
middle
bottom
(note how the paragraph spacing adjusts). Combined with
\framebox, we can create vertical diagrams easily, as illustrated in Figures
59 and 60.
\begin{center} \parbox{2cm}{
\framebox[2cm]{top} \\ \centerline{$\downarrow$} \\
\framebox[2cm]{middle} \\ \centerline{$\downarrow$} \\
\framebox[2cm]{bottom}
} \end{center}
Figure 59: Vertical Diagram Source (Result in Figure 60)
top
↓
middle
↓
bottom
Figure 60: Vertical Diagram Result (Source in Figure 59)
The box created by \parbox has its center aligned with the text, but it
has an optional argument to align its top or bottom with the text. This is
done by specifying \parbox[t]{width}{text} or \parbox[b]{width}{text},
respectively.
These commands can be combined, along with other box commands, but
there is a need for more versatility, like ovals and diagonal arrows, and more
control over positioning. A basis for this is the picture environment. To
begin, Figure 61 shows a more elaborate chart, which was created by the
picture environment, whose source is shown in Figure 62. Going through its
parts will serve to explain the various commands.
,
top left
center
bottom right
`
1
o
/
c
oval

?
Z
Z
Z
Z~
 
Figure 61: Variety of Objects in Picture Environment
The ﬁrst command begins a center environment, and I use the \setlength
command to set the units of measurement to be 1 inch. This means that when
6.1 Picture Environment 73
\begin{center} \setlength{\unitlength}{1in}
\begin{picture}(0,0)
\put( 0, 0){\circle*{.1}}
\put( 0,.5){\framebox(.7,.3){center} }
\put(1,.5){\dashbox{.01}(.7,.3)[tl]{top left} }
\put( 1,.5){\dashbox{.1}(1.2,.3)[br]{bottom right} }
\put(.65, 1){\circle{.2}} \put(.7,1.05){1}
\put( 1, 1){\oval(.5,.25)} \put(.85,1.05){oval}
\put(0,1){\fbox{$\begin{array}{c}a\\b\\c\end{array}$}}
\put(.3,.35){\vector(1,0){.3}}
\put(.65,.5){\vector(0,1){.4}}
\put( .35,.5){\vector(4,3){.5}}
\put(.55,1){\vector(1,0){.55}}
\put( 0,1){\vector(1,0){.55}}
\put(.32,1){\vector(1,0){.43}}
\put(1.2,.895){\line(1,1){.3975}}
\end{picture}
\end{center} \vspace{1in}
Figure 62: Source for Figure 61
I specify some length = 5, I am specifying 5 inches. The parameter that de
termines this is \unitlength, and the default for the picture environment is
1 pt. Then, we enter the picture environment stating that the point of entry
is the origin, indicated by the coordinates (0,0). (There is an alternative way
to begin the picture environment, which is not described here.) The ﬁlled
circle shows where (0,0) is in this picture.
Every picture command begins with \put, which is exclusively for the
picture environment. The complete syntax is: \put(r,n){stuﬀ }, where stuﬀ
can be text or some picture object. The (r. n) coordinates are relative to
where the position is when the picture environment is entered. This could
be at the left margin, as in beginning a paragraph with \noindent; it could
be a column in a table deﬁned within the tabular environment; or
it
could be in the middle of a sentence, just as the smiley face appears here
(see Exercise 1).
The ﬁrst \put in Figure 62 speciﬁes the position at the origin, and the
stuﬀ is a ﬁlled circle with diameter .1 inches (centered at the origin):
\put(0,0){\circle*{.1}} ⇒ ,
The next three commands put three diﬀerent kinds of boxes, each be
ginning at .5 inches below the origin (i.e., n = −.5). The ﬁrst is similar
to \framebox in text mode, but its syntax is diﬀerent. In picture mode it
enables control over not only the width, but also the height, and this ex
tends the position options to a second character: t = top; b = bottom. The
74 6 GRAPHICS
general form of the \framebox command in the picture environment is as
follows:
\framebox(width,height)[posn]{text}
In the example shown in Figure 62, the speciﬁcations are width = .7 inches
and height = .3 inches; the position is centered because 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 inches. The next dashed
box has the dash length set equal to .1 inches, resulting in fewer dashes to
compose the box. The box length is set to 1.2 inches, and the text is at the
bottom right because of the optional speciﬁcation, [br].
Now we come to the \circle speciﬁcation, located at coordinates (−.65. −1)
(from \put), with diameter = .2 inches. The “1” inside the circle required an
other \put, and some trial and error was needed to establish its position. We
know the center of the circle is at (−.65. −1), but that is not where we want
to put the inscribed text to be centered. Unlike the box family, we cannot
include the centering of text within the circle command. The same applies
to the \oval speciﬁcation, followed by putting text that required some trial
and error to locate. The oval, itself, has dimensions .5 .25 (inches), where
.5 measures the entire width:
width

height
6
?
After the \oval speciﬁcation, I use the \fbox command. This is the
same as I used in text mode, except here I use it to frame an array, deﬁned
as usual in math mode: the array has three rows and one column, which is
centered.
Now the code begins to draw the vectors, which are lines with arrow
heads. Both \vector and \line have the same syntax:
\line(∆r,∆n){len} \vector(∆r,∆n){len}
If ∆r = 0, the line is vertical, and len is the amount of change above or below
the original point (it does not matter what the magnitude of ∆n is; only its
sign matters). If ∆n = 0, the line is horizontal, and len is the amount of
change to the right or left of the original point (it does not matter what the
magnitude of ∆r is; only its sign matters). Otherwise, if ∆r = 0, the actual
change in r is still cn, and the slope of the line is
∆n
∆r
. This is undoubtedly
confusing, so consider Figure 63. The new point is determined by moving
6.1 Picture Environment 75
from (r
0
. n
0
) along the line with slope
∆n
∆r
until the new rcoordinate is
r
0
+ cn. Then, the new ncoordinate is n
0
+ cn
∆n
∆r
. The actual length of
the line segment is cn
1 +
∆n
∆r
2
.
slope =
∆n
∆r
r
0
n
0
r
0
+ ∆r
n
0
+ ∆n
r
0
+ cn
n
0
+ cn
∆n
∆r
Original
point
New
point
Figure 63: Line Parameters
As if this unnatural deﬁnition of the line segment were not enough, there
is an important restriction: ∆r. ∆n must be integervalued and within −6
to 6. Suppose our original point is (r
0
. n
0
), and we want our destination
point to be (r
t
. n
t
). If r
t
= r
0
, the calculation is simple: set ∆r = 0,
cn = [n
t
−n
0
[, and
∆n =
1 if n
t
n
0
;
−1 otherwise.
If r
t
= r
0
, we could have problems with approximating the results. Suppose,
for example, we want (r
t
. n
t
) = (r
0
+ 1.3. n
0
+ 1.5). If we we set cn = 1.3
to obtain the correct rcoordinate, how should we set the slope parameters?
Ideally, we would set
∆r
∆n
=
13
15
, but the restrictions do not permit this. The
closest we could come is
4
5
.
Fixing cn = r
t
− r
0
, then searching for a nearest slope approximation,
is not necessarily the best overall approximation. We could setup a least
squares estimation problem, but trial and error in selecting the parameters
tends to be just as eﬃcient. Either way, we have some work to do.
The ﬁrst \vector command in Figure 62 starts at (−.65. −1), which I
calculated to be from the “top left” box to the “center” box.
76 6 GRAPHICS
width
c
box begins here →

height
6
?
In Figure 61 the “top left” box starts at (−1. .5), and its width is .7, so
the right edge of that box is at r = −.3. Starting at n = −.35, the vertical
position changes by moving up half of the height, so the coordinate where
the arrow begins (called its tail ) is (−.3. −.5 +
1
2
.3) = (−.3. −.35). That
accounts for the initial position given by \put(.3,.35). The arrow is
to be horizontal, drawn left to right, so ∆r = 1 and ∆n = 0, as speciﬁed
with \vector(1,0). Finally, we need to determine the length, speciﬁed as
{.3}. We want the coordinate of the end of the arrow (called the head) to
be ﬂush to the left side of the “center” box. That box begins at (0. −.5),
so ∆r = 0 − (−.3) = .3. It required these computations to determine the
complete picture command: \put(.3,.35){\vector(1,0){.3}}.
Now consider the next \vector, which is a vertical arrow from the same
box to the circle below it. The initial position is calculated simply as the
midpoint of the bottom edge of the box: (r. n) = (r
0
+
1
2
/. n
0
), where the
box starts at (r
0
. n
0
) and / = /cio/t. In this case, (r
0
. n
0
) = (−1.. −.5) and
/ = .3, so we obtain the coordinates of the arrow’s tail: (r
t
. n
t
) = (−1 +
1
2
.3. −.5) = (−.65. −5), as speciﬁed. Since the arrow is downward, ∆r = 0
and ∆n < 0, given by \vector(0,1). The length is determined by where
we want the arrowhead: at the top of the circle. The circles n coordinate is
−.65, which is its center. We must add the radius, which is
1
2
(.2) since .2 is
the diameter speciﬁed by \circle{.2}. Thus, the position of the arrowhead
is (r
h
. n
h
) = (r
t
. n
c
− n
t
+ :) = (−.65. −1 − (−.5) + .1) = (−.65. −.4), and
we set cn = [∆n[ = .4, which is what is speciﬁed:
top left
`
1
?
⇐ `vector(0,1){.4}
The next arrow is doubleheaded, so we use two \vector commands to
draw one arrow left to right, then an arrow at the same end points, but drawn
right to left. Further, this involves more calculations because the arrow is
not simply horizontal or vertical. We begin the same way, by computing the
coordinates of the tail and head. The left end point is at the ncoordinate of
the center of the circle, and its rcoordinate is to the right by the length of
the radius: (r
1
. n
1
) = (r
c
+ :. n
c
) = (−.65 + .1. −1) = (−.55. −1), 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 uncertainty is the width
of the box; we know only that the center of the box was put at (0. −1), but we
6.2 PSTricks 77
do not know the width of the box. With just a few iterations, the end point
was determined to be r = 0, so cn = ∆r = .55. The reverse arrow begins at
(0. −1), and its slope is (−1. 0), which is why we have \vector(1,0){.55}.
The last vector also required trial and error, due to not having the corner
of the oval coordinates. In this case, the end points were determined to be
from (1.2. −.895) to (1.6. −.5). The former was found by trial and error, but
the latter was computed by knowing that the “bottom right” box starts at
(1. −.5) and has a width of 1.2, so the midpoint of the bottom edge is at
(1.6. −.5). Now the true slope of the line we want is
.395
.4
, but the restrictions
do not allow this. The closest slope we can have is with (∆r. ∆n) = (1. 1),
which is what is speciﬁed. Given this slope, the best choice of cn can be
found as the average of the deviations:
cn =
1
2
(.4 + .395) = .3975.
Thus, we specify \line(1,1){.3975} to obtain the line shown in Figure 61.
There are packages to extend the picture environment, and we can plot
curves, called Bezier approximations, to a set of points. However, I shall
cover these in the next section with a powerful package called PSTricks.
Table 46 (in the Appendix, p. 117) gives the commands in the picture
environment, but here are some things to note:
• Only boxes can have inscribed text; the circles and ovals require sepa
rate \put commands, which can take some trial and error to position.
• Some calculations and some trial and error are needed to align objects
and lines.
• Moving a portion of the picture can be tedious, requiring recalculations
and more eﬀort for the new positions.
• There is no direct way to control the size or style of the arrow heads,
and there is very limited control over line thicknesses.
These can make using the picture environment time consuming and rather
unpleasant. There is a better way!
6.2 PSTricks
PSTricks [15] was written by Timothy Van Zandt, and is provided free of
charge. (It is not standard with MiKTeX, but you can obtain it at CTAN [4].)
In the preamble specify \usepackage{pstall} for the entire system. (You
can use parts, in which case you specify the parts you use instead of pstall
— see [15] for loading individual portions.)
78 6 GRAPHICS
One thing you need to know is that not all of the pst results can be seen
with a dvi viewer. Some require converting to postscript and viewing the ps
ﬁle. This is especially true of commands that involve rotations.
PSTricks (pst, for short) is designed to overcome diﬃculties with using
the picture environment, some of which were listed above. Here are some of
the features of PSTricks that I shall illustrate.
• Circles and ovals, in addition to boxes, can have inscribed text.
• Lines and arrows have the same command, identifying any of a great
variety of arrowheads simply.
• Only one command is needed to put lines through a sequence of points,
and slopes need not be calculated.
• Objects can be named (as nodes) and lines and arrows can be drawn
between them by naming the tail and head, thereby eliminating the
need for calculation or trial and error.
• Arrow heads are adjustable.
• Shapes are highly variable.
• Drawing curves is simple, including plots of points that can come from
a data ﬁle, and Bezier approximations of four points are available.
Another widely distributed picturedrawing system is MetaPost [6, 7],
written by John D. Hobby, also provided free of charge. It is more diﬃcult to
learn than PSTricks, but MetaPost is more openended in its design, which
makes it potentially more versatile, especially on varying the types of ﬁle
outputs (PSTricks is tied to postscript). In particular, pdflatex (not covered
here; see [4]) does not work with PSTricks, but it does with MetaPost.
There are many packages [4], typically available free of charge, that do
many of the things done by PSTricks (and some additional things). Many
of these are described in The L
A
T
E
X Companion [5].
All of the pst commands have options to override default settings for
relevant parameters. The defaults, themselves, can be set with the \psset
command: \psset{parameter = value[,. . . ]}. For example, the default unit
of measurement is 1 cm, and the default ﬁll color is white, but we can change
them by specifying:
\psset{unit=1in,fillcolor=gray}
A fundamental command in pst is \rput, but unlike the \put command
in the picture environment, this is not the only way to put objects. The
commands, themselves, can specify where to put them. Table 19 gives
6.2 PSTricks 79
some of the common commands to draw objects and lines. For those ex
amples, the unit of measurement was set to 1 mm. For each command,
we can specify relevant options as [parameter = value]. For example, to
produce a solid circle with radius .1 cm, centered at the origin, we write
\pscircle[fillstyle=solid](0,0){.1} (having already set fillcolor=gray).
The origin is determined by where you are when issuing a pst command;
no environment is entered. Thus, I can put that circle right here: All
commands use the linewidth parameter to control the thickness of the lines
used in the drawing, and objects that could be made solid, like boxes and
circles, use the fillstyle parameter. I shall illustrate the commands in
Table 19 ﬁrst, showing the ease and versatility of PSTricks, then I shall show
some additional shapes and commands. This is meant to be an introduction,
so many features are not presented here. The User’s Guide [15] is freely
available and clearly written.
Table 19: Some Basic Drawing Commands in PSTricks
psframe(r
0
. n
0
)(r
1
. n
1
) Draws rectangle with a corner at
\psframe(0,1)(10,2)
(r
0
. n
0
) and opposite corner at (r
1
. n
1
).
pscircle(r. n){:} Draws circle centered at (r. n) with
\pscircle(5,0){2}
radius = :.
psellipse(r. n)(:
x
. :
y
) Draws ellipse centered at (r. n) with
\psellipse(3,0)(5,2)
horizontal radius = :
x
and
vertical radius = :
y
psline{o}(r
0
. n
0
) . . . (r
n
. n
n
) Draws line or arrow, determined by o:
\psline{}(0,0)(10,0)
 no arrow; > forward arrow;
\psline{<>}
<> double arrow’ < backward arrow;
(0,0)(5,2)(1,0)
(there are more!), along path given by
\psline{*}
coordinates.
(0,0)(10,2)
pspolygon(r
0
. n
0
) . . . (r
n
. n
n
) Draws closed polygon with given
\pspolygon(0,0)
coordinates; same as \psline{}. . . ,
(0,3)(6,3)
except ﬁgure is closed by drawing
line from (r
n
. n
n
) to (r
0
. n
0
).
In using these commands, we do want the \rput command in order to put
text into various objects. The idea of a box is to have some shape enclose text.
PSTricks extends the rectangle in \framebox by having a variety of shapes,
shown in Table 20. A parameter used by these commands is the distance
80 6 GRAPHICS
between the border and the text inside, called framesep=len, where the
default value of len is 3 pt. (As usual, other parameters include linewidth,
linestyle, linecolor, and fillcolor.) The pst ﬁgures are drawn after
specifying \psset{unit=1mm,fillcolor=white}.
Table 20: Boxes in PSTricks
psframebox{stuﬀ} Draws rectangle but could have rounded corners
framebox \psframebox{framebox}
framebox \psframebox[framearc=.4]{framebox}
psshadowbox{stuﬀ} Adds shadow to psframebox
shadow added \psshadowbox{shadow added}
psdblframebox{stuﬀ} Draws double frame
double frame \psdblframebox{double frame}
pscirclebox{stuﬀ} Draws circle around stuﬀ
circle \pscirclebox[linewidth=2pt]{circle}
psovalbox{stuﬀ} Draws oval around stuﬀ
oval \psovalbox[linestyle=dotted]{oval}
These commands can be used in the text. For example, we obtain
this oval by writing: . . . we obtain \psovalbox{this oval}. . .
Boxes need not be enclosed (like \makebox), and they can be scaled by
specifying one of the following:
\scalebox{size}{stuﬀ} scales stuﬀ keeping the same aspect ratio
\scalebox{width,height}{stuﬀ} scales the width and height individually
Here are some examples:
6.2 PSTricks 81
Halving
the
circle
\scalebox{.5}{\pscirclebox{
\begin{tabular}{c}
Halving \\ the \\ circle
\end{tabular} } }
Doubling
\scalebox{2}{\psframebox{
\textsl{Doubling} }}
Tall \scalebox{1 3}{Tall}
Wide \scalebox{3 1}{Wide}
There are times when we want to rotate stuﬀ. Here is how:
Left
Down Right
\rotateleft{Left}\rotatedown{Down}
\rotateright{Right}
One application is given by the following:
Who is the founder of T
E
X? Who is the founder of \TeX?
Answer: Donald E. Knuth
\rotatedown{Answer: Donald E. Knuth}
So far I have described a variety of shapes, by themselves and as enclo
sures for boxes. These can be connected by \psline, with a great variety
of styles, including variations of arrowhead shape. To avoid the tedious cal
culations in locating the coordinates of the tail and head, the objects being
joined can be referenced by name. In PSTricks, the named objects are called
nodes. Consider the following example:
Node A
Node B Node C
The source code is shown in Figure 64. After entering the centering envi
ronment and setting the default units of measurement, the \rput command
puts a node, with the \rnode command. 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 commands put nodes named B and C, each enclosed with a
frame. The \ncline command has the same arrow options as \psline, but
with the following syntax:
\ncline{o}{name of node A}{name of node B}
82 6 GRAPHICS
The ﬁrst \ncline 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 touch Node A text, which 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, which is what we
want when the nodes are enclosed boxes, like B and C. In general, node
separation can be speciﬁed for either end point, or for both end points, by
specifying nodesepA=n, nodesepB=n, or nodesep=n, respectively. (nodesepA
and nodesepB are keywords and have nothing to do with the names we assign
to our nodes.)
\begin{center}
\psset{unit=1cm}
\rput( 0, 0){\rnode{A}{Node A}}
\rput(2,1){\rnode{B}{\psframebox{Node B}}}
\rput( 2,1){\rnode{C}{\psovalbox{Node C}}}
\ncline[nodesepA=3pt]{A}{B}
\ncline[nodesepA=5pt]{<}{A}{C}
\ncline{<>}{B}{C}
\end{center} \vspace{.5in}
Figure 64: PSTricks Source for Connecting Nodes
Figure 66 shows a graph that could represent any number of things. Its
source, using PSTricks, is shown in ﬁgure 65. (Try adding one line at a time
and observe each eﬀect.)
\begin{center} \psset{unit=1cm}
% Nodes
\cnodeput(2, 0){1}{1} \cnodeput(0, 0){2}{2}
\cnodeput( 2, 1){3}{3} \cnodeput[doubleline=true]( 2,1){4}{4}
\pnode(3, 0){1tail} \ncline{>}{1tail}{1} % tailess arc into (1)
% Arcs (with labels)
\ncline{>}{1}{2} \aput{:U}{1/2} % \aput puts label above arc
\ncline{>}{2}{3} \aput{:U}{2/3}
\ncline{>}{2}{4} \bput{:U}{2/4} % \bput puts label below arc
\ncarc{>}{3}{4} \Aput{\small 3$\rightarrow$4} % \Aput keeps
\ncarc{>}{4}{3} \Aput{\small 4$\rightarrow$3} % label horizontal
\ncloop[angleB=180,loopsize=.5,arm=.2,linearc=.2]{>}{3}{3}
\Bput[5pt]{loop} % \Bput keeps label horizontal and 5pt is
% the space added between label and arc
\ncloop[angleA=180,loopsize=.5,arm=.2,linearc=.2]{<}{4}{4}
\Bput[5pt]{loop}
\end{center} \vspace{1cm}
Figure 65: Graph Source (Result in Figure 66)
6.2 PSTricks 83
1 2
3
4
1/2 2/3 2/4 3→4 4→3 loop loop
Figure 66: Graph Result (Source in Figure 65)
Now I describe curves that go through, perhaps approximately, given
points. The examples that follow use the following pst settings:
\psset{unit=.5cm,showpoints=true}
(The showpoints=true setting is what causes the points to be included in
the picture you see.)
We begin with the parabola, whose command syntax is:
\parabola{o}(r
0
. n
0
)(r
1
. n
1
),
where (r
0
. n
0
) is one point on the parabola, and (r
1
. n
1
) is the (unique) point
having dn´dr = 0. \parabola* speciﬁes ﬁlling the parabola. For example,
\psgrid[subgriddiv=1,griddots=10,gridlabels=7pt](1,0)(4,4)
\parabola{<>}(4,3)(2,0)
\parabola*[fillcolor=black,showpoints=false](1,1)(2,3)
⇒
Question: What is the pst command to draw the parabola given by
n = or
2
+ /r + c, where o = 0?
Answer: `parabola(0. c)(−
b
2a
. −
b
2
4a
+ c)
The following shows two commands: pscurve and psccurve, the latter
being a closed curve that joins the last point with the ﬁrst.
\pscurve{(>}(0,0)(1,1)(1,1)(1,1)(1,1)
\psccurve(0,0)(1,1)(1,1)(1,1)(1,1)
84 6 GRAPHICS
The Bezier curve joins two end points and comes as close as possible to
two intermediate points. The command syntax is:
\psbezier[parameters]{o}(r
0
. n
0
)(r
1
. n
1
)(r
2
. n
2
)(r
3
. n
3
)
\psbezier(0,0)(1,3)(2,1)(3,4)
We can read data from a ﬁle, perhaps produced by mathematical soft
ware like gnuplot
c
, Octave
c
, Maple
c
, Mathematica
c
, MATLAB
c
, and
SPLUS
c
. The data ﬁle just needs pairs of coordinates, which can be sepa
rated by a comma or just blank and can have parenthesis, braces, or nothing
around each pair. The following histogram was plotted by the source code in
Figure 67, which I shall explain. The data ﬁle had n = number of students
with test score = r+50. (The oﬀset of 50 was used in establishing the origin
in the plot.)
50 60 70 80 90 100
0
5
10
15
score
F
D
C
B
A
\psset{unit=2mm, showpoints=false}
\fileplot[plotstyle=dots]{mydata.dat}
\psaxes[Ox=50,Oy=0,Dx=10,Dy=5,dx=10,dy=5,ticks=y]{<>}(60,17)
\rput[r](60,2){\large score}
\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: Source Code for Drawing Histogram of Test Scores
After setting the units of measurement to 2 mm, the data ﬁle is read and
its points plotted with the \fileplot command. (Setting showpoints=false
6.2 PSTricks 85
suppresses plotting the points in the \psline commands.) The data ﬁle is
plain text and has the following entries:
% This is mydata.dat
5 2 9 4 % F = [0,65)
15 2 18 1 % D = [65,70)
22 6 27 4 % C = [70,80)
30 2 31 1 35 4 39 1 % B = [80,90)
40 2 45 2 50 1 % A = [90,100]
The plot, itself, is just the points, speciﬁed by plotstyle=dots. There
are other plot styles, such 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 command:
\psaxes[params]{o}(r
0
. n
0
)(r
1
. n
1
)(r
2
. n
2
)
where (r
0
. n
0
) is the origin, (r
1
. n
1
) is the Southeast corner, and (r
2
. n
2
)
is the Northwest corner. As in \psline, if (r
0
. n
0
) is absent, the origin is
assumed to be at (0. 0). If (r
1
. n
1
) is absent, it is assumed to be equal to the
origin. Here are some examples:
\psaxes[unit=.5cm]{>}(4,0)(8,3) ⇒
0 1 2 3
0
1
2
\psaxes[unit=.5cm]{>}(0,0)(1.1,0)(2.1,2.1) ⇒
0 1 2 −1
1
2
Note that ticks are uniformly spaced on each axes. This is suppressed for
the raxis in Figure 67 by specifying the option, ticks=y. The other pa
rameter settings are described in Table 21. (The default values, dx=dy=0,
cause the spacing to be equal (approximately) by using Dx÷\psxunit and
Dy÷\psyunit, respectively.)
86 6 GRAPHICS
Table 21: Parameters for \psaxes
Horizontal Vertical Default Meaning
Ox=n Oy=n 0 Label at origin
Dx=n Dy=n 1 Label increment
dx=n dy=n 0 Label spacing
The next command, rput[r](60,2){\large score} puts “score” in
large font, ﬂush right (indicated by [r]) at the coordinates (60. −2). Thus,
when I superimpose the commands \fileplot, \psaxes and \rput, we ob
tain the data plot. The remaining commands draw the histogram boxes and
put the letter grade above each box in sans serif font. Leaving oﬀ the “score,”
Figure 68 shows the sequence of how each \psline and \rput adds to the
picture. To ﬁt the picture and the code next to it, this is scaled (simply, by
specifying \psset{unit=1mm}):
We shall stop here, but this does not exhaust the PSTricks commands.
See [15] for lots more, including many examples.
6.3 Importing pictures
The way to import a picture into L
A
T
E
X is to convert it to encapsulated
postscript (eps). An exceptionally clear description of this, including his
torical context, is given by Keith Reckdahl [12]. (He also goes deeper
into customizing placements of pictures in ﬁgures.) Many systems that
let us draw ﬁgures, and those that plot mathematical functions or data,
have an option to export an eps ﬁle. (If you can get a ps ﬁle, you could
use \psfig, or there is a unix conversion utility, \ps2epsi.) On unix,
xfig is an excellent system to draw ﬁgures, and the export options in
clude the eps ﬁle format. A basic plotting system for functions and data,
for both unix and DOS that produces eps ﬁles, is gnuplot. This is avail
able free of charge at FTP://ftp.dartmouth.edu/pub/gnuplot/. Octave ex
tends the capabilities of gnuplot and is also available free of charge, at
http://www.che.wisc.edu/octave/. There are also commercial systems, like
Maple
c
, Mathematica
c
, MATLAB
c
, and SPLUS
c
, which can produce
eps ﬁles of plots.
Another way to obtain an eps ﬁle is with conversion. The unix systems
xv and Image Magick can do this for a large variety of graphic ﬁle formats,
including bitmap (xbm), gif and jpeg ﬁles. There are free conversion systems
on MS Windows, notably jpeg2ps, which converts jpeg ﬁles to eps, and
emftoeps, which converts Windows Metaﬁles (wmf) to eps.
Once the ﬁle is in eps format, we can import it using the Graphics Bun
dle [3], written by David P. Carlisle, provided free of charge. It comes with
MiKTeX and basic unix installations. There are two packages that provide
6.3 Importing pictures 87
essentially the same capabilities but with diﬀerent syntax. One is called
graphics, the other is graphicx. Here I use graphicx, as speciﬁed in the
preamble by \usepackage{graphicx}.
\fileplot[plotstyle=dots]{mydata.dat}
50 60 70 80 90 100
0
5
10
15
\psaxes[Ox=50,Oy=0,Dx=10,Dy=5,
dx=10,dy=5,ticks=y]{<>}(60,17)
50 60 70 80 90 100
0
5
10
15
F
\psline(1,0)(1,6)(10,6)(10,0)
\rput(5,8){\textsf{F}}
50 60 70 80 90 100
0
5
10
15
50 60 70 80 90 100
0
5
10
15
F
D
\psline(11,0)(11,2)(19,2)(19,0)
\rput(14,4){\textsf{D}}
50 60 70 80 90 100
0
5
10
15
50 60 70 80 90 100
0
5
10
15
F
D
C
\psline(20,0)(20,11)(29,11)(29,0)
\rput(25,13){\textsf{C}}
50 60 70 80 90 100
0
5
10
15
50 60 70 80 90 100
0
5
10
15
F
D
C
B
\psline(30,0)(30,8)(39,8)(39,0)
\rput(35,10){\textsf{B}}
50 60 70 80 90 100
0
5
10
15
50 60 70 80 90 100
0
5
10
15
F
D
C
B
A
\psline(40,0)(40,5)(50,5)(50,0)
\rput(45,7){\textsf{A}}
Figure 68: Sequence of PSTricks Commands to Draw Histogram
To include an eps ﬁle, simply specify \includegraphcs[options]{ﬁlename}.
For example, Figure 69 shows a ﬁgure that was imported with the following
statement:
88 6 GRAPHICS
\begin{center}\includegraphics[scale=.5]{sin.eps}\end{center}
−8 −6 −4 −2 0 2 4 6 8
−1
−0.8
−0.6
−0.4
−0.2
0
0.2
0.4
0.6
0.8
1
Figure 69: Applying \includegraphics to Import an eps File
In this case I speciﬁed the option, scale=.5, which prints the ﬁgure
half the size it was produced (in this case by MATLAB, by specifying
print sin deps after plotting the sin function over the indicated grid).
Figure 70 shows the same eps ﬁle, but with the width and height set as
follows:
\begin{center} \includegraphics[width=2in,height=1in]{sin.eps}
\end{center}
−8 −6 −4 −2 0 2 4 6 8
−1
−0.8
−0.6
−0.4
−0.2
0
0.2
0.4
0.6
0.8
1
Figure 70: Specifying Dimensions in \includegraphics
For a very large picture, we might want to specify width=\textwidth,height=!,
and let it ﬁll the entire width of the page. The height speciﬁcation (!) says
to maintain the aspect ratio.
If you ﬁnd yourself importing eps ﬁles but would like to make some
changes in L
A
T
E
X, read about the PSfrag package, by Michael C. Grant and
6.3 Importing pictures 89
David Carlisle, which comes with a basic installation (including MiKTeX),
whose documentation is at CTAN [4]. It has two basic operations: (1) edit
some string or position in the ﬁgure (i.e., the eps ﬁle), and (2) translate L
A
T
E
X
commands that you put in the ﬁgure in the ﬁrst place. The documentation
gives examples, with eps ﬁles produced by MATLAB and xﬁg.
Importing graphics is only one of the functions of graphicx. It can also
perform scaling, rotation, and sizing of an arbitrary box. The box could
contain text, pictures, or almost any stuﬀ. Here are examples:
Double your fun \scalebox{2}{Double your fun}
Open wide \resizebox{1in}{!}{\fbox{Open wide}}
R e ﬂ e c t o n t h i s \reflectbox{Reflect on this}
L
a
n
d
s
c
a
p
e
\rotatebox[origin=c]{90}{Landscape}
W
a
s
P
y
t
h
a
g
o
r
a
s
a
s
q
u
a
r
e
?
\rotatebox[origin=rt]{45}
{\psframebox{
\begin{tabular}{c}
Was\\Pythagoras\\a square?
\end{tabular}
} }
These operations are available because the programs that perform them
are used in the \includegraphics command. Although it is feasible to
perform the operation after importing a graphic, it is more eﬃcient to specify
that option in the \includegraphics. Here are some examples:
90 6 GRAPHICS
\includegraphics
{protractor.eps}
\includegraphics[width=.25\textwidth,
height=!]{protractor.eps}
\includegraphics[height=.5in,width=!,
angle=90,origin=c]{protractor.eps}
Exercises. Submit a printed copy of the L
A
T
E
X source (tex ﬁle) and printed
copy of the associated postscript result (ps ﬁle). Be sure your name is on
each.
1. Use the picture environment to draw the smiley face on page 73.
2. Draw the following graph with the picture environment, where \thicklines
is speciﬁed and \unitlength = 1mm
m
·
1
m
·
2
m
·
3
m
·
4
E
c
'
©
3. Use PSTricks to draw Figure 3 (p. 4).
6.3 Importing pictures 91
4. Use PSTricks or the picture environment to draw the following.
rhombus
5. Use PSTricks or the picture environment to draw the following.
α
β
6. Make a ﬁgure in some system that lets you save it as an eps ﬁle (or
use some conversion program). Then, include it in your document.
7. Use whatever means you prefer (or that your instructor requires) to
include each of the following ﬁgures in your document. (They were
drawn here with PSTricks, but this section did not describe all that is
needed, so you must obtain the PSTricks User’s Guide [15].)
(a) Graphic view of Pythagorean Theorem:
hypotenuse leg 1 leg 2
square of
leg 1
square
of
leg 2
square of
hypotenuse
92 6 GRAPHICS
(b) Network with arc data:
1
2
3
4
5
(25, 30) (35, 50) (45, 10) (15, 40) (15, 30) (25, 20) (35, 50)
(45, 60)
(c) The sin function:
y = sin
π
2
x
x
(d) Bernoulli family tree:
Nikolaus
(1623–1708)
Jacob I
(1654–1705)
Nikolaus
(1662–1716)
Nikolaus I
(1687–1759)
Jahann I
(1667–1748)
Nikolaus II
(1695–1726)
Daniel
(1700–1782)
Johann II
(1710–1790)
Johann III
(1746–1807)
Jocob II
(1759–1789)
93
7 Making Special Parts
7.1 Cover Page
The easiest way to make a cover page is with the \maketitle command.
This is usually done just following \begin{document}. The necessary pa
rameters are \author and \title, which can be deﬁned anyplace before
the \maketitle. Typically these are put into the preamble, or right after
\begin{document}, followed immediately by \maketitle; it depends upon
your management style.
If you see a page number on your cover page, suppress this by adding
\thispagestyle{empty}, right after \maketitle. You might also need to
initialize the page counter with \setcounter{page}{0}.
Multiple authors are separated by \and, such as in the example shown
in Figures 71 and 72. (The jagged edges in Figure 72 mean that there is
more space between the title and the top of the paper.)
Specifying \date is optional (\maketitle puts in the current date if the
date is not deﬁned). The cover page is by itself and is not numbered.
\title{The \LaTeX\ Companion}
\author{Michel Goosens \and Frank Mittelbach \and Alexander Samarin}
\date{1994}
\maketitle
Figure 71: Title Page Source (Result in Figure 72)
The L
A
T
E
X Companion
Michel Goosens Frank Mittelbach Alexander Samarin
1994
Figure 72: Title Page Result (Source in Figure 71)
Since articles often have this information on the ﬁrst page of the article
(rather than a separate page), titlepage must be speciﬁed as an option in
the \documentclass command. For example, the following does this while
specifying 12pt font as another option:
94 7 MAKING SPECIAL PARTS
\documentclass[12pt,titlepage]{article}
Addresses, aﬃliations, and other information about each author can be
added, using \\ to create new lines. For example, Figure 73 shows how the
authors appear when the \author deﬁnition in Figure 71 is changed to the
following:
\author{Michel Goosens \\ Geneva, Switzerland
\and Frank Mittelbach \\ Mainz, Germany
\and Alexander Samarin \\ Geneva Switzerland}
As illustrated in Figure 73, \maketitle puts the third author on a sep
arate line. This is because 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 L
A
T
E
X Companion
Michel Goosens Frank Mittelbach
Geneva, Switzerland Mainz, Germany
Alexander Samarin
Geneva, Switzerland
1994
Figure 73: Adding Addresses to Authors
There are times when we want to acknowledge support for one or more of
the authors. The \thanks command does this by creating a footnote, using
diﬀerent footnote marks for each one. Figures 74 and 75 illustrate this along
with some variation in the date.
7.1 Cover Page 95
\title{Pieces of $\pi$\thanks{Renamed.}}
\index{\texttt{$\backslash$thanks}} \index{footnote}
\author{Archimedes\thanks{Supported by the army.}\\ Syracuse, Sicily
\and Pythagoras \\ Samos, Ionia }
\date{210 {\sc bc} (revision of earlier version, 510 {\sc bc})}
Figure 74: Footnotes in the Cover Page Source (Result in Figure 75)
Pieces of π
1
Archimedes
2
Pythagoras
Syracuse, Sicily Samos, Ionia
210 bc (revision of earlier version, 510 bc)
1
Renamed.
2
Supported by the army.
Figure 75: Footnotes in the Cover Page Result (Source in Figure 74)
Figure 76 shows how to use only one footnote for authors having the same
aﬃliation. This uses the \footnotemark command, which puts the footnote
mark without any new text. Prior to that, the value of the footnote counter
is set back to the ﬁrst footnote mark.
\title{Doing \LaTeX}
\author{I.M. Rich \thanks{Smart University}
\and U.R. Grand \thanks{StreetSmart}
\and I.C. All \addtocounter{footnote}{2} \footnotemark
}
Figure 76: Authors with same footnote (Result in Figure 77)
96 7 MAKING SPECIAL PARTS
Doing L
A
T
E
X
I.M. Rich
1
U.R. Grand
2
I.C. All
1
1
Smart University
2
StreetSmart
Figure 77: Authors with same footnote (Source in Figure 76)
7.2 Abstract
The abstract environment is in all document styles, except article. To have
it, specify titlepage as an option in \documentclass (even if you do not in
tend to use \maketitle). This environment is deﬁned to produce an abstract
on a separate page (placed wherever you put the environment speciﬁcation),
with the header: Abstract, in boldface and centered. The abstract, itself,
is one paragraph and is printed without indentation. Figures 78 and 79 il
lustrate this. (Like the cover page, the abstract is placed far from the top of
the paper, which is not shown in Figure 79.)
\begin{abstract}
This shows that the ratio of the circumference to the diameter
of any circle is the same constant value, denoted $\pi$.
We further prove that this constant is bounded by
$\frac{223}{71} < \pi < \frac{22}{7}$.
\end{abstract}
Figure 78: Making an Abstract Source (Result in Figure 79)
7.3 Other Front Matter 97
Abstract
This shows that the ratio of the circumference to the diameter
of any circle is the same constant value, denoted π. We further
prove that this constant is bounded by
223
71
< π <
22
7
.
Figure 79: Making an Abstract Result (Source in Figure 78)
7.3 Other Front Matter
The \tableofcontents command makes a table of contents; it is placed
wherever you put the command, which should be right after the cover page.
Then, you can include lists of ﬁgures and tables with the \listoffigures
and \listoftables commands, respectively.
The table of contents generally includes numbered parts, like sections and
subsections. To include other front matter, L
A
T
E
X provides the \addcontentsline
command. For example, the table of contents in this document was obtained
with the speciﬁcations given in Figure 80.
\newpage \pagenumbering{roman} \pagestyle{myheadings}
\tableofcontents \newpage
\addcontentsline{toc}{section}{List of Figures}
\listoffigures \newpage
\addcontentsline{toc}{section}{List of Tables}
\listoftables \newpage
Figure 80: Some Front Matter Speciﬁcations for This Document
The \pagenumber speciﬁcation causes 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 cover). Then, I
declare \listoffigures, which is on page v, followed by the list of tables.
Each of these are put on a new page. Just above each declaration, I use the
\addcontentsline to add it to the table of contents, indicated by the toc
speciﬁcation. The section parameter tells the latex program to format it
like a section — ﬂush left.
The page numbering is reset when we ﬁnish the front matter by specifying
\newpage \pagenumbering{arabic} \pagestyle{headings}
This switches to the Arabic numerals and initializes the page counter.
98 7 MAKING SPECIAL PARTS
The same format as the abstract can be used for other front matter that
we want to format the same way. The only change we require is another
header name. This is done by redeﬁning the \abstractname parameter
used by the abstract environment. The \renewcommand enables us to do
this. §?? has more to say about using this command to customize many
things. For now, consider the following example that illustrates how to have
an Acknowledgments page:
\renewcommand\abstractname{Acknowledgments}
\begin{abstract}
I thank my family and friends for all of their support.
I also thank the contributors to the Comprehensive \TeX\
Archive Network (CTAN).
\end{abstract}
Alternatively, we might want something to look like a section (and au
tomatically added to the table of contents), but we do not want it to have
a section number. This is achieved by the \section* command, where the
* suppresses the numbering. For example, \section*{Preface} puts “Pref
ace” in the same style as any section, but with no number (and the section
counter remains unchanged).
7.4 Back Matter
After the main part of the document is ﬁnished, we put the bibliogra
phy (see §3 and §8.6). We might ﬁrst want to have appendices that fol
low the main text. This could be done with the appendix environment:
\begin{appendix} . . . \end{appendix}.
The last portion in the back of any book is its index. This could also
be desirable in a long report. To make an index, we have three things to put
into our source ﬁle:
1. Put \usepackage{makeidx} in the preamble.
2. Put \makeindex at the end of the preamble.
3. Put \printindex just before \end{document}.
After a successful compilation, with all references resolved, enter at the
command line:
makeindex myfile
Then, compile again. This is analogous to the use of bibtex (p. 28), and is
illustrated in Figure 81.
To have entries in the index, you use \index{entry}. For example, the
index in this book contains several occurrences of ‘ﬂushleft’. In the text,
7.5 Footnotes 99
at each occurrence, I specify \index{flushleft}. To put the entry as a
subordinate, use !. For example, \index{package!makeidx} puts the entry
‘makeidx’ under the entry ’package’.
myfile.tex myfile.dvi myfile.ps
create/edit view/print print/post
compile
latex
convert
dvips
makeindex
myfile.pdf dvipdf
Figure 81: Adding makeindex to the Command Sequence
There are packages to make other back matter: acronym makes a list of
acronyms, nomencl makes a list of nomenclature, and gloss makes a glossary.
7.5 Footnotes
The \thanks command is one way to have a footnote on the cover page,
and was shown on page 95. More generally, the \footnote command can be
used anywhere. Figures 82 and 83 illustrate.
Here is my first footnote\footnote{first};
here is my second\footnote{second}.
Figure 82: Setting a Footnote Source (Result in Figure 83)
Here is my ﬁrst footnote
1
; here is my second
2
.
1
ﬁrst
2
second
Figure 83: Setting a Footnote Result (Source in Figure 82)
\thefootnote gives the counter for footnotes, and you can change from
numbers to letters by \renewcommand{\thefootnote}{\alph{footnote}}.
You can also change to common footnote symbols by specifying
\renewcommand{\thefootnote}{\fnsymbol{footnote}}, as shown in ﬁg
ures 84 and 85.
The distance between the line that underlies part of the last line of text
to the footnote is \footnotesep, which can be controlled by \setlength.
100 8 TAKING CONTROL
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
Here is my first footnote\footnote{first};
here is my second\footnote{second}.
Figure 84: Setting a Footnote Source (Result in Figure 85)
Here is my ﬁrst footnote
∗
; here is my second
†
.
∗
ﬁrst
†
second
Figure 85: Setting a Footnote Result (Source in Figure 84)
Exercises. Submit a printed copy of both the L
A
T
E
X source (tex ﬁle) and
the associated postscript result (ps ﬁle). Be sure your name is on each.
1. Write an article with a title page and abstract. Make the main body
have at least three sections: Introduction, Main Results, and Conclu
sions.
2. Extend exercise 1 to have acknowledgments and references (using BibT
E
X).
3. Combine exercises 1 and 2 and add a table of contents showing not only
all sections and subsections, but also the abstract, acknowledgments
and references.
8 Taking Control
This section introduces you to fundamentals of customizing your document.
It is still in the context of an introduction, choosing only a few of the
things you can change. A key to these changes are the \newcommand and
\renewcommand commands, which enable you to deﬁne your own commands
and change parameter values of existing commands.
8.1 Your Own Abbreviations and Commands
The command that gives us the ability to make our own has the following
form: \newcommand{\name}[n]{whatever}, where n is the number of argu
ments, and whatever is whatever you want the command to do. Here are
two examples simply to abbreviate commands with long names:
\newcommand{\ul}{\underline}
\newcommand{\mc}{\multicolumn}
8.1 Your Own Abbreviations and Commands 101
The ﬁrst lets us write \ul{something} to underline something. The second
lets us write \mc{3}{c}{stuff} to enter a multicolumn, in either a tabular
or an array environment, spanning 3 columns and centered.
The latex compiler will not let you use a name that is already being used.
For example, if you specify \newcommand{\fbox}..., you will get a fatal error
message since there is already a \fbox command.
A related use is when the command requires some lines of code. Consider
the following example:
\newcommand{\Box}{\mbox{\begin{picture}(0,0)
\put( 2,0){\framebox(7,7)}
\end{picture} }}
(\mbox is used to ensure text mode). Now \Box ⇒ and, having deﬁned
the \Box command, we can use it in other new commands. For example,
in the preamble I speciﬁed: \newcommand{\chkbox}{$\Box^\surd\;$} Then,
\chkbox ⇒
√
Some commands are speciﬁcally for math mode, but we want them to
work in any mode. This is achieved by the command: \ensuremath{math
stuﬀ }. For example, consider \newcommand{\Gs}[1]{G_{#1}}. If we are
already in math mode, \Gs{i+j} is replaced by G_{i+j} to produce G
i+j
;
otherwise, if \Gs{i+j} is speciﬁed in text mode, it is replaced by $G_{i+j}$
to put it into math mode ﬁrst. Thus, we can specify \Gs{subscript}, no
matter which mode we are in, and obtain the correct result.
Another reason to have our own commands is for consistency, particularly
of notation. Suppose we have a key term, like the null space of a matrix.
Some authors write ^(¹), some write nul ¹, and there are still more symbols
people use. We can choose one and deﬁne
\newcommand{\nul}{\ensuremath{\mathcal{N}}}.
Then, we can write \nul(A) to obtain ^(A) (and we can be in text or math
mode when we write this). Some publishers have their own notation, so we
must be careful not to override them with ours. A way to do this is to choose
a diﬀerent name, like mynul, then add to the preamble:
\newcommand{\usenul}{\mynul}
and specify \usenul in the document. If you need to use the publisher’s,
simply change the one line to:
\newcommand{\usenul}{\nul}
(where the publisher’s command name is \nul).
The preamble can become very long as we add our commands, so it
is useful to put them in a separate ﬁle, say mydefs.tex (note the .tex
suﬃx). Then, we use the \input command to have the latex compiler read
102 8 TAKING CONTROL
it wherever it is placed. In particular, the preamble of this document contains
the command:
\input{mydefs}
(The suﬃx .tex is assumed.) Diﬀerent source ﬁles could simply input this
same ﬁle, so duplication 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 common names we might want to change. For example, in this
document the “Table of Contents” was obtained by specifying the following
in the preamble:
\renewcommand{\contentsname}{Table of Contents}.
Table 22: Intrinsic Name Parameters
What it is How it is called (keyword)
Abstract \abstractname
Appendix \appendixname
Chapter \chaptername
Contents \contentsname
Index \indexname
List of Figures \listfigurename
List of Tables \listtablename
Part \partname
References \refname for article style
\bibname for book and report styles
You might want to change the numbering of some intrinsic counter. We
saw an example of this in changing the counters for enumeration lists (p. 43).
The general form is
\renewcommand{\thecounter}{something}
Another example is to change section numbering in a report document
style. The ﬁrst level of division is assumed to be a chapter, so the numbering
will be chapter.section[.subsection]. . . If you have no chapters, it will number
the ﬁrst section as 0.1. Making the ﬁrst level division chapters will overcome
the numbering problem, but the format of chapters is diﬀerent, similar to
a book. Making the document class an article will also solve the problem,
since the section is the ﬁrst level division. This might not be appropriate due
to other considerations, such as entering the document into a database using
8.3 Your Own Environments 103
BibT
E
X, where you want it to be counted as a report, not as an article.
The way to do this is as follows:
\makeatletter
\renewcommand\thesection{\@arabic\c@section}
\makeatother
The preceding command, \makeatletter, is to make the @ character a letter.
The succeeding command, \makeatother, restores @ to its special meaning
(\@ is for certain spacing, equal to about 2 spaces).
8.3 Your Own Environments
The \newenvironment command enables us to deﬁne our own environments,
and the \renewenvironment command enables us to revise an existing en
vironment. 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 = 0), begin is what is executed upon entering the environment,
and end is what is executed upon leaving the environment. For example,
the following creates a proof environment:
\newenvironment{proof}
{\begin{flushleft} \begin{description}
\item \textit{\textbf{Proof:}}~ } % begin proof
{\hfill\rule{2.1mm}{2.1mm}
\end{description}\end{flushleft} } % end proof
Then,
\begin{proof}
First, suppose \dots \linebreak
Thus, the theorem follows.
\end{proof}
produces:
Proof: First, suppose . . .
Thus, the theorem follows.
8.4 Your Own Margins and Spacing
The default margins and spacing are set with purposeful values, and you
will usually not need to change them. When you do, however, they can
be changed by setting certain parameters in the preamble. The margins
104 8 TAKING CONTROL
of the document are controlled by the parameters shown in Figure 86 and
described in Table 23. (See Table 25 for conversion factors; in particular,
1 pt = 72.27 in.)
For example, if we are using 8
1
2
11 paper, the current settings (shown
in Table 23) break down the horizontal parts as follows:
6.14.295 pt
8.5 in
72.27 pt
1 in
39 pt
54 in
113.025 pt
1.564 in
390 pt
5.396 in
begin body stuﬀ end body stuﬀ
We can increase the text width by setting \textwidth=length in the
preamble. For example, \textwidth=6in increases the text width to 6 inches.
The body expands to the right unless we also change \oddsidemargin.
Margin settings can be negative; for example, we raise the body 1 inch by
specifying \topmargin=1in in the preamble. This might be accompanied
by increasing the text length. The geometry package provides easy speciﬁca
tions for page layout.
The \hspace* and \vspace* commands provide a great deal of control
over horizontal and vertical spacing, respectively. We might want some global
settings to make repeated use of these unnecessary. Table 24 lists some you
can set with the \setlength command, showing their default values (used
in this document).
Table 23: Margin Parameters
Current
Parameter Setting
†
Meaning
\footskip 30.0pt space between bottom of body and top of
footer
\headsep 25.0pt space between bottom of header and top of
body
\headheight 12.0pt height of header
\hoffset 0.0pt horizontal oﬀset to add to indentation of body
\oddsidemargin 29.0pt extra space added at left (applies only to odd
numbered pages if the style is twosided, in
which case there is also an `evensidemargin
parameter)
\paperheight 794.96999pt height of the paper
\paperwidth 614.295pt width of the paper
\textheight 585.38744pt height of the body
\textwidth 360.0pt width of the body
\topmargin 21.0pt space added before the top of the header
\voffset 0.0pt vertical oﬀset to add to indentation of body
†
Printed using \theparameter.
8.4 Your Own Margins and Spacing 105
\pagewidth
\pageheight
1 in +
\hoffset
1 in +
\voffset
header
body
footer
\textwidth
\textheight
\headheight
\footskip
\headsep
\topmargin
\oddsidemargin
Figure 86: Document Margins
106 8 TAKING CONTROL
Table 24: Spacing Parameters
Parameter Meaning
\itemsep space added to \parsep between items in a list.
\parindent indentation at beginning of paragraph.
\parsep space between paragraphs in the same item of a list.
\parskip space between paragraphs.
In the case of list parameters, they must be set within the list environ
ment. For \itemsep this can occur just after the \begin statement. (De
faults are restored after leaving.) For example, the lists in §2.2 (p. 12) are
spaced by default values. Here is what happens when we change \itemsep:
• The default value of \itemsep is 4.5pt plus 2.0pt minus 1.0pt, and I
have saved it by: \setlength{\mylength}{\itemsep}.
• See the above spacing between items. What you see next is with
\setlength{\itemsep}{0pt}.
• What you see next is with \setlength{\itemsep}{10pt}.
• Next is back to normal by \setlength{\itemsep}{\mylength}.
• We are back to normal with \itemsep = 4.5pt plus 2.0pt minus 1.0pt.
Figure 87 shows two enumerate lists, varying by the value of \itemsep.
1. This list speciﬁed
\setlength{\itemsep}{0pt}
right after \begin{itemize}
2. This item is fairly close to the
ﬁrst one.
1. This list speciﬁed
\setlength{\itemsep}{12pt}
right after \begin{itemize}
2. This item is farther from the
ﬁrst one.
Figure 87: Varying \itemsep to control item spacing in a list
The left margin parameter is \leftmargini for a level1 list (note the i
at the end). This must be set before the \begin command. Figure 88 gives
an example.
8.4 Your Own Margins and Spacing 107
{\setlength{\leftmargini}{2in}
\begin{itemize} \setlength{\itemsep}{0in}
\item Item 1 of list with 2in left margin
\item Item 2 of list with 2in left margin
\end{itemize}
}
Figure 88: Changing the Left Margin of a List (Result in Figure 89)
• Item 1 of list with 2in left margin
• Item 2 of list with 2in left margin
Figure 89: Changing the Left Margin of a List (Source in Figure 88)
Figures 90 and 91 show the presentation of an array with a pcolumn to
put horizontal space between the other two columns. Note how congested it
is, so we want to increase its vertical spacing.
\[ \begin{array}{lp{.3in}l}
\,B\,x_B = b_N + \frac{1}{2}\theta\delta b_N
&& \pi_N B = c_B + \frac{1}{2}\theta\delta c_B \\
B^*x_B > b_B + \frac{1}{2}\theta\delta b_B
&& \pi_N N < c_N + \frac{1}{2}\theta\delta c_N
\end{array}
\]
Figure 90: Array with Fixed Width Column Source (Result in Figure 91)
1 r
B
= /
N
+
1
2
θδ/
N
π
N
1 = c
B
+
1
2
θδc
B
1
∗
r
B
/
B
+
1
2
θδ/
B
π
N
· < c
N
+
1
2
θδc
N
Figure 91: Array with Fixed Width Column Result (Source in Figure 90)
Here is 1.3 line spacing: \renewcommand{\arraystretch}{1.3}
1 r
B
= /
N
+
1
2
θδ/
N
π
N
1 = c
B
+
1
2
θδc
B
1
∗
r
B
/
B
+
1
2
θδ/
B
π
N
· < c
N
+
1
2
θδc
N
Here is 1.6 line spacing: \renewcommand{\arraystretch}{1.6}
1 r
B
= /
N
+
1
2
θδ/
N
π
N
1 = c
B
+
1
2
θδc
B
1
∗
r
B
/
B
+
1
2
θδ/
B
π
N
· < c
N
+
1
2
θδc
N
108 8 TAKING CONTROL
Back to default: \renewcommand{\arraystretch}{1}
1 r
B
= /
N
+
1
2
θδ/
N
π
N
1 = c
B
+
1
2
θδc
B
1
∗
r
B
/
B
+
1
2
θδ/
B
π
N
· < c
N
+
1
2
θδc
N
Line spacing is controlled by \baselinestretch , but it is easier to use
the setspace package. You will have control of the whole document, or just
some lines whose space you want to control.
8.5 Your Own Output Control
You can write conditionals to do one thing or another with the ifthen package.
The syntax is
\ifthenelse{condition}{action if true}{action if false}
For example, suppose your preamble contains
\newcommand{ \printsol}[2]{ \ifthenelse{\equal{#1}{1}}%
{\textsf{\textbf{Solution. }#2}}{} }
This will test the condition if your ﬁrst argument equals 1. If so, it will print
Solution. followed by your second argument; if not, it will do nothing.
This is illustrated in ﬁgures 92 and 93.
How much is 2+2?
\printsol{\sol}{4}
Figure 92: \ifthenelse Source (Results in Figure 93)
`def`sol{0}
.
.
.
How much is 2+2?
`def`sol{1}
.
.
.
How much is 2+2? Solution. 4
Figure 93: \ifthenelse Results (Source in Figure 92)
Another example is to decide on page numbering. Suppose that you
want no page numbering if there is only one page. If there is more than
one page, suppose you want to use headings in the header with page num
bers. You can do this as follows. First, just before \end{document}, put
\label{lastpage}. Just after \begin{document}, put the following:
\ifthenelse{\equal{\pageref{lastpage}}{1}}{\pagestyle{empty}}%
{\pagestyle{headings}}
This will test if the value of \pageref{lastpage} is equal to 1. If so,
there is only one page, and the ﬁrst statement applies: \pagestyle{empty}.
If not, there is more than one page, and the second statement applies:
\pagestyle{headings}.
8.6 Your Own Bibliography 109
8.6 Your Own Bibliography
You can choose not to use BibT
E
X, and use thebibliography environment
instead. You will have complete control over the formatting, and there
will be no sorting — the list of references will appear in the order you put
them. Instead of the BibT
E
X commands, \bibliography{mybiblio} and
\bibliographystyle{plain}, specify the following:
\begin{thebibliography}{n}
\bibitem[what appears]{label (that you cite)} entry
.
.
.
\end{thebibliography}
where n is the width of the widest label you want to allow. (It works if
you specify 99.) Each \bibitem is an entry, as described for BibT
E
X in §3
(p. 28), with label the unique identiﬁer used by the \cite command. The
option is an alternative to having the references numbered, and you can enter
whatever you like.
Here is a complete example with two references, which I formatted to
agree with the plain style of BibT
E
X:
\begin{thebibliography}{99}
\bibitem{companion} Michel Goosens, Frank Mittelbach and Alexander
Samarin, \textit{The \LaTeX\ Companion}, AddisonWesley
Publishing Company, Reading, MA, 1994.
\bibitem{tex} Donald E. Knuth, \textit{The \TeX\ Book},
AddisonWesley Publishing Company, Reading, MA,
15th edition, 1989.
\end{thebibliography}
These will appear in the document’s list of references even if they are not
cited. They can be cited in the same way described in §3: by \cite{companion}
and \cite{tex}, respectively. When citing Knuth’s book, for example, we
obtain [2] in the text. Alternatively, we can exercise the option:
\bibitem[Knuth, 1989]{tex} Donald E. Knuth, . . .
in which case \cite{tex} ⇒ [Knuth, 1989].
Some publishers give you no choice, but if you are writing a report and
have control over the formatting, it generally helps the reader to know some
thing about the citation. Thus, [Knuth, 1989] is preferred to [2] because
it immediately gives the reader information about the document without
having to ﬂip to the bibliography section.
With you in control, there is no format monitoring, so each entry appears
however you put it, even if there are inconsistencies in style. This is one
reason it is usually better to use BibT
E
X, even though you lose control
over what appears (i.e., they will be numbers). The bib style ﬁle, such as
110 8 TAKING CONTROL
plain.bst, applies in either case. Most installations come with more than
the basic plain, and its three variations (given on p. 36). Alternative bst ﬁles
are achicago (from the frankenstein package), apalike and plainnat (from
natbib), which give the author and year, such as [Knuth, 1989] instead of [8].
These packages provide even more versatility in how the citations appear
(see [4] or [5, Chapter 13]).
If you want to have several bibliographic units in one document, such as
at the end of each chapter of a book, use the bibunits package, which you
obtain from CTAN [4].
Closing Remarks
Now you know how to write a mathematical document in L
A
T
E
X2
ε
and you
know there is much more you can learn to gain reﬁnements. Besides what
you can do yourself to elevate the quality of the results, there are many
packages, available from CTAN [4]. Figure 94 shows the preamble used for
this document. As you begin to use packages, it is necessary to become aware
of updates. You can visit CTAN from time to time, or you can join their
newsgroup at comp.text.tex (can be done in Google by clicking on Groups).
You will ﬁnd other packages useful, depending upon your technical area.
Here are some packages that give you special symbols: chemsym, qsymbols,
SIunits, wasysym, and xypic. Also, the algorithm package enables an environ
ment to write source code with standard language elements, and there are
others with similar properties or for particular programming languages (viz.,
cpascal and listings). The graphtex package specializes in all sorts of graphs,
including those commonly found in automata theory.
APPENDIX 111
\usepackage{amsmath} % formerly amstex
\usepackage{amssymb} % ams symbols (\mathbb fonts)
\usepackage{amscd} % draws commutative diagrams
\usepackage{bm} % bold math fonts (\mathbm)
\usepackage{graphicx,pstall} % graphics
\usepackage{hyphenat} % enables control over hyphenation
\usepackage{fancyvrb,moreverb} % verbatim
\usepackage{float} % enable float [H] option
\usepackage[T1]{fontenc} % ...to write \textbf{\textsc{..}}
\usepackage{ifthen} % ifthenelse {condition}{true}{false}
\usepackage{makeidx} % index
\usepackage{mathrsfs} % more math symbols (viz., \mathscr)
\usepackage{multirow} % like multicolumn
\usepackage{theorem} % enables more control over newtheorem
\usepackage{url} % \url{...}
\renewcommand\contentsname{Table of Contents} % Change ‘Contents’
\renewcommand\url{\begingroup\urlstyle{sf}\Url} % put url in sf font
\input{mydefs} % My commands and environments
\makeindex % make myfile.idx (input to makeindex at command line)
Figure 94: Most of the Preamble for this Book
Appendix
This contains complete tables of font information and basic L
A
T
E
X commands.
It is designed like a reference manual for easy lookup, beginning with Ta
ble 25, which gives conversion among three common units of measurement.
Table 25: Conversions of Common Units of Measurement
pt in cm
pt 1 .01384 .03515
in 72.27 1 2.54
cm 28.45 .3937 1
Table 26 is a guide to how most of the remaining tables are organized.
Afterwards, Table 45 gives special symbols that can be used in either text or
math mode, and Table 46 gives the commands for the picture environment.
112 APPENDIX
Table 26: Reference Tables
Table Contents
Text mode 27 Commands/Environments for Font Appearance
28 Commands/Environments for Controlling Position
29 Text Accents and Symbols
30 Commands for Counters
31 Commands/Environments to Organize Document
32 Commands to Control Document Style
Math mode 33 Commands to Control Fonts in Math Mode
34 Accents in Math Mode
35 Spacing Commands in Math Mode
36 Greek and Special Letters
37 Frequently Used Mathematical Symbols
38 Binary Operations
39 Operators and Quantiﬁers
40 Special Functions
41 Relation Symbols
42 Arrows
43 Dots Circles, Triangles and Lines
44 Variable Size Symbols
Table 27: Commands/Environments for Text Font Appearance
textbf textit textrm textsc textsf texttt
tiny scriptsize footnotesize small normalsize large
Large LARGE huge Huge underline verb
verbatim
Table 28: Commands/Environments for Controlling Text Position
bigskip center centerline clearpage flushleft
flushright hfill hspace hspace* linebreak
medskip newpage noindent nolinebreak nopagebreak
pagebreak quotation quote raisebox samepage
smallskip tabbing tabular verse vfill
vspace vspace*
APPENDIX 113
Table 29: Text Accents and Special Symbols
á \’{a} ˘ u \u{u} ç \c{c} ˙ x \.{x}
è \‘{e} ñ \~{n} d
.
\d{d} ¯z \={z}
î \^{i}
˝
H \H{H} b
¯
\b{b} ˇ v \v{v}
ö \"{o} oo \t{oo} . . . \dots
æ \ae œ \oe å \aa ø \o
Æ \AE Œ \OE Å \AA Ø \O
Ł \L ß \ss ¿ ?‘ ¡ !‘
Table 30: Commands for Counters
addtocounter label newcounter pageref
ref refstepcounter setcounter stepcounter
thecounter value
Table 31: Commands/Environments to Organize Document
abstract addcontentsline addtocontents
appendix bibliography bibliographystyle
listoffigures listoftables makeindex
maketitle printindex section
subsection subsubsection subsubsubsection
tableofcontents thanks thebibliography
Table 32: Commands to Control Document Style
markright markboth pagenumbering pagestyle
renewcommand setlength thispagestyle
Table 33: Commands to Control Fonts in Math Mode
left boldmath (set in text mode)
cal displaystyle mathbf mathcal
mathit mathnormal mathrm mathsf
mathtt mbox overbrace overline
right textstyle underbrace underline
114 APPENDIX
Table 34: Accents in Math Mode
ˇ o \check{a} ˘ c \breve{e}
´
i \acute{i} ` o \grave{o}
˙ r \dot{x} ¨ n \ddot{y} ¯ . \bar{z} · \vec{v}
ˆı `hat{`imath} ˜ , `tilde{`jmath} \hbar
¯ rn. `widehat{xyz}
o/c `widetilde{abc}
(Note that it is better style to use \imath, rather than i, and \jmath,
rather than ,, to avoid the clash between the accent and dot.)
Table 35: Spacing Commands in Math Mode
What you write What you see
x y ⇒ rn no space
x\,y ⇒ rn thin space
x\;y ⇒ r n medium space
x\quad y ⇒ r n space = 1em
x\qquad y ⇒ r n space = 2em
x\!y ⇒ rn negative thin space
x\negmedspace y ⇒ rn negative medium space
x\negthickspace y ⇒ rn negative thick space
Table 36: Greek and Special Letters
α \alpha θ \theta o o τ \tau
β \beta ϑ \vartheta π \pi υ \upsilon
γ \gamma ι \iota c \varpi φ \phi
δ \delta κ \kappa ρ \rho ϕ \varphi
c \epsilon λ \lambda · \varrho χ \chi
ε \varepsilon j \mu σ \sigma ψ \psi
ζ \zeta ν \nu$ ς \varsigm ω \omega
η \eta ξ \xi
Γ \Gamma Λ \Lambda Σ \Sigma Ψ \Psi
∆ \Delta Ξ \Xi Υ \Upsilon Ω \Omega
Θ \Theta Π \Pi Φ \Phi
ℵ \aleph / \ell 1 \Re · \Im
/. . . 7 {`mathcal A...Z}
APPENDIX 115
Table 37: Frequently Used Mathematical Symbols
{superscript} ^{} / \prime ∞ \infty ∅ \emptyset
{subscript} _{}
Table 38: Binary Operations
± \pm ∩ \cap ∪ \cup \odot
∓ \mp ¯ \sqcap . \sqcup ⊗ \otimes
\times ∧ \wedge ¬ \uplus . \oslash
÷ \div ∨ \vee ⊕ \oplus \ominus
` \setminus
¸
\bigcap
¸
\bigcup
¸
\bigodot
` \backslash
\bigvee
¸
\bigoplus
¸
\bigotimes
¸
\biguplus
\bigwedge
¸
\bigsqcup
Table 39: Operators and Quantiﬁers
∇ \nabla ∂ \partial
√
\surd ℘ \wp
∀ \forall ∃ \exists \neg
Table 40: Special Functions
arccos arcsin arctan arg cos cosh cot coth
csc det dim exp gcd hom inf ker
lg lim liminf limsup ln log max min
Pr sec sin sinh sup tan tanh
Table 41: Relation Symbols
≤ \leq ≥ \geq = \neq ≡ \equiv
≺ \prec ~ \succ ∼ \sim
.
= \doteq
_ \preceq _ \succeq · \simeq [= \models
< \ll \gg
∼
= \cong ∝ \propto
⊂ \subset ⊃ \supset · \asymp ∈ \in
⊆ \subseteq ⊇ \supseteq ≈ \approx ÷ \ni
_ \sqsubseteq _ \sqsupseteq
116 APPENDIX
Table 42: Arrows
← \leftarrow ←− \longleftarrow ↑ \uparrow
⇐ \Leftarrow ⇐= \Longleftarrow ⇑ \Uparrow
→ \rightarrow −→ \longrightarrow ↓ \downarrow
⇒ \Rightarrow =⇒ \Longrightarrow ⇓ \Downarrow
↔ \leftrightarrow ←→ \longleftrightarrow  \updownarrow
⇔ \Leftrightarrow ⇐⇒ \Longleftrightarrow ¨ \Updownarrow
→ \mapsto −→ \longmapsto \nearrow
← \hookleftarrow → \hookrightarrow ` \searrow
÷ \leftharpoonup ÷ \rightharpoonup \swarrow$
÷ \leftharpoondown ÷ \rightharpoondown ` \nwarrow
\rightleftharpoons
Table 43: Dots, Circles, Triangles and Lines
◦ \circ ( \bigcirc
\cdots
.
.
.
\ddots
.
.
. \vdots • \bullet
· \frown \smile
´ \triangle \diamond
> \triangleright \triangleleft
´ \bigtriangleup \bigtriangledown
> \bowtie ⊥ \perp
· \top ⊥ \bot
¬ \dashv ¬ \vdash
∠ \angle  \
[ \mid  \parallel
Some Tips 117
Table 44: Variable Size Symbols
¸
\sum
\int
\oint
¸
\prod
....
. \overbrace{ . } .
....
\underbrace{ . }
¸
\coprod . \overline{ . } . \underline{ . }
n
d
\frac{n}{d}
√
. \sqrt{ . }
These use `left and `right
() ( ) ¦¦ \{ \} [] [ ]
[  \lfloor  \rfloor
` \backslash \lceil  \rceil
' \langle ` \rangle
Table 45: Special Symbols in Both Text and Math Modes
†
\dag § \S c ( \copyright
‡ \ddag ¹ \P £ \pounds
. . . \ldots
Table 46: Commands and Parameters in Picture Environment
put(r. n){stuff } multiput(r. n)(∆r. ∆n){nn:/c:}{stuff }
line(r. n){cnot/} framebox(nidt/. /cio/t)[j]{tcrt}
vector(r. n){cnot/} dashbox{do:/
s
i.c}(nidt/. /cio/t)[j]{tcrt}
circle{:odin:) makebox(nidt/. /cio/t)[j]{tcrt}
circle*{:odin:) oval(nidt/. /cio/t)[j]
linethickness{di:cn:ion}
j ∈ ¦l,r,t,b,lt,lb,rt,rb¦. For oval, it is the portion selected;
for boxes, j is where the text goes.
Some Tips
Here are some tips that apply in special situations.
Structuring large documents. Theses, books, and other large documents
are best managed with the \input command. The document might
look like this:
118 Some Tips
Preamble
\begin\{document}
\input{Abstract}
\input{Chapter1}
\input{Chapter2}
.
.
.
\end\{document}
Preamble
\begin\{document}
%\input{Abstract}
\input{Chapter1}
%\input{Chapter2}
.
.
.
\end\{document}
(a) Separate chapters in a document
(input ﬁles are
Abstract.tex, Chapter1.tex, . . . )
(b) Compiling just Chapter 1
This is also a good structure for coauthoring.
Counting words. Under linux enter dvi2tty file.dvi  wc words
This takes file.dvi as input into the program dvi2tty, which con
verts it into a plain text ﬁle (without latex commands). That output
ﬁle is passed to the command wc, which counts the words. If you need
to apply this to a portion of the document, such as an abstract, you
can put that portion into a skeleton latex ﬁle and compile it. Using
the above structure, this is particularly easy to obtain the word or line
count of any section.
Commenting text. Besides putting % in column 1, you can logically delete
a block of text by \if 0 ... \fi. This is a good way to manage a
document when you might want to remove some text with the idea
that you it might be restored, at least in part.
\if 0
stuﬀ here is ignored
\fi
(See §8.5 for more general control.)
\newcommand vs. \def. It is generally better to use \newcommand because
you will get an error if the command name is already deﬁned, such as by
some package. The syntax is \newcommand{\name}[#]{what to do};
for example, \newcommand{\note}[1]{\texttt{Note: #1}} deﬁnes a
\note command that has one argument. When you specify \note{hello},
you will get Note: hello in the text.
\def is to be used only when you want to allow an override (without
warning). Its syntax is \def\name{what} or \def\name#1{what} if
there is one argument. To suppress printing all notes, deﬁned by the
above \note command, you can specify \def\note#1{ }. This says to
do nothing when seeing \note{stuﬀ}. You can have an \input ﬁle with
many commands and environment deﬁnitions that you use repeatedly.
It might have something like the following:
REFERENCES 119
\newcommand{\note}[1]{\texttt{note: #1}}
% \def\note #1{ } % activate to suppress printing notes
A “better” alternative (avoiding \def) is to use
%\renewcommand{\note}[#1]{} % activate to suppress printing notes
The \note command is useful when collaborating, and you could deﬁne
a separate one for each author, showing initials.
There is also the \providecommand. This has the same syntax as
\newcommand, but it does not issue an error if the command is al
ready deﬁned. It does nothing if the command exists; otherwise, it
deﬁnes the command.
Making / clear. It is good practice to use \ell in math mode when you
want the letter ell because it is easier to distinguish \ell from the
number 1. Compare / vs.  with 1 — also compare the source:
$\ell$ vs. $l$ with $1$.
Also consult the T
E
X Catalog Online [14].
References
[1] Johannes L. Braams. Babel, a multilingual styleoption system for use
with L
A
T
E
X’s standard document styles. TUGboat, 12(2):291–301, 1991.
Available at CTAN [4].
[2] Johannes L. Braams, David P. Carlisle, Alan Jeﬀrey, Frank Mittelbach,
Chris Rowley, and Rainer Schöpf. L
A
T
E
X2
ε
and the LaTeX3 project.
World Wide Web, http://www.latexproject.org/latex3.html, 1994–99.
[3] David P. Carlisle. Packages in the ‘graphics’ bundle. World Wide Web,
CTAN /macros/latex/required/graphics/ (see [4] for replacing CTAN),
1994–99.
[4] Comprehensive T
E
X archive (CTAN). UK: ftp.tex.ac.uk/texarchive/;
Germany: ftp.dante.de/texarchive/; USA: ftp.tug2.cs.umb.edu/tex
archive/ . These are host sites, which contain a list of mirror sites.
[5] Michel Goosens, Frank Mittelbach, and Alexander Samarin. The L
A
T
E
X
Companion. AddisonWesley Publishing Company, Reading, MA, 1994.
[6] John D. Hobby. A User’s Manual for MetaPost. Computing Sci
ence Technical Report no. 162, AT&T Bell Laboratories, Murray Hill,
New Jersey, 1992. Available at http://cm.belllabs.com/who/hobby/
MetaPost.html/.
120 REFERENCES
[7] John D. Hobby. Drawing Graphs with MetaPost. Computing Science
Technical Report no. 164, AT&T Bell Laboratories, Murray Hill, New
Jersey, 1993. Available at http://cm.belllabs.com/cs/cstr/164.ps.gz.
[8] Donald E. Knuth. The T
E
X Book. AddisonWesley Publishing Company,
Reading, MA, 15th edition, 1989.
[9] Leslie Lamport. L
A
T
E
X: A Document Preparation System. Addison
Wesley Publishing Company, Reading, MA, 1986 (also see 2nd edition,
1994).
[10] L
A
T
E
X2
ε
for authors. CTAN /macros/latex/doc/usrguide.ps (see [4] for
replacing CTAN), 1995–99.
[11] Oren Patashnik. BibT
E
Xing. World Wide Web, http://www.uic.edu/
depts/adn/infwww/ps/btxdoc.ps, 1988.
[12] Keith Reckdahl. Using imported graphics in L
A
T
E
X2
ε
. World Wide Web
site Version 2.0, Comprehensive T
E
X Archive, CTAN /info/epslatex.ps
(see [4] for replacing CTAN), 1995–97.
[13] Christian Schenk. MiKT
E
X Local Guide. World Wide Web, http:
//www.miktex.de/, 1998–99 (version 1.2).
[14] Graham Williams. T
E
X Catalogue Online. Technical report, CTAN,
http://www.ctan.org/texarchive/help/Catalogue/catalogue.html.
[15] Timothy Van Zandt. PSTricks: PostScript macros for Generic TeX.
World Wide Web, http://www.tug.org/applications/PSTricks/, 1993–98.
Index
`Bigg, 63
`Big, 63
`addtocounter, 43
`arraystretch, 107
`author, 93
`baselineskip, 25, 55
`baselinestretch, 25, 108
`bibliographystyle, 36
`bibliography, 36
`bigg, 63
`bigskip, 11
`big, 63
`boldmath, 47
`cdots, 56, 61
`centerline, 7, 19
`cite, 37
`clearpage, 41
`cline, 16
`dashbox, 72
`date, 93
`def, 118
`displaystyle, 48, 55
`documentclass, 1, 93
`dotfill, 25
`dots, 8
`dvi2tty, 118
`dvipdf, 4, 28, 99
`dvips, 3
`ensuremath, 101
`equal, 108
`fboxrule, 42
`fboxsep, 42
`fbox, 9, 41, 55, 71, 74
`footnotesep, 99
`frac, 48, 60
`framebox, 71, 74
`frame, 9
`hfill, 10, 12, 25
`hline, 15, 54
`hrulefill, 25
`hspace*, 23, 25
`hspace, 25
`imath, 114
`input, 101, 117
`itemsep, 106
`jmath, 114
`kill, 23
`label, 39, 53
`left, 56, 117
`linebreak, 23
`line, 74
`listoffigures, 97
`listoftables, 97
`makebox, 72
`makeindex, 98
`maketitle, 93
`mathbb, 59
`mathscr, 59
`mathfont, 47
`mbox, 51, 57, 58
`medskip, 11
`multicolumn, 19, 101
`newcommand, 36, 100, 118
`newcounter, 42
`newenvironment, 103
`newline, 24
`newpage, 24, 41
`newtheorem, 61, 62
`nocite, 37
`nohyphens, 24
`noindent, 10
`nolinebreak, 24
`nopagebreak, 24
`oddsidemargin, 104
`overbrace, 56
`overline, 56
`overset, 65
`pagebreak, 24
`pagenumbering, 97
`pageref, 40, 62
121
122 INDEX
`pagestyle, 97, 108
`parbox, 18, 19, 72
`parindent, 106
`parsep, 106
`parskip, 106
`partial, 60
`prime, 54
`printindex, 98
`prod, 48
`providecommand, 119
`psset, 78
`raggedright, 57
`raisebox, 57
`refstepcounter, 43
`ref, 39, 40, 53, 62
`renewcommand, 25, 34, 43, 98, 100,
119
`renewenvironment, 103
`right, 56, 117
`samepage, 24
`section*, 98
`section, 5
`selectfont, 38
`setcounter, 43
`setlength, 42, 72, 99
`smallskip, 11
`sqrt, 48
`stackrel, 65
`stepcounter, 43
`subsection, 5
`substack, 65
`tableofcontents, 97
`textstyle, 48
`textwidth, 104
`textfont, 8
`thanks, 94
`theenumi, 43
`thefootnote, 95
`thecounter, 39, 43
`title, 93
`underbrace, 56
`underline, 9, 16, 56
`underset, 65
`unitlength, 72, 73
`url, 24, 33
`usepackage, 25, 41, 58, 59, 61, 77
`value, 43
`vector, 74
`verb, 21, 118
`vfill, 25
`vspace*, 25
`vspace, 25, 55
`widehat, 56
`widetilde, 56
``, 15
pdftex, 78
titlepage, 93
accents, 22
AMS, 1
amsmath, 61
Bezier curve, 84
bibtex program, 28
body, 1
boldmath, 47
box, 72
coauthoring, 118
column speciﬁcation, 16
command line, 1
comment, 20
comments, 1, 118
compile, 1
conditional assignment, 56
counting words, 118
cover page, 93
cross referencing, 35
dash, 10
debugging, 2
derivative, 60
document styles, 1
DOS, 3, 28
dvi viewer, 3
dvips, 4
emftoeps, 86
INDEX 123
environment, 1, 6
abstract, 96, 98
appendix, 98
array, 51, 54, 57
axiom, 62
center, 6
corollary, 62
description, 12, 21
document, 1, 93
enumerate, 14
eqnarray, 53
eqnarray*, 53
equation, 54
ﬁgure, 40, 41
ﬂushleft, 6, 18, 19, 57
ﬂushright, 6
gather, 64
gather*, 64
itemize, 13
large, 9
longtable, 20
picture, 72
quotation, 10
quote, 9
smallmatrix, 64, 65
tabbing, 22
table, 40, 41
tabular, 15, 21, 41, 56
thebibliography, 109
theorem, 61
verbatim, 21
verse, 11
ﬁle
bib, 28, 29, 32, 34–36
bst (bib style), 36, 110
dvi, 1, 78
eps, 86
jpeg, 86
ps (postscript), 3, 78, 86
tex, 1, 32
wmf, 86
ﬂoat, 40
ﬂoat page, 41
ﬂoating object, 40
font size, 4, 9, 55
font style
bold small caps, 9
boldface, 8
boldmath, 47
calligraphic, 47
Greek, 47
italic, 8, 16
math mode, 47, 54, 58
nonEnglish, 22
Roman, 16
sans serif, 8
slanted, 8
small caps, 8, 16
typewriter, 8
underlined, 8
footnote, 95, 99
fractions, 48
ghostview, 3
global setting, 43
graph, 82
Hamiltonian, 60
horizontal ﬁll, 10
hyphenation, 24
index (making of), 98
jpeg2ps, 86
Lagrangian, 59
landscape, 81
Laplace transform, 59
latex command, 1
line spacing, 11, 25
bibliography, 38
list environment, 12
description, 12
enumerate, 14
itemize, 13
local setting, 42
124 INDEX
make index, 98
math display mode, 45, 48, 52
mathbf, 47
matrix equation, 54
message, 2
Overfull . . . , 2
Repeated entry, 37
Underfull . . . , 2
warning, 2
MetaPost, 78
MiKTeX, 3, 77, 86
nodes, 81
package, ix, 1, 4, 8
acronym, 99
algorithm, 110
amscd, 65
amsmath, 61, 64
amssymb, 58
babel, 22
bibunits, 38, 110
bm, 48
cpascal, 110
chemsym, 110
fancyvrb, 111
ﬂoat, 41
fontenc, 9
frankenstein, 110
geometry, 104
gloss, 99
graphicx, 87
graphtex, 110
hyphenat, 24
ifthen, 108
listings, 110
longtable, 20
makeidx, 98
mathrsfs, 59
moreverb, 111
nomencl, 99
psfrag, 88
pstricks, 77
qsymbols, 110
setspace, 25, 108
showkeys, 40
SIunits, 110
theorem, 63
url, 33
wasysym, 110
xypic, 110
page numbering, 108
paragraph positions, 6
preamble, 1, 35, 103, 110
quotation marks, 10
rotate, 81
section, 5
SIAM, 1
spacing, 12, 104
~, 24
horizontal, 25
line, 11, 25
list, 106
math mode, 48, 50, 107
vertical, 11, 25
special character, 1, 12, 15, 20, 21,
24, 29, 45, 103
`textspec , 21
in url, 33
special function, 58
stacking, 65
subscript, 46
stack, 65
subsection, 5
superscript, 46
tabbing commands, 22
table, 15
ticks, 85
transpose, 54
trigonometric functions, 58
units of measurement, 4, 16, 72,
78, 79, 81, 84, 111
INDEX 125
unix, 3, 28, 86
wc, 118
word count, 118
xdvi, 3
YAP, 3
i
Table of Contents
List of Figures List of Tables Preface Acknowledgments
A Sources of L TEX Software
iii vi viii ix ix 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 6 12 15 20 22 23 25 25 28 28 28 28 32 34 36 37 38 39 39 39 40 42 44
1 Overview 2 Text 2.1 Fonts and Paragraphs . . . . 2.2 Lists . . . . . . . . . . . . . . 2.3 Making Tables . . . . . . . . 2.4 Special Characters . . . . . . 2.5 Tabbing . . . . . . . . . . . . 2.6 Line, Page, and Word Breaks 2.7 Spacing . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . 3 Bibliography with BibTE X 3.1 Overview . . . . . . . . . 3.2 The bib File . . . . . . . . 3.2.1 Main body . . . . 3.2.2 Web citations . . . 3.2.3 Additional features 3.3 Declaration and Citation . 3.4 Some Controls . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4 Counters, Labels, and References 4.1 Basic Concepts . . . . . . . . . . 4.2 Intrinsic Counters . . . . . . . . . 4.3 Figures and Tables . . . . . . . . 4.4 Deﬁning Your Own . . . . . . . . Exercises . . . . . . . . . . . . . . . .
ii 5 Math Mode 5.1 Mathematical Symbols . . . . . . . . . . . 5.2 Fractions and Variable Size Functionality 5.3 Arrays and Equations . . . . . . . . . . . 5.4 Special Functions and Alphabets . . . . . 5.5 Derivatives and Integrals . . . . . . . . . . 5.6 Theorems and Deﬁnitions . . . . . . . . . 5.7 Reﬁnements . . . . . . . . . . . . . . . . . 5.8 Grammar . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . 6 Graphics 6.1 Picture Environment 6.2 PSTricks . . . . . . . 6.3 Importing pictures . Exercises . . . . . . . . . 7 Making Special Parts 7.1 Cover Page . . . . 7.2 Abstract . . . . . . 7.3 Other Front Matter 7.4 Back Matter . . . . 7.5 Footnotes . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 46 48 51 58 60 61 63 66 67 71 71 77 86 90
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . .
93 . 93 . 96 . 97 . 98 . 99 . 100 . . . . . . 100 100 102 103 103 108 109 110 111 117 119 121
8 Taking Control 8.1 Your Own Abbreviations and Commands 8.2 Your Own Names, Titles and Numbers . . 8.3 Your Own Environments . . . . . . . . . . 8.4 Your Own Margins and Spacing . . . . . . 8.5 Your Own Output Control . . . . . . . . . 8.6 Your Own Bibliography . . . . . . . . . . Closing Remarks Appendix Some Tips References Index
. . . . . A Your First L TEX Source File . . . . . . . . . . . . . . . . . \parbox Result (Source in Figure 24) . . . . . . . . . . . . Positioning Paragraphs Source (Result in Figure 7) . . . . Alternative enumerate Symbols Source (Result in Figure 37) Alternative enumerate Symbols Result (Source in Figure 36) Variable Sizes Source (Result in Figure 39) . Tabbing Result (Source in Figure 29) . . . .
1 2 4 5 6 6 7 7 8 9 9 11 11 13 13 14 14 15 15 16 16 17 17 19 19 20 20 21 23 23 28 37 42 42 42 44 44 48 48 49 50
. . . . . . . . . Framed Figure with Caption at Top . . . \displaystyle Source (Result in Figure 41) . . . . . . . . . . . . . . . . . . . Centering Source (Result in Figure 9) . . . . . . . . . . . . . . . . . . . . \parbox Source (Result in Figure 25) . . . Variable Sizes Result (Source in Figure 38) . . . . . . . . . . . . . . . . . . . Description List Environment . . . . . . . An Introductory Document Source (Result in Figure 5) . . . . . . . . . . Itemize List Environment Result (Source in Figure 15) . . . . . Multicolumn Source (Result in Figure 27) . . . Skipping Line Spaces Source (Result in Figure 13) . . . A 2 × 3 Table . . . Tabbing Source (Result in Figure 30) . Adding bibtex to the Command Sequence .iii
List of Figures
1 2 3 4 5 6 7 8 9 10 11 12 13 14 16 15 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
A The Structure of a L TEX Document. . . . . . . . . . Some Font Sizes Source (Result in Figure 11) . . . . . . . . . . Nested Tables Result (Source in Figure 22) . . . . Multicolumn Result (Source in Figure 26) . . . . . . . . . . . . . . . Framed Figure with Caption at Bottom . . Some Font Sizes Result (Source in Figure 10) . . . . . . Command Sequence from Source to Postscript or PDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Enumerate List Environment Source (Result in Figure 18) . . . . . . . . . . . . Itemize List Environment Source (Result in Figure 16) . . . . . . . . . . . . . . . . . . . . . . . . A Table with Partially Spanning Horizontal and Vertical Lines Nested Tables Source (Result in Figure 23) . . . . . An Introductory Document Result (Source in Figure 4) . . A Document to Print the Bibliographic Database . . . . . . . . . . . . . . . . . . . . . . Skipping Line Spaces Result (Source in Figure 12) . . . . . . . . . . . . . . . . A 2 × 3 Table with Horizontal and Vertical Lines . . . . . . . . . . . . \displaystyle Result (Source in Figure 40) . . . . . . . . . . . . . Framed Figure 34 Source . . Centering Result (Source in Figure 8) . Positioning Paragraphs Result (Source in Figure 6) . Obtaining Brackets in a Description List Environment . . . . . . . . . . . . . . Enumerate List Environment Result (Source in Figure 17) . . . . . . .
. . .iv 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 Examples to Compare Text and Display Modes . . . . 57 . . . . 50 . . . Applying \includegraphics to Import an eps File . . Source Code for Drawing Histogram of Test Scores . . . . . . Sequence of PSTricks Commands to Draw Histogram . . . Graph Result (Source in Figure 65) . . . . . . eqnarray Environment Result (Source in Figure 43) . . 95 . . . . . \raggedright in parbox Result (Source in Figure 53) . . . . . . 93 . . . . . . . Some Front Matter Speciﬁcations for This Document . . . Footnotes in the Cover Page Source (Result in Figure 75) Footnotes in the Cover Page Result (Source in Figure 74) Authors with same footnote (Result in Figure 77) . . Horizontal Braces Result (Source in Figure 49) . Line Parameters . gather* Environment Result (Source in Figure 55) . Title Page Result (Source in Figure 71) . . . . . 99 . . 53 . . . . . . Commutative Diagram Source (Result in Figure 58) . . . . . 100
. Adding Addresses to Authors . Setting a Footnote Source (Result in Figure 85) . 97 . . . . . . . . . . . . Adding makeindex to the Command Sequence . . 88 . . . . Horizontal Braces Source (Result in Figure 50) . . . . . Vertical Diagram Result (Source in Figure 59) . . . . . . . Specifying Dimensions in \includegraphics . . . 64 . . . 54 . Making an Abstract Result (Source in Figure 78) . 56 . . . . 55 . . 82 . . 96 . . . 99 . . . . . . . . . . . . . 95 . . . . . \raggedright in parbox Source (Result in Figure 54) . . . . . . . . . . . 53 . 73 . 93 . . PSTricks Source for Connecting Nodes . . . 72 . . . . . . . 97 . . Source for Figure 61 . . . . . . . . Setting a Footnote Source (Result in Figure 83) . . . . 95 . . . . . . . . . . Nested Arrays Source (Result in Figure 48) . . . . Authors with same footnote (Source in Figure 76) . . . 83 . . Commutative Diagram Result (Source in Figure 57) . . . . . . . . . . Vertical Diagram Source (Result in Figure 60) . . . 55 . . . 99 . . . 57 . . . . . . . Setting a Footnote Result (Source in Figure 82) . . . . 82 . . Making an Abstract Source (Result in Figure 79) . . . . . . . . gather* Environment Source (Result in Figure 56) . 58 . . 72 . . \flushleft in parbox Result (Source in Figure 51) . . . . . . . . 94 . . . . . 64 . . . Title Page Source (Result in Figure 72) . . . . . . . . . . . eqnarray Environment Source (Result in Figure 44) . . . . . . . . . . 72 . . . . 96 . . . . . . . . . Variety of Objects in Picture Environment . 54 . . . Nested Arrays Result (Source in Figure 47) . . Graph Source (Result in Figure 66) . . . . . . . . . . . . 58 . . . . 66 . . . . . . . . Matrix Equation Result (Source in Figure 45) . . 87 . 66 . . . . . 84 . 88 . 56 . . . . . . 75 . . . . . . \flushleft in parbox Source (Result in Figure 52) . . . Matrix Equation Source (Result in Figure 46) . . .
. . . . . . . . . . . Most of the Preamble for this Book . . . . . . . . . . . . . Changing the Left Margin of a List (Result in Figure 89) . . . . .v 85 86 87 88 89 90 91 92 93 94 Setting a Footnote Result (Source in Figure 84) . . . Document Margins . . . . . . . . . . . . . . \ifthenelse Results (Source in Figure 92) . . . . . . . . . . . . . . . . Changing the Left Margin of a List (Source in Figure 88) . Array with Fixed Width Column Source (Result in Figure 91) Array with Fixed Width Column Result (Source in Figure 90) \ifthenelse Source (Results in Figure 93) . . . . . . . . . . . 100 105 106 107 107 107 107 108 108 111
. Varying \itemsep to control item spacing in a list .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Tabbing Environment . . . . . . . Some Common Mathematical Functions . . . . . . . . . . . . . . Relation Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Greek and Special Letters . . . . . . . . . . . . . . . . Spacing Commands in Math Mode . . Commands/Environments for Controlling Text Position Text Accents and Special Symbols . . . . . . Some Accents for Letters . . . . . . . . . . . . . Binary Operations . . . . . Numerals to Print Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Frequently Used Mathematical Symbols . . . . . . . . . . Commands to Control Document Style . . . . . . . . Accents in Math Mode . . . . . . . . . . . Intrinsic Name Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Margin Parameters . . . . . . . . Transpose of a Vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Special Functions . . . . . . . Commands to Control Fonts in Math Mode . . . . . . Variable Size Mathematical Operation Symbols . . . . . . . . . . . Commands for Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Parameters for \psaxes . . . . . . . . . . . Writing Special Characters . Some Mathematical Operations . . . . . Boxes in PSTricks . . . .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 37 38 39 40 41 Intrinsic Font Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Order Relations . . . Examples of Mathematical Functions . . . . . . . . . . . . . . . . . . . . The \kill Tabbing Command . . . . . . . . . . . . . . . . . . Notation Using mathbb Fonts from amssymb Package . . . . . Set Notation . . . . . . . . . . . . . . . . . . . Some Basic Drawing Commands in PSTricks . . Operators and Quantiﬁers . . . . . . . . . . . . . . . . . . . . . . . . . . Figure and Table Location Options . . . . . . Commands/Environments for Text Font Appearance . . . . . . . . . . . . . Reference Tables . . . . . . . . . . . . . . . . . . . . Spacing Parameters . . Commands/Environments to Organize Document . . . . . . . . . Some Symbols in Logic . . . . . . . . . . . . The \mathfont Commands . . . . . . . . 8 21 22 22 23 41 43 44 46 46 47 49 51 51 54 59 59 59 79 80 86 102 104 106 111 112 112 112 113 113 113 113 113 114 114 114 115 115 115 115 115
. . . . . Conversions of Common Units of Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . Default Settings for enumerate Counters . . . . . . .
Circles. . . . . . . . . . Dots.vii 42 43 44 45 46 Arrows . . . . . . . . . . . . . . . . . . . . . Special Symbols in Both Text and Math Modes . . Commands and Parameters in Picture Environment . . . . . . . . . . . . 116 116 117 117 117
. . . . . . . . . . . Variable Size Symbols . . . . . . . . . . . . . . . . . . . . . . . Triangles and Lines . .
Braams. Originally believing that he could write a program in less than a year that could typeset documents. 10]. You enter some editor that saves plain text ﬁles. it will take longer. or article. By contrast. Carlisle. L TEX (pronounced Lahtek or Laytek) is a collection of macros built on top of TEX that “represents a balance between A functionality and ease of use” [9. you type text freely until you need something special. especially getting used to functioning at the command line. not a word processor. Knuth [8]. For one who is just learning how to use a computer. p. the basics that are covered should take less than 10 hours. A A comprehensive coverage of L TEX and the many enhancements to it is A X Companion [5]. thesis. the ﬁner points require more study. and Rainer Schöpf [2]. Chris Rowley. and he permanently changed the way mathematical A documents are prepared. My goal is to oﬀer enough of an introduction that someone not acquainted with A A L TEX (or with TEX) can write a term paper. and one could do all of the exercises. using L TEX 2ε to produce high quality results. It was 10 years later that he published his seminal book [8]. Frank Mittelbach. low cost publications in mathematics and related disciplines that caused Knuth (pronounced Kahnooth) to invent TEX (pronounced Tek) in the late 1970’s. This is a typesetting program. omitting many of the things L TEX 2ε can do. L TEX 2ε is the current version. In any case. xiii]. a descendant of A L TEX. based on TEX.
A Happy L TEXing. this book is designed to given by the The L TE A be a succinct introduction. Greenberg Denver. but he published articles along the way. like ai +ε
1 + (x − µ)2 dx Φ(ε) . which should be just a few classes. developed by a team of volunteers: Johannes L.
ε→0+
lim
ai
It was the desire to have high quality. such as italic font or a complex mathematical expression. Then. Alan Jeﬀrey. — Harvey J. designed by Leslie Lamport [9]. Colorado
. he actually ended up deﬁning an entire branch of research in computer science. particularly unix. originated by Donald E.viii
Preface
A The majority of this book is about using L TEX 2ε [2. David P. Exercises are provided for guided instruction. For one who is well acquainted with computers.
is at the Comprehensive TeX Archive Network (CTAN) [4]. Last. I thank Allen G. USA. Axel Reichert. Mårten Svantesson.ix
Acknowledgments
The author thanks the many contributors in the comp.text. 2. particularly Donald Arseneau.org/ in Boston. but not least. notably William Briggs.dante. The best A source of these. Andrea Dean. Anton Schwaighofer. and MiKTeX [13] is available free of charge for DOS systems. I also received useful comments from people who read an earlier draft that I made available on the web. Timothy Murphy. Graversen whose indepth review has made this version much better than my original. Jonathan Fine. Sebastian Rahtz. who A taught me L TEX in the ﬁrst place. I especially thank Kasper B. and additional packages that extend the L TEX capabilities (to which I refer in this book). Robin Fairbairns.ac. Germany (in German). and 3.tex. David Carlisle. who were very generous with taking time to answer so many questions on a regular basis.tug. provided feedback that led to several points of clariﬁcation. http://www. MA. http://ctan.de/ in Mainz. Dan Luecking. Bernd Schandl. Thomas Ruedas. at three host sites (and many mirrors):
1. UK.
A Sources of L TEX Software
A The basic L TEX software system is available free of charge for unix systems.
. http://www.tex newsgroup. Denis Girou. Holder.uk/ in Cambridge. One student. David Haller. Herman Bruyninckx. and Matt Swift. These all describe how to search and browse the FTP sites for software and documents.
. Among these are professional societies. \end{document}
Anything following % is ignored (used for comments).tex.g. and slides.
% This is myfile. which you enter by running Start−→Programs−→MSDOS Prompt. as well as more advanced topics for customizing your document. A Are you ready to write your ﬁrst L TEX document? Copy the source ﬁle shown in Figure 2 and name it myfile. All that follows is ignored (could be used for comments). Most publishers have their own style. some of the options. Later. depending upon the style. concentrating on getting started A with using L TEX as quickly as possible. . which is plain text. notably the American Mathematical Society (amsmath style) and the Society for Industrial and Applied Mathematics (siam style). For example. declaring use of packages \begin{document} . which I shall describe in greater detail throughout this book. like margin settings and other preamble speciﬁcations are covered. letter.1
1
Overview
A You will create a ﬁle. The focus throughout this book is on the article style. I refer to myfile. enter: latex myfile (In an MS Windows system. called the L TEX source. Preamble (blank lines do not matter)
Body This is the document environment. the intrinsic document styles are: article. which the
. To keep things simple.
In the preamble.
A Figure 1: The Structure of a L TEX Document. report. I shall be using defaults for almost everything. Then. its suﬃx is . The only one you need to be concerned with now is the dvi ﬁle..tex % notes to yourself can go here \documentclass[options]{style} optional speciﬁcations — e. or by Start−→Run and entering cmd or command into the window. the command line is the DOS command line. which they provide for you to download. book.) This is called compiling your source. there are many options. Further. at the command line.tex as a plain text source ﬁle that you create.tex. Figure 1 shows the structure of this ﬁle. which creates several output ﬁles.
\end{document}
A Figure 2: Your First L TEX Source File
latex program (called a “compiler”) names myfile.. You got messages. or to a diﬀerent name. so you have a collection of backups... which you will come to know and love). This is called debugging your source.) Change 1 to another qualiﬁer each time (e. Case 2. In unix do this by entering: cp p myfile. Sometimes the error message tells you what went wrong. Something went wrong and you need to ask for help. where the destination is either a: or some backup ﬁle name. One of three things will have occurred: Case 1. If all went well. (If you are familiar with
.tex myfile1. Case 3.. such as missing a brace (characters { and }. but they were not fatal errors... ). use copy myfile. or some command was not recognized due to being misspelled.. That way you will know that what you did in the last few minutes contains the error.tex (The p is to keep the date and time of the source ﬁle. .2
1 OVERVIEW
\documentclass{article} \begin{document} Hello world. 2 .. . Do not worry about these. You got a fatal error message.. Many times the message is not very informative. so you are advised to compile often. You got no messages. If you are running under DOS.g. the ﬁrst thing to do is save a backup by copying your source ﬁle to another subdirectory. Overfull \vbox . Underfull \hbox . You must ﬁnd and correct it.dvi. Underfull \vbox .tex destination. Among the nonfatal messages you will generally see are warnings like: Overfull \hbox .
tex (otherwise. In unix this could be pico. If you are in a unix environment. Wordpad or MS Word. when saving the ﬁle. you need to learn how to create. a free software system by Christian Schenk. At the DOS command line you enter: YAP myfile You will see various options for viewing and printing. your installation might already have ﬁle output as the default. it will use . You should even put in hard return characters (i. you must take absolutely no advantage of its formatting. or you can use Notepad. so you ﬁrst need to convert the dvi ﬁle to postscript. In DOS you can use EDIT at the command line. you can view the result with the dvi viewer.) This will result in the creation of the postscript ﬁle myfile. xdvi does not have a print option. Under unix.ps. dvips. and you must continue to specify the suﬃx as . You can print it by any number of ways.) Next you want to view the result. (There is more to do if you are working remotely. At the command line enter: dvips myfile o (The o tells the system you want the output to go to a ﬁle.tex
. you can run a program called ghostview. You will need to ﬁnd out more about viewing and printing postscript ﬁles that suit your particular needs. To view or print a postscript ﬁle under DOS.e. The same conversion program can be run under DOS (and comes with MiKTeX). is called YAP..3 DOS. the viewer that comes with MiKTeX [13]. enter EDIT myfile. xdvi. if not. be sure to specify plain text. lpr myfile. If you want to check that the ﬁle is really plain text. This is done with the program. and you might want to obtain myfile. vi or vim. Summarizing. press Enter at the end of a line instead of letting the word processor do it for you). At the command line enter: xdvi myfile and it will come on your screen. rather than just print. emacs.ps for a variety of reasons. however.) If you are using DOS. and save plain text ﬁles. in which case the o is not needed. including posting it on the web.doc as its suﬃx).ps. and never use tabs. you begin by entering a plain text editor. including the unix command. in which case you might ask someone for help. In MS Word. nothing more need be said. If you use a word processor. edit.
) Once you have your source ready to compile. A This book is designed for quick entry into using L TEX.4
1 OVERVIEW
at the DOS command line and see how the ﬁle appears. Execute these commands for the source ﬁle shown in Figure 2. It tells you how to deﬁne your own commands and how to separate them into an input ﬁle that simpliﬁes changing things. Congratulations!
create/edit compile latex myfile.) The orientation here is by function. but do not be reluctant to read the last chapter.
.ps myfile. and I shall introduce speciﬁc packages throughout this book. The result should be one line of output: Hello World.tex
view/print convert dvips myfile. use your favorite search engine to ﬁnd them. except to say that they are used to fulﬁll some function. and em (like the letter m.” indicated in Figure 1. cm (centimeters). which can be printed. (One of A the strengths of L TEX is the community of people who provide packages for everyone to use at no cost. and if all is well. like notation.pdf
Figure 3: Command Sequence from Source to Postscript or PDF Now change your document to specify a font size of 12pt (default is 10pt) by changing your ﬁrst line to the following:
\documentclass[12pt]{article}
The “pt” (abbreviation for “point”) is one of the units of measurement. enter your dvi viewer. about 1 A E 72 in. other units used in many parts of L T X are in (inches).dvi dvipdf
print/post
myfile. beginning with how to write text. which is a printer measure equal to the width of M in the current font). You can alternatively (or also) convert the dvi ﬁle to a pdf ﬁle by the command dvipdf myfile These steps are given in Figure 3. enter latex myfile. Under unix or DOS use dvips to convert the dvi ﬁle to a postscript (ps) ﬁle. I also cannot elaborate just yet on “using packages. (There are some free text editors on the web.
consider how to make sections and subsections in article style. A will demonstrate the superior quality of the L TEX results.5
2
Text
We begin by illustrating the most common text formatting.
lots
Skipping four lines is the same as skipping one line . Note the automatic numbering. and how extra spaces and blank lines have no eﬀect.) First.
\section{This is a Section} \subsection{This is a subsection} This is the body of the subsection.it starts a new paragraph. much like you A would want in a word processor. % Blank lines mean nothing here. especially tables. (The power of L TEX will be evident when we get to mathematical expressions. and I can put in of blanks with no effect. \subsection{Here is another subsection} \section{Here is another section} \end{document}
Figure 4: An Introductory Document Source (Result in Figure 5)
. in the preamble. but even some text. Figure 4 is the source that produces the result in Figure 5. showing how sections and subsections are deﬁned. I can move to a new line anytime. \begin{document} % Begin document "environment".
\documentclass[12pt]{article} % We have defined the document to be an article using 12 point font.
ﬂush right. and justiﬁed (the default). \end{flushleft} \begin{flushright} This is another paragraph. but in the flushright environment.1
Fonts and Paragraphs
Figure 6 shows the source to produce diﬀerent paragraph positions: centered. ﬂush left. The added space you see between the above paragraphs is due to entering those environments. Text remains centered as long as we remain in this environment. \end{environment}
\begin{center} The text is centered because I have entered the center environment. . The general form of an environment uses the following syntax: \begin{environment} .
1. a concept you need to understand about L TEX.2
Here is another subsection
2
Here is another section
Figure 5: An Introductory Document Result (Source in Figure 4)
2. Skipping four lines is the same as skipping one line — it starts a new paragraph.
Figure 6: Positioning Paragraphs Source (Result in Figure 7)
. Note that these are A environments. You will have occasion to use all four paragraph positions. I can move to a new line anytime. . and I can put in lots of blanks with no eﬀect. and have begun the flushleft environment.6
2 TEXT
1
1.1
This is a Section
This is a subsection
This is the body of the subsection. \end{center} \begin{flushleft} Now we are out of the centering environment. \end{flushright} I am back to normal justification.
you can use the \centerline command. shown in Figures 8 and 9. Text remains centered as long as we remain in this environment. You will have occasion to use all four paragraph positions. I am back to normal justiﬁcation.} This continues after centering. This continues after centering.
This precedes center environment. Now we are out of the centering environment. Figure 7: Positioning Paragraphs Result (Source in Figure 6) Instead of the center environment. they diﬀer in that the environment skips a line before and after the paragraph. \end{center}
Figure 8: Centering Source (Result in Figure 9)
. but in the ﬂushright environment. The added space you see between the above paragraphs is due to entering those environments. This precedes centerline.2. \centerline{This line is centered. This is another paragraph. \begin{center} This line is centered. and have begun the ﬂushleft environment.1 Fonts and Paragraphs
7
The text is centered because I have entered the center environment.
This is \textsl{slanted}.8 This precedes center environment. This is \textit{italic}. sc. This is \textsf{sans serif}. For example. (The ⇒ symbol can be read as “produces. tt}. slanted. produces: This paragraph is not indented. it. small caps. Table 1 lists the fonts that are intrinsic in a basic latex installation. sans serif. sf.”) Note the use of the \dots command. This is \texttt{typewriter}. . This continues after centering. A \textit{group} is defined on a set of elements \dots ⇒A group is deﬁned on a set of elements . as seen in Table 1. Figure 9: Centering Result (Source in Figure 8)
2 TEXT
You can also suppress indentation of the ﬁrst line of a paragraph with the \noindent command. The argument of \textbf is \textit{bolditalic}. you will have particular use for the italic font. rm. (More fonts are available in packages. typewriter. Here is an example: \noindent This paragraph is not indented. italic. This is \textsc{small caps}. where font is one of {bf. This line is centered.) In technical writing. as it is used when introducing a new term.
. For example. This line is centered. roman. usually free of charge.
Some combinations of font styles can be produced. Table 1: Intrinsic Font Styles What you write This is \textbf{boldface}. . sl. This continues after centering. The general form is \textfont{text}. which produces the ellipsis. This precedes centerline. \textbf{\textit{bolditalic}} ⇒ bolditalic. ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ How This This This This This This This it is is is is is is is appears boldface. This is \textrm{roman}.
Font size can also be varied at will. You might want to make something {\small small} or {\footnotesize smaller} or even {\scriptsize smaller still}. you must put \usepackage[T1]{fontenc} in your preamble to obtain:
\textbf{\textsc{bold small caps}} ⇒ bold small caps. Figure 11: Some Font Sizes Result (Source in Figure 10) The use of braces to enclose a font size speciﬁcation is like an environment. p.1 Fonts and Paragraphs
9
A Not all combinations are in the basic L TEX 2ε installation. Figures 10 and 11 give the source and result for common variations. Optionally. Here is an example using the quote environment. The environment syntax is useful when you want to keep the size for a large block of text. \end{size}. Now consider ways to indent a block of text. These size variations can be combined with font styles. and the braces format is useful for short phrases. You can make it really tiny.}.
. We can also frame text just by writing \frame{text}. Notice how the paragraph spacing changes to accommodate the variation in font size. You can also make it {\huge huge}.
Figure 10: Some Font Sizes Source (Result in Figure 11)
You can make the text large or
You can also make it .\end{large} produces the same result as {\large This is large. . For example. (More on framing in §6. we can explicitly use the environment syntax: \begin{size} . (There is no intrinsic environment for font styles.) To overline is as straightforward. such as using {\Large\textbf{heading}} for some heading.
You can make the text {\large large} or {\Large larger} or even {\LARGE larger still}. In particular. You might want to make something small or smaller or even smaller still. which was generated by putting \begin{quote} before the text and \end{quote} after it:
huge
larger or even larger
still. but learning it must wait until we enter math mode. \begin{large} This is large. We can give frame some room around the edges by using \fbox instead. 71. You can make it really {\tiny tiny}.) It is straightforward to underline text — just write \underline{text}. .2.
. to create this more stylistic quotation punctuation. I used ‘‘ ’’.10
2 TEXT The construction of the real number system. Sometimes it is important to make a completely ‘unbiased’ decision. in ways and for reasons that are only very indirectly reﬂected in his overt activity. • The dash that appears before each name is created by three minus signs.” — Donald E. The convention is that one dash is for hyphenation. to make the line ﬂush right. The more minus signs you use. was motivated by the need to ﬁx calculus.”
. this can be overridden by the \noindent command. “Computers do not dream.) Here is an example that was created by putting \begin{quotation} before the text and \end{quotation} after it. but we know what they indicate: a great deal of information processing goes on far beneath the surface of man’s purposive behavior. the longer the dash.e. or a sequence of one line quotes.
The quote environment is intended for short quotes. except the ﬁrst line of each new paragraph is indented. It is also rumored that some college professors prepare their grades on such a basis. notably by Dedekind cuts. Turing “There are reports that many executives make their decisions by ﬂipping a coin or by throwing darts.. for example in situations where a ﬁxed decision made each time would cause the algorithm to run more slowly. by skipping a line and entering \hfill (which means horizontal ﬁll). after their quote. separated by blank lines. generally one short paragraph (as above). two are for ranges. The indentation is the same as the quote. The quotation environment is used for long quotations. not " ". any more than they play. etc. having more than one paragraph (separated by blank lines).e. such as page numbers. We are far from certain what dreams are good for. Here are some other things to notice about this example: • There are left and right quotation marks. which ran into trouble due to insuﬃcient rigor in dealing with limits. Turing and Donald E. Knuth. Knuth The quotes are by two pioneers of algorithms. Alan M. and three are for punctuation — i. (Just as in the regular text. use preceding “i. Their names appear on the right.” — Alan M. this ability is occasionally useful in computer algorithms.
men who are thus ignorant are unable to perceive their own ignorance and so do not seek a remedy. medium and big. The space you now see just above is a small skip. The space you see above is a big skip.
The space you now see just above is a small skip. each line is a stanza in the verse. The following was generated by putting \begin{verse} before the text and \end{verse} after it: Neglect of mathematics works injury to all knowledge.1 Fonts and Paragraphs
11
• There is extra space between the two quotations. The space you see just above is a medium skip. Figure 13: Skipping Line Spaces Result (Source in Figure 12) The verse environment indents oppositely: lines after the ﬁrst. And what is worse.
Figure 12: Skipping Line Spaces Source (Result in Figure 13)
This is a ﬁrst line. Later. Figures 12 and 13 illustrate three levels of skipping: small. since he who is ignorant of it cannot know the other sciences or the things of this world. \bigskip The space you see above is a big skip. \medskip \smallskip
The space you see just above is a medium skip. This was done with the \bigskip command. . we shall look at a way to have a much ﬁner range of vertical spacing.
This is a first line. (Designed for poetry. This is just an ordinary line space. }. . — Roger Bacon The italics were speciﬁed in the usual way.2. This is just an ordinary line space. by enclosing Bacon’s verse with \textit{.
.
Basic Document Preparation. A tilde. rather than a new line. To illustrate.Roger Bacon \end{verse}
2. and its versatility puts it far ahead of word processors.2
Lists
There are three intrinsic list environments. I will show you how to do virtually any mathematical expression in line with the text. the result would be L TEXprovides. here is the use of a description list environment A to itemize steps involved in learning L TEX. There are a great many things to learn beyond the simple introducA tion when using L TEX to prepare a thesis.
A LT
Two new things appear in the example: the use of \LaTeX to produce Without the EX. even with a space after \LaTeX in the source. L TEX provides a means to make tables with the tabular environment. Other.
A Mathematics. distinguished by what appears at the beginning of each item: number. following \LaTeX. but this time it is on the last line of the verse.. Knowing how to create a bibliography. and list items are enough to prepare a basic document without mathematics or tables (like a resume). (The reason is that a space (or some delimiter) is needed after \LaTeX (or any keyword) in order to distinguish it completely. which requires no space. } \hfill . or in math display mode. this form of indentation makes it clear. like a comma.12
2 TEXT
and if a stanza runs long. in particular with BibTE X. and one might want a punctuation mark. again from the \hfill command.. and the use of ~ (called “tilde”) to enter a space. report or article. whose source is indicated by Figure 14. This has progressed a great deal in the past few years thanks to many people who have provided packages free of charge. or your description (perhaps nothing).)
.) Bacon’s name appears ﬂush right. bullet. Knowing how to setup the latex source ﬁle. make paragraphs. vary fonts. This is a power of L TEX and one reason why it has become standard in writing mathematical papers.
Bibliography. This is achieved by not skipping a line after the verse: \begin{verse} \textit{Neglect of mathematics .
A Making Tables.
Graphics.
] There are a great many things to learn .] Knowing how to setup . Note the indentation of each item and the spacing between items.2. • This is item 2 and we shall limit to just this few.. If present. A blank line within an item does create a new paragraph. the description 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. Unlike the verse environment.] This is the power of \LaTeX~ and one ..] \LaTeX~ provides a means .. using the indentation of the itemize environment..... Figure 16: Itemize List Environment Result (Source in Figure 15)
...2 Lists
\begin{description} \item [Basic Document Preparation...} \end{description}
produces the following result: This is how one item in a description list environment looks with no optional text at the beginning. it is printed in boldface. With no option. – A second (nested) itemized list changes the bullet and indents another level. Figures 15 and 16 illustrate the itemize list environment. which prints bullets. and the lines extend all the way to the right margin. \end{description}
13
Figure 14: Description List Environment The text within the square brackets is an option. Blank lines before an item have no eﬀect. For example.] Knowing how to create a bibliography .
\begin{description} \item \textsf{This is how one item in a description list environment looks with no optional text at the beginning. but any type of list can be nested within any other type.
• This is item 1 and our task has just begun.] This has progressed a great deal in the . \item [Mathematics. as in this example. Next. You see the nesting of two itemize lists. \item [Graphics. \item [Other. \item [Making Tables. \item [Bibliography. the ﬁrst line goes almost to the left margin..
2 TEXT
Blank lines
\item This is item 2 and we shall limit to just this few. Figures 17 and 18 illustrate with three levels of nesting. before an item have no effect. \begin{enumerate} \item Back to item 1. \begin{enumerate} \item One again! \item Two (b) or knot 2b? \end{enumerate} \end{enumerate} \end{enumerate}
Figure 17: Enumerate List Environment Source (Result in Figure 18)
. but we are not yet done. \item Two is new. the numbering changes at each level. I describe the enumerate list environment. A blank line within an item does create a new paragraph. using the indentation of the itemize environment.
\begin{enumerate} \item This is item 1. With nested enumeration. and we are having fun.14
\begin{itemize} \item This is item 1 and our task has just begun. \item This is item 2. \begin{itemize} \item A second (nested) itemized list changes the bullet and indents another level. \end{itemize} \end{itemize}
Figure 15: Itemize List Environment Source (Result in Figure 16) Finally. and it’s time to number anew. where the default numbering is with Arabic numerals.
The column speciﬁcations can have  on either side to indicate a vertical line. This is item 2. i. \\. In the body of the table. How it appears left 1 center 2 right 3 What you write
\begin{tabular}{lcr} left & center & right \\ 1 & 2 & 3 \end{tabular}
Figure 19: A 2 × 3 Table We can draw a horizontal line before any new row by specifying \hline. . last row spec [\\ options] \end{tabular}
As indicated. abbreviated by just one character: l. The way to vary vertical line drawing is with the column speciﬁcations: put  only where you want a vertical line. This is item 1.3 Making Tables
15
1. and we are having fun. (b) Two is new. Figure 20 illustrates a combined use of these options. Each column speciﬁcation can be left. c or r. One again! ii.3
Making Tables
which has the following
A table is made with the tabular environment. each row ends with two backslashes. To draw a line after the last row.2. . Two (b) or knot 2b? Figure 18: Enumerate List Environment Result (Source in Figure 17)
2. (a) Back to item 1. Figure 19 shows an example of a 2 × 3 table. 2. The way to vary horizontal line drawing is by using
. syntax: \begin{tabular}{column specs} options ﬁrst row spec \\ . respectively. We could draw lines that span some rows and/or columns. center or right. and it’s time to number anew. enter \\ \hline (the \\ is simply part of the syntax and does not add an extra row to the table). but we are not yet done. each column is separated by &.
16 How it appears 110 210 120.12 220. 130 230 What you write
2 TEXT
\begin{tabular}{lcr} \hline 110 & 120 & 130 \\ \hline 210 & 220 & 230 \\ \hline \end{tabular}
Figure 20: A 2 × 3 Table with Horizontal and Vertical Lines \cline{ﬁrst col last col } instead of \hline. This is illustrated in Figure 21. How it appears Name Bob Sue Test 1 67 72 Test 2 72 67 What you write
\begin{tabular}{lcc} Name & Test 1 & Test 2 \\ \cline{11} Bob & 67 & 72 \\ Sue & 72 & 67 \\ \cline{23} \end{tabular}
Figure 21: A Table with Partially Spanning Horizontal and Vertical Lines We can 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 specifying \textsf{ before entering the tabular environment (and closing with } just after it). • Within the tables, fonts are varied: Roman is in the Roman font, speciﬁed by \textrm{Roman}, Greek is in italic, speciﬁed by \textit{Greek}, and upper case is in small caps, speciﬁed by \textsc{upper case}. • A new column speciﬁcation is introduced: p{length}, where any unit of measure can be used as the length of the spacing. In this example .3 inches is speciﬁed. Note that this counts as a column, so you see && to separate the two tables, each being a column of the main table. • The \underline command is used to underline Table 1, which is column 1 of the main table, whereas \cline{33} is used to underline all of column 3 of the main table, headed by Table 2. There are times when we want to put a good bit of text into some columns
2.3 Making Tables
\textsf{ \begin{tabular}{lp{.3in}l} \\ \underline{Table 1} && Table 2 \\ \cline{33} \\ \begin{tabular}{lc} \hline Object & Symbols used \\ \hline variable & lower case \textrm{Roman} \\ parameter & \textit{Greek} \\ constant & \textsc{upper case} \textrm{Roman} \\ \end{tabular} && % Begin Table 2 \begin{tabular}{rcc} \hline * & 1 & 2 \\ \cline{22} & 3 & 4 \\ \cline{11}\cline{33} \end{tabular} \end{tabular} } % end sf
17
Figure 22: Nested Tables Source (Result in Figure 23) Table 1 Object variable parameter constant Symbols used lower case Roman Greek upper case Roman Table 2
*
1 3
2 4
Figure 23: Nested Tables Result (Source in Figure 22) of a table. Suppose, for example, we write the following:
\begin{tabular}{ll} \hline This amount of text is too long to fit on one line of the page. & This is column 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 column 2.
One solution is to insert new rows and break up the text manually:
18
\begin{tabular}{ll} \hline This amount of text is too long to fit on one & This is column 2. \\ line of the page. & \\ \hline \end{tabular}
2 TEXT
⇒
This amount of text is too long to ﬁt on one line of the page.
This is column 2.
Instead, one can assign a ﬁxed width to a column by specifying p{length}. For example,
\begin{tabular}{p{2in}l} \hline This amount of text is too long to fit on one line of the page. & This is column 2. \\ \hline \end{tabular}
⇒
This amount of text is too long to ﬁt on one line of the page.
This is column 2.
Another solution is to use the \parbox command (short for “paragraph box”). This has the form \parbox[option]{width}{text}, where the option is the placement: t = top and b = bottom (default is center). Here are two examples:
\begin{tabular}{ll} \hline \parbox{2in}{This amount of text is too long to fit on one line of the page.} & This is column 2. \\ \hline \end{tabular}
⇒
This amount of text is too long to ﬁt on one line of the page.
This is column 2.
\begin{tabular}{ll} \hline \parbox[t]{2in}{This amount of text is too long to fit on one line of the page.} & This is column 2. \\ \hline \end{tabular}
⇒
This amount of text is too long to ﬁt on one line of the page.
This is column 2.
They diﬀer only in the placement of the paragraph box, the latter being at the top to align it with column 2 in the manner shown. When making a column or parbox small, the spacing can become unsightly due to being justiﬁed. This is overcome with the ﬂushleft environment. Figures 24 and 25 illustrate this, and note that it contains other commands that can be in any paragraph.
rather than a ﬁxed constant. on either side. The second argument is any valid column speciﬁcation.3 Making Tables
\begin{center} \begin{tabular}{ll} \parbox[t]{3in}{\begin{flushleft} This is column 1.
Figure 25: \parbox Result (Source in Figure 24) Any measurement. For example. the third argument is the text. and I might want to display something: How sweet it is. Figures 26 and 27 illustrate these uses of \multicolumn. . \multicolumn{number }{col spec}{entry}. If we want some heading to span several columns. which I have put in sans serif font. Suppose. this is done by the command. such as the width of a paragraph box.
This is column 2.} \end{flushleft} } \end{tabular} \end{center}
19
Figure 24: \parbox Source (Result in Figure 25)
This is column 1. or without. see exercise 9 at the end of this chapter and consider \parbox{. r. we want the columns to be left justiﬁed.}}\medskip This is not the same as \medskip\fbox{\centerline{How sweet it is. The ﬁrst is used to center ‘Test number’ over columns 2 and 3. which I have put in sans serif font. for example... The \multicolumn command can also serve to override some column speciﬁcation. can be determined by some length parameter. c. The line in the source begins with & to skip column 1. then the
. This is not the same as How sweet it is. Finally. a vertical line speciﬁcation. but we want the headers to be centered. and I might want to display something: \medskip\centerline{\fbox{How sweet it is.3\linewidth}.}} \end{flushleft} } & \parbox[t]{1in}{\begin{flushleft}\textsf{This is column 2. such as l. This must be in the range 1 to however many columns remain from the current position. with.2. The ﬁrst argument is the number of columns to span (starting where \multicolumn is speciﬁed).
In particular. (Recall that the braces by themselves create a local environment. A but the longtable package enables automatic page breaks by the L TEX compiler. (You obtain the package from CTAN [4].) In the preamble. the vertical line at the end is missing because c was speciﬁed instead of c. \ delimits every L TEX command. which has most of the same options.) When using a keyword to specify a special character. like {\large. . Of particular importance are the braces.20
2 TEXT
\multicolumn speciﬁes 2 columns. Table 2 (next page) illustrates this with commonly
. The Appendix contains complete tables of these special characters (including those I do not cover explicitly in the chapters).5 70. instead of the tabular environment. How do we print such characters? One way is with the symbol. and % ends a line. like \%. }. centered with vertical lines before and after.5
Figure 27: Multicolumn Result (Source in Figure 26) Tables that are too long to ﬁt on one page could be broken manually. Then. is needed.5 \\ \hline & \multicolumn{2}{c}{Taken in class} \\ \cline{23} \end{tabular} \end{center}
Figure 26: Multicolumn Source (Result in Figure 27) Test number 1 2 67 72 72 67 Taken in class
Student Bill Charleetah
Average 70. The last use of \multicolumn centers ‘Taken in class’ over columns 2 and 3. specify \usepackage{longtable}. Unlike the ﬁrst use. itself.
\begin{center} \begin{tabular}{lccc} & \multicolumn{2}{c}{Test number} \\ \multicolumn{1}{c}{Student} & 1 & 2 & Average \\ \hline Bill & 67 & 72 & 70. The second use simply centers the ‘Student’ header.5 \\ Charleetah & 72 & 67 & 70. like \textbackslash. Other times a keyword. enabling comments. written as \{ \} to obtain { }. in that they delimit A something.
2. .4
Special Characters
We have already seen that some characters are special. it appears with whatever font is active. specify the longtable environment.
Unlike all other commands.
Figure 28: Obtaining Brackets in a Description List Environment
Table 2: Writing Special Characters Character (Roman) {} %$#&_ \ ^ ~ r [] How you write it \{ \} \% \$ \# \& \_ \textbackslash \textasciicircum \textasciitilde \textregistered {[ ]} Other fonts italic {} %$#&_ \ ^ ~ r [] large
{} %$#&_ \ ^ ~ r []
Another way to print the unprintable is with the verbatim environment or the \verb command. which can contain any character except itself. The verbatim environment uses the usual syntax: \begin{verbatim} .2. . \end{description}
[This is not option] for item. What you write
\begin{description} \item [This is option] for item. \end{verbatim}
. [ ]. illustrated in Figure 28. (Another is in the tabular environment (page 15).) How it appears This is option for item. The brackets. but I omitted a discussion of position options that are speciﬁed by brackets. One example is the description list environment.4 Special Characters
21
used special characters. It uses any other character to delimit a string. except when they are used to delimit an option in the syntax. we can write \verb@{}%$#\@ to generate the string {}%$#\ (delimited by @). in which case they can be obtained by enclosing them in braces. are diﬀerent because they can be entered directly. \end{description} \begin{description} \item {[This is not option]} for item. \verb does not use braces to delimit its argument. which is printed in typewriter font style. . For example.
\\ ends each row. \"{b}\~{c}\^{d} ⇒ b˜d. ?‘⇒¿ and \aa⇒å. the ﬁrst sentence continues normally.. In addition. such as Babel [1] (also see [5. For example. Another class of special characters are letters with accents. A L TEX has a basic library of accents and special characters for writing in languages other than English. 20). these are not suﬃcient. In some cases.22
2 TEXT
This is how the source code was created for the ﬁgures. write Poincar\’{e} to have Poincaré and G\"{o}del to have Gödel. like Figure 26 (p. without extra spaces. Table 4: The Tabbing Environment What you see Begin: set tab 1. Table 3: Some Accents for Letters What you write \"{a} \‘{e} \’{i} \~{o} \^{u} ⇒ ⇒ ⇒ ⇒ ⇒ What you see ä è í õ û
2. and \> to move to a tab setting. Chapter 9]). . An accent could be applied to any letter. For that purpose there are some packages. . yet it is needed to deﬁne the tab. so that the position of the tab is not equivalent to that of a table’s column. Table 4 shows a simple case with two basic tabbing commands. a complete table is in the Appendix. Table 5 illustrates how this is solved with the
. some of which are shown in Appendix Table 29 — e.g. particularly if the entire document is to be in a nonEnglish language. Table 3 shows some common examples. even if it does not relate to some ¨cˆ language — for example. but unlike the tabular environment. \= to deﬁne a tab setting. set tab 2 skip to 1 then to 2 skip to 2 What you write
\begin{tabbing} Begin: \=set tab 1\dots \=set tab 2\\ \>skip to 1 \>then to 2\\ \> \>skip to 2 \end{tabbing}
Sometimes we do not want to have the longest portion of text ﬁrst.5
Tabbing
The tabbing environment provides an alternative to the tabular environment by letting you set your own column tabs.
then speciﬁes \kill instead of \\ to suppress (or “kill”) the printing of the line. In the ﬁrst tabbing. Page. this could result in an undesirable appearance. Table 5: The \kill Tabbing Command What you see 13 sting like a bee 468on’t be late d What you write
\begin{tabbing} 13 \= sting like a bee \\ 468 \> don’t be late \\ \end{tabbing} \begin{tabbing} 468 \= don’t be late \kill 13 \> sting like a bee \\ 468 \> don’t be late \\ \end{tabbing}
13 sting like a bee 468 don’t be late
Figures 29 and 30 illustrate the tabbing environment with ﬁxed ﬁeld widths. Page.6
Line.
\begin{tabbing} \= \hspace*{. and Word Breaks
You can cause a new line by entering \linebreak. then it uses the name of the last ﬁeld to set what follows.5in} \= \hspace*{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 Source (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 (Source in Figure 29)
2. like the following:
. and Word Breaks
23
\kill command. making ‘468’ extend past the tab.2. the lines are in the order we want.6 Line. It ﬁrst uses the \hspace* command for horizontal spacing. The second tabbing puts the longer ﬁeld ﬁrst. in order to set the tab correctly. When text is justiﬁed (the default). but the tab is set by the shorter string ‘13’.
use the space character ~. 10’. Sometimes. you want to suppress hyphenation. Also. however. The \newline command forces a new line without justifying it. even if it means extending into the right margin.} ⇒Here is the extreme example. it is better style to keep certain ‘words’ together. such as ‘ﬁgure 1’ or ‘p. and follow the simple installation instructions. This can be done by specifying \usepackage{hyphenat} in the preamble. \textsf{Here is the extreme \newline example. preventing a line break.
2 TEXT
is
The \nolinebreak command works analogously. you obtain the following:
A Word breaks are hyphenations that L TEX does for you. Sometimes. Sometimes. There are two commands to force a page break: \pagebreak and \newpage. you want to suppress hyphenation.
{\samepage line 1 \nopagebreak line 2 }
A Word breaks are hyphenations that L TEX does for you.}
Then.) Then. to suppress hyphenation. rather than completing the line as \pagebreak does. enter:
\nohyphens{Word breaks are hyphenations that \LaTeX\ does for you. however. you specify the \nohyphens command. however.} ⇒This example extreme. Here is an example that keeps line 1 on the same page as line 2. The \newpage command follows the analogy with \newline in forcing a page break precisely at the point it is speciﬁed. The \nopagebreak command disallows a page break immediately following the next blank line.
.24 \textsf{This example is \linebreak extreme. To prevent a line break where you want a blank. to suppress it. For example. The \samepage command prevents a page break within its scope. (You might have to download the package from CTAN [4].~10. We would thus write figure~1 or p. the ﬁrst sentence of this paragraph has a hyphen. you want to suppress hyphenation.
. .
That is why you see the 1 inch space at the beginning of the second line.2. . For example. These have one argument: the amount of space to be inserted. Submit a printed copy of both the L TEX source (tex ﬁle) and
1. . Be sure your name is on each. The easiest way to control line spacing throughout your document is to specify usepackage{setspace} in your preamble. . . you use \vspace*{2in} to put a 2 inch margin at the top (\vspace would not insert the space). However. . . . . . The vertical space is not added if this goes to the top of a new page.3in} here. . one diﬀerence is that you need to change font size before this change goes into eﬀect. . . . \hspace would not insert the 1 inch.2}\small\normalsize the associated postscript result (ps ﬁle). .7
Spacing
We have already seen the use of ~ to insert one space and \hfill to put the remaining text ﬂush right. . that is what \vspace* does. . . . . . . . . The \hspace command has no eﬀect at a line boundary. The most versatile method to insert horizontal spaces is with \hspace and \hspace*. . . . . . . . . This acts like renewing the \arraystretch setting and remains in eﬀect until changed. . In particular. . I insert . .7 Spacing
25
2.2} to increase the spacing modestly (actual increase depends upon the font size). . but the \verb\hspace* \hspace*{1in} inserts the space no matter what. . \hrulefill Analogously. For example. Two variations of \hfill are: \dotfill . . . ⇒ I insert . specify \renewcommand{\baselinestretch}{1. You could write \renewcommand{\baselinestretch}{1. vertical spacing is controlled by \vspace. You can. . if you want to make your own title page. . Write a paragraph in article [and letter] style with the following properties:
. . This gives you three commands: \singlespacing \onehalfspacing \doublespacing Right after you specify one of these. . . . . .
A Exercises. but \hspace* does. . . . so vspace{\baselineskip} skips one line at the next new line. that spacing will commence. . . .3 in here. at the very beginning of your document. .3~in \hspace{. . however. The height of one line of normal text is in the keyword \baselineskip. the previous sentence is written as:
The \verb\hspace command has no effect at a line boundary. . . but the \hspace* inserts the space no matter what. \vspace* and \vfill. . .
Write a paragraph in article style and make a cover page with the following properties (like the cover page of this document): • All lines are centered.
. 5. (b) Each font style in Table 1 is used for one complete word. • Your name appears second in letters that are not as large as the title. but larger than normal size. and it is preceded by extra space. (c) Both paragraphs are indented. • The title appears ﬁrst in very large letters. (d) There is added space between paragraphs. Produce the following table: Colors Primary Secondary Red Green Blue Orange Yellow Purple 6. Give an enumeration of at least three things you like about mathematics. (b) No paragraph is indented. 4. Produce the following table (including the accents and alignments). (c) Each font style in Table 1 is used for two consecutive complete words. • Your email address appears third. • Course number and title appears next. • Date appears last. with extra space preceding it.26
2 TEXT (a) Each font style in Table 1 is used as one letter in a word that has more than one letter. Give the same list without numbers. • Your web address appears fourth. 2. 3. with extra space preceding it. Write two paragraphs in article [and letter] style with each of the following properties: (a) Default indentation on both paragraphs.
Create a 3column text such that each column is a paragraph of arbitrary length using about 1 of the page width each. Use the tabbing environment to produce what you see on page 30. How can you have an entire table whose columns are of ﬁxed width? 9. Produce the following:
rate of mass accumulation in the compartment
net rate of mass entering the = compartment by convection
net rate of + mass entering by diﬀusion. Use the tabbing environment to produce the following: apples integral derivative grapefruit sum diﬀerence variables constants 11.7 Spacing Mathematician Gabrielle Emilie Le Tonnelier de Breteuil Marquise du Châtelet Benjamin Banneker Sophie Germain Julius König Rózsa Péter 7.
. Payoﬀs ($) Player A 1 4 2 5 3 6 Player B 1 3 5 2 4 6 Birth Death
27
1706 1731 1776 1849 1905
1749 1806 1831 1913 1977
8. 3 10. Produce the following table. 12.2.
bib.1
The bib File
Main body
For purpose of this introduction.tex
view/print convert dvips myfile.bib.4. until you do not have any “unresolved” bibliography citations. BibTE X [11] was developed by Oren Ptashnik and is available free of charge. It reads a plain text ﬁle.1
Bibliography with BibTE X
Overview
It might seem strange to have this section so early. and I want them to use BibTE X. The bib ﬁle contains the bibliographic database. suppose your bibliography is in a ﬁle called mybiblio. about which you need not be concerned). you do not have to bibtex myfile again until you change your bib ﬁle or add a citation.
create/edit compile latex myfile.2
3. We
.2. The execution looks like this (same under unix and DOS): latex myfile bibtex myfile latex myfile You might have to compile with latex more times. instead of with §7.ps myfile.pdf
Figure 31: Adding bibtex to the Command Sequence
3.dvi dvipdf bibtex
print/post
myfile. from which a second latex compilation causes the bibliography to be created. which could extend beyond one document. The bibtex program that you apply to your source creates another ﬁle (which you need not examine). Once this is successful. but that name is arbitrary as long as it ends with . This added loop is illustrated in Figure 31. That is because I require students to produce an annotated bibliography early in the semester.28
3 BIBLIOGRAPHY WITH BIBTE X
3
3. So here we are. called a bib ﬁle (plus one of the ﬁles created by the latex compiler.
you can put both of their names. ﬁeld = "value". here are a few things to note. year = "1989". labels are casesensitive.
• Each bib entry must have a unique label. Knuth". Before listing each style (article is one style) and the ﬁelds they can or must have (author is one ﬁeld). some people add another keyword.
A • The label is arbitrary. The use of one keyword is somewhat simplistic and could cause problems with a great number of entries because the labels must be unique. address = "Reading. but do not use any L TEX special characters or blanks. with more than 2. Here are two styles I have seen. (Linguistically. . Knuth’s book [8] would be entered as follows: @article{tex.) In the ﬁrst form. title = "The {\TeX} Book". the label is speciﬁed as tex and it must be followed by a comma. Each entry has the following form: @type {label . if there are two publications by the same authors in the same year. . In the second form. publisher = "AddisonWesley Publishing Company". the use of the Latin et al. after the year (no blank). } Most authors develop a style to labeling bibliographic entries.89 knuth:tex
With two authors. } For example.
. in formal writing follows this rule. if there are two publications by the same authors in the same year. have two entries with tex as their label. so tex is not the same as TeX. In the example. which are the entries you want to include in its database. Also. which you might consider: Form author . you can add et al. . for example. . You must discover what style works best for you. b.2 The bib File
29
begin with the most important part of your bib ﬁle. . edition = "15th". so it can be cited without ambiguity in the source ﬁle. MA".year author :ﬁrst_keyword_in_title Example knuth. some people add a.3. We cannot. author = "Donald E. .
inbook is a part of a book. and ﬁelds are separated by commas (hence the comma after the terminal quote). publisher. Required ﬁelds: author or editor. and it gives ﬂexibility if you want to add a ﬁeld or change the order. chapter and/or pages. booktitle. month. such as a chapter or just some range of pages.30
3 BIBLIOGRAPHY WITH BIBTE X • The order of the ﬁelds is arbitrary. year. Optional ﬁelds: volume or number. type. Optional ﬁelds: volume. but it will not hurt anything. year. Required ﬁelds: author or editor. pages. series. title. number. year. type. • Fields do not have to be on separate lines.
. volume or number. For example. printed document.
• There is a ﬁnal } to close the entry — @type{ . edition. Required ﬁelds: author. address. . Optional ﬁelds: editor. ﬁrst. address. month. edition. Remember to put each author’s name as ﬁrst last or last. howpublished. address. Here is a list of standard entry types with their required ﬁelds. incollection is a part of a book having its own title. title. What are “optional ﬁelds” in BibTE X are not necessarily optional as far as having a complete bibliography citation. Required ﬁelds: author. The last ﬁeld does not require a comma at the end. the volume and page numbers of an article are necessary to include even though they are optional to satisfy BibTE X syntax. title. title. Optional ﬁelds: author. article refers to an article from a journal or magazine. . even if they are valid ﬁelds in other types of entries. year. (What is “necessary” depends upon the standard one applies. month. edition. year.
A • The ﬁeld value can be anything recognized by L TEX. publisher. booklet refers to a bound. month. title. book refers to a book with an explicit publisher. month. chapter series. but it is more readable that way. publisher.) Fields that are neither required nor optional are ignored. }. Required ﬁelds: author or key. even mathematical symbols in math mode. but without an explicit publisher. pages. the compiler will think the ﬁrst name is Knuth and the last name is Donald. address. journal. series. Optional ﬁelds: volume or number. If you put Knuth Donald. but most journals require the volume of the journal and the page numbers for the cited article.
misc is when nothing else ﬁts. school. year. Optional ﬁelds: type. title. publisher. Required ﬁelds: author. For example. month.". address. which has no person as an author. organization. Optional ﬁelds: type. publisher. Optional ﬁelds: editor. Required ﬁelds: author or key (see note below). month. Required ﬁelds: author. title. month. volume or number. techreport is a report published by some institution. The bibliography will be sorted with the key. howpublished. enter an unrecognized ﬁeld. Optional ﬁelds: author. year. If a document has no author. series. address. you must provide a key for sorting. month. year. unpublished is a document with an author and title. volume or number. month. organization. year. note. title. school. (Some note of explanation is required. Required ﬁelds: author. address. Optional ﬁelds: type.) Required ﬁelds: author. address. the note ﬁeld is always an option. but not formally published. title. number. month. If a required ﬁeld is missing when you compile. title. booktitle. which vary by the type of entry. year. edition. To have a comment that is not printed. series. address. title. Possibly there will be some standard ﬁxup. consider the following entry for A L TEX 2ε [10]. (this is ignored with no error message given).3.
31
In addition to the optional ﬁelds listed. year. phdthesis is a PhD thesis. even as a technical report. organization. institution. month. Required ﬁelds: author.. Required ﬁelds: author or key (see note below). proceedings Required ﬁelds: title. address. used to order this entry relative to author
. Optional ﬁelds: month. Optional ﬁelds: author. manual is some technical documentation. title. mastersthesis is a Master’s thesis. year. you will get an error message.2 The bib File inproceedings is an article in a conference proceedings. This lets you enter a note that will appear at the end of the citation. LaTeX2e. Optional ﬁelds: editor. year. such as comment = ". but it is best if you provide the missing ﬁeld value. pages..
title = "The {\LaTeX} Companion". There is no universally accepted standard for how to reference web documents. }
The use of the braces in {\LaTeX} is to tell the bibtex program to take everything inside just as it is written (for the latex program to process). but here is one way. year = "199599". however. institution = "Comprehensive {\TeX} Archive". the World Wide Web did not exist. That defeats one of the primary advantages of using A L TEX and BibTE X in the ﬁrst place: we want to let the style ﬁles determine the ﬁnal form. year = "1994". Now it is a major source of information. MA". address = "Reading. author = "Michel Goosens and Frank Mittelbach and Alexander Samarin". Instead. the bibtex program might try to process it itself and produce an A unintended result.
3 BIBLIOGRAPHY WITH BIBTE X
@manual{usrguide. use this feature inappropriately by putting braces around everything. [5] in this document has the following BibTE X entry:
@Book{companion. otherwise.32 names. type = "World Wide Web site".2. Otherwise. }
When there are multiple authors. we separate them with and (no commas). key = "LaTeX2e". address = "{CTAN\url{/macros/latex/doc/usrguide. the bibtex program will produce ‘fourier analysis’ (the plain style produces article titles in lower case. 3. publisher = "AddisonWesley Publishing Company". such as writing {F}ourier analysis to force the capital F. The use of braces to force a particular result is necessary in other instances. except the ﬁrst letter of the ﬁrst word). If it is a book. In ordinary L TEX.2 Web citations
When BibTE X was developed. For example. we write G\"{o}del to produce Gödel. use the book type and specify:
. The key will not be printed. we write G{\"{o}}del. title = "{\LaTeXe} for authors". or simply G{\"o}del.ps} (see~\cite{CTAN} for replacing CTAN)}". This applies to accents too. so we can switch styles and use the same source (tex and bib ﬁles). but this will not work in BibTE X. Some authors.
and writing it will produce a space. and with latex having no place to break. and it would appear as ‘Jr. Braams and David P. ~ is in many urls. These diﬃculties are overcome by specifying:
address = "\url{http://www. Jr. author = "William Strunk{. you will run into some diﬃculty with writing urls. publisher = "World Wide Web". title = "Elements of Style". Its main use is to determine where the url can be broken in order to put it on two lines. you will see a line with lots of spaces (for justiﬁcation). The default font it uses is tt.
33
Here is an example:
@book{Strunk. the url could contain special characters. One A example is the L TEX 2ε reference [2].columbia. Also. address = "url ". if needed. Another feature of the url package is that \url prints special characters. Otherwise. There are occasions when we want to reference an entire web site. but you can change this to TimesRoman or sans serif font with the speciﬁcation: \urlstyle{rm} or \urlstyle{sf}.’ is the ﬁrst name of the author. not the tilde. it is deﬁned in a package. given by:
@misc{latex2e.}". respectively. a url could become very long. followed by the url. like ~. title = "{\LaTeXe} and the {LaTeX}3 Project". the comma would signal the bibtex program that ‘Jr. The use of the braces in the name is to be sure that the author appears as intended: William Strunk.
. without the braces.3. }
The reference \cite{StrunkWhite} presumes there is the entry for the original publication. For one thing. author = "Johannes L.edu/acis/bartleby/strunk/}".
A The \url speciﬁcation is not actually an intrinsic command in L TEX.columbia.edu/acis/bartleby/strunk/". Carlisle and Alan Jeffrey and Frank Mittelbach and Chris Rowley and Rainer Sch{\" o}pf". year = "1999". note = "This is the web version of the classic book by Strunk and White~\cite{StrunkWhite}". Eventually.2 The bib File
publisher = "World Wide Web". To have the \url command active in your document. put the following declaration into your preamble: \usepackage{url}. William Strunk’. use that style but include the url as a note or in the address ﬁeld. address = "http://www. in particular. An unsightly line with spaces could also appear after the url. Jr. If the document is a technical report.
and you shall learn more about A packages in §6.34
3 BIBLIOGRAPHY WITH BIBTE X
howpublished = "World Wide Web. We can concatenate strings and/or literals with #. (That is why we needed the quotes before. \url{http://www.3 Additional features
One element of good style is to be consistent in your terms. editor = "My Father". One sometimes sees “Kluwer.” and still other times “Kluwer Pub. 3. year = "1994".2.” To help be consistent and to save some work in the long run when we write many diﬀerent documents and produce more bib ﬁles. editor = dad.” Besides consistency. where I describe enhancements for having graphics in L TEX. title = mom # dad. the three ﬁeld values are equivalent to:
author = "My Mother". we merely change the one string value and recompile.” other times “Kluwer Academic Publishers. For example. we can deﬁne strings with the entry:
@string{name = "string"}
Then. an advantage is that if some name changes. we can enter:
publisher = kluwer.latexproject/org/latex3. when we wrote literals.html}". title = "My MotherMy Father". However.) For example. we can refer to the string anywhere in the value of a ﬁeld by excluding the quotes.
Then.
}
We have seen several packages so far. suppose we write
@string( mom = "My Mother" ) @string( dad = "My Father" ) author = mom. about which I shall say more when I describe ways to customize your document in §??. suppose we deﬁne:
@string{kluwer = "Kluwer Academic Publishers"}
Then.
to produce the publisher value = “Kluwer Academic Publishers. including abbreviations and names of publishers. this is the ﬁrst use of \renewcommand.
.
Kluwer Academic Press.S. Art{\’e}miadis". }
Then.
[2]
BibTE X also recognizes a preamble in our bib ﬁles to enable us to deﬁne A some L TEX commands. For example. as a literal:
title = mom # "~" # dad. Recent Advances in Fourier Analysis and its Applications: Proceedings of the NATO Advanced Study Institute. pages 311–316.K. ~. publisher = kluwer. Byrnes.K. editor = "J.2 The bib File
35
Note the absence of a space between the string values in the title. Byrnes and Jennifer L.S. = mom # " My Father". The general form is
@Preamble{ string }
where string is any concatenation of literals and strings.
The same title as the above is obtained by any of the following:
title title = "My Mother " # dad. Byrnes and Jennifer L. we can have the following entry:
@InProceedings{Artemiadis:FAA89311. use the space character. author = "N. Artémiadis. title = "Recent Advances in {F}ourier Analysis and its Applications: Proceedings of the {NATO} {A}dvanced {S}tudy {I}nstitute".
Another useful feature of BibTE X is the crossref ﬁeld for cross referencing. crossref = "Byrnes:FAA89". To ensure a space. pages = "311316".3. the result would appear as follows:
[1] N. Here is an example [11] that is useful for guiding the sorting of references in a special circumstance:
. Byrnes". 1990. }
If these were the only references. Results on the absolutely convergent series of functions and of distributions. In Byrnes and Byrnes [2]. the other values are literals):
@Proceedings{Byrnes:FAA89. editors. title = "Results on the Absolutely Convergent Series of Functions and of Distributions". suppose we have the following entry (kluwer is a string. year = 1990. J.
we fool the bibtex program with the following speciﬁcations: Volume 1
year = "{\noopsort{a}}1973". Here is a list of the most basic ones (included in every installation): plain is the most common because it formats entries according to accepted standards. before \end{document}. unsrt diﬀers from plain by sorting entries by the order in which they are cited. including some provided by publishers. thus putting volume 1 ﬁrst.bib. so just the years appear. does not actually print the letters. There are other bibliography format styles. The deﬁnition of \noopsort. then by year.
This fools the bibtex program into thinking the years are a1973 and b1971. The second command deﬁnes the format style of the bibliography to be plain. Command \noopsort ignores the argument that it receives. and they are labeled with numbers. \noopsort.
. rather than numbers.
Volume 2
year = "{\noopsort{b}}1971". it is used to deﬁne a command. mybiblio. producing nothing (indicated by {}). requiring one argument. alpha diﬀers from plain by citing by labels. but a second edition of volume 1 is printed in 1973. To force the ﬁrst volume to sort before the second. originally published 1971.36
3 BIBLIOGRAPHY WITH BIBTE X
@Preamble{ "\newcommand{\noopsort}[1]{}" }
The \newcommand is something I shall describe more fully in §??. however. among other things (to give a more compact bibliography). Entries are sorted by the alphabetical order of author names. The bib entries would have the years in the opposite order than we want because sorting is ﬁrst by the authors. For now.3
Declaration and Citation
At the end of your source ﬁle (where you want the bibliography to appear). put the following commands (in either order): \bibliography{mybiblio} \bibliographystyle{plain} The ﬁrst declares the bibliography to be in the bib ﬁle. abbrv diﬀers from plain by abbreviating names of journals. breaking ties with the year of publication. which comes with every installation of latex.
3. Suppose there is a 2volume work by the same authors. rather than by the author names. Here is how this can be used. which are the same.
) The rule is that only those bib entries that are cited appear in the ﬁnal document. [8] is produced by specifying \cite{tex}. In particular. If we have the same entry with diﬀerent labels.another} The bibtex program will search them sequentially for any citation. if we want to have every entry in our bib ﬁle appear. For example. even if it is not cited explicitly. (In the option. You can put more than one citation. 46” in the citation.~46]{latex} produces [9. If we want only some particular list of entries to appear. such as:
\bibliography{mybiblio. For example. the L TEX command is \cite{label [.latex} produces [8. they will appear twice if both labels are used (or if we used \nocite{*}).. we use \nocite with their labels. You can insert some further citation information as an optional input argument to the \cite command. Figure 32 shows a complete source ﬁle for having all entries in mybiblio. Repeated entry– telling us which label is repeated. such as \nocite{tex} to be sure Knuth’s TEX book appears. 46] in this document. the entries must be identical. we will get a fatal error message. ]}. The reason is that we can maintain one large bib ﬁle and write many documents that use it. delimited by [ ]. even if the main document is spaced diﬀerently. but know that many other styles have been written and are available free of charge. \cite[p. otherwise. For example. A To cite particular references. There are times when we want to be sure a particular bib entry appears. \cite{tex. the ~ is used to ensure that there is a space but no line break when giving the page number as “p. separated by commas.3.
3. put \renewcommand{\baselinestretch}{1} \selectfont
. If we have the same label in both bib ﬁles. we specify \nocite{*}. . p. but we do not want to cite it in the text. 9] for this document. where label is what we put in our bib ﬁle entry.4 Some Controls
37
We shall use only the plain style here. Just before the \bibliography statement.bib appear.4
Some Controls
You might want to have the bibliography singlespaced. . and that is the entire document!
\documentclass[12pt]{article} \begin{document} \nocite{*} \bibliographystyle{plain} \bibliography{mybiblio} \end{document}
Figure 32: A Document to Print the Bibliographic Database We can specify more than one bib ﬁle. This is done with the \nocite command.
The default is Bibliography. (c) An entire web site. Produce a document with one paragraph that cites three bibliographic items. Produce a document with one paragraph that cites three bibliographic items. U. 3. You do this by specifying (sometime before the bibliography): \renewcommand{\refname}{References} for article style \renewcommand{\bibname}{References} for book and report styles You can have more than one bibliography by using the bibunits package. which is available at CTAN [4]. 1990. one for each of the following types: (a) A technical report on the web. which consists of at least one entry for each of six diﬀerent document types. I. Rich. If you also want to change the font size (or style). You can change the heading put by bibtex. and the associated postscript result (ps ﬁle). How to Square a Circle. 4. \selectfont is not needed. and you can change the properties. (b) A book on the web. the BibTE X data (bib ﬁle). [1] I. you could specify \renewcommand{\baselinestretch}{1} \small to have the bibliography set in small font size (and single spaced).M.
1. Impossible Dreams. (b) An entire book with at least three authors.F. at least one entry must have more than two authors. that will do. such as the heading. 1990. chapter 1.M. MacTaco.
A Exercises. but you might want to have it be References. 1999. Submit a printed copy of the L TEX source (tex ﬁle). volume II. [2] [3] I.M. MacTaco. Rich. volume I. This will let you put diﬀerent bibliographies throughout your document. Produce a document that has only a bibliography composed of the following three entries (in the order shown). editor. one for each of the following types: (a) An article in a journal. (c) A chapter in a book.R. Be sure your name is on each.
. Further. Thus. Tu. second edition. (d) A technical report.38
3 BIBLIOGRAPHY WITH BIBTE X
The \selectfont command is needed to activate the change in \baselinestretch. Impossible Dreams. editor. Volume II of Rich [2]. Produce a document that lists your entire database. and V. Smart. 2. Money.
whose numbers I could write by \thesubsection\ and \thesection.
4. NJ. . except do not use L TEX special characters or blanks. Then. Here I illustrate some of those that are in all document styles. 1945. Labels. \thepage produces the page number. Princeton. There are times when you just want to produce the counter value. For example. you are reading subsection 4. can be labelled and referenced in the same manner.e. and References
Basic Concepts
A counter is a numerical value that refers to something that is being numbered. ﬁgures. Van Nostrand. NJ. without a label.2
Intrinsic Counters
A Anything to which L TEX assigns a number has a counter associated with it. and a reference is a citation to a label. Produce an annotated bibliography of the following form (note the indentations on left and right margins): [1] P.1
Counters. The L TEX syntax for referencing a label is \ref{label }. Halmos. respectively. On the other hand. and there are modern descendants. the following labels were deﬁned (when the subsection and subsubsection were ﬁrst written):
. Naive Set Theory. in this book I deﬁned: \section{Bibliography with \Bibtex} \label{sec:Bibliography} Now I can refer to §3 by \S\ref{sec:Bibliography}. A where label is unique in the document. Counters that depend upon the style. . [2] G. if you want to use the counter’s numerical value as an argument in a command. which I assign to my Ph. This is a good book. 1960. The next 100 reveal lack of understanding the ﬁrst 100. Princeton. and equations. Princeton University Press. For example. students. placed where the counter’s value is set. Polya.R. like a chapter in a book. This is a seminal book that articulates the problemsolving — i. The choice of label is arA bitrary. This is done by \thecounter..39
5. A label is the identiﬁcation of A a particular value. The ﬁrst 100 pages seem simple. sections. such as . You are looking at page 39. In the next section I describe intrinsic counters and illustrate how to label and reference them. Similarly. I shall introduce the ﬁgure and table environments. which I was able to print by writing \thepage. which have intrinsic counters associated with them.2 of section 4.
4
4.D. To illustrate how I can reference other parts of this document. theoremproving — process. specify \value{counter }. How To Solve It. just as the labels in the bib ﬁle entries. The L TEX syntax for labeling a counter is \label{label }. There are many editions. such as pages.
(If you have a lot of labels and need to keep track of them by printing each label and citation in your drafts. I use the preﬁx eqn. is any string you want to use A that does not contain embedded blanks or special characters used by L TEX. such as subsubsec:webcite. as given in [9].~\pageref{subsec:bibfile} ⇒ p. The choice of label.) Because ﬁgures and tables are not split. [\caption{caption[\label{label }]}] \end{table}
The caption. and I used the preﬁx subsec here. The label to reference a ﬁgure or table is put inside the caption. In the exercise to list what you like about mathematics. 28 For any counter. which is an element of good style. You can choose any labeling convention that is meaningful to you. [\caption{caption[\label{label }]}] \end{figure}
\begin{table}[options] [\caption{caption[\label{label }]}] . syntax: \begin{figure}[options] [\caption{caption[\label{label }]}] . 24 that ~ is used to have a space without a linebreak.)
4. Some people use this same form but with diﬀerent preﬁxes. 32 p. I can refer to these as follows: \S\ref{subsec:bibfile} ⇒ §3. \pageref{counter }. it will not be understood. For equations. just as \ref{counter } gives its value. The four choices
. For that reason they are called “ﬂoating objects. page 60. can go at the top or bottom. The environment options deﬁne where the ﬂoat is to be located. if present.” or ﬂoats. In my choice of label. I entered the label \label{exer:likeaboutmath} (page 26). That is a matter of style. even though you will get no error message. This helps me to distinguish labels for diﬀerent things. such as ss for subsection and e for equation. (If you put it outside the caption. I used the structure preﬁx :name. where you put it is where it will appear.) Equation (6). their exact location depends upon how much room there is.3
Figures and Tables
which have the same
In this section I describe ﬁgure and table environments. . AND REFERENCES
\subsection{The bib File} \label{subsec:bibfile} \subsubsection{Web citations} \label{subsubsec:webcite} Then. (Recall from p. was labelled \label{eqn:hessian}. . . which I can now reference as exercise #4 by writing \#\ref{exer:likeaboutmath}.2 I can also refer to their page numbers: p. see the showkeys package at CTAN [4]. so in this sentence I wrote its number by \ref{eqn:hessian} (with parenthesis added) and its page number by \pageref{eqn:hessian}.2.2 \S\ref{subsubsec:webcite} ⇒ §3. .40
4 COUNTERS.~\pageref{subsubsec:webcite} ⇒ p. LABELS. gives the page number where its label is deﬁned.
if this page does not have enough room). This is done with the \clearpage command.
The placement of a ﬂoat is sometimes a source of frustration. One cause could be an accumulation of ﬂoats that should be cleared at some point before continuing. Floats can be framed. if possible. neither of these A conditions is necessary for their L TEX environments.
. Locate at the bottom of the page (or the next page. called a ﬂoat page. However. The ﬁgures and tables in this document appear as the form: Figure number : caption vs. perhaps on a page by itself. In this document most tables and ﬁgures are speciﬁed with [ht]. followed by a ﬁgure or table. it diﬀers from a ﬁgure only in its name.
Table 6: Figure and Table Location Options Option h t b p Meaning Locate here (where the environment is declared). Locate on a separate page. For example. notably pictures. If there is not enough room. we generally use the ﬁgure environment to present what we usually think of as ﬁgures.4. but the table environment does not have to contain a table. The table environment is not to be confused with the tabular environment. We might specify [ht] and ﬁnd the ﬂoat in an unexpected place.” the place where it is speciﬁed in the source. The latter makes tables. Figures 33 and 34 illustrate how to frame a ﬁgure with a thick border. which means they are to be placed “here. This does the same as \newpage. it is to be located at the top of the following page.3 Figures and Tables
41
are shown in Table 6. which has no text. It is also advisable to specify \usepackage{float} in the preamble. This option is used in many places in this book. One of the enhancements is the placement option: [H]. and they have separate counters. which is why you sometimes see pages with some blank space in the lower portion. only ﬁgures and tables. and we generally use the table environment to present information in tabular form. As a matter of style. which insists that the ﬂoat be placed here (note the capital H and no other option speciﬁed). using the \fbox command. I did this to avoid confusion by having some ﬂoat appear pages after it is cited and discussed. Table number : caption That’s it. Locate at the top of the next page. except that it also prints all remaining ﬂoating objects.
4
Deﬁning Your Own
In the preamble you can deﬁne your own counter with the \newcounter command: \newcounter{name}[within] where name is the (unique) name of the counter (cannot be the same as one of the intrinsic counter names). 2. . (This is called a local setting. 1. You can also deﬁne the counter to be within another counter. within section 1.
Figure 35: Framed Figure with Caption at Top This is framed with default parameter values. they will be 1.
.1.2. AND REFERENCES
\begin{figure}[ht] \begin{center} \setlength{\fboxrule}{3pt} % make border lines thick \setlength{\fboxsep}{. s. but you can specify the type of numeral. .) Thus.2.1. This will cause the value of mycounter to be reset to 0 when entering a new section. . . . For example.
4. .2in} % increase distance to border \fbox{ This is a framed figure. \newcounter{mycounter} deﬁnes a counter whose name is mycounter. more generally. . the values of mycounter will be of the form s. LABELS. The counter values are printed in Arabic numerals.42
4 COUNTERS. For example. \newcounter{mycounter}[section] deﬁnes mycounter to be within the section counter. . Further. the frame in Figure 35 has thin lines and no extra padding around the border. instead of the printed values being 1. . . shown in Table 7. The initial value of the counter is 0. } \end{center} \caption{Framed Figure with Caption at Bottom \label{fig:fboxbottom}} \end{figure}
Figure 33: Framed Figure 34 Source
This is a framed ﬁgure. upon leaving the ﬁgure environment. Also note how the caption is put at the top (see exercise 3).
Figure 34: Framed Figure with Caption at Bottom
The parameter settings have returned to their default values. when printed within section s.
b. we can specify \stepcounter{mycounter}. had its label changed to what is speciﬁed in the source: \renewcommand{\labelenumii}{\theenumii. 2. (ii). . \stepcounter{mycounter} (\themycounter). iv. B. 1. If we just want to increment the counter by 1. whose counter is enumii. We can change these to be any type we want. The default numeral type is arabic. but you can change the appearance to be any of those listed in Table 7 by applying the \renewcommand to \thecounter. so we must change them back if we want to restore the defaults. For example. 4. . II. This is done with the \refstepcounter command. For example. I. where the types of numerals for the four levels are: arabic. d. . \setcounter{mycounter}{5} sets the value of mycounter to 5. . .
This can be used for intrinsic counters too. . write \refstepcounter{mycounter} \label{mylabel} Then. such as illustrated in Figures 36 and 37. 3. we want to be able to label it for future reference. \dots ⇒ (i). page).4 Deﬁning Your Own
43
Table 7: Numerals to Print Counters What you see a. . . For example. . we can use \ref{mylabel} and \pageref{mylabel} wherever we like. shown in Table 8. iii. \setcounter{mycounter}{0} \renewcommand{\themycounter}{\roman{mycounter}} \stepcounter{mycounter} (\themycounter). .
. This can also be used to transfer the value of one counter to another. For example. . alph. C. These changes remain in eﬀect (called a global setting). IV. The second level. to increment mycounter by 1 and establish a label to its value at the place this is done. . What you write \alph{mycounter} \Alph{mycounter} \arabic{mycounter} \roman{mycounter} \Roman{mycounter}
Counter values can be incremented with the \addtocounter command. For example. Counter values can be set to some absolute value with the \setcounter command. . roman and Alph. \setcounter{mycounter}{\value{page}} sets the value of mycounter to the current page number (value of the intrinsic counter. i. D. which also increments its value. When using a counter for some nonintrinsic sequence. For example.} (the “appearance” parameter is \labelenumii). c. . . . \addtocounter{mycounter}{1} adds 1 to the value of mycounter. III. . .4. ii. consider the enumerate list environment. A.
Write a document with at least two pages and two sections. Introduction II. (a) Reference §2 by a label that you assign to section 2 (make whatever
. Be sure your name is on each. Picnics and frolic Figure 37: Alternative enumerate Symbols Result (Source in Figure 36)
Table 8: Default Settings for enumerate Counters Counter
enumi enumii enumiii enumiv
What changes numeral label numeral label numeral label numeral label
Command
\renewcommand{\theenumi}{\arabic{enumi}} \renewcommand{\labelenumi}{(\theenumi)} \renewcommand{\theenumii}{\alph{enumii}} \renewcommand{\labelenumii}{(\theenumii)} \renewcommand{\theenumiii}{\roman{enumiii}} \renewcommand{\labelenumiii}{(\theenumiii)} \renewcommand{\theenumiv}{\Alph{enumiv}} \renewcommand{\labelenumiv}{(\theenumiv)}
of the associated postscript result (ps ﬁle). and use the \ref or \pageref command to reference each of the following. Terms and Concepts A.
A Exercises. Groups and ﬁelds B. Submit a printed copy of the L TEX source (tex ﬁle) and printed copy
1. AND REFERENCES
\renewcommand{\theenumi}{\Roman{enumi}} \renewcommand{\theenumii}{\Alph{enumii}} \renewcommand{\labelenumii}{\theenumii.} \begin{enumerate} \item Introduction \item Terms and Concepts \begin{enumerate} \item Groups and fields \item Picnics and frolic \end{enumerate} \end{enumerate}
% changes numeral type % changes appearance
Figure 36: Alternative enumerate Symbols Source (Result in Figure 37)
I.44
4 COUNTERS. LABELS. Put an enumerated list of items near the beginning of your document.
. The $ delimiter keeps the mathematical expression in the text. . . . like this: A consequence of Einstein’s postulates is that $E = mc^2$. like this: A consequence of Einstein’s postulates is that \[E = mc^2. Produce two numbered lists such that the second starts its numbering where the ﬁrst leaves oﬀ.\] ⇒ A consequence of Einstein’s postulates is that E = mc2 .1 . item 1 4. . and reference them by label. item 1 2. Produce Figure 35. 2. List 1. . item 2 Now we are out of list 1 . The other form is math display mode. Produce lists using the enumerate environment with the following appearance: 1. . 3. .2 . . . produce the following: 1. 1. . List 2. (c) Reference item #2 of your enumerated list. \]. $ or \[. . Include two tables and ﬁgures in your document. 2. . . 4. 2. . For example. signiﬁed by delimiters $.2 . Also reference the page that they appear.
. begin list 2. 1.1 . . (b) Somewhere near the end of your document reference the page number of the ﬁrst section. ⇒ A consequence of Einstein’s postulates is that E = mc2 . . item 2
5
Math Mode
One can write mathematical expressions by entering math mode. List 1. List 2. 3. . .45
label name you like). . 2. 5.
produced by $A^c$ and $A^\prime$. The complement of A often appears as ∼ A.46
5 MATH MODE
Table 9: Some Mathematical Operations Operation Symbol subscript _ superscript ^ multiply \times divide \div Example How it appears What you write x_3 x3 3 x x^3 a×b a\times b a÷b a\div b
5. produced by $\sim A$. but this is not universal notation. respectively. For example. as in the following examples: A\not\subseteq B x\not\in A\cup B A\setminus B\not\supset B ⇒ ⇒ ⇒ A⊆B x∈A∪B A\B ⊃B
Table 10: Set Notation What it is empty set intersection union set minus element in subset (proper) subset or equal superset (proper) superset or equal How it appears ∅ ∩ ∪ \ ∈ ⊂ ⊆ ⊃ ⊇ What you write
\emptyset \cap \cup \setminus \in \subset \subseteq \supset \supseteq
. Table 9 shows other common operations in math mode. (Each of the tables in this section applies only to math mode. and some use A. The order of subscripts and superscripts does not matter: x_{a+b}^{c+d} ⇒ xc+d a+b x^{c+d}_{a+b} ⇒ xc+d a+b Table 10 shows some set notation. xa+b is written as $x_{a+b}$ and xa is written as $x^{a^2}$. produced by $\overline{A}$.) The braces enclose an expression that can be used to deﬁne a more com2 plex operand. ^.1
Mathematical Symbols
The example also illustrates the use of the superscript operator. Preceding any symbol by \not puts the line through the symbol. some authors use Ac or A .
The following illustrates this. Note that \boldmath is surrounded by the braces. otherwise. sf. as shown in Table 11. however. this applies only to letters.5. cal. tt} (analogous to the \textfont command. causing unintended results when applied to other symbols. For example. Font style. \mathfont{expression}. and they are speciﬁed by spelling them as keywords. p. ˜ {\boldmath$\tilde A\times\vec{1}\otimes\overline{2}$} ⇒ A × 1 ⊗ 2 ˜ 1 $\mathbf{\tilde A\times\vec{1}\otimes\overline{2} }$ ⇒ A × ˜ ⊗ 2 Table 11 illustrates the outcome of each font for this expression: \mathfont{\tilde A\times\vec{1}\otimes\overline{2}}
Table 11: The \mathfont Commands Font Style boldface calligraphic italic normal roman sans serif typewriter Command \mathbf \mathcal \mathit \mathnormal \mathrm \mathsf \mathtt Example Result ˜ 1 A×˜⊗2 ˜ A×∞⊗∈ ˜ ×1 ⊗2 A ˜ ˜ A×⊗ ˜ 1 A×˜⊗2 ˜ ×˜⊗2 A 1 ~×~⊗2 A 1
The calligraphic style applies only to capital letters. where font is one of: {bf. {\boldmath $x^n+y^n=z^n$} ⇒ xn + y n = z n . 8). For example. Unlike \boldmath. Greek letters are deﬁned only in math mode. does not apply to math mode because math mode has its own. it. we can control the font style of letters with the command. The calligraphic alphabet looks like this (and it is available only in math mode): ABCDEFGHIJ KLMN OPQRST UVWX YZ. separate from text mode. even when leaving and reentering.1 Mathematical Symbols
47
You can control the size of the font by using the usual speciﬁcation before entering math mode. \boldmath$A\supset B$ text $B\cup C$ ⇒ A ⊃ B text B ∪ C {\boldmath$A\supset B$} text $B\cup C$ ⇒ A ⊃ B text B ∪ C Within math mode. without the braces. but not to special mathematical symbols. and returns to normal style in the second case. normal. Write ${\cal P} = A + B$ to produce P = A + B. You can make math fonts boldface by specifying \boldmath before entering math mode. digits and accents. math fonts would remain bold. where B ∪ C is boldface in the ﬁrst case. to produce α−β =∆−δ
. rm. For example. the calligraphic fonts remain in eﬀect: $\cal P = A + B$ ⇒ P = A + B. For example. {\Large $(x\div y) + z$} ⇒ (x÷y)+z .
\]. p. Figures 38 and 39 illustrate this with another example. but if we want x+y 4 . erally designed to do so. “Making Greek letters is as easy as π (or Π)” (written $\pi$ or $\Pi$). and I present more examples below. Here is a more complex equation in math display mode: x2 + yα A= . Some mathematical symbols adjust their size to ﬁt the expression.). which uses the \sqrt and \prod functions:
\[ \sqrt{\frac{\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 Source (Result in Figure 39)
N n=1
3
i∈In i∈I∞
xn i
xi
Figure 39: Variable Sizes Result (Source in Figure 38)
Notice that even though it is written in math display mode. but also produces proper spacing. but you can force either of the two styles with the \displaystyle and \textstyle commands. Figures 40 and 41 illustrate this. Table 12 shows some of the most common of these. We could use \boldmath to achieve this. 1 + x2η +1 written as \[ A = \frac{x^2+y_\alpha}{1+\frac{\eta}{x^2+1}}. L TEX compilers make judgments about the layout. The general form is \frac{numerator }{denominator }. where the numerator and denominator can be any expression. as 4 .\delta \]. Note how the sizes of the fractions adjust automatically.\beta = \Delta . (Not every Greek letter is included — see Appendix Table 36.
. but there is a package that not only provides the boldface font. 43] says.48
5 MATH MODE
write \[ \alpha . symbols whose size you would want to adapt to expressions are gen\. As Lamport [9. then \bm{\beta} ⇒β. by preceding the math mode with \large. between the integrand and dx. the indices on the A sums and product appear as they would in line.
5. we use the \frac command: $\frac{x+y}{4}$. we could write $(x+y)/4$ to make (x + y)/4. In the preamble specify \usepackage{bm}. note the use of \.2
Fractions and Variable Size Functionality
To make fractions. This inserts a thin space (compare the results by writing the expression with and without A the In L TEX. We can make this appear x+y larger.) The \mathbf does not make Greek letters boldface. In the case of the integrals.
dx\right]
parentheses
() x 1+y {} xi
i
braces
brackets
∞ 0
[] f (x) dx
\[ \sqrt{\frac{\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 Source (Result in Figure 41)
In text mode you can force the display style of placing these subscripts and superscripts on functions. Figure 42 gives more examples to compare in line text and display mode. as though it were in display mode.5. The “default” is not always predictable.2 Fractions and Variable Size Functionality
49
Table 12: Variable Size Mathematical Operation Symbols
Operation sum
How it appears
n
What you write
\sum
xi
i=1
\sum_{i=1}^n x_i \int
integral
b
f (x) dx
a
\int_a^b f(x)\. math display mode does not always use displaystyle.dx \left( \right) \left(\frac{x}{1+y} \right) \left\{ \right\} \left\{\sum_i x_i \right\} \left[ \right] \left[\int_0^\infty f(x)\. in particular.
. using \textstyle and \displaystyle to override the default form for the mode. as well as sizing the expression.
0] = \{x\ni x \le 0\} a_j\prec b_i \equiv b_i \succ a_j \forall y\. and a half space by \. write \[ (x\in A\Rightarrow x\in B) \Leftrightarrow (A\subseteq B). write \[ \forall x\exists y\ni [P(x)\wedge Q(y)]. In math mode a full space is obtained by specifying \.\{x: x\not\prec y\} \not\subset {\cal A} ⇒ ⇒ ⇒ (−∞.. For example. Here is how each looks: \forall x \exists y ⇒ ∀x∃y \forall x\.50
5 MATH MODE
N
xn i
n=1
3
i∈In
xi
i∈I∞
Figure 41: \displaystyle Result (Source in Figure 40) What to write in text mode
\frac{x}{2} \displaystyle\frac{x}{2} \max_{x\in X} \displaystyle\max_{x\in X}
Appearance
x 2
What to write in display mode
\textstyle\frac{x}{2} \frac{x}{2} \textstyle\max_{x\in X} \max_{x\in X}
x 2 maxx∈X max
x∈X
Figure 42: Examples to Compare Text and Display Modes
Table 13 shows symbols used in logical expressions. including negative spacing. 0] = {x aj bi ≡ bi x ≤ 0} aj
∀y {x : x
y} ⊂ A
. shown in Appendix Table 35. \exists y ⇒ ∀x ∃y \forall x\. \] To have ∀x∃y [P (x) ∧ Q(y)]. to have (x ∈ A ⇒ x ∈ B) ⇔ (A ⊆ B).) Table 14 shows some relations for ordered sets (besides those on the keyboard: < = >). Here are some examples: (\infty. \] The quantiﬁers in this last example seem a bit crowded. \exists y ⇒ ∀x ∃y (There are other spacing commands. so we might want to add some spacing between terms.
3 Arrays and Equations
51
Table 13: Some Symbols in Logic Logical Term existential quantiﬁer universal quantiﬁer negation disjunction conjunction implication equivalence such that How it appears What you write ∃ \exists ∀ \forall ¬ \neg ∨ \vee ∧ \wedge → \rightarrow ⇒ \Rightarrow ⇔ \Leftrightarrow ≡ \equiv \ni
Table 14: Order Relations Relation less than or equal greater than or equal not equal precedes precedes or equals succeeds succeeds or equals How it appears ≤ ≥ = What you write
\le \ge \ne \prec \preceq \succ \succeq
We have seen how to embed math mode into text.5. . written as $x_i < 0 for all i=1.\dots$ written as $x_i < 0$ for all $i=1. Compare each of the following: xi < 0f oralli = 1. which I shall illustrate in the next section. . and all letters are in the math form of italic (not quite the same as the italic in text mode). .\dots$ written as $x_i < 0 \mbox{ for all } i=1. xi < 0 for all i = 1. .\dots$
The ﬁrst line points out that blanks mean nothing in math mode. The use of \mbox is particularly convenient in math display mode. It has the form:
. . but we can also do the reverse with the \mbox command. and more. xi < 0 for all i = 1.
5. . .3
Arrays and Equations
The array environment is to math mode what tabular environment is to text mode. . .
7 \. 7. last row spec [\\ options] \end{array}
5 MATH MODE
The column speciﬁcations and options are the same as in the tabular environment.2 y = 2. but the body is in math mode.87 $ & $12. speciﬁes a space. using \mbox for each header entry.2 \\ \hline \end{array} \]
or
\begin{center} \begin{tabular}{ccc} Variable & Current Value & Limit \\ \hline $x$ & $ 1. using the math mode designation for each body entry: $.52
\begin{array}{column specs}options ﬁrst row spec \\ .87 −12.5 \\ z &=& 7.2 This can be generated by either of the following two ways:
\[\begin{array}{ccc} \mbox{Variable} & \mbox{Current Value} & \mbox{Limit} \\ \hline x & 1. .2 \\ y &=& 2.
. . or with the array environment. so it can be generated in either of two ways: with the tabular environment. Variable Current Value Limit x 1. otherwise.234567$ & $ 1 $ \\ $y$ & $9. (= x+y) \end{array} \] The \.2 $ \\ \hline \end{tabular} \end{center}
You can align a series of equations to appear this way: x = 5.234567 & 1 \\ y & 9.87 & 12.234567 1 y −9. .7 (= x + y) The above was produced by the following use of math display mode (which is always centered): \[ \begin{array}{lcl} x &=& 5. .5 z = 7. The following table has text headers and math body. $.7 (= x+y) ⇒ 7.7(= x + y).
specialized to this column speciﬁcation.5. there are times when we need to use more than one line for an ‘equation. It does. There is no apparent advantage to this since the same result can be produced by the ordinary array environment. Further.) The relation need not literally be an equation. but each row is numbered: x = y = y z (1) (2)
(Another diﬀerence is that the eqnarray environment uses displaystyle.3 Arrays and Equations
53
Another environment is eqnarray. Figures 43 and 44 give an example. The \nonumber command causes no number to be assigned to the ﬁrst part of the second equation. This is like a 3column array with speciﬁcations {lcl}.) We use the eqnarray environment directly (without entering math display mode). which is the same as eqnarray. as above.
. so the above is produced by the following: \begin{eqnarray} x &=& y \label{eqn:xy} \\ y &=& z \label{eqn:yz} \end{eqnarray} The \label statements are to illustrate that we can reference these by writing (\ref{eqn:xy}) to produce (1) and (\ref{eqn:yz}) to produce (2). however. let us change our mind easily as to whether or not to include equation numbers by simply adding or removing the * from the environment speciﬁcation. anything could be used for the middle column. but without the equation numbers. (Note that \ref gives just the number.
\begin{eqnarray} x &\mbox{is equal to}& y \\ y & \preceq & \frac{a+b+c+d}{\Psi} + \frac{e+f+g+h}{\Phi} + \nonumber \\ & & I+K+J+L \end{eqnarray}
Figure 43: eqnarray Environment Source (Result in Figure 44)
x is equal to y a+b+c+d e+f +g+h + + y Ψ Φ I +K +J +L
(3)
(4)
Figure 44: eqnarray Environment Result (Source in Figure 43)
There is also an eqnarray* environment.’ in which case we need to suppress the numbering of all but one of the rows. parentheses are added.
Table 15 shows other ways to denote the transpose of a vector.1 1. there is the equation* environment. and the horizontal line separating the blocks is obtained by specifying \hline before the second row of the outer array.0 22. Figures 45 and 46 show how to present a matrix equation.1 x1 x2 .54
5 MATH MODE
For a single. Also. This poses no particular advantage over specifying eqnarray and merely entering one row (except that column separators (&) are not used in the equation environment).0 & 22. note how x is speciﬁed. which suppresses the equation numbering.3 \\ 21.0 & 2. {cc}. Notice how the vertical line was drawn by the column speciﬁcation.2 1.
. numbered equation. there is the equation environment. as illustrated in Figures 47 and 48. x3
Figure 46: Matrix Equation Result (Source in Figure 45)
Array environments can be nested.3 21.
Table 15: Transpose of a Vector What you write x’ x^t x^T x^{\mathsf{T}} x^{\mbox{\tiny $T$}} ⇒ ⇒ ⇒ ⇒ ⇒ How it appears x xt xT xT xT
\begin{equation*} Ax^\prime = \left[ \begin{array}{rrr} 1.1 & 1. \end{equation*}
Figure 45: Matrix Equation Source (Result in Figure 46) Ax = 1.0 −2.1 \\ \end{array} \right] \left( \begin{array}{cc} x_1 \\ x_2 \\ x_3 \end{array} \right).2 & 1. To illustrate. Analogous to eqnarray*.
rather than absolute measurements for spacing. like \baselineskip. putting \vspace{. In particular. it is better to use parameters. sometimes used for emphasis.dx &=& \displaystyle\frac{1}{\tau} \\ \\ &=& \displaystyle\oint_a^{b+c} \Psi(x)\. This could be overcome by putting a vertical space command just after the expression. For example. which you might change. which is the height of one line of normal text.dx \end{array} $}
∞ 0
xe−τ x dx =
1 τ
b+c
⇒
=
a
Ψ(x) dx
We can use \fbox within math mode. (In the longrun. such as writing $x = \fbox{y} + z$ to produce x = y + z.2\baselineskip} after x = y + z causes extra vertical space equal to 20% of the value of \baselineskip.5. causing an undesirable clash. Note how the line height does not adjust to the frame.3 Arrays and Equations
\[ \left[ \begin{array}{cc} \begin{array}{ccc} A_{11} & A_{12} & A_{13} \\ A_{21} & A_{22} & A_{23} \end{array} & 0 \\ \hline 0 & \begin{array}{cc} B_{11} & B_{12} \\ B_{21} & B_{22} \end{array} \end{array} \right] \]
55
Figure 47: Nested Arrays Source (Result in Figure 48) A11 A12 A13 A21 A22 A23 0 0 B11 B12 B21 B22
Figure 48: Nested Arrays Result (Source in Figure 47)
We can enclose mathematical expressions in a box. because the former takes into account the font size. \fbox{$ \begin{array}{lcl} \displaystyle\int_0^\infty xe^{\tau x}\.)
.
56
Now consider the following conditional −1 0 f (x) = 1
A produced by the following L TEX code:
5 MATH MODE
assignment: if if if x < 0; x = 0; x > 0.
\[ 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 because \left and \right must balance — i.e., there must be an equal number of each. It is not necessary that the left symbol be related to the right one — i.e., \left\{ does not require \right\} to balance; any right symbol will do. The period is not printed in this case, used speciﬁcally for this purpose of balance. We have seen the use of \left and \right for brackets around a matrix. Now A the use of the \left L TEX command for conditional assignment raises related uses of the underbrace and overbrace. Figures 49 and 50 illustrate these, along with \overline, \underline, \widehat and \widetilde.
\[ \begin{array}{cc} \mbox{This sum has} \\ \mbox{an overbrace} \\ \overbrace{\overline{i\dots j} + \underline{k\cdots l}} & \underbrace{\widehat{xy}  \widetilde{ab}} \\ & \mbox{This difference} \\ & \mbox{has an underbrace} \end{array} \]
Figure 49: Horizontal Braces Source (Result in Figure 50)
This sum has an overbrace i...j + k···l xy − ab This diﬀerence has an underbrace Figure 50: Horizontal Braces Result (Source in Figure 49)
We often need to mix mathematical notation and text. We could use the tabular environment and specify inline math mode where needed (with $), or we
5.3 Arrays and Equations
57
could use the array environment and use either the \mbox or \parbox (see p. 18) to enter the text. There are, however, some nuances 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 spacing gives a poor appearance.) The problem is that \flushleft skips a line, which ruins the alignment (even though [t] is speciﬁed). The solution is to use the \raggedright command, as shown in ﬁgures 53 and 54. In addition, the \raisebox command is used to lower the small matrix, giving it some space below the horizontal line.
\renewcommand{\arraystretch}{1.2} \begin{center} \begin{small} \begin{tabular}{lll} Matrix & Definition & Example \\ \hline \parbox[t]{.9in}{Covariance} & \parbox[t]{2in}{\flushleft $A_{ij} = E[(X_i\mu_i)(X_j\mu_j)]$, where $\{X_i\}$ are random variables, and $E[\cdot]$ is the expected value operator with $\mu_i=E(X_i)$. } & \parbox[t]{1.4in}{\scriptsize $\left[\begin{array}{rrrrr} \frac{1}{2}&0 \\ 0&\frac{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~ \vspace{.05in} \\ \half &\mbox{for}& x=~~0~ \vspace{.05in}\\ \fourth &\mbox{for}& x=~~1. \end{array}\right.$ } \vspace{.1in} \\ \hline \end{tabular} \end{small} \end{flushleft} \renewcommand{\arraystretch}{1}
Figure 51: \flushleft in parbox Source (Result in Figure 52)
Matrix Covariance Aij = E[(Xi − µi )(Xj − µj )], where {Xi } are random variables, and E[·] is the expected value operator with µi = E(Xi ). Deﬁnition Example
1 2
0
1 2
0
2 for X2 = X1 and P r[X1 = x] 1 for x = −1 4 1 = for x = 0 2 1 for x = 1. 4
Figure 52: \flushleft in parbox Result (Source in Figure 51)
58
5 MATH MODE
\begin{center} \begin{small} \begin{tabular}{lll} Matrix & Definition & Example \\ \hline \parbox[t]{.9in}{Covariance} & \parbox[t]{2in}{\raggedright $A_{ij} = E[(X_i\mu_i)(X_j\mu_j)]$, where $\{X_i\}$ are random variables, and $E[\cdot]$ is the expected value operator with $\mu_i=E(X_i)$. } & \parbox[t]{1.4in}{\scriptsize\raisebox{.1in}{ $\left[\begin{array}{rrrrr} \frac{1}{2}&0 \\ 0&\frac{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~ \vspace{.05in} \\ \half &\mbox{for}& x=~~0~ \vspace{.05in}\\ \fourth &\mbox{for}& x=~~1. \end{array}\right.$ } \vspace{.1in} \\ \hline \end{tabular} \end{small} \end{center}
Figure 53: \raggedright in parbox Source (Result in Figure 54)
Matrix Covariance Deﬁnition Aij = E[(Xi − µi )(Xj − µj )], where {Xi } are random variables, and E[·] is the expected value operator with µi = E(Xi ). Example
1 2
0
1 2
0
2 for X2 = X1 and P r[X1 = x] 1 4 for x = −1 1 = for x = 0 2 1 for x = 1.
4
Figure 54: \raggedright in parbox Result (Source in Figure 53)
5.4
Special Functions and Alphabets
Math mode recognizes a collection of special functions. Table 16 shows some common ones. These special functions are used to make the source clearer, rather than using \mbox to achieve the same result. Among the special functions are the complete set of trigonometric functions. For example, we write $\tan\theta = \frac{\sin\theta}{\cos\theta}$ to prosin duce: tan θ = cos θ . Appendix Table 40 (p. 115) has a much longer list of special θ functions, as also a package of AMS symbols, of the examples shownyour preamble There is well as the arrows used in some which you declare in in Table 17. with \usepackage{amssymb}. This gives the following alphabet with the mathbb font: $\mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ ⇒ ABCDEFGHIJKLMNOPQRSTUVWXYZ
for which you specify \usepackage{mathrsfs} in the preamble. rather than .x}
lim xn
lim inf log xn max f (x)
x∈X
tan(θ + π) ln x
For example.x_n \max_{x\in X}f(x) \frac{\tan(\theta + \pi)}{\ln\.5. L is often used to denote the Laplace transform or the Lagrangian. $\Re$. Table 18 shows how \mathbb can be used for specifying other numerical spaces.4 Special Functions and Alphabets
59
Table 16: Some Common Mathematical Functions Function limit lim inf log maximum tangent How it appears lim lim inf log max tan What you write
\lim \liminf \log \max \tan
Table 17: Examples of Mathematical Functions How it appears textstyle displaystyle limn→∞ xn lim inf n↓0 log xn maxx∈X f (x)
tan(θ+π) ln x n→∞ n↓0
What you write
\lim_{n\rightarrow\infty}x_n \liminf_{n\downarrow 0}\log\. the real line is sometimes denoted by R. This gives the following alphabet: $\mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ ⇒A BC DE F G H I J K L M N OPQRS T U V W X Y Z In particular. which is A the L TEX special symbol. ⇒ ⇒ ⇒ ⇒ How it appears R C Z Q What it means Real values Complex values Integer values Rational values
Another alphabet is \mathscr.
.
Table 18: Notation Using mathbb Fonts from amssymb Package What you write† \mathbb{R} \mathbb{C} \mathbb{Z} \mathbb{Q} † In math mode.
∂f (x)/∂xn ). denoted by the symbol . . The Hessian is the matrix of second partial derivatives: 2
∂f (x)
(5)
f (x) =
∂ 2 f (x) . and its mathematical deﬁnition is the vector of ﬁrst partial derivatives: f (x) = (∂f (x)/∂x1 .60
5 MATH MODE
and H is sometimes used to denote the Hamiltonian. and {\large$\frac{\partial f(x)}{\partial x}$} to produce ∂x . . df (x)/dx. . we can use (x) the \frac command to produce dfdx . \]
. note how the outer integral is large in the following expression: b xeλf (x) dx X(v) lim Φ(v) dv. so you can write \partial f(x)/\partial x to produce ∂f (x)/∂x.dv . For example. The partial derivative symbol. is written \partial.dx} {\oint_{X(v)} e^{\lambda f(x)}\. which are both variablesize symbols. \end{array} \] There seems to be some crowding in this direct speciﬁcation. or. H. The usual notation for the gradient of a function is the nabla. ∂.dx}\right \.)
5.
A I leave it as an exercise to show the L TEX code that produced equation (5). Compare with the following and see if you can produce it:
2
f (x) =
∂ 2 f (x) . which is an upside down delta (introduced by A Hamilton in 1853). (also called “del”). which is also used by some authors. . (Compare with \mathcal. In L TEX it is produced by \nabla. eλf (x) dx a λ→∞ X(v) This was obtained by the following code: \[ \int_a^b \lim_{\lambda\rightarrow\infty} \left \frac{\oint_{X(v)} xe^{\lambda f(x)}\. ∂xi ∂xj
(6)
There are two integral signs: \int⇒ and \oint⇒ . by writing $df(x)/dx$.5
Derivatives and Integrals
We can express a total derivative. ∂xi ∂xj
This was produced by the following code: \[ \begin{array}{lll} \nabla^2f(x) &=& \left[ \displaystyle \frac{\partial^2f(x)} {\partial x_i \partial x_j} \right].\Phi(v)\.
6 Theorems and Deﬁnitions
(Note the use of the thin space. xn ) dx1 · · · dxn
write \[ \int_0^\infty \int_0^{x_n} \int_0^{x_{n1}} \cdots \int_0^{x_2} H(x_1.. there is no solution to xn + y n = z n for x.1” appears. . 223]): \usepackage{amsmath} in the preamble (see The L TE (u v − v u) · dS =
S τ
(u
·
v−v
·
u) dτ.x_n)\.5. and the spacing of the integral signs.6
Theorems and Deﬁnitions
The foundations of mathematics are axioms and rules of inference.z\in \LZ_{++}$. . there is no solution to $x^n + y^n = z^n$ for \newline $x. p. are better with A the following.\dots.y. y. The rules create theorems.1 For n > 2. consider the following: (u v − v u) · dS =
S τ
(u
·
v−v
·
u) dτ. \. but is also the name of the associated counter.
Note how the domains are centered on the multiple integrals and the spacing of the integral signs. all text is in italic. the theorem was produced by the following L TEX code:
\begin{theorem} For $n > 2$. This is so fundamental that L TEX has the facility to deﬁne a special environment that includes a keyword. . like “Theorem.” and a name. which are statements whose truths are established relative to the A underlying logic. which is not only the name of the environment. Notice how “Theorem 5.
5. \end{theorem}
. To have
∞ 0 0 xn 0 xn−1 x2
61
···
0
H(x1 .) Deﬁnite multiple integrals are no problem. .
The domains of integration. z ∈ Z++ .dx_1\cdots dx_n \] However. Consider the following example: Theorem 5.1. and we have the counter value: \thetheorem=5. which is not produced by standard L TEX 2ε . This was deﬁned in the preamble by: \newtheorem{theorem}{Theorem}[section]
A Then. but by specifying A X Companion [5.
so it must be diﬀerent from all other environment and counter names. This was created by ﬁrst entering (in the preamble):
. and a unique name for the environment. also used as a counter. It was deﬁned in the preamble as follows: \newtheorem{corollary}{Corollary}[theorem] Note that this is within the theorem counter. \end{corollary} The following creates an axiom environment that is not within any other counter. \newtheorem{axiom}{Axiom} The “Axiom of Choice” can then be stated thusly: Axiom 1 From any (inﬁnite) family of sets a new set can be created that contains exactly one element from each set in the family. which can be intrinsic or some other counter deﬁned by the \newcounter command (p. In this document. like Theorem. This was created by the following code: \begin{axiom} \label{axm:choice} From any (infinite) family of sets a new set can be created that contains exactly one element from each set in the family. To further illustrate. \end{axiom} The label allows us to refer to the Axiom of Choice as ‘Axiom 1 on page 62’ by writing Axiom~\ref{axm:choice} on page~\pageref{axm:choice}. like theorem.62
5 MATH MODE
Other theoremlike environments can be deﬁned to have the same properties. The within option deﬁnes the counter to be within some other. I deﬁned the theorem environment to be numbered within the section. here is a corollary environment: Corollary 5.1.1. which is valid by having been deﬁned by its own \newtheorem. and it deﬁnes a counter. 42) or by some other \newtheorem. but this is generally not desirable for a deﬁnition.1 The sum of cubes cannot be a cube. the above corollary was written as: \begin{corollary} The sum of cubes cannot be a cube. so you see Theorem 5. rather than Theorem 1. The environment created by \newtheorem puts the text in italics.1 The circumference of a sphere is the circumference of any great circle on the sphere. Then. Consider the following example: Deﬁnition 5. Here is the syntax: \newtheorem{name}{keyword }[within] The name deﬁnes the environment name. This requires both a keyword.
The use of text font environments comes close to the corresponding math size.
$\big(E=mc^2\big)$ ⇒ E = mc2 . however. delimiter size control commands. Huge↔Bigg). .
{\large(}$E=mc^2${\large)} ⇒ (E = mc2 ). \end{mydefn}
For more customization. This is more evident with the square and angular brackets:
$\Big[E=mc^2\Big]$ ⇒ E = mc2 . which apply to a single character: \big. This was created by ﬁrst entering (in the preamble): {\theorembodyfont{\rmfamily} \newtheorem{mydefn}{Definition}[section]} Then.
There are. and \Bigg. Whereas \left and \right commands adjust the size of a mathematical delimiter to ﬁt the enclosed expression. .1 The circumference of a sphere is the circumference of any great circle on the sphere. . the theorem package enables a wide range of variations over the font style (among other things).
. in the text: \begin{defn} The circumference of a sphere is the circumference of any great circle on the sphere. .5. (large↔big. \end{defn} Compare this with the following:
63
Deﬁnition 5. $\bigg\langleE=mc^2\bigg\rangle$ ⇒ E = mc2 . in the text: \begin{mydefn} The \textit{circumference of a sphere} is the circumference of any great circle on the sphere. like parentheses and braces. One way is with a size command — for example. especially the thicknesses.7
Reﬁnements
Mathematical delimiters. must be varied to enclose some expressions. we can also enlarge these delimiters ourselves. \bigg.7 Reﬁnements
\newtheorem{defn}{Definition}[section] Then. For example. but they are diﬀerent.
5. \Big. {\Large[}$E=mc^2${\Large]} ⇒[E = mc2 ].
and n is the number of columns it spans.
The remaining reﬁnements use the amsmath package (introduced on p. Figures 55 and 56 illustrate this. 61 for obtaining better multiple integrals). The amsmath package has a command to put dots across any number of columns in an array.64
5 MATH MODE
{\LARGE$\langle$}$E=mc^2${\LARGE$\rangle$} ⇒ E = mc2 .
. b \scriptsize produces a d . where spacing determines the spacing between the dots. except the equations are not aligned. (Note that there are no column speciﬁcations. in math mode. respectively. Its syntax is \hdotsfor[spacing]{n}. The gather and gather* environments allow the new line speciﬁcation.) This is not equivalent to preceding the array speciﬁcation with a text size environment. For example. the spacing and parentheses are not the same. we could produce a b c d by spec
ifying $\left(\begin{array}{cc} a&b \\ c&d \end{array}\right)$. The same result with equation numbers is obtained by the gather environment. \\. An alb ternative is with the amsmath smallmatrix environment: a d is obtained c by $\left(\begin{smallmatrix} a&b \\ c&d \end{smallmatrix}\right)$. in particular.V = H_0 \\ A(x) = \{y: \phi(y) = \cup_{a\in \cal A} \Psi(x)\} \end{gather*}
Figure 55: gather* Environment Source (Result in Figure 56)
(a + b)2 = a2 + 2ab + b2 L ⊕ M ε − V = H0 A(x) = {y : φ(y) = ∪a∈A Ψ(x)} Figure 56: gather* Environment Result (Source in Figure 55) When writing a matrix within text.
\begin{gather*} (a+b)^2 = a^2 + 2ab + b^2 \\ {\cal L} \oplus M^\varepsilon . While the letters inside the matrix are apc proximately the smallmatrix size. They behave like the eqnarray and eqnarray* environments.
. ....5.......... ..
The \stackrel command lets us put characters over a relation: For def example.. (Specify \usepackage{amscd} in the preamble..5]{5} \\ \end{array}\right
65
1 2 3 4 5 . but you can use the smallmatrix environment or the \substack command:
$\displaystyle\sum_{\substack{i\in I\\j\in J\\k\in K}} A_{ij} = \underset{\begin{smallmatrix} i\in I\\j\in J\\k\in K \end{smallmatrix}} {\sum} A_{ij}$
⇒
i∈I j∈J k∈K
Aij =
i∈I j∈J k∈K
Aij
Another package in the ams family is amscd.....
$\overset{a}{X}$ $\underset{b}{Y}$ $\overset{a}{\underset{b}{Z}}$
⇒ ⇒ ⇒
X Y
b
a
Z
b
a
This can be used to stack subscripts:
$\displaystyle{\sum_{ \stackrel{ \mbox{\scriptsize$i\in I$} } {j\in J} } } A_{ij} = \underset{j\in J} { \underset{i\in I}{\sum} } A_{ij} $
⇒
i∈I j∈J
Aij =
i∈I j∈J
Aij
Nesting the \underset command can be unwieldy. Figures 57 and 58 illustrate this. The
... . With more generality....... the \overset and \underset amsmath commands enable us to put any characters over or under any character........7 Reﬁnements
\left\begin{array}{ccccc} 1 & 2 & 3 & 4 & 5 \\ \hdotsfor{3} \\ & \hdotsfor{3} \\ \hdotsfor[2]{5} \\ \hdotsfor[.. which makes it easy to draw commutative diagrams.. n^+\stackrel{\mathrm{def}{=}n+1 ⇒ n+ = n + 1. For example...) The horizontal arrows are speciﬁed by @>>> (left to right) with any expression placed above or below...
” But a group had not yet been deﬁned. and phrases are appropriately punctuated.
\[ \begin{CD} A @>a>> \alpha @VV\beta V D @>>d> \end{CD} \] B @>>> \gamma @AAA E @>e>> C \\ @VVV\delta \\ F
Figure 57: Commutative Diagram Source (Result in Figure 58) A −−→ B −−→ C −− −− α β γ δ D −−→ E −−→ F −− −−
d e a
Figure 58: Commutative Diagram Result (Source in Figure 57) There are many more reﬁnements.8
Grammar
When writing mathematical expressions.66
5 MATH MODE
vertical arrows are speciﬁed by @VVV (down) or @AAA (up). people make some common errors. where P is a permutation matrix. The general guide is to treat a mathematical expression linguistically. with an expression placed to its left or right. clauses are separated by commas. For example. For example. A symmetric rearrangement of a matrix has the following form: R = P t M P. Here are some of the most common elements of grammar to consider. .
. All possible horizontal and vertical placements are illustrated. 2. Many of these are described in The L TEX Companion [5. As you read articles notice that those that are among the most confusing are when the authors used a term that is not deﬁned until pages later. Punctuate math display mode. Chapter 8]. we might see “The distinguishing property of an abelian group is the commutivity . .
5. which is incorrect to omit. note the colon before the display and the comma at its end. In English this means that every sentence has a subject and predicate. Deﬁne before use. and more packages to make things A nicer. The expression usually needs a comma or period. and you can see an online catalog of packages at CTAN [4]. 1.
. v). Suppose A and C are expressions.’ or ‘Suppose A. then . 3. Produce each of the following formulas in line with text (construct your own sentences that contain them. 6. (a) ln ex = x (b) sin{θ + 2π} = sin θ
. The expression. An object has only one deﬁnition. Produce the following in math display mode with the array environment and/or with the eqnarray* environment.) 1. √ (a) x2 = B 2 − 4AC implies x = ± B 2 − 4AC. a A ﬁgure appears after its ﬁrst reference. The form. ∆2 Fn = Fn+2 − 2Fn+1 + Fn = 2Fn − Fn+1 . then tell the reader something like. Equivalence needs commas. ‘A if and only if B.’ should be written as ‘A if. . ‘If A. and it is important that the reader be told of this. instead of Φ(uk . “We shall use Φk . 0 otherwise. (Lookup special symbols in the Appendix. then C.5. and only if. B. . and the comma is used to clarify where the antecedent (A) ends and the consequent (C) begins. 5.’ seems like it ought to be all right. when there is no risk of confusion.” The overriding principle is clarity. 4. it follows that ∆2 Fn+1 = ∆Fn .
2. however. . For example. v k ). L TEX does this automatically. Then. If either A or C are compound. Sometimes we deﬁne the complete object. Be sure your name is on each.’
A Exercises. v) = au + bv. but you might want to take control over locating ﬁgures. we cannot later refer to Φ(u. (b) If ∆Fn+1 = Fn . In English. Reference object is located after the reference. is not correct. the second form is clearer. C. (c) x+ = x if x ≥ 0. For example. Φ(u. this is not correct. if we write Φ = au + bv. and include proper punctuation). Produce each of the following in math display mode.’ The ﬁrst form is preferred if A and C are simple expressions. C. We can write either ‘If A. Submit a printed copy of the L TEX source (tex ﬁle) and of the
associated postscript result (ps ﬁle).8 Grammar
67
3. If .
1
.3 + a1 a2 a3 b1 b2 b3 = α −β γ −δ λ θ .2 −1.1 2. (b) α1 + β 2 − x2 + y 3 8. √ A−1 (b) (0. . Produce each of the following expressions: (a) x = y mod n = x − y = kn for some k = 0. 7.2 2. C T x)T . (a) q ∗ (G) ≥ max ∆(G).1 −1. 1. Produce the following equation in math display mode. 1. 6. .
(c)
(−x 3 + a)2 dx.3 −2. Produce the expression in the Preface. . xT ) √ 3 3 V = 2
a 0
A B 0 C
=
0 xT C
= (0. Produce each of the following in line with text (that you compose) and in math display mode.68 (c) yn = (d) f (x) =
n=0 n−1 i=i0 ∞
5 MATH MODE xi ⇒ yn+1 − yn = xn − xi0 f (n) (0) xn n!
∂ (e) ∂x
x2 a
f (y)dy = 2xf (x2 )
(f) MFe(H2 O)6 = 6MH2 O + MFe 4.
5. (a) A = {S ∈ S : S ∈ S} (b) F × P ≤ π a11 a12 a21 a22 CB BC
? def
(c)
9. Produce equations (5) and (6). Produce each of the following formulas in math display mode (with punctuation): 2m(GA ) if G = ∅. xT )T = (0.
∂f (x) ∂xj x=¯ . What is grammatically wrong with each of the following segments. ∂f (x)/∂xj } if xj = bj 11. Produce the following: 13. (b) Strictly positive integers: Z++ . Proof: The determinate of a nonsquare matrix cannot be zero because it is not deﬁned. Therefore. Deﬁnition 2 A matrix is nonsingular if it is not singular. (c) Complex nvectors: Cn . Theorem 1 Every nonsquare matrix has an inverse. (d) Nonnegative rational nvectors: Qn . the matrix is nonsingular.8 Grammar
69
10. conditional assignment (with array environment). x
. This implies it has an inverse. Produce the following symbols: (a) Extended reals: R∞ . + 12. ∂f (x)/∂xj } if xj = aj + ∂f (x)/∂xj if aj < xj < bj f (x)j = min{0. Produce the following: Deﬁnition 1 A matrix is singular if its determinate is zero. Combine your knowledge of derivatives. and mathematical symbols to produce the following (called the truncated gradient): max{0. (b) A result of these assumptions is the following equation E = mc2 Einstein ﬁrst noticed this equivalence between energy (E) and mass (m). (a) A key is how to add velocities the formula is (u + v) 1 + uv c2 where c is the velocity of light. 14.5.
Adding velocity vectors: u + v. (1/2)1/4
16. Figure 1 (above) shows how to add velocities simply as vectors. You are to produce the mathematical expressions shown in math display mode. t = the right size and location. (d) Now we consider adding velocities. The following is tricky to get the evaluation expression. Now suppose y(ω) is speciﬁed and we want to ﬁnd x. where A is an m × n matrix and b is an mvector. 1 2 3 4 a 1 1 0 0 c 0 0 1 1 d 0 1 0 1 e 1 0 0 1
A=
17. Column pointers: A=
. 15. (e) Theorem If x.
u
u+v v
Figure 1. then n < 3.70
5 MATH MODE (c) Let x be an nvector and ω a scalar. d f (x + t dt
+
1 2
to be
f (x))
t= 1 2 b 0 1 1 0
=−
2v + 1. y. z ∈ Z+ and xn + y n = z n . Note the row and column labels outside the matrix. and deﬁne y = Ax − ωb. Row pointers: A= 11 12 21 22 ← rows in 1 ← rows in 2 (this arrow is closer to matrix) 11 12 21 22 ↑ ↑ columns columns in 1 in 2
18. The remaining exercises are more diﬃcult.
By itself. Use standard L TEX 2ε commands. and r = right. as follows:
\fbox{left}$\longrightarrow$\fbox{center}$\longrightarrow$\fbox{right}
⇒ left −→ center −→ right The \framebox command can be used instead of \fbox to produce the same result.71 19. it lets us stack short phrases.
\framebox[2cm][l]{left}$\longrightarrow$\framebox[2cm][c]{center}$% $\longrightarrow$\framebox[2cm][r]{right}
⇒ left
−→
center
−→
right
The % at the end of the ﬁrst line is to avoid having a blank between the center box and the $\longrightarrow$ that follows it. given as 2 cm for each box. but I do not provide a complete list of the relevant packages A (see CTAN [4] and The L TEX Companion [5]).1
Picture Environment
If all we want is a series of boxes and arrows. c = center. Use a package to import some standard graphics ﬁle. I illustrate each. 2. \framebox also has two optional arguments to control the length of the box and the position of the text within it. The second optional argument is the position of the inscribed text: l = left. However. We can make the contents of a box obey all paragraph controls in text mode by the \parbox command. For example.
. we can do this simply with \fbox and a long arrow in math mode. The ﬁrst optional argument of this \framebox command is the width of the box. Row and column pointers: A= 11 12 21 22 ↑ ↑ columns columns in 1 in 2 ← rows in 1 ← rows in 2
6
Graphics
A Graphics may be part of a L TEX document by one of three ways: A 1.
6. notably the picture environment.
3. Use a graphics package to draw within the document.
Combined with bottom \framebox. but it has an optional argument to align its top or bottom with the text.
\begin{center} \parbox{2cm}{ \framebox[2cm]{top} \\ \centerline{$\downarrow$} \\ \framebox[2cm]{middle} \\ \centerline{$\downarrow$} \\ \framebox[2cm]{bottom} } \end{center}
Figure 59: Vertical Diagram Source (Result in Figure 60) top ↓ middle ↓ bottom Figure 60: Vertical Diagram Result (Source in Figure 59) The box created by \parbox has its center aligned with the text. Going through its parts will serve to explain the various commands. This is done by specifying \parbox[t]{width}{text} or \parbox[b]{width}{text}.72
6 GRAPHICS
top like middle (note how the paragraph spacing adjusts). A basis for this is the picture environment. which was created by the picture environment. but there is a need for more versatility. like ovals and diagonal arrows. and more control over positioning. along with other box commands. whose source is shown in Figure 62.b
c
Z Z Z ~ . These commands can be combined. we can create vertical diagrams easily. Figure 61 shows a more elaborate chart. To begin. respectively.
v
top left

center
Z
? 1m
a
. as illustrated in Figures 59 and 60.
and I use the \setlength command to set the units of measurement to be 1 inch. This means that when
. .oval
bottom right
Figure 61: Variety of Objects in Picture Environment The ﬁrst command begins a center environment.
Every picture command begins with \put. indicated by the coordinates (0.1){.3975}} \end{picture} \end{center} \vspace{1in}
73
Figure 62: Source for Figure 61 I specify some length = 5. 1){\oval(.25)} \put(. and the stuﬀ is a ﬁlled circle with diameter .. (There is an alternative way to begin the picture environment.1}} \put( 0... which is not described here..43}} \put(1. but its syntax is diﬀerent.0) \put( 0. The parameter that determines this is \unitlength.1}(1.5 inches below the origin (i. 1){\circle{.1 inches (centered at the origin): \put(0.895){\line(1. as in beginning a paragraph with \noindent.4}} \put( . I am specifying 5 inches. The
.01}(. y = −.) The ﬁlled circle shows where (0. or ph it could be in the middle of a sentence.1){\fbox{$\begin{array}{c}a\\b\\c\end{array}$}} \put(. This could be at the left margin.7.0).. In picture mode it enables control over not only the width. Then.35){\vector(1.5){\framebox(.32. each beginning at .2.1){.1 Picture Environment
\begin{center} \setlength{\unitlength}{1in} \begin{picture}(0. y) coordinates are relative to where the position is when the picture environment is entered.1}} ⇒ v The next three commands put three diﬀerent kinds of boxes.3){center} } \put(1.5){\dashbox{.5}} \put(..2}} \put(.6. 0){\circle*{. The ﬁrst is similar to \framebox in text mode.5){\vector(4..0) is in this picture.1. we enter the picture environment stating that the point of entry is the origin.1){\vector(1. which is exclusively for the picture environment..7.1){\vector(1.05){oval} \put(0. and this extends the position options to a second character: t = top. where stuﬀ can be text or some picture object.0){.85. The (x. and the default for the picture environment is 1 pt.55}} \put(.0){.3)[tl]{top left} } \put( 1..7.5).05){1} \put( 1. The complete syntax is: \put(x. just as the smiley face appears here (see Exercise 1). but also the height.3}} \put(.5){\vector(0.0){.5. it could p be a column in a table deﬁned within the tabular environment.5){\dashbox{.55.0){\circle*{.y){stuﬀ }..e.35. b = bottom.3.2.1.. The ﬁrst \put in Figure 62 speciﬁes the position at the origin.65.1){\vector(1.65.55}} \put( 0.0){..3){.3)[br]{bottom right} } \put(.
The new point is determined by moving
. Now the code begins to draw the vectors. I use the \fbox command. The same applies to the \oval speciﬁcation. We know the center of the circle is at (−. the line is horizontal.∆y){len} \vector(∆x. so consider Figure 63. which is centered. The box length is set to 1.01 inches. resulting in fewer dashes to compose the box.1 inches. having the same dimensions as the framed box. Unlike the box family. but that is not where we want to put the inscribed text to be centered. and the text is at the bottom right because of the optional speciﬁcation. if ∆x = 0. which are lines with arrow heads.5 measures the entire width:
' & $ 6 . If ∆y = 0. with the length of the dash set to . we cannot include the centering of text within the circle command. Both \vector and \line have the same syntax:
\line(∆x.7 inches and height = .2 inches.5 × . −1). and some trial and error was needed to establish its position. the position is centered because that is the default. only its sign matters). This is undoubtedly confusing. the line is vertical. Otherwise. The next dashed box has the dash length set equal to . has dimensions . This is the same as I used in text mode.∆y){len}
If ∆x = 0.25 (inches). where .65. followed by putting text that required some trial and error to locate. located at coordinates (−. deﬁned as usual in math mode: the array has three rows and one column.65. the speciﬁcations are width = . The oval. itself.3 inches.height ? %
width
After the \oval speciﬁcation. the actual ∆y change in x is still len. The next \put puts a dashed box. The “1” inside the circle required another \put. and len is the amount of change to the right or left of the original point (it does not matter what the magnitude of ∆x is.74
6 GRAPHICS
general form of the \framebox command in the picture environment is as follows:
\framebox(width. [br]. −1) (from \put). and len is the amount of change above or below the original point (it does not matter what the magnitude of ∆y is. Now we come to the \circle speciﬁcation. except here I use it to frame an array. and the slope of the line is ∆x .height)[posn]{text}
In the example shown in Figure 62.2 inches. with diameter = . only its sign matters).
and we want our destination point to be (xt . how should we set the slope parameters? 13 Ideally.
. and 1 if yt > y0 . we have some work to do.3.6. the calculation is simple: set ∆x = 0. but trial and error in selecting the parameters tends to be just as eﬃcient. If we we set len = 1. we want (xt . 5 Fixing len = xt − x0 . yt ). The actual length of ∆y 2 the line segment is len 1 + ∆x .
y0 + ∆y
∆y y0 + len ∆x Original point y0 x0
∆y slope = ∆x
New point
x0 + len
x0 + ∆x
Figure 63: Line Parameters As if this unnatural deﬁnition of the line segment were not enough. Suppose our original point is (x0 . Either way. y0 ) along the line with slope ∆x until the new xcoordinate is ∆y x0 + len. we would set ∆x = 15 . Then. for example.3 to obtain the correct xcoordinate. then searching for a nearest slope approximation. yt ) = (x0 + 1. y0 ). ∆y must be integervalued and within −6 to 6. The ﬁrst \vector command in Figure 62 starts at (−. there is an important restriction: ∆x. ∆y = −1 otherwise. the new ycoordinate is y0 + len ∆x .65.5). Suppose. y0 + 1. If xt = x0 . If xt = x0 . but the restrictions do not permit this. which I calculated to be from the “top left” box to the “center” box. we could have problems with approximating the results. The ∆y closest we could come is 4 . −1). We could setup a leastsquares estimation problem. len = yt − y0 .1 Picture Environment
75
∆y from (x0 . is not necessarily the best overall approximation.
so we use two \vector commands to draw one arrow left to right.. In this case. Now consider the next \vector.65.55. and we set len = ∆y = . so ∆x = 0 − (−.35. −5). Finally. so we obtain the coordinates of the arrow’s tail: (xt . which is what is speciﬁed: top left ⇐ \vector(0.3}. −.65 + . and this needs some trial and error.4} 1m The next arrow is doubleheaded. That 2 accounts for the initial position given by \put(.3.4. The length is determined by where we want the arrowhead: at the top of the circle. which is a vertical arrow from the same box to the circle below it. so ∆x = 1 and ∆y = 0. yh ) = (xt .1. The arrow is to be horizontal.5). −.35){\vector(1. then an arrow at the same end points. y1 ) = (xc + r.3. we need to determine the length. The uncertainty is the width of the box. so the right edge of that box is at x = −.76
66
GRAPHICS
width

height
?
box begins here → c
In Figure 61 the “top left” box starts at (−1.4). as speciﬁed. given by \vector(0. The head is to be ﬂush with the left edge of the \fbox. −1).3}}.0){. Starting at y = −.. Further.0).7.. y) = (x0 + 1 h. ∆x = 0 and ∆y < 0. the vertical position changes by moving up half of the height. drawn left to right. −1) = (−.35).2 is 2 the diameter speciﬁed by \circle{. yc ) = (−. y0 ) = (−1.5) and h = . this involves more calculations because the arrow is not simply horizontal or vertical.1) = (−.3) = . y0 ) and h = height. −1).3. Thus. −. −.3. It required these computations to determine the complete picture command: \put(. as speciﬁed with \vector(1.1){.65. so the coordinate where the arrow begins (called its tail ) is (−.2) since .3.65.3. y0 ). and its xcoordinate is to the right by the length of the radius: (x1 . −.5) + . We must add the radius. We want the coordinate of the end of the arrow (called the head ) to be ﬂush to the left side of the “center” box. −. That box begins at (0. but drawn right to left. yc − yt + r) = (−. speciﬁed as {. where the 2 box starts at (x0 . which is its center. The initial position is calculated simply as the midpoint of the bottom edge of the box: (x. but we
?
. we know only that the center of the box was put at (0.1). so that is where we \put the ﬁrst arrow. . the position of the arrowhead is (xh .3) = (−. The circles y coordinate is −. by computing the coordinates of the tail and head. yt ) = (−1 + 1 2 .5). which is 1 (.65.5) = (−.5 + 1 .3. We begin the same way. (x0 . −1 − (−. The left end point is at the ycoordinate of the center of the circle.2}.3. Since the arrow is downward.35). and its width is .
3975} to obtain the line shown in Figure 61. but here are some things to note: • Only boxes can have inscribed text. due to not having the corner of the oval coordinates. and is provided free of charge. • Some calculations and some trial and error are needed to align objects and lines. the circles and ovals require separate \put commands. we specify \line(1. 0). With just a few iterations. In this case.2. −. The reverse arrow begins at (0. p. which can take some trial and error to position. and its slope is (−1. requiring recalculations and more eﬀort for the new positions.4 do not allow this. 1).)
. in which case you specify the parts you use instead of pstall — see [15] for loading individual portions.4 + .895) to (1. but the latter was computed by knowing that the “bottom right” box starts at (1. −1). I shall cover these in the next section with a powerful package called PSTricks. so len = ∆x = .) In the preamble specify \usepackage{pstall} for the entire system. which is why we have \vector(1. However. • Moving a portion of the picture can be tedious.5).2 PSTricks
77
do not know the width of the box. Now the true slope of the line we want is . which is what is speciﬁed. There are packages to extend the picture environment. 2 Thus.55}. but the restrictions . but you can obtain it at CTAN [4]. the end points were determined to be from (1. The closest slope we can have is with (∆x.395 .395) = .5) and has a width of 1. • There is no direct way to control the size or style of the arrow heads. (You can use parts. 117) gives the commands in the picture environment.2. (It is not standard with MiKTeX. −. Table 46 (in the Appendix. the end point was determined to be x = 0.5). called Bezier approximations. These can make using the picture environment time consuming and rather unpleasant.0){. the best choice of len can be found as the average of the deviations: len = 1 (. and we can plot curves. There is a better way!
6. so the midpoint of the bottom edge is at (1. The former was found by trial and error.3975. ∆y) = (1.6.2
PSTricks
PSTricks [15] was written by Timothy Van Zandt. to a set of points. −.55.6. The last vector also required trial and error.1){. −. and there is very limited control over line thicknesses. Given this slope.6.
this is not the only way to put objects. • Objects can be named (as nodes) and lines and arrows can be drawn between them by naming the tail and head. but it does with MetaPost. including plots of points that can come from a data ﬁle. themselves. ]}. for short) is designed to overcome diﬃculties with using the picture environment. typically available free of charge.fillcolor=gray}
A fundamental command in pst is \rput. can have inscribed text. In particular. thereby eliminating the need for calculation or trial and error. • Shapes are highly variable. • Drawing curves is simple. some of which were listed above. • Circles and ovals. • Arrow heads are adjustable. 7]. which makes it potentially more versatile. and Bezier approximations of four points are available. in addition to boxes. PSTricks (pst. This is especially true of commands that involve rotations. and the default ﬁll color is white. The commands. All of the pst commands have options to override default settings for relevant parameters. that do many of the things done by PSTricks (and some additional things).78
6 GRAPHICS
One thing you need to know is that not all of the pst results can be seen with a dvi viewer. can specify where to put them. It is more diﬃcult to learn than PSTricks. The defaults. written by John D. see [4]) does not work with PSTricks.. Here are some of the features of PSTricks that I shall illustrate. • Lines and arrows have the same command. Many A of these are described in The L TEX Companion [5]. Hobby. also provided free of charge. . the default unit of measurement is 1 cm. can be set with the \psset command: \psset{parameter = value[. pdflatex (not covered here. especially on varying the types of ﬁle outputs (PSTricks is tied to postscript). Table 19 gives
. but we can change them by specifying:
\psset{unit=1in. but unlike the \put command in the picture environment. but MetaPost is more openended in its design. and slopes need not be calculated. Another widely distributed picturedrawing system is MetaPost [6. There are many packages [4]. • Only one command is needed to put lines through a sequence of points. . For example. identifying any of a great variety of arrowheads simply. Some require converting to postscript and viewing the ps ﬁle. themselves.
I shall illustrate the commands in Table 19 ﬁrst. shown in Table 20. . Draws circle centered at (x. y0 ) . along path given by coordinates. y0 ) and opposite corner at (x1 .2)
Draws rectangle with a corner at (x0 . For example. y0 ). Thus.1)(10. yn ) to (x0 . PSTricks extends the rectangle in \framebox by having a variety of shapes. determined by a: . y)(rx .0){. showing the ease and versatility of PSTricks. . .3)(6.
pscircle(x. like boxes and circles. (xn . Table 19: Some Basic Drawing Commands in PSTricks psframe(x0 .2)(1. we can specify relevant options as [parameter = value]. use the fillstyle parameter. The origin is determined by where you are when issuing a pst command. we write \pscircle[fillstyle=solid](0. y) with radius = r. yn )
\pspolygon(0. to produce a solid circle with radius .0){2}
psellipse(x. same as \psline{}. <> double arrow’ <. y1 )
\psframe(0. . centered at the origin. y) with horizontal radius = rx and vertical radius = ry Draws line or arrow. Draws closed polygon with given coordinates.0) \psline{*} (0.2 PSTricks
79
some of the common commands to draw objects and lines. The idea of a box is to have some shape enclose text.6. y0 )(x1 .2)
psline{a}(x0 .2)
pspolygon(x0 . so many features are not presented here. I can put that circle right here: commands use the linewidth parameter to control the thickness of the lines used in the drawing.0)(10.1 cm. All no environment is entered. .0)(10. we do want the \rput command in order to put text into various objects.0) (0.1} (having already set fillcolor=gray). y1 ). For each command.0) \psline{<>} (0. except ﬁgure is closed by drawing line from (xn . then I shall show some additional shapes and commands. .no arrow. Draws ellipse centered at (x.0)(5. (xn . A parameter used by these commands is the distance
.0)(5. The User’s Guide [15] is freely available and clearly written. yn )
\psline{}(0. > forward arrow. This is meant to be an introduction. y){r}
\pscircle(5.backward arrow. the unit of measurement was set to 1 mm. ry )
\psellipse(3. (there are more!). and objects that could be made solid. For those examples.3)
In using these commands. . y0 ) .
and fillcolor.height}{stuﬀ} Here are some examples: scales stuﬀ keeping the same aspect ratio scales the width and height individually
. . linestyle. called framesep=len.80
6 GRAPHICS
between the border and the text inside.) The pst ﬁgures are drawn after specifying \psset{unit=1mm.4]{framebox}
Adds shadow to psframebox
\psshadowbox{shadow added}
Draws double frame
\psdblframebox{double frame}
Draws circle around stuﬀ
\pscirclebox[linewidth=2pt]{circle}
Draws oval around stuﬀ
\psovalbox[linestyle=dotted]{oval}
These commands can be used in the text. . . . we obtain this oval by writing: . Table 20: Boxes in PSTricks psframebox{stuﬀ} framebox framebox psshadowbox{stuﬀ} shadow added psdblframebox{stuﬀ} double frame pscirclebox{stuﬀ} circle psovalbox{stuﬀ} oval Draws rectangle but could have rounded corners
\psframebox{framebox} \psframebox[framearc=.fillcolor=white}. where the default value of len is 3 pt. linecolor. we obtain \psovalbox{this oval}. other parameters include linewidth. and they can be scaled by specifying one of the following: \scalebox{size}{stuﬀ} \scalebox{width. Boxes need not be enclosed (like \makebox). For example. (As usual.
Here is how:
\rotateleft{Left}\rotatedown{Down} \rotateright{Right}
Left Right Down One application is given by the following: Who is the founder of TEX?
Answer: Donald E. Consider the following example: Node A Node B Node C
Who is the founder of \TeX? \rotatedown{Answer: Donald E. but with the following syntax:
\ncline{a}{name of node A}{name of node B }
. The syntax for \rnode is:
\rnode{name}{stuﬀ }
The next two commands put nodes named B and C. including variations of arrowhead shape. by themselves and as enclosures for boxes. In PSTricks. the named objects are called nodes. To avoid the tedious calculations in locating the coordinates of the tail and head.2 PSTricks Halving the circle
\scalebox{. each enclosed with a frame. Knuth So far I have described a variety of shapes. the objects being joined can be referenced by name. and the text Node A is put there (with no frame). After entering the centering environment and setting the default units of measurement. The name is set to A. The \ncline command has the same arrow options as \psline. Knuth}
The source code is shown in Figure 64.5}{\pscirclebox{ \begin{tabular}{c} Halving \\ the \\ circle \end{tabular} } } \scalebox{2}{\psframebox{ \textsl{Doubling} }}
81
Doubling
Tall Wide
\scalebox{1 3}{Tall} \scalebox{3 1}{Wide}
There are times when we want to rotate stuﬀ. with the \rnode command. with a great variety of styles. These can be connected by \psline. the \rput command puts a node.6.
is shown in ﬁgure 65.linearc=.2]{>}{3}{3} \Bput[5pt]{loop} % \Bput keeps label horizontal and 5pt is % the space added between label and arc \ncloop[angleA=180.loopsize=. which is what we want when the nodes are enclosed boxes.loopsize=.2.5in}
Figure 64: PSTricks Source for Connecting Nodes Figure 66 shows a graph that could represent any number of things. 0){2}{2} \cnodeput( 2.arm=.1){\rnode{B}{\psframebox{Node B}}} \rput( 2.)
\begin{center} \psset{unit=1cm} \rput( 0. Otherwise. (nodesepA and nodesepB are keywords and have nothing to do with the names we assign to our nodes. using PSTricks. nodesepB=n. or for both end points.2.arm=.linearc=. the line would touch Node A text.82
6 GRAPHICS
The ﬁrst \ncline in Figure 64 draws a plain line from node A to node B. (Try adding one line at a time and observe each eﬀect. respectively. The separation is exaggerated to 5 pt in the arrow from node C to node A.5. node separation can be speciﬁed for either end point. 1){3}{3} \cnodeput[doubleline=true]( 2. In general. like B and C. 0){1tail} \ncline{>}{1tail}{1} % tailess arc into (1) % Arcs (with labels) \ncline{>}{1}{2} \aput{:U}{1/2} % \aput puts label above arc \ncline{>}{2}{3} \aput{:U}{2/3} \ncline{>}{2}{4} \bput{:U}{2/4} % \bput puts label below arc \ncarc{>}{3}{4} \Aput{\small 3$\rightarrow$4} % \Aput keeps \ncarc{>}{4}{3} \Aput{\small 4$\rightarrow$3} % label horizontal \ncloop[angleB=180. Its source.1){4}{4} \pnode(3. The [nodesepA=3pt] option gives 3 pt separation between the end of the line and node A.5. or nodesep=n.)
\begin{center} \psset{unit=1cm} % Nodes \cnodeput(2.2]{<}{4}{4} \Bput[5pt]{loop} \end{center} \vspace{1cm}
Figure 65: Graph Source (Result in Figure 66)
. which is not what we want. The default value is nodesep=0pt. by specifying nodesepA=n. 0){\rnode{A}{Node A}} \rput(2.1){\rnode{C}{\psovalbox{Node C}}} \ncline[nodesepA=3pt]{A}{B} \ncline[nodesepA=5pt]{<}{A}{C} \ncline{<>}{B}{C} \end{center} \vspace{. 0){1}{1} \cnodeput(0.
2 PSTricks
83
3 1 loop 2/4 2/3 1/2 4→3 3→4 2 4
Figure 66: Graph Result (Source in Figure 65) Now I describe curves that go through.1)(2. y1 ).showpoints=true}
(The showpoints=true setting is what causes the points to be included in the picture you see. and (x1 .
2
\pscurve{(>}(0. y0 )(x1 . given points.3)
⇒
Question: What is the pst command to draw the parabola given by y = ax2 + bx + c.0)(4.4) \parabola{<>}(4.gridlabels=7pt](1.0)(1.0)(1.1)(1.1)
.0) \parabola*[fillcolor=black. the latter being a closed curve that joins the last point with the ﬁrst.1)(1.5cm. whose command syntax is:
\parabola{a}(x0 .1)(1.1)(1. perhaps approximately.griddots=10.1)
\psccurve(0.
\psgrid[subgriddiv=1. For example.3)(2.1)(1. y0 ) is one point on the parabola.showpoints=false](1. where a = 0?
b b Answer: \parabola(0.1)(1. c)(− 2a . y1 ) is the (unique) point having dy/dx = 0.6.
where (x0 .) We begin with the parabola. \parabola* speciﬁes ﬁlling the parabola. − 4a + c) The following shows two commands: pscurve and psccurve. The examples that follow use the following pst settings:
\psset{unit=.
dy=5.Dy=5. The command syntax is:
\psbezier[parameters]{a}(x0 . or nothing around each pair. MATLAB c . y1 )(x2 . y3 )
\psbezier(0.1)(3.11)(29.6)(10. The data ﬁle just needs pairs of coordinates.10){\textsf{B}} \psline(40. which I shall explain.0) \rput(45. which can be separated by a comma or just blank and can have parenthesis.4)
We can read data from a ﬁle. 4){\textsf{D}} \psline(20.0)(20. y2 )(x3 .Oy=0. Maple c . and SPLUS c .0)(1.0) \rput(35. the data ﬁle is read and its points plotted with the \fileplot command. 7){\textsf{A}}
Figure 67: Source Code for Drawing Histogram of Test Scores After setting the units of measurement to 2 mm. Mathematica c . 8){\textsf{F}} \psline(11. Octave c .5)(50.8)(39.0)(11.2)(19.dat} \psaxes[Ox=50.0) \rput(14.2)(19.13){\textsf{C}} \psline(30.3)(2.)
15 C 10 F 5 0 50 60 D 70 80 90 100 B A
score
\psset{unit=2mm.dx=10.8)(39.0)(30. y0 )(x1 .ticks=y]{<>}(60.0) \rput(25.6)(10.Dx=10. The data ﬁle had y = number of students with test score = x + 50.0)(1. showpoints=false} \fileplot[plotstyle=dots]{mydata.0) \rput( 5. braces.17) \rput[r](60. (The oﬀset of 50 was used in establishing the origin in the plot.2){\large score} \psline(1.5)(50. The following histogram was plotted by the source code in Figure 67. (Setting showpoints=false
.0)(40.84
6 GRAPHICS
The Bezier curve joins two end points and comes as close as possible to two intermediate points. perhaps produced by mathematical software like gnuplot c .11)(29.
0)(1. and there are 11 dot styles. y1 )(x2 .5cm]{>}(0.) The data ﬁle is plain text and has the following entries: % This is mydata. cause the spacing to be equal (approximately) by using Dx÷\psxunit and Dy÷\psyunit. y1 ) is absent.6.1.1) ⇒
.0)(8.70) [70. y0 ) is the origin. There are other plot styles. As in \psline. The other parameter settings are described in Table 21. speciﬁed by plotstyle=dots. if (x0 . ticks=y. y2 )
where (x0 . (The default values. axes are superimposed with the \psaxes command:
\psaxes[params]{a}(x0 . such as plotstyle=line.0)(2.)
\psaxes[unit=.65) [65. the origin is assumed to be at (0. it is assumed to be equal to the origin.1. y0 ) is absent. y0 )(x1 . y1 ) is the Southeast corner.2 PSTricks
85
suppresses plotting the points in the \psline commands.3) ⇒
\psaxes[unit=. This is suppressed for the xaxis in Figure 67 by specifying the option. 0). dx=dy=0.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.100]
The plot.plotstyle=dots]{mydata. itself. (x1 . and (x2 . Here is one of the alternatives:
\fileplot[dotstyle=+.2. is just the points.90) [90.5cm]{>}(4. Here are some examples: 2 1 0 0 1 2 3 2 1 −1 0 1 2 Note that ticks are uniformly spaced on each axes. If (x1 .80) [80. respectively.dat} ⇒
Next. y2 ) is the Northwest corner.
(If you can get a ps ﬁle.edu/pub/gnuplot/. MATLAB c . is gnuplot. The unix systems xv and Image Magick can do this for a large variety of graphic ﬁle formats. and the export options include the eps ﬁle format. which converts jpeg ﬁles to eps. you could use \psfig.) On unix. for both unix and DOS that produces eps ﬁles. See [15] for lots more. like Maple c . gif and jpeg ﬁles. Once the ﬁle is in eps format. have an option to export an eps ﬁle.che.dartmouth. including bitmap (xbm). Octave extends the capabilities of gnuplot and is also available free of charge. at http://www. this is scaled (simply. Mathematica c . and emftoeps. A basic plotting system for functions and data. xfig is an excellent system to draw ﬁgures. is given by Keith Reckdahl [12].edu/octave/.3
Importing pictures
A The way to import a picture into L TEX is to convert it to encapsulated postscript (eps). It comes with MiKTeX and basic unix installations. or there is a unix conversion utility. which converts Windows Metaﬁles (wmf) to eps.86
6 GRAPHICS
Table 21: Parameters for Horizontal Vertical Default Ox=n Oy=n 0 Dx=n Dy=n 1 dx=n dy=n 0
\psaxes Meaning Label at origin Label increment Label spacing
The next command. rput[r](60. but this does not exhaust the PSTricks commands. and those that plot mathematical functions or data. To ﬁt the picture and the code next to it. The remaining commands draw the histogram boxes and put the letter grade above each box in sans serif font. An exceptionally clear description of this.2){\large score} puts “score” in large font. There are two packages that provide
. \ps2epsi. including historical context. Thus. we can import it using the Graphics Bundle [3]. including many examples. There are also commercial systems. Carlisle.
6.” Figure 68 shows the sequence of how each \psline and \rput adds to the picture. by specifying \psset{unit=1mm}): We shall stop here. \psaxes and \rput. Another way to obtain an eps ﬁle is with conversion. ﬂush right (indicated by [r]) at the coordinates (60. provided free of charge.) Many systems that let us draw ﬁgures. we obtain the data plot. notably jpeg2ps. −2). There are free conversion systems on MS Windows. written by David P. when I superimpose the commands \fileplot. This is available free of charge at FTP://ftp. and SPLUS c . (He also goes deeper into customizing placements of pictures in ﬁgures. which can produce eps ﬁles of plots. Leaving oﬀ the “score.wisc.
6)(10.Oy=0.Dx=10. Here I use graphicx.8)(39.2)(19.8)(39.3 Importing pictures
87
essentially the same capabilities but with diﬀerent syntax.8){\textsf{F}} 50 60 70 80 90 100 \psaxes[Ox=50.7){\textsf{A}} 80 90 100 50 F D 60 70 C B 80 90 100 \psline(30.0)(11. the other is graphicx.5)(50.11)(29.dat}
15 10 5 0 15 10 5 0 15 10 5 0 15 10 5 0 15 10 5 0 15 10 5 0 50 F D 60 70 80 90 100 50 F D 60 70 C B A \psline(40.0)(30.Dy=5. For example. Figure 69 shows a ﬁgure that was imported with the following statement:
.0)(40.17)
60
70
80
90
100
Figure 68: Sequence of PSTricks Commands to Draw Histogram To include an eps ﬁle.4){\textsf{D}} 50 F \psline(1.
\fileplot[plotstyle=dots]{mydata. simply specify \includegraphcs[options]{ﬁlename}.6.5)(50.0)(1.0) \rput(14.6)(10.10){\textsf{B}} 50 F D 60 70 C 80 90 100 \psline(20.0) \rput(5.0) \rput(25.0) \rput(45.2)(19.ticks=y]{<>}(60. as speciﬁed in the preamble by \usepackage{graphicx}. One is called graphics.11)(29.13){\textsf{C}} \psline(11.0)(20. dx=10.dy=5.0) \rput(35.
6 −0. read about the PSfrag package.2 −0. we might want to specify width=\textwidth.6 −0.4 −0. by Michael C.4 0. by specifying the sin function over the indicated grid).2 −0.eps}\end{center}
1 0.8 −1 −8
−6
−4
−2
0
2
4
6
8
Figure 69: Applying \includegraphics to Import an eps File In this case I speciﬁed the half the size it was produced print sin deps after plotting Figure 70 shows the same eps follows: option.6 0.height=1in]{sin. The height speciﬁcation (!) says to maintain the aspect ratio.8 −1 −8
−6
−4
−2
0
2
4
6
8
Figure 70: Specifying Dimensions in \includegraphics For a very large picture.2 0 −0.88
6 GRAPHICS
\begin{center}\includegraphics[scale=.4 0.4 −0.height=!. but with the width and height set as
\begin{center} \includegraphics[width=2in. and let it ﬁll the entire width of the page.eps} \end{center}
1 0.5. scale=.6 0. If you ﬁnd yourself importing eps ﬁles but would like to make some A changes in L TEX.8 0. ﬁle. Grant and
.8 0.5]{sin. which prints the ﬁgure (in this case by MATLAB.2 0 −0.
It can also perform scaling. It has two basic operations: (1) edit A some string or position in the ﬁgure (i. with eps ﬁles produced by MATLAB and xﬁg. Here are some examples:
. the eps ﬁle). or almost any stuﬀ.3 Importing pictures
89
David Carlisle. and (2) translate L TEX commands that you put in the ﬁgure in the ﬁrst place. which comes with a basic installation (including MiKTeX).e. Importing graphics is only one of the functions of graphicx. rotation.. Here are examples:
Double your fun \scalebox{2}{Double your fun}
\resizebox{1in}{!}{\fbox{Open wide}} \reflectbox{Reflect on this} \rotatebox[origin=c]{90}{Landscape} \rotatebox[origin=rt]{45} {\psframebox{ \begin{tabular}{c} Was\\Pythagoras\\a square? \end{tabular} } }
Open wide
siht no tceﬂeR Landscape
a Py W a sq ag s or ua a re s ? th
These operations are available because the programs that perform them are used in the \includegraphics command. The documentation gives examples. pictures. and sizing of an arbitrary box. Although it is feasible to perform the operation after importing a graphic. whose documentation is at CTAN [4]. The box could contain text.6. it is more eﬃcient to specify that option in the \includegraphics.
eps}
\includegraphics[width=.origin=c]{protractor.eps}
\includegraphics[height=. where \thicklines is speciﬁed and \unitlength = 1mm vm 1
E vm 2 c
A Exercises.5in. Be sure your name is on each. 4). 1. Use the picture environment to draw the smiley face on page 73.
. Use PSTricks to draw Figure 3 (p.90
6 GRAPHICS
\includegraphics {protractor. 2. height=!]{protractor.width=!. angle=90.eps}
copy of the associated postscript result (ps ﬁle). Draw the following graph with the picture environment. Submit a printed copy of the L TEX source (tex ﬁle) and printed
© vm 4'
vm 3
3.25\textwidth.
7. so you must obtain the PSTricks User’s Guide [15]. include it in your document. (They were drawn here with PSTricks. but this section did not describe all that is needed. Use PSTricks or the picture environment to draw the following.) (a) Graphic view of Pythagorean Theorem:
square of hypotenuse square of leg 2
hypotenuse leg 1 2
square of leg 1
.3 Importing pictures 4.
91
rhombus
5. Make a ﬁgure in some system that lets you save it as an eps ﬁle (or use some conversion program). Use PSTricks or the picture environment to draw the following. Then. Use whatever means you prefer (or that your instructor requires) to include each of the following ﬁgures in your document.6.
β α
6.
40) (45. 60)
3
5
(c) The sin function:
y = sin
π x 2
x
(d) Bernoulli family tree:
Nikolaus (1623–1708)
Jacob I (1654–1705)
Nikolaus (1662–1716)
Jahann I (1667–1748)
Nikolaus I (1687–1759)
Nikolaus II (1695–1726)
Daniel (1700–1782)
Johann II (1710–1790)
Johann III (1746–1807)
Jocob II (1759–1789)
. 20) (25. 30) 50) (45.92 (b) Network with arc data: 2 4
6 GRAPHICS
(15. (35. 10)130) 50) (15. (35.
or right after \begin{document}. right after \maketitle. suppress this by adding \thispagestyle{empty}. titlepage must be speciﬁed as an option in the \documentclass command.93
7
7. Multiple authors are separated by \and. the following does this while specifying 12pt font as another option:
. which can be deﬁned anyplace before the \maketitle. You might also need to initialize the page counter with \setcounter{page}{0}. This is usually done just following \begin{document}. The cover page is by itself and is not numbered. If you see a page number on your cover page.
\title{The \LaTeX\ Companion} \author{Michel Goosens \and Frank Mittelbach \and Alexander Samarin} \date{1994} \maketitle
Figure 71: Title Page Source (Result in Figure 72)
A The L TEX Companion
Michel Goosens
Frank Mittelbach Alexander Samarin
1994
Figure 72: Title Page Result (Source in Figure 71) Since articles often have this information on the ﬁrst page of the article (rather than a separate page).) Specifying \date is optional (\maketitle puts in the current date if the date is not deﬁned). (The jagged edges in Figure 72 mean that there is more space between the title and the top of the paper. The necessary parameters are \author and \title. For example.1
Making Special Parts
Cover Page
The easiest way to make a cover page is with the \maketitle command. such as in the example shown in Figures 71 and 72. it depends upon your management style. followed immediately by \maketitle. Typically these are put into the preamble.
All three authors would be put on separate lines if the address information were extended further. Figures 74 and 75 illustrate this along with some variation in the date. Germany \and Alexander Samarin \\ Geneva Switzerland}
As illustrated in Figure 73. or if the names were very long.94
7 MAKING SPECIAL PARTS
\documentclass[12pt. and other information about each author can be added. Germany
Alexander Samarin Geneva. Switzerland
Frank Mittelbach Mainz.titlepage]{article}
Addresses. Switzerland
1994 Figure 73: Adding Addresses to Authors There are times when we want to acknowledge support for one or more of the authors. \maketitle puts the third author on a separate line.
. The \thanks command does this by creating a footnote.
A The L TEX Companion
Michel Goosens Geneva. Figure 73 shows how the authors appear when the \author deﬁnition in Figure 71 is changed to the following:
\author{Michel Goosens \\ Geneva. aﬃliations. using diﬀerent footnote marks for each one. For example. using \\ to create new lines. Switzerland \and Frank Mittelbach \\ Mainz. This is because the added width of author information makes it too long to ﬁt on one line.
510 bc)
1 Renamed. which puts the footnote mark without any new text.R.C. \and U. 2 Supported
by the army. \and I. 510 {\sc bc})}
95
Figure 74: Footnotes in the Cover Page Source (Result in Figure 75)
Pieces of π 1
Archimedes2 Syracuse. Ionia
210 bc (revision of earlier version.
\title{Doing \author{I. This uses the \footnotemark command. Sicily Pythagoras Samos. Prior to that.}\\ Syracuse. the value of the footnote counter is set back to the ﬁrst footnote mark.}} \index{\texttt{$\backslash$thanks}} \index{footnote} \author{Archimedes\thanks{Supported by the army. } \LaTeX} Rich \thanks{Smart University} Grand \thanks{StreetSmart} All \addtocounter{footnote}{2} \footnotemark
Figure 76: Authors with same footnote (Result in Figure 77)
. Ionia } \date{210 {\sc bc} (revision of earlier version. Sicily \and Pythagoras \\ Samos.7.M.1 Cover Page
\title{Pieces of $\pi$\thanks{Renamed.
Figure 75: Footnotes in the Cover Page Result (Source in Figure 74) Figure 76 shows how to use only one footnote for authors having the same aﬃliation.
)
\begin{abstract} This shows that the ratio of the circumference to the diameter of any circle is the same constant value. denoted $\pi$. This environment is deﬁned to produce an abstract on a separate page (placed wherever you put the environment speciﬁcation). Rich1
U.96
7 MAKING SPECIAL PARTS
A Doing L TEX
I. specify titlepage as an option in \documentclass (even if you do not intend to use \maketitle). (Like the cover page. the abstract is placed far from the top of the paper. except article.2
Abstract
The abstract environment is in all document styles. We further prove that this constant is bounded by $\frac{223}{71} < \pi < \frac{22}{7}$.C.R. itself. which is not shown in Figure 79. in boldface and centered. All1
1 Smart
University
2 StreetSmart
Figure 77: Authors with same footnote (Source in Figure 76)
7. \end{abstract}
Figure 78: Making an Abstract Source (Result in Figure 79)
. with the header: Abstract. is one paragraph and is printed without indentation.M. The abstract. Grand2
I. To have it. Figures 78 and 79 illustrate this.
3 Other Front Matter
97
Abstract This shows that the ratio of the circumference to the diameter of any circle is the same constant value.7. L TEX provides the \addcontentsline command. indicated by the toc speciﬁcation. like sections and A subsections. the table of contents in this document was obtained with the speciﬁcations given in Figure 80. followed by the list of tables.
\newpage \pagenumbering{roman} \pagestyle{myheadings} \tableofcontents \newpage \addcontentsline{toc}{section}{List of Figures} \listoffigures \newpage \addcontentsline{toc}{section}{List of Tables} \listoftables \newpage
Figure 80: Some Front Matter Speciﬁcations for This Document The \pagenumber speciﬁcation causes the page numbers for the front matter to be put into Roman numerals. just after the cover). Each of these are put on a new page. We further prove that this constant is bounded by 223 < π < 22 . which should be right after the cover page. I declare \listoffigures. which is on page v.3
Other Front Matter
The \tableofcontents command makes a table of contents. That is why you see the Table of Contents on page i (ﬁrst numbered page. For example. The page numbering is reset when we ﬁnish the front matter by specifying
\newpage \pagenumbering{arabic} \pagestyle{headings}
This switches to the Arabic numerals and initializes the page counter. Then. denoted π. respectively. Then. it is placed wherever you put the command.
. The table of contents generally includes numbered parts. The section parameter tells the latex program to format it like a section — ﬂush left. you can include lists of ﬁgures and tables with the \listoffigures and \listoftables commands. I use the \addcontentsline to add it to the table of contents. 71 7 Figure 79: Making an Abstract Result (Source in Figure 78)
7. Just above each declaration. To include other front matter.
4
Back Matter
After the main part of the document is ﬁnished. \end{abstract}
Alternatively. After a successful compilation. enter at the command line: makeindex myfile Then. but we do not want it to have a section number. The last portion in the back of any book is its index. compile again. but with no number (and the section counter remains unchanged). The \renewcommand enables us to do this. 28). consider the following example that illustrates how to have an Acknowledgments page:
\renewcommand\abstractname{Acknowledgments} \begin{abstract} I thank my family and friends for all of their support. and is illustrated in Figure 81. with all references resolved. The only change we require is another header name. . For example. . To make an index. where the * suppresses the numbering. we put the bibliography (see §3 and §8. This could be done with the appendix environment: \begin{appendix} . we might want something to look like a section (and automatically added to the table of contents). Put \makeindex at the end of the preamble.6). Put \printindex just before \end{document}. \section*{Preface} puts “Preface” in the same style as any section. To have entries in the index.98
7 MAKING SPECIAL PARTS
The same format as the abstract can be used for other front matter that we want to format the same way.
. In the text. For now. This is done by redeﬁning the \abstractname parameter used by the abstract environment. you use \index{entry}. For example. 3. I also thank the contributors to the Comprehensive \TeX\ Archive Network (CTAN). §?? has more to say about using this command to customize many things. This could also be desirable in a long report. Put \usepackage{makeidx} in the preamble. This is achieved by the \section* command.
7. This is analogous to the use of bibtex (p. 2. \end{appendix}. the index in this book contains several occurrences of ‘ﬂushleft’. we have three things to put into our source ﬁle: 1. We might ﬁrst want to have appendices that follow the main text.
More generally. which can be controlled by \setlength. use !. and gloss makes a glossary. \index{package!makeidx} puts the entry ‘makeidx’ under the entry ’package’.7. and was shown on page 95.ps myfile. here is my second2 .5 Footnotes
99
at each occurrence.dvi dvipdf makeindex
print/post
myfile. the \footnote command can be used anywhere.tex
view/print convert dvips myfile. Figures 82 and 83 illustrate.
create/edit compile latex myfile.
Here is my first footnote\footnote{first}.
Figure 82: Setting a Footnote Source (Result in Figure 83) Here is my ﬁrst footnote1 . You can also change to common footnote symbols by specifying \renewcommand{\thefootnote}{\fnsymbol{footnote}}.
.
1 2
ﬁrst second
Figure 83: Setting a Footnote Result (Source in Figure 82) \thefootnote gives the counter for footnotes. nomencl makes a list of nomenclature.
7. as shown in ﬁgures 84 and 85. To put the entry as a subordinate. here is my second\footnote{second}.5
Footnotes
The \thanks command is one way to have a footnote on the cover page. For example.pdf
Figure 81: Adding makeindex to the Command Sequence There are packages to make other back matter: acronym makes a list of acronyms. and you can change from numbers to letters by \renewcommand{\thefootnote}{\alph{footnote}}. The distance between the line that underlies part of the last line of text to the footnote is \footnotesep. I specify \index{flushleft}.
100
8 TAKING CONTROL
\renewcommand{\thefootnote}{\fnsymbol{footnote}} Here is my first footnote\footnote{first}.
8
Taking Control
This section introduces you to fundamentals of customizing your document.
A Exercises. Be sure your name is on each. choosing only a few of the things you can change.
8. Extend exercise 1 to have acknowledgments and references (using BibTE X). Submit a printed copy of both the L TEX source (tex ﬁle) and
1. where n is the number of arguments.
Figure 84: Setting a Footnote Source (Result in Figure 85) Here is my ﬁrst footnote∗ . and Conclusions. here is my second† . but also the abstract.
∗ †
ﬁrst second
Figure 85: Setting a Footnote Result (Source in Figure 84)
the associated postscript result (ps ﬁle). Here are two examples simply to abbreviate commands with long names:
\newcommand{\ul}{\underline} \newcommand{\mc}{\multicolumn}
. A key to these changes are the \newcommand and \renewcommand commands. 2. acknowledgments and references. It is still in the context of an introduction. Make the main body have at least three sections: Introduction. Combine exercises 1 and 2 and add a table of contents showing not only all sections and subsections. here is my second\footnote{second}. and whatever is whatever you want the command to do.1
Your Own Abbreviations and Commands
The command that gives us the ability to make our own has the following form: \newcommand{\name}[n]{whatever }. Main Results. Write an article with a title page and abstract. 3. which enable you to deﬁne your own commands and change parameter values of existing commands.
If we are already in math mode. The second lets us write \mc{3}{c}{stuff} to enter a multicolumn. Some authors write N (A). we can specify \Gs{subscript}. simply change the one line to:
\newcommand{\usenul}{\nul}
(where the publisher’s command name is \nul). √ \chkbox ⇒ Some commands are speciﬁcally for math mode.tex suﬃx). if \Gs{i+j} is speciﬁed in text mode... and obtain the correct result. if you specify \newcommand{\fbox}. Some publishers have their own notation. it is replaced by $G_{i+j}$ to put it into math mode ﬁrst.8.0) \put( 2. in either a tabular or an array environment. Thus. The preamble can become very long as we add our commands. no matter which mode we are in. having deﬁned the \Box command. Now \Box ⇒ and. some write nul A. we can write \nul(A) to obtain N (A) (and we can be in text or math mode when we write this). Suppose we have a key term. For example. \Gs{i+j} is replaced by G_{i+j} to produce Gi+j . but we want them to work in any mode. in the preamble I speciﬁed: \newcommand{\chkbox}{$\Box^\surd\. For example. we can use it in other new commands. say mydefs. Then. We can choose one and deﬁne \newcommand{\nul}{\ensuremath{\mathcal{N}}}. so it is useful to put them in a separate ﬁle.$} Then. then add to the preamble:
\newcommand{\usenul}{\mynul}
and specify \usenul in the document.1 Your Own Abbreviations and Commands
101
The ﬁrst lets us write \ul{something} to underline something. The latex compiler will not let you use a name that is already being used. Then. Consider the following example:
\newcommand{\Box}{\mbox{\begin{picture}(0. spanning 3 columns and centered. A related use is when the command requires some lines of code. so we must be careful not to override them with ours. and there are still more symbols people use.. like mynul. you will get a fatal error message since there is already a \fbox command.7)} \end{picture} }}
(\mbox is used to ensure text mode). If you need to use the publisher’s.tex (note the .0){\framebox(7. we use the \input command to have the latex compiler read
. A way to do this is to choose a diﬀerent name. This is achieved by the command: \ensuremath{math stuﬀ }. otherwise. For example. particularly of notation. consider \newcommand{\Gs}[1]{G_{#1}}. Another reason to have our own commands is for consistency. like the null space of a matrix.
section[.) Diﬀerent source ﬁles could simply input this same ﬁle. so duplication of work is avoided.102
8 TAKING CONTROL
it wherever it is placed. the preamble of this document contains the command:
\input{mydefs}
(The suﬃx . We saw an example of this in changing the counters for enumeration lists (p.tex is assumed. The ﬁrst level of division is assumed to be a chapter. . This might not be appropriate due to other considerations. but the format of chapters is diﬀerent. In particular.
Table 22: Intrinsic Name Parameters What it is Abstract Appendix Chapter Contents Index List of Figures List of Tables Part References How it is called (keyword)
\abstractname \appendixname \chaptername \contentsname \indexname \listfigurename \listtablename \partname \refname for article style \bibname for book and report styles
You might want to change the numbering of some intrinsic counter.2
Your Own Names. Titles and Numbers
There are times when we prefer some name other than the default.subsection]. similar to a book. If you have no chapters. . it will number the ﬁrst section as 0. 43).
8. For example. such as entering the document into a database using
. The general form is
\renewcommand{\thecounter }{something}
Another example is to change section numbering in a report document style. in this document the “Table of Contents” was obtained by specifying the following in the preamble:
\renewcommand{\contentsname}{Table of Contents}. Making the document class an article will also solve the problem. Table 22 shows the common names we might want to change. since the section is the ﬁrst level division. Making the ﬁrst level division chapters will overcome the numbering problem.1. so the numbering will be chapter.
8. where you want it to be counted as a report.1mm} \end{description}\end{flushleft} } % end proof Then. the theorem follows. \end{proof} produces: Proof: First. .3
Your Own Environments
The \newenvironment command enables us to deﬁne our own environments. suppose \dots \linebreak Thus. . equal to about 2 spaces). Thus. not as an article. the following creates a proof environment: \newenvironment{proof} {\begin{flushleft} \begin{description} \item \textit{\textbf{Proof:}}~ } % begin proof {\hfill\rule{2. \makeatletter. the theorem follows. For example. The way to do this is as follows:
\makeatletter \renewcommand\thesection{\@arabic\c@section} \makeatother
The preceding command. n = number of arguments (omit [0] for n = 0).
8. and the \renewenvironment command enables us to revise an existing environment.
8.1mm}{2.4
Your Own Margins and Spacing
The default margins and spacing are set with purposeful values. they can be changed by setting certain parameters in the preamble. is to make the @ character a letter. restores @ to its special meaning (\@ is for certain spacing. suppose . \begin{proof} First. and you will usually not need to change them. They have the same syntax:
newenvironment{name}[n]{begin}{end } renewenvironment{name}[n]{begin}{end }
where name is the name of the environment. and end is what is executed upon leaving the environment. When you do. \makeatother. however. The succeeding command. The margins
. begin is what is executed upon entering the environment.3 Your Own Environments
103
BibTE X.
104
8 TAKING CONTROL
of the document are controlled by the parameters shown in Figure 86 and described in Table 23.295pt \textheight 585.025 pt 1.0pt \topmargin 21.96999pt \paperwidth 614. The \hspace* and \vspace* commands provide a great deal of control over horizontal and vertical spacing.0pt 12. Table 24 lists some you can set with the \setlength command. in particular. for example.295 pt 390 pt 5. respectively.396 in 8. the current settings (shown 2 in Table 23) break down the horizontal parts as follows:
72.0pt Meaning space between bottom of body and top of footer space between bottom of header and top of body height of header horizontal oﬀset to add to indentation of body extra space added at left (applies only to odd numbered pages if the style is twosided.0pt \voffset 0. if we are using 8 1 × 11 paper.27 pt 39 pt 1 in 54 in
begin body stuﬀ
6. The body expands to the right unless we also change \oddsidemargin.0pt 29.) For example. For example. showing their default values (used in this document). The geometry package provides easy speciﬁcations for page layout. We might want some global settings to make repeated use of these unnecessary.0pt † Printed using \theparameter. (See Table 25 for conversion factors.0pt 0.14. Table 23: Margin Parameters Parameter \footskip \headsep \headheight \hoffset \oddsidemargin Current Setting† 30.
. 1 pt = 72.38744pt \textwidth 360.564 in
We can increase the text width by setting \textwidth=length in the preamble.5 in
end body stuﬀ
113.0pt 25.27 in. Margin settings can be negative. in which case there is also an \evensidemargin parameter) height of the paper width of the paper height of the body width of the body space added before the top of the header vertical oﬀset to add to indentation of body
\paperheight 794. we raise the body 1 inch by specifying \topmargin=1in in the preamble. \textwidth=6in increases the text width to 6 inches. This might be accompanied by increasing the text length.
8.4 Your Own Margins and Spacing
\pagewidth
105
1 in + \voffset \topmargin
header
\headsep
\headheight
\textheight \textwidth
\pageheight
body
\oddsidemargin
footer
1 in + \hoffset
\footskip
Figure 86: Document Margins
.
0pt.0pt minus 1. • See the above spacing between items. Here is what happens when we change \itemsep: • The default value of \itemsep is 4. This list speciﬁed \setlength{\itemsep}{0pt} right after \begin{itemize} 2.106
8 TAKING CONTROL
Table 24: Spacing Parameters Parameter
\itemsep \parindent \parsep \parskip
Meaning space added to \parsep between items in a list.
1.
Figure 87: Varying \itemsep to control item spacing in a list The left margin parameter is \leftmargini for a level1 list (note the i at the end). What you see next is with \setlength{\itemsep}{0pt}.2 (p. indentation at beginning of paragraph.0pt minus 1.
. 1.) For example. • We are back to normal with \itemsep = 4.5pt plus 2. This item is farther from the ﬁrst one. (Defaults are restored after leaving. the lists in §2. This must be set before the \begin command. • Next is back to normal by \setlength{\itemsep}{\mylength}.0pt.5pt plus 2. This item is fairly close to the ﬁrst one. space between paragraphs. Figure 88 gives an example. space between paragraphs in the same item of a list. they must be set within the list environment. • What you see next is with \setlength{\itemsep}{10pt}. varying by the value of \itemsep. This list speciﬁed \setlength{\itemsep}{12pt} right after \begin{itemize} 2. Figure 87 shows two enumerate lists.
In the case of list parameters. and I have saved it by: \setlength{\mylength}{\itemsep}. 12) are spaced by default values. For \itemsep this can occur just after the \begin statement.
8.6 line spacing: \renewcommand{\arraystretch}{1.
\[ \begin{array}{lp{.6} B xB = bN + 1 θδbN 2 B ∗ xB > bB + 1 θδbB 2
1 πN B = cB + 2 θδcB 1 πN N < cN + 2 θδcN
.3} B xB = bN + 1 θδbN 2 B ∗ xB > bB + 1 θδbB 2
1 πN B = cB + 2 θδcB 1 πN N < cN + 2 θδcN
Here is 1. so we want to increase its vertical spacing. Note how congested it is.3 line spacing: \renewcommand{\arraystretch}{1.B\.3in}l} \.x_B = b_N + \frac{1}{2}\theta\delta b_N && \pi_N B = c_B + \frac{1}{2}\theta\delta c_B \\ B^*x_B > b_B + \frac{1}{2}\theta\delta b_B && \pi_N N < c_N + \frac{1}{2}\theta\delta c_N \end{array} \]
Figure 90: Array with Fixed Width Column Source (Result in Figure 91)
1 B xB = bN + 2 θδbN B ∗ xB > bB + 1 θδbB 2 1 πN B = cB + 2 θδcB 1 πN N < cN + 2 θδcN
Figure 91: Array with Fixed Width Column Result (Source in Figure 90) Here is 1.4 Your Own Margins and Spacing
{\setlength{\leftmargini}{2in} \begin{itemize} \setlength{\itemsep}{0in} \item Item 1 of list with 2in left margin \item Item 2 of list with 2in left margin \end{itemize} }
107
Figure 88: Changing the Left Margin of a List (Result in Figure 89)
• Item 1 of list with 2in left margin • Item 2 of list with 2in left margin Figure 89: Changing the Left Margin of a List (Source in Figure 88) Figures 90 and 91 show the presentation of an array with a pcolumn to put horizontal space between the other two columns.
Suppose that you want no page numbering if there is only one page.108
8 TAKING CONTROL Back to default: \renewcommand{\arraystretch}{1}
1 B xB = bN + 2 θδbN ∗ x > b + 1 θδb B B B B 2 1 πN B = cB + 2 θδcB 1 πN N < cN + 2 θδcN
Line spacing is controlled by \baselinestretch . put the following:
\ifthenelse{\equal{\pageref{lastpage}}{1}}{\pagestyle{empty}}% {\pagestyle{headings}}
This will test if the value of \pageref{lastpage} is equal to 1. and the ﬁrst statement applies: \pagestyle{empty}. or just some lines whose space you want to control. Just after \begin{document}. there is more than one page. it will print Solution. . it will do nothing. just before \end{document}. How much is 2+2? Solution. but it is easier to use the setspace package.
How much is 2+2? \printsol{\sol}{4}
Figure 92: \ifthenelse Source (Results in Figure 93) \def\sol{0} .5
Your Own Output Control
You can write conditionals to do one thing or another with the ifthen package. }#2}}{} }
This will test the condition if your ﬁrst argument equals 1. You can do this as follows. If so. . put \label{lastpage}. If there is more than one page. there is only one page. You will have control of the whole document. How much is 2+2? \def\sol{1} . 4
Figure 93: \ifthenelse Results (Source in Figure 92) Another example is to decide on page numbering. and the second statement applies: \pagestyle{headings}. if not. followed by your second argument. If not. . suppose you want to use headings in the header with page numbers. If so.
8. suppose your preamble contains
\newcommand{ \printsol}[2]{ \ifthenelse{\equal{#1}{1}}% {\textsf{\textbf{Solution. The syntax is \ifthenelse{condition}{action if true}{action if false} For example. . First.
. This is illustrated in ﬁgures 92 and 93.
Knuth. MA. When citing Knuth’s book. they will be numbers). we can exercise the option:
\bibitem[Knuth. \bibitem{tex} Donald E. \end{thebibliography}
These will appear in the document’s list of references even if they are not cited. such as
. AddisonWesley Publishing Company. we obtain [2] in the text. . and use thebibliography environment instead. (It works if you specify 99.. 15th edition.8.
in which case \cite{tex} ⇒ [Knuth. MA. with label the unique identiﬁer used by the \cite command. [Knuth. which I formatted to agree with the plain style of BibTE X:
\begin{thebibliography}{99} \bibitem{companion} Michel Goosens. The bib style ﬁle. 1994. so each entry appears however you put it. Thus.) Each \bibitem is an entry. 28). and you can enter whatever you like. \bibliography{mybiblio} and \bibliographystyle{plain}. 1989] is preferred to [2] because it immediately gives the reader information about the document without having to ﬂip to the bibliography section.e. \textit{The \LaTeX\ Companion}. but if you are writing a report and have control over the formatting. . Knuth. They can be cited in the same way described in §3: by \cite{companion} and \cite{tex}. as described for BibTE X in §3 (p. Instead of the BibTE X commands. 1989]{tex} Donald E. . AddisonWesley Publishing Company. Reading. . specify the following:
\begin{thebibliography}{n} \bibitem[what appears]{label (that you cite)} entry . Some publishers give you no choice. it generally helps the reader to know something about the citation. even if there are inconsistencies in style. You will have complete control over the formatting. Frank Mittelbach and Alexander Samarin. Alternatively. Here is a complete example with two references.6
Your Own Bibliography
You can choose not to use BibTE X. and there will be no sorting — the list of references will appear in the order you put them. This is one reason it is usually better to use BibTE X.6 Your Own Bibliography
109
8. With you in control. 1989. there is no format monitoring. \end{thebibliography}
where n is the width of the widest label you want to allow. \textit{The \TeX\ Book}. . 1989]. The option is an alternative to having the references numbered. for example. even though you lose control over what appears (i. respectively. Reading.
including those commonly found in automata theory. it is necessary to become aware of updates. As you begin to use packages. and there are others with similar properties or for particular programming languages (viz. or you can join their newsgroup at comp.110
8 TAKING CONTROL
plain. These packages provide even more versatility in how the citations appear (see [4] or [5. qsymbols. Closing Remarks
A Now you know how to write a mathematical document in L TEX 2ε and you know there is much more you can learn to gain reﬁnements. You will ﬁnd other packages useful. apalike and plainnat (from natbib). such as [Knuth. depending upon your technical area. applies in either case. and xypic. Figure 94 shows the preamble used for this document. Most installations come with more than the basic plain. 36). SIunits. which you obtain from CTAN [4].tex (can be done in Google by clicking on Groups).bst. Also. Besides what you can do yourself to elevate the quality of the results. wasysym. the algorithm package enables an environment to write source code with standard language elements. and its three variations (given on p. 1989] instead of [8]. there are many packages.text. Chapter 13]). You can visit CTAN from time to time. The graphtex package specializes in all sorts of graphs. such as at the end of each chapter of a book. Here are some packages that give you special symbols: chemsym. use the bibunits package. cpascal and listings). which give the author and year.. available from CTAN [4]. Alternative bst ﬁles are achicago (from the frankenstein package). If you want to have several bibliographic units in one document.
.
Table 25: Conversions of Common Units of Measurement pt in cm pt 1 72.idx (input to makeindex at command line)
Figure 94: Most of the Preamble for this Book
Appendix
A This contains complete tables of font information and basic L TEX commands.54 1
Table 26 is a guide to how most of the remaining tables are organized.}
\renewcommand\contentsname{Table of Contents} % Change ‘Contents’ \renewcommand\url{\begingroup\urlstyle{sf}\Url} % put url in sf font \input{mydefs} % My commands and environments \makeindex % make myfile..27 28. Afterwards. and Table 46 gives the commands for the picture environment.03515 2.APPENDIX
111
\usepackage{amsmath} \usepackage{amssymb} \usepackage{amscd} \usepackage{bm} \usepackage{graphicx.3937 cm .. which gives conversion among three common units of measurement...01384 1 . Table 45 gives special symbols that can be used in either text or math mode..moreverb} \usepackage{float} \usepackage[T1]{fontenc} \usepackage{ifthen} \usepackage{makeidx} \usepackage{mathrsfs} \usepackage{multirow} \usepackage{theorem} \usepackage{url}
% % % % % % % % % % % % % % %
formerly amstex ams symbols (\mathbb fonts) draws commutative diagrams bold math fonts (\mathbm) graphics enables control over hyphenation verbatim enable float [H] option . \mathscr) like multicolumn enables more control over newtheorem \url{.45 in . beginning with Table 25.
. It is designed like a reference manual for easy lookup..to write \textbf{\textsc{.pstall} \usepackage{hyphenat} \usepackage{fancyvrb.}} ifthenelse {condition}{true}{false} index more math symbols (viz.
Triangles and Lines Variable Size Symbols
Table 27: Commands/Environments for Text Font Appearance
textbf tiny Large verbatim textit scriptsize LARGE textrm footnotesize huge textsc small Huge textsf normalsize underline texttt large verb
Table 28: Commands/Environments for Controlling Text Position
bigskip flushright medskip pagebreak smallskip vspace center hfill newpage quotation tabbing vspace* centerline hspace noindent quote tabular clearpage hspace* nolinebreak raisebox verse flushleft linebreak nopagebreak samepage vfill
.112
APPENDIX
Table 26: Reference Tables Table
Text mode 27 28 29 30 31 32 Math mode 33 34 35 36 37 38 39 40 41 42 43 44
Contents
Commands/Environments for Font Appearance Commands/Environments for Controlling Position Text Accents and Symbols Commands for Counters Commands/Environments to Organize Document Commands to Control Document Style Commands to Control Fonts in Math Mode Accents in Math Mode Spacing Commands in Math Mode Greek and Special Letters Frequently Used Mathematical Symbols Binary Operations Operators and Quantiﬁers Special Functions Relation Symbols Arrows Dots Circles.
APPENDIX
113
Table 29: Text Accents and Special Symbols
á è î ö æ Æ Ł \’{a} \‘{e} \^{i} \"{o} \ae \AE \L u ˘ ñ ˝ H oo œ Œ ß \u{u} \~{n} \H{H} \t{oo} \oe \OE \ss ç d .. b ¯ ..{x} \={z} \v{v} \o \O !‘
Table 30: Commands for Counters
addtocounter ref thecounter label refstepcounter value newcounter setcounter pageref stepcounter
Table 31: Commands/Environments to Organize Document
abstract appendix listoffigures maketitle subsection tableofcontents addcontentsline bibliography listoftables printindex subsubsection thanks addtocontents bibliographystyle makeindex section subsubsubsection thebibliography
Table 32: Commands to Control Document Style
markright renewcommand markboth setlength pagenumbering thispagestyle pagestyle
Table 33: Commands to Control Fonts in Math Mode
left cal mathit mathtt right boldmath (set displaystyle mathnormal mbox textstyle in text mode) mathbf mathcal mathrm mathsf overbrace overline underbrace underline
. å Å ¿ \c{c} \d{d} \b{b} \dots \aa \AA ?‘ x ˙ ¯ z v ˇ ø Ø ¡ \.
rather than i. .y x\quad y x\qquad y x\!y x\negmedspace y x\negthickspace y ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ ⇒ What you see xy xy xy x y x y xy x y x y no space thin space medium space space = 1em space = 2em negative thin space negative medium space negative thick space
Table 36: Greek and Special Letters
α β γ δ \alpha \beta \gamma \delta \epsilon ε \varepsilon ζ \zeta η \eta Γ \Gamma ∆ \Delta Θ \Theta ℵ \aleph A . Z {\mathcal \theta \vartheta \iota \kappa \lambda \mu \nu$ \xi \Lambda \Xi \Pi \ell A.114
APPENDIX
Table 34: Accents in Math Mode
a \check{a} e ˇ ˘ x \dot{x} ˙ y ¨ ˆ \hat{\imath} ı xyz \widehat{xyz} \breve{e} ´ \acute{i} i \ddot{y} z \bar{z} ¯ \tilde{\jmath} ˜ abc \widetilde{abc} o ` v \grave{o} \vec{v} \hbar
(Note that it is better style to use \imath.. rather than j.Z} θ ϑ ι κ λ µ ν ξ Λ Ξ Π o π ρ σ ς Σ Υ Φ o \pi \varpi \rho \varrho \sigma \varsigm \Sigma \Upsilon \Phi \Re τ υ φ ϕ χ ψ ω Ψ Ω \tau \upsilon \phi \varphi \chi \psi \omega \Psi \Omega \Im
. and \jmath. to avoid the clash between the accent and dot.y x\.. .)
Table 35: Spacing Commands in Math Mode
What you write x y x\.
= = ∝ ∈ \equiv \doteq \models \propto \in \ni
⊂ ⊆
⊃ ⊇
.APPENDIX
115
Table 37: Frequently Used Mathematical Symbols
{superscript} {subscript} ^{} _{} \prime ∞ \infty ∅ \emptyset
Table 38: Binary Operations
± × ÷ \ \ \pm \mp \times \div \setminus \backslash \biguplus ∩ ∧ ∨ \cap \sqcap \wedge \vee \bigcap \bigvee \bigwedge ∪ \cup \sqcup \uplus \oplus \bigcup \bigoplus \bigsqcup ⊗ \odot \otimes \oslash \ominus \bigodot \bigotimes
⊕
Table 39: Operators and Quantiﬁers
∀ \nabla \forall ∂ ∃ \partial \exists √ ¬ \surd \neg ℘ \wp
Table 40: Special Functions
arccos csc lg Pr arcsin det lim sec arctan dim liminf sin arg exp limsup sinh cos gcd ln sup cosh hom log tan cot inf max tanh coth ker min
Table 41: Relation Symbols
≤ \leq \prec \preceq \ll \subset \subseteq \sqsubseteq ≥ \geq \succ \succeq \gg \supset \supseteq \sqsupseteq = ∼ ∼ = ≈ \neq \sim \simeq \cong \asymp \approx ≡ .
. \circ \cdots \vdots \frown \triangle \triangleright \bigtriangleup \bowtie \top \dashv \angle \mid .. • . \bigcirc \ddots \bullet \smile \diamond \triangleleft \bigtriangledown \perp \bot \vdash \ \parallel
⊥ ⊥
∠ 
. Circles. Triangles and Lines
◦ ··· . .116
APPENDIX
Table 42: Arrows
← ⇐ → ⇒ ↔ ⇔ → ← \leftarrow \Leftarrow \rightarrow \Rightarrow \leftrightarrow \Leftrightarrow \mapsto \hookleftarrow \leftharpoonup \leftharpoondown \rightleftharpoons ←− ⇐= −→ =⇒ ←→ ⇐⇒ −→ → \longleftarrow \Longleftarrow \longrightarrow \Longrightarrow \longleftrightarrow \Longleftrightarrow \longmapsto \hookrightarrow \rightharpoonup \rightharpoondown ↑ ⇑ ↓ ⇓ \uparrow \Uparrow \downarrow \Downarrow \updownarrow \Updownarrow \nearrow \searrow \swarrow$ \nwarrow
Table 43: Dots.
Some Tips
117
Table 44: Variable Size Symbols
\sum \prod \coprod
n d
\int . . √ . \overbrace{ . } \overline{ . } \sqrt{ . } \{ \} \lfloor \lceil \rangle [] . .
\oint \underbrace{ . } \underline{ . }
\frac{n}{d} (  \backslash \langle )
These use \left and \right ()  \ {} [ ] \rfloor \rceil
Table 45: Special Symbols in Both Text and Math Modes
†
‡ ...
\dag \ddag \ldots
§ ¶
\S \P
c £
\copyright \pounds
Table 46: Commands and Parameters in Picture Environment
put(x, y){stuff } multiput(x, y)(∆x, ∆y){number}{stuff } line(x, y){length} framebox(width, height)[p]{text} vector(x, y){length} dashbox{dashs ize}(width, height)[p]{text} circle{radius) makebox(width, height)[p]{text} circle*{radius) oval(width, height)[p] linethickness{dimension} p ∈ {l,r,t,b,lt,lb,rt,rb}. For oval, it is the portion selected; for boxes, p is where the text goes.
Some Tips
Here are some tips that apply in special situations. Structuring large documents. Theses, books, and other large documents are best managed with the \input command. The document might look like this:
118 Preamble \begin\{document} \input{Abstract} \input{Chapter1} \input{Chapter2} . . . \end\{document}
(a) Separate chapters in a document (input ﬁles are Abstract.tex, Chapter1.tex, . . . )
Some Tips Preamble \begin\{document} %\input{Abstract} \input{Chapter1} %\input{Chapter2} . . . \end\{document}
(b) Compiling just Chapter 1
This is also a good structure for coauthoring. Counting words. Under linux enter dvi2tty file.dvi  wc words This takes file.dvi as input into the program dvi2tty, which converts it into a plain text ﬁle (without latex commands). That output ﬁle is passed to the command wc, which counts the words. If you need to apply this to a portion of the document, such as an abstract, you can put that portion into a skeleton latex ﬁle and compile it. Using the above structure, this is particularly easy to obtain the word or line count of any section. Commenting text. Besides putting % in column 1, you can logically delete a block of text by \if 0 ... \fi. This is a good way to manage a document when you might want to remove some text with the idea that you it might be restored, at least in part. \if 0 stuﬀ here is ignored \fi (See §8.5 for more general control.) \newcommand vs. \def. It is generally better to use \newcommand because you will get an error if the command name is already deﬁned, such as by some package. The syntax is \newcommand{\name}[#]{what to do}; for example, \newcommand{\note}[1]{\texttt{Note: #1}} deﬁnes a \note command that has one argument. When you specify \note{hello}, you will get Note: hello in the text. \def is to be used only when you want to allow an override (without warning). Its syntax is \def\name{what} or \def\name#1{what} if there is one argument. To suppress printing all notes, deﬁned by the above \note command, you can specify \def\note#1{ }. This says to do nothing when seeing \note{stuﬀ}. You can have an \input ﬁle with many commands and environment deﬁnitions that you use repeatedly. It might have something like the following:
REFERENCES
\newcommand{\note}[1]{\texttt{note: #1}} % \def\note #1{ } % activate to suppress printing notes
119
A “better” alternative (avoiding \def) is to use
%\renewcommand{\note}[#1]{} % activate to suppress printing notes
The \note command is useful when collaborating, and you could deﬁne a separate one for each author, showing initials. There is also the \providecommand. This has the same syntax as \newcommand, but it does not issue an error if the command is already deﬁned. It does nothing if the command exists; otherwise, it deﬁnes the command. Making clear. It is good practice to use \ell in math mode when you want the letter ell because it is easier to distinguish \ell from the number 1. Compare vs. l with 1 — also compare the source: $\ell$ vs. $l$ with $1$. Also consult the TE X Catalog Online [14].
References
[1] Johannes L. Braams. Babel, a multilingual styleoption system for use A with L TEX’s standard document styles. TUGboat, 12(2):291–301, 1991. Available at CTAN [4]. [2] Johannes L. Braams, David P. Carlisle, Alan Jeﬀrey, Frank Mittelbach, A Chris Rowley, and Rainer Schöpf. L TEX 2ε and the LaTeX3 project. World Wide Web, http://www.latexproject.org/latex3.html, 1994–99. [3] David P. Carlisle. Packages in the ‘graphics’ bundle. World Wide Web, CTAN /macros/latex/required/graphics/ (see [4] for replacing CTAN), 1994–99. [4] Comprehensive TEX archive (CTAN). UK: ftp.tex.ac.uk/texarchive/; Germany: ftp.dante.de/texarchive/; USA: ftp.tug2.cs.umb.edu/texarchive/ . These are host sites, which contain a list of mirror sites.
A [5] Michel Goosens, Frank Mittelbach, and Alexander Samarin. The L TEX Companion. AddisonWesley Publishing Company, Reading, MA, 1994.
[6] John D. Hobby. A User’s Manual for MetaPost. Computing Science Technical Report no. 162, AT&T Bell Laboratories, Murray Hill, New Jersey, 1992. Available at http://cm.belllabs.com/who/hobby/ MetaPost.html/.
//www.0. AddisonWesley Publishing Company. Comprehensive TEX Archive. 1998–99 (version 1.uic.ps (see [4] for replacing CTAN). MA. The TEX Book.
A [12] Keith Reckdahl. World Wide Web site Version 2. 1995–99. Drawing Graphs with MetaPost. L TEX: A Document Preparation System. AddisonWesley Publishing Company. Murray Hill.edu/ depts/adn/infwww/ps/btxdoc. [15] Timothy Van Zandt. Available at http://cm. CTAN. 1994). PSTricks: PostScript macros for Generic TeX.gz. [8] Donald E.html. BibTE Xing. CTAN /info/epslatex.ps (see [4] for replacing CTAN). World Wide Web.ps.
A [9] Leslie Lamport.belllabs. Hobby. MA. 15th edition. 1986 (also see 2nd edition.miktex. 1995–97.
http:
[14] Graham Williams.org/applications/PSTricks/.
[13] Christian Schenk. Reading. 1989. 164.ps. 1993.org/texarchive/help/Catalogue/catalogue. http://www. A [10] L TEX 2ε for authors. CTAN /macros/latex/doc/usrguide. World Wide Web.tug. World Wide Web.
[11] Oren Patashnik.de/.120
REFERENCES
[7] John D. Technical report. Reading. Using imported graphics in L TEX 2ε .ctan. TE X Catalogue Online. 1993–98. AT&T Bell Laboratories. MiKTE X Local Guide. http://www.
. New Jersey. 1988. Computing Science Technical Report no. Knuth.2).com/cs/cstr/164. http://www.
47 \cdots. 4. 19 \cite. 60 \framebox. 40. 3 \ensuremath. 93 \dotfill. 23 \label. 41. 118 \dvipdf. 37 \nohyphens. 106 \jmath. 24 \oddsidemargin. 71. 24 \newpage. 101. 108 \fboxrule. 28. 63 \Big. 36 \bigg. 11 \big. 62 \nocite. 24 \noindent. 98 \maketitle. 114 \kill. 25 \dots. 56. 72 \date. 10 \nolinebreak. 36 \bibliography. 24 \nopagebreak. 114 \input. 101 \equal. 74 \frame. 99 \dvips. 36. 48. 25 \hline. 97 \listoftables. 7. 24. 72 \makeindex. 55 \baselinestretch. 59 \mathfont. 93 \baselineskip. 108 \bibliographystyle. 56. 23. 1. 93 \mathbb. 25 121 \hspace*. 97 \makebox. 74 \footnotesep. 107 \author. 63 \boldmath. 42 \fboxsep. 42 \newenvironment. 12. 47 \mbox. 104 \overbrace. 118 \newcounter. 25 \hspace. 43 \arraystretch. 55. 56 \overline. 101 \newcommand. 56 \overset. 8 \dvi2tty. 118 \displaystyle. 58 \medskip. 61. 9 \hfill. 10. 74 \listoffigures. 93 \def. 16 \dashbox. 15. 65 \pagebreak. 71. 61 \centerline. 11 \multicolumn. 41 \newtheorem. 25 \imath. 57. 48. 97 \pageref. 25.Index
\Bigg. 25. 53 \left. 54 \hrulefill. 55 \documentclass. 59 \mathscr. 99 \frac. 39. 23 \line. 24 \pagenumbering. 51. 117 \itemsep. 41 \cline. 63 \bigskip. 19. 37 \clearpage. 42 \fbox. 103 \newline. 100. 9. 117 \linebreak. 63 \addtocounter. 62
.
25. 61 Bezier curve. 56 \underline. 39. 3 dvips. 28 body. 16 command line. 5 \selectfont. 48 \providecommand. 106 \partial. 74 \verb. 43 \title. 118 \vfill. 72 \parindent. 65 \tableofcontents. 72. 94 \theenumi. 77 \value. 3. 72. 20 comments. 35 dash. 2 derivative. 65
INDEX \unitlength. 25. 42. 72 coauthoring. 57 \raisebox. 43 \subsection. 56 \widetilde. 19. 86
. 56 \underset. 78 \raggedright. 59. 18. 97 \textstyle. 56 \\. 58. 93 cross referencing. 34. 98 \prod. 1 comment. 24. 43 \ref. 103 \right. 56 counting words. 1 conditional assignment. 95 \thecounter. 48 \textwidth. 40. 33 \usepackage. 1 DOS. 43 \vector. 62 \renewcommand. 60 \prime. 119 \renewenvironment. 9. 93 accents. 22 AMS. 5 \substack. 61. 100. 1. 39. 65 \stepcounter.122 \pagestyle. 43 \thefootnote. 56. 78 titlepage. 117 \samepage. 10 debugging. 28 dvi viewer. 108 \parbox. 97. 11 \sqrt. 119 \psset. 43. 16. 41. 54 \printindex. 47 box. 98 \section. 73 \url. 118 cover page. 4 emftoeps. 25 \vspace. 38 \setcounter. 15 pdftex. 55 \widehat. 1 boldmath. 53. 43 \setlength. 104 \textfont. 118 compile. 57 \refstepcounter. 48 \stackrel. 93 \underbrace. 8 \thanks. 118 column speciﬁcation. 98. 84 bibtex program. 106 \parskip. 106 \parsep. 24 \section*. 99 \smallskip. 1 amsmath. 25 \vspace*. 60 document styles. 25. 21.
47. 86 ﬂoat. 98 array. 25 bibliography. 41. 47 italic. 78 eps. 32. 1. 22 Roman. 8 small caps. 40. 41 tabular. 3 global setting. 53 eqnarray*. 8. 57 axiom. 38 list environment. 98 appendix. 9 longtable. 18. 13 large. 21 verse. 1. 60 horizontal ﬁll. 99 fractions. 95. 41 ﬂushleft. 11 ﬁle bib. 61 verbatim. 98 jpeg2ps. 19. 20 picture. 15.INDEX environment. 86 tex. 28. 86 Lagrangian. 59 landscape. 24 index (making of). 6. 12. 1. 6 gather. 57 ﬂushright. 12 description. 14 eqnarray. 1. 34–36 bst (bib style). 64 itemize. 62 center. 11. 65 tabbing. 72 quotation. 42
123
. 22 table. 32 wmf. 51. 40. 54. 40 font size. 110 dvi. 96. 8 footnote. 6 abstract. 4. 86 ps (postscript). 47 calligraphic. 40 ﬂoat page. 8 boldmath. 54. 81 Laplace transform. 6 corollary. 82 Hamiltonian. 13 local setting. 86 jpeg. 54 ﬁgure. 21 document. 56 thebibliography. 9 boldface. 21. 8 underlined. 29. 62 description. 41 ﬂoating object. 16 typewriter. 10 quote. 55 font style bold small caps. 109 theorem. 16 sans serif. 64. 12 enumerate. 78. 36. 47 Greek. 3. 43 graph. 14 itemize. 58 nonEnglish. 93 enumerate. 8. 1 line spacing. 64 gather*. 8 slanted. 9 smallmatrix. 59 latex command. 16 math mode. 9. 10 hyphenation. 53 equation. 48 ghostview.
40 SIunits. 16. 46 tabbing commands. 22 bibunits. 35. 58 units of measurement. 88 pstricks. 54 message. 50. 1. 78 MiKTeX. 22 table. 37 Underfull . 21 in url. 5 SIAM. 98 math display mode. 72. . 48 cpascal. 86 nodes. 15 ticks. 110 longtable. 59 moreverb. 110 quotation marks. 4. 5 superscript. 77 qsymbols. 10 rotate. 110 chemsym. 20. 20 makeidx. . 110 theorem. 48. 46 stack. 47 matrix equation. . 1 spacing. 65 subsection. 78. 21. 110 hyphenat. 12. 45. . . 65 amsmath. 110 geometry. 11. 24 horizontal. 99 psfrag. 81. 58 stacking. 33 special function. 54 trigonometric functions. 84. 4. 111 nomencl. 15. 12. 98 mathrsfs. 25 special character. 110 xypic. 29. 108 showkeys. 45. 77. 111 ﬂoat. 110 fancyvrb. 99 algorithm. 8 acronym. 6 preamble. . 103 \textspec . 52 mathbf. 108 paragraph positions. 1. 24. 25 list. 64 amssymb. 25 line. 81
INDEX
section. 87 graphtex. ix. 99 graphicx. 48. 11. 103. 65 subscript. 110 amscd. 79. 33 wasysym. 1.124 make index. 2 warning. 41 fontenc. 107 vertical. 2 Overfull . 25. 2 MetaPost. 104 gloss. 63 url. 81 package. 110 setspace. 24 ifthen. 108 listings. 9 frankenstein. 3. 106 math mode. 58 babel. 104 ~. 85 transpose. 61. 2 Repeated entry. 38. 111
. 110 page numbering. 110 bm.
3
125
.INDEX unix. 86 wc. 3 YAP. 118 xdvi. 28. 118 word count. 3.