A LaTEX Tutorial

A LaTEX
Tutorial
A Collection of Handouts And Exercises for
The Technically Uninitiated
by Linda Bethel
Graduate School of Business
September 9, 2005
2
CONTENTS
Contents
1 Getting Started: An Overview
1.1 PCTEX vs. LATEX vs. TEX . . . . .
1.2 Three Files . . . . . . . . . . . . .
1.3 Using the Application: An Overview
1.4 Create a Practice Document . . . .
.
.
.
.
7
7
7
8
9
Practice Document
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . .
10
10
11
12
3 Typing Basic Text: Character Formatting
3.1 Type Face . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 Type Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3 Font Sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14
14
15
17
4 Typing Basic Text: Text Peculiarities
18
5 Typing Basic Text: Special Characters
20
6 Typing Basic Text: Foreign Characters
22
7 Typing Basic Text: Vertical Formatting
7.1 Glue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
24
24
8 Typing Basic Text: Horizontal Formatting
26
9 Basic Math: Using Math Mode
9.1 Subscripts and Superscripts . . . . . . . . . . . . . . . . . . . . . . .
9.2 Grouping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.3 Math Accents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
29
29
29
30
10 Basic Math: Math Tables
31
11 Basic Math: Grouping
35
2 Getting Started: Opening a
2.1 Step by Step . . . . . . . .
2.2 Environments . . . . . . .
2.3 Option, Effect . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3
CONTENTS
12 Display Math Mode
12.1 Two Display Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . .
38
39
13 Not So Basic Math: Equation Labeling
13.1 The Label Command . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.2 The Double Whammy . . . . . . . . . . . . . . . . . . . . . . . . . . .
41
41
42
14 Not
14.1
14.2
14.3
43
43
44
44
So Basic Math: Multi-Line Display Math
Eqnarray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
And There’s More... . . . . . . . . . . . . . . . . . . . . . . . . . . .
Eqnarray* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15 Not So Basic Math: Math
15.1 The Array Command . .
15.2 Two Specialized Arrays .
15.2.1 Cases . . . . . .
15.2.2 Matrices . . . . .
15.3 Summary . . . . . . . .
Arrays
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
.
.
.
.
.
45
45
46
46
47
48
16 Not So Basic Math: Text in Math Mode
16.1 Roman Font . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.2 Text Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
49
49
49
17 Not So Basic Text: The Preamble
17.1 \usepackage{...} . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17.2 New Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
52
52
52
18 No So Basic Text: The Title Page
18.1 Titlepage Commands . . . . . . . . . . . . . . . . . . . . . . . . . . .
18.2 The Abstract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
53
53
54
19 Not
19.1
19.2
19.3
55
55
56
56
So Basic Text: The Main
Sectioning Commands . . .
Labeling . . . . . . . . . . .
Footnotes . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Body
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
4
CONTENTS
20 Not So Basic Text: Lists and Quotations
20.1 Lists . . . . . . . . . . . . . . . . . . . . .
20.1.1 Bulleted Lists . . . . . . . . . . . .
20.1.2 Numbered Lists . . . . . . . . . . .
20.1.3 Word-Labeled Lists . . . . . . . . .
20.2 Nesting Lists . . . . . . . . . . . . . . . .
20.3 Customizing the itemize Command . . . .
20.4 Quotes and Quotations . . . . . . . . . . .
.
.
.
.
.
.
.
57
57
57
58
58
59
60
60
21 No So Basic Text: Tables
21.1 Typing Tables in LATEX . . . . . . . . . . . . . . . . . . . . . . . . . .
21.2 More Table Commands . . . . . . . . . . . . . . . . . . . . . . . . . .
61
61
63
22 No So Basic Text: Theorems
22.1 Defining the theorem environment . . . . . . . . . . . . . . . . . . . .
22.2 Using the theorem environment . . . . . . . . . . . . . . . . . . . . .
64
64
64
23 No So Basic Text: The bibliography
23.1 Bibitem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23.2 Using the cite Command . . . . . . . . . . . . . . . . . . . . . . . . .
66
66
66
24 More Tables
24.1 Row and Column Lines . . . . .
24.1.1 Column Lines . . . . . .
24.1.2 Row Lines . . . . . . . .
24.1.3 Cline . . . . . . . . . . .
24.2 The Multicolumn . . . . . . . .
24.2.1 Tricks with Multicolumn
24.3 The Table Environment . . . .
24.4 Additional Table Commands . .
24.5 Longtable . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
68
68
68
69
69
69
70
70
71
72
25 BibTeX
25.1 Steps for using BibTeX . . . . . . . . . . . . . . . . . . . . . . . . . .
25.2 A word about PCTeX and MikTeX . . . . . . . . . . . . . . . . . . .
25.3 Sample Bib file entries . . . . . . . . . . . . . . . . . . . . . . . . . .
73
73
74
75
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
5
CONTENTS
26 Make Index
26.1 Using MakeIndex . . . . . . . . . .
26.2 The Process . . . . . . . . . . . . .
26.3 A word about PCTeX and MikTeX
26.4 Fine Tuning Your Index . . . . . .
.
.
.
.
76
76
76
77
77
27 Graphics
27.1 The Special Command . . . . . . . . . . . . . . . . . . . . . . . . . .
27.2 The Includegraphics Command . . . . . . . . . . . . . . . . . . . . .
27.3 The Figure Environment . . . . . . . . . . . . . . . . . . . . . . . . .
78
78
79
80
28 Figures
82
29 Homework
88
30 Exercises
90
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Getting Started
1
Getting Started: An Overview
What is LATEX?
What is LATEX? LATEX is a powerful, elegant typesetting program, which can
be confusing to the newcomer. The main reason for the confusion is that it’s a
WYSIWYS (what you see is what you see) program rather than a WYSIWYG (what
you see is what you get) program. That is, LATEX commands are logical and conceptual
rather than visual. For example, a command to center text will work from anywhere
on the page and the user will not immediately see the text actually centered on the
screen. The centering takes place during the typesetting process, and the user sees
the centering only after the document is typeset.
1.1
PCTEX vs. LATEX vs. TEX
These notes are spcifically designed to teach you how to use PCTEX in the Windows
environment. PCTEX is an application for the PC that utilizes LATEX commands.
While these LATEX commands are transferable to other systems, I do not cover LATEX
on other types of machines or programs, such as UNIX or Mac. What I refer to as
simply “TEX” or “Plain TEX,” is the collection of root commands on which LATEX is
loosely based. To “TEX” a document is to compile all the commands you’ve typed.
1.2
Three Files
The PCTEX application uses 3 interconnected files:
1. The text (or input) file where you type the TEX commands
(usually called filename.TEX);
2. The log file which narrates the typesetting process, including any TEX
errors you might have made (TEX calls this filename.log); and,
3. The typeset file which shows you your document as it will be printed
(filename.dvi).
Getting Started: An Overview
1.3
8
Using the Application: An Overview
To use PCTEX, open the application from the list of program files located in the
START menu. The first window you will see as the application opens is the text (or
input) window. This is the window in which you will do your typing and entering
of commands. To typeset, choose “LaTeX” from the format window. (See figure),
and click on the “Typeset” button. The TEX log file or log window will appear
immediately on the screen. This is where TEX shows you how it is reading your
commands; this is also where TEX lists by line number any mistakes you have made.
After the document has completed typesetting, the typeset window (or DVI file)
will appear. This is the window which contains the final document after PCTEX has
read in all your typed text and commands. The TEX name for the typeset document
is called the “DVI” file. In order to print the typeset version of the document, choose
“Print DVI” from the file menu. Find the DVI file, and print.
Getting Started: An Overview
1.4
9
Create a Practice Document
1. Launch PCTEX.
2. Input text into the input window, which is the first window that appears.
3. When you are finished typing the document, save it (filename.TEX).
4. Choose “LaTeX” from the Format menu.
5. Click the “Typeset” button. If you haven’t saved it already, LATEX will
ask you to save the document.
6. The log window appears which narrates the typesetting process
7. When PcTEX has finished reading your document, go back to the input
window and correct any errors.
8. Save and re-typeset the document.
9. If there are no more errors, choose “PrintDVI” from the File menu to
print the typeset document.
• Note PcTEX will not allow you to do anything else with the document
while it is typesetitng. PcTEX must be finished typesetting in order
for you to re-enter the input window. You will not see any changes to
your document unless you re-typeset.
2
Getting Started: Opening a Practice Document
Now I will show you how to open a practice document so that you will have the
opportunity to experiment with the various commands and exercises that are to
follow.
2.1
Step by Step
1. Open the PcTEX application. In the File menu, choose “new”.
2. In the input window, type
\documentclass[12pt]{article}.
\begin{document}
The documentstyle command tells LATEX to format your document as
an article (rather than a book or letter, for example). The TEX default
is 10pt type; the command in square brackets (called an optional argument) enlarges the size to 12pt. The \begin{document} command
officially begins the document environment.
A. Note the backslash. This means “command”.
3. Type any text. It doesn’t matter where you break the line when you
type, as LATEX does not recognize white space between words unless
specified with a command (more about this later).
4. Double-space between paragraphs (LATEX will automatically indent).
5. When you are finished typing, at the bottom of the document type
\end{document}.
This command closes the document and tells LATEX you are ready to
typeset.
6. Follow the procedures in Summary: 9 Easy Steps and print the document. When you save this document, save it somewhere you can find
later so you can use it for typing the exercises and/or experimenting
with the commands.
2. Getting Started: Opening a Practice Document
2.2
11
Environments
The idea of environment is central to LATEX. The LATEX program has many pre-set
environments intended to make text and math formatting easier. Such environments
include for example, text justification, lists, and tables. The largest, most general
environment is the documentclass.
The documentclass command encompasses a large array of formatting decisions
which have been pre-set by LATEX and defines the page environment in which you
type the document. These page formatting options include margins, paragraph indentation, paragraph spacing, headers and footers, and section heading styles. The
styles and their general usage are as follows.
Style, Command, Usage
Style
Command
article \documentclass{article}
report \documentstyle{report}
book
letter
\documentclass{book}
\documentclass{letter}
Usage
Generally used for short, simple documents.
Meant for longer documents that will
be broken into chapters and sections.
Meant for typesetting actual books.
Meant for letters.
2. Getting Started: Opening a Practice Document
2.3
12
Option, Effect
In the command \documentstyle[12pt]{article} an option in square brackets was
selected. Each documentstyle comes with a few formatting choices. The following are
the general choices available to all styles.
Option
Type size
(Default: 10 pt)
# Columns
(Default: one)
# sides
(Default: one-sided,
except in book style)
Displayed Equations
(Default: centered)
Equation Numbers
(Default: right)
Title Page
(Default:
\maketitle
places the title page
at the top of the
first page in article
style, and on a separate
page in other styles.)
Command
[12 pt]
[11 pt]
[twocolumn]
[twoside]
[fleqn]
leqno
[titlepage]
Result
12 point type
11 point type
Two columns of text.
(newspaper style)
Intended for two-sided
copying: binding margin on left
side for odd numbered pages,
right side for even numbered
pages; headers may differ for
odd and even numbered pages,
depending on document style.
Left-align displayed equations.
Align equation numbers with the
left margin.
\maketitle places the title page
on a separate page.
(For use with article style).
Typing Basic Text
3
Typing Basic Text: Character Formatting
Type Faces, Styles, and Sizes
There are two general changes you can make to the fonts in LATEX. One is changing
the type face, and the other is changing the type style.
3.1
Type Face
The good news is that there are only four type faces in LATEX.
(1) “\rm” produces normal roman type.
You won’t need to use this command very often, because it’s the default
type face in LATEX.
(2) “\sf” produces sans serif text.
The sans serif font provides a change from the default roman type.
(3) “\tt” produces typewritten text.
Though this is not used very often, it does help to make a distinction.
You will probably only want to use it when other options for emphasis
have been exhausted.
(4) Either \begin{equation} with \end{equation} or \[ with \] produces
“math italic.”
This is the font used in math mode. This font will be covered in the
chapters on math typing.
Typing Basic Text: Character Formatting
3.2
15
Type Style
The following are the five options for type styles you can use in LATEX.
(1) “\bf ” produces boldface type.
This is the most commonly used font for emphasis. Like all other good
things, however, you can have too much of it. Be careful not to overdo
boldfacing.
(2) “\it” produces italic type.
This is the second most commonly used font for emphasis. After the
end of the italicized text, be sure to include “\/”. This will add a little
extra space before reverting to normal text, preventing the next word
or words from running too close to the italicized text.
(3) “\sl” produces slanted type.
Slanted type is mostly used for things like journal titles or proclamations in papers (theorems, etc.). Because it does not produce quite as
noticeable an effect as italicized text, it can be used for larger groups
of text without causing reader eye irritation (whole paragraphs of italicized text can be very annoying; but slanted paragraphs don’t have
quite as much of an impact). You’ll also need to add “\/” to the end
of slanted text (same as italicized text).
Typing Basic Text: Character Formatting
16
(4) “\sc” produces small caps text.
The small caps font is used mostly in titles and section headings.
(5) “\em” produces an emphasis text, one that is different from the prevailing font. This is obviously used to emphasize a word or phrase, and
is relative to the font which surrounds the command. For example,
Output
Input
I hate you. {\bf I {\em hate\/} you.}
I hate you.
{\it I {\rm hate} you.}
And so forth.
Note that the italic correction should always be included when italic or slanted type
is followed by type that is neither italic nor slanted; if you are not sure what \em will
do, then put in the italic correction as it has no effect unless italic or slanted type is
followed by type that is neither.
Typing Basic Text: Character Formatting
3.3
17
Font Sizes
Unlike PlainTEX, LATEX offers a selection of easily accessible font sizes:
Example
This is tiny
This is script size
This is footnote size
This is small
This is normal size
Command
\tiny
\scriptsize
\footnotesize
\small
\normalsize
This is large
\large
This is larger
\Large
This is very large
This is huge
This is even huger
For example, to produce “Hello” you would type
{\bf \large Hello}.
\LARGE
\huge
\Huge
4
Typing Basic Text: Text Peculiarities
Peculiarities
There are five peculiarities to typing basic (meaning simple, easy, rudimentary, elementary, read: non-mathematical !) text in LATEX. They are as follows:
(1) Quotation Marks: ‘, “, ’, and ”.
Left-hand quotation marks (both singular and plural) are typed using
the left accent mark (‘), usually located in the left-hand portion of the
keyboard. Right-hand quotation marks (both singular and plural) can
be typed using either the right accent mark (’), or by using a double
quote symbol (").
(2) Dashes and Hyphens: -, –, —, and −.
These four dashes and hyphens are used in four different situations
(oddly enough!). The first is used strictly as a hyphen, as in “doublejointed.” Type it as a single -. The second is used in place of the word
“to,” as in “p. 79–80.” Type it as --. The third is used as a dash in a
sentence—when one part of the sentence needs to be set off from the
other. Type it as ---. And the last is used in math, as in x − y. We’ll
worry about this one later (and no, it’s not ----!).
(3) Spaces:
.
Did you catch that example? No? Well, here’s another one: . Spaces
in TEX are, for the most part, taken care of automatically. As a general
rule, just type a space when you want a space and TEX will adjust the
final amount of printed space according to typesetting standards (e.g.,
LATEX puts a little more space at the end of a sentence so that you
no longer have to remember to type two spaces after a period). One
peculiar thing, however, is that LATEX interprets a single carriage return
(usually marked “return” on your keyboard!) as a space and not as the
end of a paragraph.
Typing Basic Text: Text Peculiarities
19
(4) Paragraphs:
There are a few ways to tell LATEX to end a paragraph; but the easiest
(and the only one we’re going to learn right now) is just to “double
return” (remember that we’ve already said a single return is just like
a space?). That is, put a blank line in-between the two separate paragraphs to tell TEX to separate them. TEX will automatically indent a
new paragraph unless you tell it not to do so.
(5) Ties: ~
Ties are just like spaces, except they “tie” two objects together; i.e.,
they can’t be broken at the end of a line or page (hence the name,
“tie”. . . get it?!). If you want two objects to be tied together, simply
connect them with the ‘~’ symbol. For example, it is customary to
prevent line breaks in the following situations: when stating a page
reference (p.~79–80); in a date (July~4, 1776); when referring
to named parts of a document (figure~2); within names (Mr.~Chang);
and in other examples we’ll see later.
5
Typing Basic Text: Special Characters
You have already seen that several characters on your keyboard serve a special purpose. For example:
\
The backslash tells LATEX to begin a control sequence;
{
The left curly bracket begins a group;
}
The right curly bracket ends a group; and
~
The tilde is used to tie textual objects together on the same line.
There are several other characters which serve special purposes. Some
of them we will learn to use very soon; and others we probably won’t
see again until much later. However, it’s time to be introduced to them
so that you know what they are. Now, say “hello” to:
%
The percent symbol is used to make comments in your text window
which you don’t want to appear in the typeset version of your document
(anything that appears on an input line after a percent symbol will not
be typeset);
&
The ampersand is used as an alignment tab (we will see this more when
we get into math alignments and tables);
#
The pound or number symbol is used as a parameter variable in alignments and also in writing definitions;
$
The dollar sign is used as the introduction and ending to math items
(we will be using this one a great deal . . . and soon!);
^
The caret symbol is used in math mode to indicate a superscript; and
The underscore is used in math mode to indicate a subscript.
Typing Basic Text: Special Characters
21
Typing Special Characters as Part of Text
So, how do you get LATEX to typeset these characters when they appear naturally
in text? That’s a good question to which you can probably guess the answer: the
general rule is simply to place a backslash in front of them in the input window. This
general rule applies with no modifications to the percent symbol (%), the ampersand
(&), the number symbol (#), the dollar sign ($), and the underscore ( ).
When you place a backslash in front of the caret (^) and the tilde (~), you get
accents on the immediately following character (see handout 2D). There is never really
any need to use these characters by themselves; but should you ever have to do so,
there are several creative ways (because basic LATEX is so flexible!).
Finally, the backslash (\) and both curly brackets ({ and }) can only be used
in math mode. That is, they must be surrounded by dollar signs in your input
window. To produce a typeset curly bracket, precede it in your input window with a
backslash; to produce a typeset backslash, type “\backslash” in your input window
(both in math mode).
6
Typing Basic Text: Foreign Characters
As you read earlier about special characters, typing a backslash before a caret or
a tilde produces an accent on the letter immediately following. Here is a list of
additional accents and foreign characters you can produce in LATEX:
Command Produces
\‘o
\’o
\^o
\"o
\~o
\=o
\.o
\u o
\v o
\H o
\t oo
\c o
\d o
\b o
\oe,\OE
\ae,\AE
\aa,\AA
\o,\O
\l,\L
\ss
ò
ó
ô
ö
õ
ō
ȯ
ŏ
ǒ
ő
o⁀ o
o̧
o.
o
¯
œ,Œ
æ,Æ
å,Å
ø,Ø
l,L
ß
grave accent
acute accent
circumflex or “hat”
umlaut or dieresis
tilde or “squiggle”
macron or “bar”
dot accent
breve accent
háček or “check”
l ong Hungarian umlaut
tie-after accent
cedilla accent
dot-under accent
bar-under accent
French ligature OE
Latin and Scandinavian ligature AE
Scandinavian A-with-circle
Scandinavian O-with-slash
Polish suppressed-L
German “es-zet” or sharp S
Of course, the accents listed above with the letter ‘o’ can be used on any other
appropriate letter as well.
Typing Basic Text: Foreign Characters
23
It is important to note that the commands which include letters in them (the
commands from “\u” on) must be followed immediately by a space, as opposed to
those which have only symbols in them (those before “\u”). The reason for this is
that LATEX would not know when to stop reading the lettered command sequences
without a space to end them.
There are also:
\i ı dotless i
\j  dotless j
which are used when ‘i’ and ‘j’ are given an accent.
7
Typing Basic Text: Vertical Formatting
There are four main ways to tell LATEX to skip vertically on the page:
• “\smallskip” skips roughly a single line space;
• “\medskip” skips roughly a space and a half;
• “\bigskip” skips roughly a double space; and,
• “\vspace{dimension}” will allow you to skip any amount you choose.
The dimension in the last command can be replaced with any unit of measurement:
inches (in), centimeters (cm), points (pt), whatever you feel most comfortable using.
As an example, you could type “\vspace{1in}” and LATEX would skip 1 inch. Keep in
mind, though, that LaTEX understands spaces as being relative to something–a one
inch skip vertically down from a title, for example. You can’t start a page with a skip
because LATEX wouldn’t have anything to skip from. In that case, you would put an
asterick in the command, to tell LATEX that this is a non-relative skip:
\vspace*{dimension}
7.1
Glue
We say that the first three vertical spacing commands skip “roughly” a certain amount
because they actually insert space relative to the rest of the page. In other words,
LATEX will determine exactly how far to skip based on how much room there is on
the page for the skip (within certain limitations). For example, a \bigskip is defined
as being anywhere between 8 and 16 points. As LATEX is typesetting the page, it
determines exactly how much room there is for each skip and “stretches” or “shrinks”
the amount of space depending on how much room there is (in the case of a \bigskip,
as little as 8 points or as much as 16 points, but usually somewhere closer to 12
points). You will sometimes hear people talk about blank space as “glue” because of
this ability to stretch and shrink.
Typing Basic Text: Vertical Formatting
25
Additionally, there are:
• \vfil, and
• \vfill.
These commands tell LATEX to insert blank space (“glue”) with much more stretchability and shrinkability than any of the other commands. You probably won’t have
too much direct need for these, except in the case of inserting a pagebreak. The
commands for a pagebreak are:
\vfill
\eject
The \vfill fills the vertical space between the end of the text and the end of the page,
and \eject tells LATEX to move to the next page. You could simply use \eject, but if
you only had a few lines of text, LATEX would try to vertially
spread the information out to fill the page; inserting the \vfill keeps this from
happening.
8
Typing Basic Text: Horizontal Formatting
The following commands tell LATEX to horizontally position the bracketed text, either
to the left, right, or center:
\begin{flushleft}
text, text
\end{flushleft}
\begin{flushright}
text, text
\end{flushright}
\begin{center}
text, text
\end{center}
Notice that these formatting commands are treated like environments in LATEX .
You must begin and end the environment, but the text within remains fluid. It is
possible to manually terminate a line within the environment, and the command for
doing this is:
\\
and a multi-lined title might look like this:
\begin{center}
\bf \large TITLE\\[.5in]
AUTHOR
\end{center}
Typing Basic Text: Horizontal Formatting
27
Notice also that the font commands, boldface and large, do not need extra curly
brackets because LATEX will extend them only through the end of the environment.
The font commands WILL continue, however, until you tell them to stop by indicating
a new font. Notice also a dimension in square brackets. This is an optional argument
and tells the program to skip the indicated space between the lines in the environment
(in this example, the extra space is .5 inches). You can use a negative space also, if
you find you ever have the need for that.
Horizontal Skips
There are three main ways to tell LATEX to skip horizontally on a page:
• “\quad” skips about the length of the letter “m” in whatever font you
are currently using;
• “\qquad” skips about twice that much (what a surprise!);
• “\hspace{dimension}” will allow you to skip any amount you choose.
Just as with vertical skipping, you can use both “regular” inches (in), centimeters
(cm), or points (pt); or you can use the “true” measurements: truein, truecm, or
truept. Remember what we said about regular measurements being relative to the
rest of the page (they will magnify along with the text if you magnify the document),
but “true” measurements always stay the same size.
Additionally, there are:
• \hfil, and
• \hfill.
Just like the related vertical commands, these commands tell TEX to insert blank
space (“glue”) with much more stretchability and shrinkability than any of the other
commands (in the horizontal direction this time instead of vertical!). And, also just
like the vertical “fills,” you probably won’t have too much direct need for these. But
if you understand the concept of “glue,” you will almost definitely be able to find a
use for them sometime.
Basic Math
9
Basic Math: Using Math Mode
Using Math Mode
Dollar signs ($) surrounding a word or command indicate “math mode,” or “math
font.” The math font includes math symbols, Greek letters, and text. Any text in
math mode is printed in italics, called “math italics.” Once you learn the symbols
and Greek letters, the actual set of math commands is very simple. Tables of various
math symbols and Greek letters follow.
As an example of the way commands work in math mode, if you wanted to typeset
the Greek letter β, you would type “$\beta$” in the input window and compile.
LaTeX reads the command, executes it, and gives you a .dvi with the β ready to
print.
9.1
Subscripts and Superscripts
• An underscore ( ) in math mode indicates subscript:
$C i$ in the input window −→ Ci in the typeset window.
• A carat (^) in math mode indicates superscript:
$C^i$ in the input window −→ C i in the typeset window.
9.2
Grouping
As we have seen with other LATEX commands, the curly brackets ({ and }) are used to
group text together—to tell LATEX when a group begins and ends. The curly brackets
are used in math mode this way as well.
As an example, if you want more than one character subscripted, you need to
group them with brackets:
$C {ijk}$ in the input window
−→ Cijk in the typeset window.
The same thing applies for superscript:
$C^{ijk}$ in the input window
−→ C ijk in the typeset window.
Basic Math: Using Math Mode
9.3
30
Math Accents
We have discussed special characters and accents in normal text. LaTEX also has special characters in math mode, called “math accents,” which use different commands
than they do in normal text typing:
$\hat a$
$\check a$
$\tilde a$
$\acute a$
$\grave a$
$\dot a$
$\ddot a$
$\breve a$
$\bar a$
$\vec a$
â
ǎ
ã
á
à
ȧ
ä
ă
ā
~a
These accents generally apply only to the next, single character and can’t be
grouped.
10
Basic Math: Math Tables
Note: All the commands in this handout must occur in math mode (i.e., between
dollar signs).
Greek Letters
\alpha
\beta
\gamma
\delta
\epsilon
\varepsilon
\zeta
\eta
\theta
\vartheta
α
β
γ
δ
ǫ
ε
ζ
η
θ
ϑ
ι
κ
λ
µ
ν
ξ
o
π
̟
ρ
\iota
\kappa
\lambda
\mu
\nu
\xi
o
\pi
\varpi
\rho
̺
σ
ς
τ
υ
φ
ϕ
χ
ψ
ω
\varrho
\sigma
\varsigma
\tau
\upsilon
\phi
\varphi
\chi
\psi
\omega
Ξ
Π
Σ
Υ
\Xi
\Pi
\Sigma
\Upsilon
Φ
Ψ
Ω
\Phi
\Psi
\Omega
Uppercase
\Gamma
\Delta
\Theta
\Lambda
Γ
∆
Θ
Λ
Openings and Closings
[
{
]
}
\lbrack
\lbrace
\rbrack
\rbrace
⌊
h
⌋
i
\lfloor
\langle
\rfloor
\rangle
⌈
\lceil
⌉
\rceil
Basic Math: Math Tables
32
Miscellaneous Symbols
ℵ
h̄
ı

ℓ
℘
ℜ
ℑ
∂
∞
\aleph
\hbar
\imath
\jmath
\ell
\wp
\Re
\Im
\partial
\infty
′
∅
∇
√
△
\
\prime
\emptyset
\nabla
\surd
\top
\bot
\|
\angle
\triangle
\backslash
≥
≻
≫
⊃
⊇
⊒
∋
⊣
|
k
\geq
\succ
\succeq
\gg
\supset
\supseteq
\sqsupseteq
\ni
\dashv
\mid
\parallel
⊤
⊥
k
6
∀
∃
¬
♭
♮
♯
♣
♦
♥
♠
\forall
\exists
\neg
\flat
\natural
\sharp
\clubsuit
\diamondsuit
\heartsuit
\spadesuit
Relations
≤
≺
≪
⊂
⊆
⊑
∈
⊢
⌣
⌢
\leq
\prec
\preceq
\ll
\subset
\subseteq
\sqsubseteq
\in
\vdash
\smile
\frown
≡
∼
≃
≍
≈
∼
=
⊲⊳
∝
|=
.
=
⊥
\equiv
\sim
\simeq
\asymp
\approx
\cong
\bowtie
\propto
\models
\doteq
\perp
Negated Relations
6<
6≤
6≺
6
6⊂
6⊆
6
⊑
\not<
\not\leq
\not\prec
\not\preceq
\not\subset
\not\subseteq
\not\sqsubseteq
6>
6≥
6≻
6
6⊃
6⊇
6⊒
\not>
\not\geq
\not \succ
\not\succeq
\not\supset
\not\supseteq
\not\sqsupseteq
6=
6≡
6∼
6≃
6≈
∼
6=
6≍
\not=
\not\equiv
\not\sim
\not\simeq
\not\approx
\not\cong
\not\asymp
Basic Math: Math Tables
33
Binary Operations
±
∓
\
·
×
∗
⋆
⋄
◦
•
÷
\pm
\mp
\setminus
\cdot
\times
\ast
\star
\diamond
\circ
\bullet
\div
∩
∪
⊎
⊓
⊔
⊳
⊲
≀
△
▽
\cap
\cup
\uplus
\sqcap
\sqcup
\triangleleft
\triangleright
\wr
\bigcirc
\bigtriangleup
\bigtriangledown
∨
∧
⊕
⊖
⊗
⊘
⊙
†
‡
∐
\vee
\wedge
\oplus
\ominus
\otimes
\oslash
\odot
\dagger
\ddagger
\amalg
Arrows
←
⇐
→
⇒
↔
⇔
7
→
←֓
↼
↽
⇀
↽
\leftarrow
\Leftarrow
\rightarrow
\Rightarrow
\leftrightarrow
\Leftrightarrow
\mapsto
\hookleftarrow
\leftharpoonup
\leftharpoondown
\rightleftharpoons
←−
⇐=
−→
=⇒
←→
⇐⇒
7−→
֒→
⇀
⇁
\longleftarrow
\Longleftarrow
\longrightarrow
\Longrightarrow
\longleftrightarrow
\Longleftrightarrow
\longmapsto
\hookrightarrow
\rightharpoonup
\rightharpoondown
↑
⇑
↓
⇓
l
m
ր
ց
ւ
տ
\uparrow
\Uparrow
\downarrow
\Downarrow
\updownarrow
\Updownarrow
\nearrow
\searrow
\swarrow
\nwarrow
Basic Math: Math Tables
34
Function Names
These are all math functions which should be typeset in roman type (as opposed
to the usual math italics). The following commands will typeset the related function
in roman type.
\arccos
\arcsin
\arctan
\arg
\cos
\cosh
\cot
\coth
\csc
\deg
\det
\dim
\exp
\gcd
\hom
\inf
\ker
\lg
\lim
\liminf
\limsup
\ln
\log
\max
\min
\Pr
\sec
\sin
\sinh
\sup
\tan
\tanh
“Large” Operators
These “large operators” can be used in both normal math mode and “display
math” mode (we’ll talk about display math later). They should be used in either
case when the operator has a subscript or superscript and should be distinguished
from their smaller counterparts. For example, “\Sigma” should be used to describe
the capital Greek character Σ; however, “\sum” should be used when the symbol has
P
a subscript or superscript, as in ni=1 .
PX
QY
`a
R
H
Z
I
\sum
\prod
\coprod
\int
\oint
T\
\bigcap
S[
\bigcup
W_
\bigvee
FG
\bigsqcup
V^
\bigwedge
JK
\bigodot
LM
\bigoplus
NO
\bigotimes
U]
\biguplus
11
Basic Math: Grouping
Now that you have mastered the tables of Greek and math symbols, it’s time to learn
a few more frequently used math commands:
(1) \sqrt
(2) \frac
(3) \atop
(4) \sum
(5) \int
As we shall see in the following examples, all five of these commands require
special grouping.
(1) \sqrt: This is the square root command. Though this command doesn’t
ALWAYS require grouping like the others, it’s still good to be acquainted with how grouping works with it. Note that the curly brackets
surround only the information that is to go into the square root sign.
The command itself is on the outside of the curly brackets.
\sqrt{X + Y + Z}
√
X +Y +Z
(2) \frac: This is the fraction command. The command stands outside the
curly brackets, with both the numerator and denominator are enclosed
in curly brackets.
• \frac{X}{Y}
X
Y
36
11. Basic Math: Grouping
(3) \atop: This command is used to place two pieces of information on top
of each other. Note that this command stands in the center, and the
curly brackets surround the entire expression.
X
Y
• {X \atop Y}
(4) \sum: This command looks like an upper case sigma, but acts differently. With the \sum command, the super- and subscripts are placed
either to the side (in regular math mode) or directly on top and bottom (in display math mode) of the summation sign. The super- and
subscripts are called “limits.”
Regular Math Mode:
PX+Y
$\sum^{X + Y} {A + B}$
A+B
Display Math Mode:
\[\sum^{X + Y} {A + B}\]
X+Y
X
A+B
37
11. Basic Math: Grouping
(5) \int: This is the integral command. The super- and subscripts for \int
are also called limits. However, unlike \sum, the limits appear to the
side of the integral sign in both regular math and display modes
(although you can change that with the “\limits” command).
Regular Math Mode:
$\int^{X + Y} {A + B}$
R X+Y
A+B
Display Math Mode:
\[\int^{X + Y} {A + B}\]
Z
X+Y
A+B
12
Display Math Mode
There are two ways to indicate “display math mode.”
• \[; and,
• \begin{equation} paired, of course, with \end{equation}.
We will discuss the differences between these two methods in a moment, but for the
present, note the differences just between regular (in-text) math mode and displayed
math mode:
Regular Math Mode:
Finally, we know that $(X + Y)\times B$ is, as
suspected, non-differentiable.
Finally, we know that (X + Y ) × B is, as suspected, non-differentiable.
Display Math Mode:
Finally, we know that
$$(X + Y)\times B$$
is, as suspected, non-differentiable.
Finally, we know that
(X + Y ) × B
is, as suspected, non-differentiable.
Display Math Mode
39
The obvious differences in the typeset versions are that display math mode:
• centers the equation on a new line,
• puts a little extra space above and below the equation; and,
• the display command takes the place of dollar signs.
LATEX also adjusts the sizing of symbols in display mode, making them larger if
necessary (e.g., the numerators and denominators of fractions are made larger in
display mode than they are in regular math mode).
Note also the difference in input style—namely, that we have begun the text we
want to display on a new input line. While this is not necessary, it does make things
easier to find when you come back to edit. However, you need to be careful not
to include a blank line in your input above or below displayed text. Can you guess
why? That’s right: because those blank lines will be interpreted as indicating a new
paragraph and LATEX will include more space than is necessary to properly display
the equation.
12.1
Two Display Styles
As I indicated above, there are three ways to indicate display mode. The differences
between them are small, and only sometimes important.
• \[ is the way to indicate display mode in LaTEX if you do NOT want
the equation numbered. LaTEX automatically numbers the equations
otherwise.
• \begin{equation} and \end{equation} automatically numbers the
equations and allows you to label them.
Not So Basic Math
13
Not So Basic Math: Equation Labeling
As I said earlier, LaTEX will automatically number your displayed equations. The
command pair that you use to do this, again, is \begin{equation} and \end{equation}.
So, what if there is a textual reference to a specific equation? If you update the numbering, by inserting an equation somewhere for example, you will want the textual
reference to update as well. LATEX does this by allowing you to “name” the equation,
so that the textual reference can link to the name and then update the number. This
is called “labeling” and can be used in many LATEX environments.
13.1
The Label Command
The command is simply \label{‘‘name"}, and comes before the \end{equation}
command. Then, the textual reference look like this, \ref{‘‘name"}. For example,
\begin{equation}
\alpha + \sqrt{\beta - \infty}
\label{fred}
\end{equation}
would give you:
α+
q
β−∞
(1)
And, somewhere in the text you would type:
\ref{fred}
LaTEX then finds “fred” and places fred’s number in that place. For example,
this current sentence contains the reference command, (\ref{fred}) (1). Notice
that I typed parentheses around the reference command to format the referenced
number to be like the equation number. If I have many types of environments labeled,
like propositions, proofs, Lemmas, I might also specify that this is an equation, like
Equation (\ref{fred}).
Not So Basic Math: Equation Labeling
13.2
42
The Double Whammy
In order for LATEX to read references, label them, and typeset, you need to typeset a
document twice. The first typeset will read the commands and store the information
into an auxiliary file. The second typeset will read the auxiliary file and fill in the
correct numbers. PcTEX will actually give you a dialogue box that gives you the
option to re-typeset.
We will see in subsequent sections that almost any LATEX environment can be
labelled and referred to.
14
Not So Basic Math: Multi-Line Display Math
Frequently, you will need to type displayed equations that take up more than just
one line. There are two basic commands that will help you to accomplish this.
They are:
• \eqnarray; and
• \eqnarray*.
14.1
Eqnarray
The command \eqnarray is used when you need to align the different lines of a
multi-line equation, and you need to number any or all of them.
The format for \eqnarray is:
\begin{eqnarry}
math text & = &
math text & = &
\end{eqnarray}
math text\\
math text
There are many things to note:
• The \begin and \end eqnarray is set up much like begin and end
equation, and in fact takes the place of the begin and end equation
commands;
• Ampersands (&) are used as tab markers;
• LATEX sees the equation as having three columns:
A right-aligned math text column;
A centered equal sign (or other operator); and,
A left-aligned math text.
• A double backslash (\\) tells LATEX to end the line;
• There is no double backslash on the last line of text–apparently LATEX
knows to end the last line of the equation (duh).
Not So Basic Math: Multi-Line Display Math
14.2
44
And There’s More...
Confused yet? There’s more! When you use eqnarray, LATEX automatically numbers
each line. There are a couple of finer points about this command:
• If you don’t want a particular line numbered, you type \nonumber
before the double backslash;
• If you want a little less or a little more space between lines (you might
have some giant fractions that need more room), you simply add an
optional argument(the same type of argument we saw that goes with
document styles and horizontal formatting). This optional argument is
simply a pair of square brackets with a vertical skip amount, after the
double backslash. For example, \\[5pt] adds more space, or \\[-5pt]
subtracts a little space.
• AND, since this is a LATEX environment, each and any of the lines can
be specifically labeled for future reference. It’s as if LATEX sees each
line like a little mini-equation.
For example, an eqnarray with the first line not numbered, 5 points of extra space
between the second and third lines, and the third line labeled would look like this:
\begin{eqnarry}
math text &
math text &
math text &
math text &
\end{eqnarray}
14.3
=
=
=
=
& math text\\\nonumber
& math text\\[5pt]
& math text\\\label{fido}
& math text
Eqnarray*
The \eqnarray* command is exactly like the regular eqnarray command except that
NONE of the lines are numbered. All the lines can still be labelled and spaced, just
like the previous command.
15
Not So Basic Math: Math Arrays
We have seen the eqnarray (equation + array) command which lines up parts of an
equation. Now we will see an “array” command which lines up material within an
equation. An “array” is LATEX-talk for a table in math mode. Any time you want to
line things up inside an equation, you use an array, and they, for the most part, are
fairly simple to use.
15.1
The Array Command
The array command has two parts: the beginning and end argument (like the line
formatting arguments and the equation arguments) and a set-up argument. All arguments are enclosed in curly brackets. The set-up argument is simply a shorthand
to tell LATEX how many columns you want and how you want them justified. For
example, to set-up a three column array where all the columns are left-justified, the
array command would look like this:
\begin{array}{lll}
Similarly, you would use a “c” to center the math text and an “r” to right-justify
it. After you begin the array, columns are marked by ampersands (&) and end-oflines are marked by a double backslash(\\), just like the eqnarray commands. So,
our array would look like this:
\[
\begin{array}{lll}
math & math & math \\
math& math & math
\end{array}
\]
Please note:
• All of the formatting you saw in eqnarray applies here, the optional
argument ([5pt]), the labeling, the ampersands, double backslash. Just
think of it as, where the eqnarray had three columns that were already
set up as right-, center-, and left-justified, the array command will allow
to set your own number and justification of columns.
Not So Basic Math: Math Arrays
15.2
Two Specialized Arrays
15.2.1
Cases
46
The first special case of an array is called “case.” This is an array that generally has
only two columns, centered and left-justified. The second column usually contains
non-math text. And usually there is only one delimeter (a left curly bracket). The
output for a case looks like this:
(
1 < 2 for all δ → ∞
0
otherwise
The input would look like this:
\[
\left\{ \begin{array}{ll}
1<2 & \hbox{for all } \delta \rightarrow \infty\\
0 & \hbox{otherwise}
\right.
\]
Please note:
• There is a left delimeter (in this case a curly bracket), but no right
delimeter. Therefore, we tricked LATEX and typed \right. in the
place where LATEX would be looking to match the \left{.
• The way cases are generally used, the material in the second column
involves non-math text. Therefore, we have placed the non-math text
in an \hbox.
• The cases format can contain more than two rows, but usually contains
only two columns.
Not So Basic Math: Math Arrays
15.2.2
47
Matrices
The matrix format can have multiple columns and multiple rows; the information
is centered, and the whole thing is generally surrounded by delimeters. The output
would look like this:


a+b
0
c+d

a+b c+d 

 0
c+d a+b
0
And the input would look like this:
\[
\left(
\begin{array}{ccc}
a + b & 0 & c + d\\
0 & a + b & c + d\\
c + d & a + b & 0
\end{array}
\right)
\]
Please note:
• Unlike the cases format, text in each column is centered.
• Like cases format, the matrix format can have more than two rows;
however, unlike cases, the matrix can also have more than two columns
by adding additional ampersands on each line.
Not So Basic Math: Math Arrays
15.3
48
Summary
Case
Ampersand for alignment
Text justification
\\at end of each line
Surrounded by a delimiter
# of columns
# of rows
Display only
Font change after &
Matrix
yes
yes
left
center
yes
yes
no–left {
yes
2
any
any
any
yes
yes
yes (need \hbox{}) no (stays in math mode)
16
Not So Basic Math: Text in Math Mode
As you know, LaTEX prints everything that is in math mode as “math italics.” Sometimes, however, you may want to type a word or two of regular text inside an equation.
There are two ways to do this.
16.1
Roman Font
One way to type text in math mode is simply to specify the roman font. For example,
to get
Θ × σ or Θ × α
you could enter
\[\Theta\times\sigma {\rm\ or\ } \Theta\times\alpha\].
• Note that the \rm (“roman”) command is enclosed in curley brackets
(as all character formatting commands usually are).
• Note that we have included a \ followed by a space on either side of the
roman text. This is necessary because all we have done is to change the
style of the current font; we have not changed the mode in which TEX
is operating. Remember that TEX ignores spaces in math mode unless
you specify otherwise (with a \ followed by a space or some other type
of horizontal spacing such as \quad).
16.2
Text Mode
Another way to type text in math mode is to actually change the mode, by putting the
text into “horizontal text” mode instead of math mode by using the \hbox command.
In the example above, you could also have typed
\[\Theta\times\sigma \hbox{ or } \Theta\times\alpha\].
Not So Basic Math: Text in Math Mode
50
• Note that the \hbox command is outside the curly brackets.
• When using \hbox, you can simply type a space inside the group and
TEX will typeset a space (unlike when using the \rm command where
you had to type \ followed by a space). Again, you could also use
\quad for more space.
• The problem with using \hbox arises when you need text in a size
other than normal text size (e.g., a superscript). The command \hbox
changes the mode of TEX operation from math to text, so superscripts
are no longer available.
General Rule: It is probably easiest to use \hbox unless you think you might need
roman text in a non-text size, in which case you should use \rm.
Not So Basic Text
17
Not So Basic Text: The Preamble
Parts of a Preamble
The Preamble
The preamble, a bit of space before the beginning of the content of the document,
is the place where you include any macro packages you might want to use, list any
new definitions you may have written, and list any definitions of new theorems.
17.1
\usepackage{...}
This is the command that tells LATEX to read in any macro packages you wish to use
in the document. These packages can range from a style file that gives the headers
a little more pizazz to a set of definitions that allow you to include graphics in the
paper. Most packages come installed with PCTeX, but more are listed in the AFS
space of the Leland directory, and they can be easily downloaded.
17.2
New Commands
As if there weren’t already too many commands, LATEX allows you to easily create
new ones. The command looks like this:
\newcommand{\new name}{string of characters and/or old commands}.
For example, you may find that in a certain paper you are typing “θ̂t+1 ” very
often. You can write a little definition for this expression,
\newcommand{\ht}{\hat\theta {t+1}}}.
And, as long as you use the expression inside math mode, it will work like a
charm. As you can guess, however, if you put dollar signs into the definition itself,
the expression won’t need them later on. In this particular case, leaving the dollar
signs out makes sense, because you would not very likely be using the expression
outside of math mode.
18
No So Basic Text: The Title Page
The Titlepage
In LATEX, both article style and report style have a “\maketitle” command that
makes setting up a titlepage easier. By default, the titlepage is on a separate page in
the report style and on the top of the first page in the article style. You can use the
“[titlepage]” option in article style if you wish the titlepage to be separate.
18.1
Titlepage Commands
These are the commands for a titlepage:
\title{Title of document}
\author{Author\and Author\thanks{Acknowledgements}}
\date{\today}
\maketitle
• The \title{} command automatically centers, bolds, and enlarges the
text.
• Note that the \author command can handle more than one name with
the \and; this, however, centers the names on one line. If you want
the authors names on separate lines, a double backslash acts as a line
break, for example,
\author{First author’s name\\
and\\
Second author’s name}
• The \thanks{} command comes inside the author command’s curly
brackets. This produces an unnumbered footnote.
18. No So Basic Text: The Title Page
54
• The \today command will insert today’s date, whatever it is. If you
want a particlular date, simply type it in.
• The \maketitle command tells LATEX to produce all the titlepage commands.
• Note that, although these definitions make it easier to type a titlepage,
they also make it very difficult to type things differently than the way
LATEXhas it set up.
18.2
The Abstract
LATEX has an Abstract environment which titles and indents the abstract. In the
report style, the abstract receives a separate page, and in the article style the abstract
is placed just below the title. Using the “[titlepage]” option with the article style
places the abstract on a separate (as well as the title, as mentioned above).
To use the abstract environment, directly after the \maketitle command, simply
type
\begin{abstract}
Type the text of the abstract
\end{abstract}
19
19.1
Not So Basic Text: The Main Body
Sectioning Commands
LATEX utilizes sectioning commands to help you divide the document into parts. All
but the paragraph and subparagraph will be automatically numbered. The following
is a list of the commands.
\part (used with article style)
\chapter (used with book style)
\section
\subsection
\subsubsection
\paragraph
\subparagraph
\appendix
You type the actual title of the section in curly brackets, for example,
\section{Introduction}.
The appendix
The appendix section receives a special mention because LATEX automatically
names these sections as “Appendix A” and so forth.
56
19. Not So Basic Text: The Main Body
19.2
Labeling
Any command in LATEX that automatically numbers (like an equation, section, or
item) can be labeled for future reference. For example, you may want to label a
section, and refer to it later on by its label rather than by its number. LATEX will
automatically update the references as it numbers. That way, you don’t have to worry
about changing the numbering as the paper is revised in case a section is deleted or
the order is changed. As well, you don’t actually see the numbering of equations
and sections until after the document is typeset, so numbering and referring to the
numbers by hand can be tedious.
The Labeling and Referencing Commands
Environment and Label
\begin{equation}\label{eq1}
\section{Introduction}\label{intro}
\item\label{item1}
\begin{theorem}\label{th1}
Referencing the Label
\ref{eq1}
\ref{intro}
\ref{item1}
\ref{th1}
There may be times when you want an un-numbered section. To do this, you type
\section*{ Name of section}
This will give you a section titled “Name of Section” that is not numbered and will
not appear in the table of contents.
19.3
Footnotes
LATEX has a very simple format for making footnotes. The command looks like this:
\footnote{Text of footnote}
You type the footnote into the text of the document where you want the footnote
number to occur. The footnotes are automatically numbered.
20
Not So Basic Text: Lists and Quotations
We have already touched on large text environments such as document styles like
article and book. We have also touched on small text environments such as line
centering and font changes. Here, we will look at medium-sized text environments
such as at lists, quotations, theorems, and tables.
Lists
20.1
LATEX has three list styles: bulleted, numbered, and descriptive or word-labeled. We
will look at each of these in turn. Like all LATEX environments, each list style opens
with a \begin{list style} and ends with an \end{list style} with the text environment
commands in between.
20.1.1
Bulleted Lists
To create a bulleted list, you type
\begin{itemize}. Then, each item begins with \item until you are finished with
the list. A sample list might look like this:
\begin{itemize}
\item Buy groceries,
\item Buy gas for car,
\item Do laundry.
\end{itemize}
The output would look like this:
• Buy groceries,
• Buy gas for car,
• Do laundry.
Not So Basic Text: Lists and Quotations
20.1.2
58
Numbered Lists
Creating a numbered list is similar to creating a bulleted list. You type,
\begin{enumerate}
\item Buy groceries,
\item Buy gas for car,
\item Do laundry.
\end{enumerate}
The output would look like this:
1. Buy groceries,
2. Buy gas for car,
3. Do laundry.
20.1.3
Word-Labeled Lists
Word-labeled lists are interesting, as they are used to describe word or subject, like
a dictionary or encyclopedia entry. For example, to type a word-labeled list,
\begin{description}
\item[Dog] An animal that runs around and barks.
\item[Cat] An animal that runs from dogs.
\end{description}
The output for this would look like:
Dog An animal that runs around and barks.
Cat An animal that runs from dogs.
Not So Basic Text: Lists and Quotations
20.2
59
Nesting Lists
Nesting lists means putting a list within a list. LATEX will nest lists down to four
levels. To nest, you simply begin another list within a list. This can become complicated, however, and it is important that you keep track of the beginning and ending
of each of your beginnings and endings. The symbols for bulleted lists are bullets,
dashes, asterisks, and dots. The hierarchy of symbols for the enumerate environment
are numbers, (a), (b), and so on, i, ii, then A., B. and so on. To nest a bulleted list,
for example, you would type
\begin{itemize}
\item Buy groceries,
\begin{itemize}
\item milk
\item potatoes
\item apples
\end{itemize}
\item Buy gas for car.
\end{itemize}
Producing,
• Buy groceries,
– milk
– potatoes
– apples
• Buy gas for car.
Not So Basic Text: Lists and Quotations
20.3
60
Customizing the itemize Command
The itemize command can be customized to use different symbols. To do this, you
type,
\begin{itemize}
\item[$\dagger$] Buy groceries
\end{itemize}
This would produce:
† Buy groceries.
Be aware, though, that each new nesting would revert to the default symbol. Also,
each new list environment will begin numbering from the top level.
20.4
Quotes and Quotations
Both the quote and quotation environment indent the text on both sides to set it
off from the main text body. Generally, the quote command is used for smaller text
fragments, and quotation for larger texts, as the quotation command narrows the line
spacing to further set the quotation off from the test of the text. These environments
are similar in structure, beginning with \begin{quote or quotation} and ending
with \end{ quote or quotation}.
21
21.1
No So Basic Text: Tables
Typing Tables in LATEX
This is the basic format for typing tables:
\begin{center}
\begin{tabular}{ccc}
text & text & text \\
text & text & text \\
text & text & text \\
text & text & text
\end{tabular}
\end{center}
Note that
• \begin and \end{center}–tables are usually, but don’t have to be,
centered;
• \begin and \end{tabular}–starts and ends the table environment;
• {ccc} is the number and alignment of columns: c is for centering, l
would be for left align, and r would right align text within the column;
• & is the tab marker, measured according to the widest line in each
column; and,
• \\ is the line break. The last line of a table doesn’t need this.
No So Basic Text: Tables
62
An Input and Output Example
Input
\begin{center}
\begin{tabular} {lcr}
left-aligned text & centered text & right-aligned text \\
some text & text & more text \\
different text & a lot of text & a little text \\
text & text in the center & text
\end{tabular}
\end{center}
Output
left-aligned text
some text
different text
text
centered text
right-aligned text
text
more text
a lot of text
a little text
text in the center
text
No So Basic Text: Tables
21.2
63
More Table Commands
\hline will produce a horizontal line in the table.
\cline{2-4} will produce a horizontal line extending across selected
columns (in this case, columns 2 through 4).
Typing a “|” between the column markers (l,r, and c) will produce a
vertical line between the columns.
After the line break (\\) you can add a little vertical space by typing
[.5cm], for example; conversely, you can also reduce the vertical space
by typing [-.5cm].
You can extend a heading across columns by typing
\multicolumn{3}{c}{Heading}\\
– The {3} refers to the number of columns you want to span across
(in this case, 3).
– The {c} refers to how you want the heading aligned (in this case,
centered).
– Be sure to end even this line with a double backslash (\\).
22
No So Basic Text: Theorems
Another important text environment is the theorem environment. In LATEX, “theorem” is used to denote any labeled text that is set off from the main body by extra
space and a font change. The type of text a theorem is used for is to state a definition,
pose a thesis or problem. Different theorem headings could be Lemma, Proposition,
Definition
The label will include a number and can be referenced. The environment must be
defined, however, before it can be used. There is no generic “\begin{theorem}” in
LATEX.
22.1
Defining the theorem environment
To define a theorem, near the beginning of your document (usually just after
\begin{document}), type \newtheorem{theorem}{Theorem}
• “newtheorem” tells LATEXthat a theorem-like enviromnent is going to
be defined.
• {theorem} (lower case) is the name you will use to invoke the environment.
• {Theorem} (upper case) is the printed title.
22.2
Using the theorem environment
To use this environment, type
\begin{theorem} and then simply type the theorem. To end a theorem, simply type
\end{theorem}. Note that the theorem environment recognizes a double-return as a
new paragraph and will not end the environment until you type \end{theorem.}
22. No So Basic Text: Theorems
65
Here is an example of the input and the look of the output.
\newtheorem{theorem}{Theorem}
\begin{theorem}
This is an example of a theorem style. Note the italics.
Note the boldface title and the theorem number. It is amazingly
easy to use and quite handy.
\end{theorem}
Theorem 1 This is an example of a theorem style. Note the italics. Note the boldface title and the theorem number. It is amazingly easy to use and quite handy.
23
No So Basic Text: The bibliography
The Bibliography
There are two ways in LATEX to produce a bibliography. One way is to use a
pre-typed database containing the bibliographic information in fields with each entry
labeled. We will not focus on this method at the present time.
The second method is to use a variation of the itemize environment and type the
entries yourself. This is a very simple method and we will look at briefly here.
23.1
Bibitem
The environment for the bibliography starts like this:
\begin{thebibliography}{99}
The “99” is merely a place marker for the item numbers. You can have up to
three digits (“{999}”).
The bibliographic list looks like this,
\bibitem{label} Bibliographic information.
\bibitem{label} Bibliographic information.
\end{thebibliography}
23.2
Using the cite Command
You need to label each entry in order to cite it in the text:
\cite{label}
Advanced Issues
24
More Tables
The initial table format is fairly straightforward:
• \begin{tabular} begins the environment.
• {lcr} tells LATEX how many and the justification for each column.
• & ampersands act as tabs.
• \\ double backslash tells LATEX that it is the end of the line.
• The last line of the table does not need the double backslash.
• \end{tabular} ends the environment.
Sample:
\begin{tabular}{rrr}
some text & some text & some text\\
some text & some text & some text\\
some text & some text & some text
\end{tabular}
This gives you a table with three right-justified columns and 3 rows.
24.1
Row and Column Lines
To add a line between columns, you need to put the command in the table prologue.
24.1.1
Column Lines
This table will have vertical lines before and after each column:
\begin{tabular}{|r|l|c|}
Obviously in LATEX, you cannot have a column line that only extends part way down
the length of the table.
24. More Tables
24.1.2
69
Row Lines
To add lines between rows, you use the command \hline after the line break:
some text & some text & some text\\\hline
24.1.3
Cline
You can also add a line to extend across only some of the columns by using \cline{}
For example:
some text & some text & some text\\\cline{2-3}
This would tell LATEX to draw a horizontal line under columns 2 and 3.
24.2
The Multicolumn
There are times when you want information to merge across columns. The command
to do this is called multicolumn. It works like this:
\multicolumn{3}{c}{Text}
• The command is placed in the column you want merged.
• The first argument, {3}, tells LaTeX how many columns will be merged.
• The second argument, {c}, tells LaTeX how you want the information
justified.
• The last set of curly brackets, {Text}, is the actual text. If you don’t
put the text into curely brackets, only the first word will be merged.
Sample:
\begin{tabular}{rrrr}
some text & some text & some text & some text\\
some text & \multicolumn{2}{c}{Some Text} & some text\\
some text & some text & some text & some text
\end{tabular}
This tells LATEXin the second row, spread the words Some Text centered across the
middle two columns.
24. More Tables
24.2.1
70
Tricks with Multicolumn
You can use the multicolumn command to trick LATEX into formatting individual cells
differently than what is defined in the prologue. To do this, you use multicolumn for
just one cell. For example, you can use the multicolumn command in the header row
to center the column heads:
\begin{tabular}{rr}
\multicolumn{1}{c}{First Column title}
& \multicolumn{1}{c}{Second Column title}
This would center the column headers even though you specified all columns to be
right-justified.
24.3
The Table Environment
When you need a table to be numbered with a caption, you use the table environment.
A numbered list of tables can then be placed after the table of contents with the
command: \lot (stands for List of Tables, imaginatively enough). This environment
“wraps” around the tabular environment. For example:
\begin{table}
\begin{tabular}{ }
..................
\end{tabular}
\caption{Title of table}
\end{table}
The table environment is a “float,” meaning LATEX will place it as a single block
of information somewhere on the page. The following are some commands to help
you take control of where the table appears.
• h = “here”, this exact position
• t = top of the current page
• b = bottom of the current page
• p = place on a float page
• ! = ignore restrictions (emphasis).
24. More Tables
71
For example,
\begin{table}[h!]
will tell LATEX to place the table here!
As well, the normal \begin{center} and \end{center} do not work in the table
environment. You need to use \centering instead, like this:
\begin{table}
\centering
\begin{tabular}. . .
24.4
Additional Table Commands
There several additional commands which can give you more control over the look
and feel of a table.
• \tabcolsep—this indicates half the width of the horizontal space between columns (default = 6pt)
– To use this command, you type, for example,
\setlength{\tabcolsep}{2pt}
• \arraystretch—this controls the space between rows (default = 1; 1.5
would move the rows 50% further apart).
– To use this command, you type, for example,
\renewcommand{\arraystretch}{2}
These commands will affect the tables for the rest of the document unless you put
them inside the \begin{center} command. For example:
\begin{center}
\renewcommand{ \arraystretch}{2}
\begin{tabular}. . . ..
24. More Tables
24.5
72
Longtable
Sometimes you need a table to extend beyond one page. Creating two tables would
work, if you compiled first and knew where they should end. But if the information
in a column on one page had a different width than the information on the next page,
the table columns wouldn’t match. The Longtable package enables you to extend
your table over more than one page, letting LATEX make the page break for you, as
well as keeping the column widths intact. The commands for this package are mostly
the same as for the regular tabular environment, except that there are a few extra
for a headline and footline (headings and footings for the table across pages).
Longtable is a package, so you need to tell LATEX to use it:
\documentclass[12pt]{article}
\usepackage{longtable}
\begin{document}
Sample:
\setlongtables
\begin{longtable}{ccc}
{\bf Text} & {\bf Text} & {\bf Text}\\
\endhead
. . . . . . . . . . . . . . . . . . ..
\end{longtable}
This would tell LATEX to place the boldface headings on the subsequent pages.
25
BibTeX
There are two ways to produce a bibliography in LATEX. One way is to use the
\bibitem command, a specialized form of the item environment. This has already
been covered. The second way is to use BibTeX, an add-on utility that interfaces
with a bibliographic database and creates a bibliography.
25.1
Steps for using BibTeX
1. You need a .bib file. An small sample file is included at the end of this
section.
• This is the database, containing all the bibliographic information;
• It is an ascii file with a list of fields for each entry;
• It is called filename.bib
2. You need citations within the text that are taken from the .bib file.
BibTeX creates a reference list from the citations only, not from an
independent source.
Text references look like this: \cite{name}
3. Place the bibliography commands where you want the bibliography to
appear:
• \bibliographystyle{path and style}
• \bibliography{name and path of bib file}
4. Bibliography styles that come loaded with LATEX:
• Plain
• Unsrt
• Alpha
• Abbrv
• Acm
25. BibTeX
74
• Apelike
• There are many many styles available from the internet or from
specific journals or other programs like Scientific Word.
5. Typeset once. This creates an .aux file which contains all the citation
commands (as well as any other references).
6. Choose BibTeX under the Tools menu. BibTeX
• creates a .bbl (which is actually the bibitem file) file from the
information in the .aux file; and,
• creates a .blg file, the log of the BibTeX process (just like the .log
file created from texing).
7. Typesetting again reads the .bbl file into the tex file.
8. Typesetting a third time resolves citation references.
9. Summary:
• Typeset once
• BibTeX once
• Typeset twice more.
10. In the Figures section of this document, there is a schematic of the
whole process.
25.2
A word about PCTeX and MikTeX
There are a few differences between the way these two applications deal with TEXtools.
The commands within the document are identical, but the processes vary slightly.
PCTeX has a Tools menu that contains both BibTeX and MakeIndex. First, you
compile as usual. Then you choose BibTeX under the Tools menu. Then, you compile
once again. For MikTeX users, the process is easier. First you compile as usual. Then
you choose the BibTeX button. Then, you compile once again.
25. BibTeX
25.3
75
Sample Bib file entries
@BOOK{delmey:78,
AUTHOR = {C. Dellacherie and P.-A. Meyer},
TITLE = {Probabilities and Potential},
PUBLISHER={North-Holland},
ADDRESS={Amsterdam},
YEAR = {1978}}
@ARTICLE{ChenS:93,
author =
{R.-R. Chen and L. Scott},
title =
{Maximum Likelihood Estimation for
a Multifactor Equilibrium Model of the Term Structure of Interest
Rates},
journal =
{Journal of Fixed Income},
year =
{1993},
volume =
{3},
pages =
{14-31}, }
Note
• After the entry type (book, article, etc.) the entry is “named”– ChenS:93.
This is the name you will use for the citation. For example:
\cite{ChenS:93}
• The bib entries are highly structured. As the bibliographic style will
determine most of the text formatting in the entry, forcing capital
letters or type styles, or any other formatting choices, requires special
commands.
• For setting up a bib file correctly, refer to The LATEXCompanion by
Goossens, Mittelbach, and Samarin, or any other LATEX reference book.
26
Make Index
LATEX has a very handy command, \index, that allows you to create an index as you
input text.
26.1
Using MakeIndex
MakeIndex is a utility like BibTeX. You need to input the commands and then run
the utility. To use this utility, you need to do several things.
1. In the preamble, type two things:
(a) First, type \usepackage{makeidx};
(b) then, type \makeindex.
2. Then, when you find a word that you would like compiled in an index,
type \index{word}.
3. At the end of the document where you want the index to appear, type
\printindex.
After compiling, a page titled Index will appear at the back of your document including the index entries.
26.2
The Process
As with BibTeX, compiling for an index requires several iterations.
1. The first time you compile, the index requests are stored in an “.idx”
file, which functions as an information storage file, like an .aux file.
2. The second time you typeset, LATEX creates an “.ind” file, which is the
alphabetized index.
3. The third time you compile, the .ind file is read back into the body of
the document and the references resolved.
4. Summary: Typeset three times.
A schematic of this process is included in the Figures section.
26. Make Index
26.3
77
A word about PCTeX and MikTeX
There are a few differences between the way these two applications deal with TEXtools.
The commands within the document are identical, but the processes vary slightly.
PCTeX has a Tools menu that contains both BibTeX and MakeIndex. First, you
compile as usual. Then you choose MakeIndex under the Tools menu. Then, you
compile once again. For MikTeX users, the process is easier. First you compile as
usual. Then you choose the Index button. Then, you compile once again.
26.4
Fine Tuning Your Index
You can create subcategories by using an exclamation sign in your entry. Thus,
\index{word!subword}
will result in an entry that looks like this:
word, 1
subword, 1
You can also cross reference by typing
\index{word|see{subword}}
which will result in an entry that looks like this:
word, see subword
You can as well designate a page range. You do this by typing
\index{word|(} on the first page of your range, and
\index{word|)} on the last page of your range
will result in an entry that looks like this:
word, xx-xxx
27
Graphics
There are two ways to include graphics using PCTeX. One way is to use a command unique to PCTeX, but not always available to LATEX in other programs (Unix,
MikTeX). This is the “special” command:
27.1
The Special Command
\vspace{3in}
\special{bmp:
\medskip
file path and name.bmp}
Note that you need to manually add the amount of space you need for the figure.
You can also size the figure by typing in either an x (horizontal) dimension or a y
(vertical) dimension. By adding either an x or y dimension, LATEX scales the graphic
proportionally. You can add an x and a y dimension to scale the graphic to your own
needs.
\vspace{3in}
\special{bmp: file path and name.bmp x = 2.75in}
\medskip
The special command will recognize the following graphic file types:
bmp
ps
wmf
eps
emf
The special command will not recognize the following graphic file types:
jpeg
gif
tif
27. Graphics
27.2
79
The Includegraphics Command
The other cway to include graphics into a LaTeX file is to use the graphicx package.
To do this, you type
\usepackage{graphicx}
in the document prologue. As MikTeX and Unix only recognize ps and eps graphics,
this package is the best way to include graphics. This package is good for ps and eps
graphics only:
\includegraphics{filepath and name.eps}
Notice that this package automatically adds the space you will need. Further, scaling
and rotating is easy:
\includegraphics[scale=.5, angle=90]{filepath and name.eps}
This would tell LaTeX to scale the graphic to half its size and rotate it 90 degrees.
27. Graphics
27.3
80
The Figure Environment
Like tables, you can “wrap” a figure environment around a graphic that would tell
LaTeX
• to treat the figure like a float
– LaTeX sees a float as a block of information,
– LaTeX will not break the block across pages,
– LaTeX will place this block where it decides is the most appropriate space.
• allow for a caption,
• let you name it (for referencing),
• number it, and
• allow for a “list of figures” (lof) in the table of contents.
This is how the figure environment would look with the \includegraphics command.
Note that, since the figure will be numbered, it can also be labeled for future reference.
The caption can be placed either above or below the graphic.
\begin{figure}\label{fig1}
\includegraphics{fig}
\caption{This is a figure caption}
\end{figure}
Figures
28
Figures
The following pages contain figures of various LATEX structures. The first structure
is an outline of the layout for a typical paper. The second figure shows how LATEX
sees a page with it various dimensions. The last two figures, bibtex and index, show
the process LATEX uses to compile a bibliography from a bibliographic database and
compile an index, respectively.
83
28. Figures
Outline of a Document
Specify class
\documentclass[12pt]{article}
\usepackage{natbib, graphicx}
\newcommand{\ht}{\hat\theta}
\newtheorem{lemma}{Lemma}
\makeindex
Relevant packages
Personalized definition
Theorem environment defined
Include an index
}
\begin{document}
\title{Practice Document}
\author{Ms. La Tex}
\date{\today}
\maketitle
Preamble
Start document
}
Article heading
}
Abstract
}
Main body
\tableofcontents
\begin{abstract}
Text of abstract
\end{abstract}
\section{Introduction}\label{intro}
Text of first section.
\section{Onwards and Upwards}\label{on}
Text of second section.
\appendix
\section{Name of appendix}\label{name}
} Appendices
\begin{thebibliography}{99}
\bibitem{key}{Reference information.}
}
\end{thebibliography}
\printindex
\end{document}
References
Print index
End document
84
28. Figures
Page Layout
1-inch
default
margin
Header
textheight
1-inch
default
margin
Body
textwidth
Footer
oddsidemargin = left margin
evensidemargin = right margin
To set left margin:
\setlength{\oddsidemargin}{dimension}
\setlength{\textwidth}{dimension}
oddsidemargin assumes 1-in default
To set top margin:
\setlength{\topmargin}{dimension}
\setlength{\textheight}{dimension}
topmargin assumes 1-in default
85
28. Figures
Creating a Bibliography
Using BibTeX
\documentclass[12pt]{article}
\usepackage{chicago}
Bib definition file
Examples: chicago, harvard, natbib
Typeset
Reads bib file
to create .aux file with
bib information
Uses .bst file
Under Tools Menu
Choose BibTeX
Reads .aux file with
bib information
Typeset
Reads .bbl file
Creates .blg file
Typeset
Document
includes bib
Includes .bbl into tex file
and resolves citations
.bib = bibliography database
.bst = bib style file
.blg = bib log file
.bbl = formatted reference file
Creates .bbl file
86
28. Figures
Creating an Index
\documentclass[12pt]{article}
\usepackage{makeidx}
Typeset
Creates .idx file
Uses .ist file
Under Tools Menu
Choose Makeindex
Creates .ind file
Creates .ilg file
Typeset
Document
includes index
Reads .ind file
.idx = raw (unsorted) index file
.ist = index style file
.ilg = index log file
.ind = alphabetized index file
Homework
29
Homework
The following four assignments are meant to reinforce what was covered in class. I
will assign one each week. Do the best you can on each one, but if you run into
problems, please don’t hesitate to ask for help.
Exercises
30
Exercises
The following exercises are meant to reinforce various types of material that were
covered in class. They focus on issues, like math typesetting, that I consider need
plenty of practice. These are not assigned like homework, but are included if you
think you need the extra practice. If you run into problems, please don’t hesitate to
ask for help.