Text Formatting with L

A
T
E
X
A Tutorial
Academic and Research Computing, April 2007
Table of Contents
1. L
A
T
E
X Basics 1
1.1 What is T
E
X? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 What is L
A
T
E
X? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 How L
A
T
E
X Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 The L
A
T
E
X Input File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4.1 Entering L
A
T
E
X Commands . . . . . . . . . . . . . . . . . . . . . . 2
1.4.2 Entering Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4.3 Special Characters . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4.4 Structure of the Input File . . . . . . . . . . . . . . . . . . . . . . 4
1.5 Some L
A
T
E
X Vocabulary . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2. Creating A L
A
T
E
X Document 7
2.1 Document Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Class Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.4 Making a Title Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.5 Making a Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.6 Behind the Scenes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.6.1 Auxiliary Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.6.2 How a Page is Built . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.7 Example: Report Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.8 Example: Letter Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3. Document Layout 13
3.1 Line Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2 Paragraphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.3 Text Justification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4 Margins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.5 Headers, Footers, and Page Numbering . . . . . . . . . . . . . . . . . . . 15
ii ♦ Contents
4. Within the Text 16
4.1 Section Headings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.2 Changing Type Style and Size . . . . . . . . . . . . . . . . . . . . . . . . 17
4.3 Starting New Lines and New Pages . . . . . . . . . . . . . . . . . . . . . 18
4.4 Leaving Horizontal and Vertical Space . . . . . . . . . . . . . . . . . . . 18
4.5 Drawing Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.6 Footnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.7 Centering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.8 Quotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.9 Reproducing Text As-Is . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.10 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.11 Cross References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5. Tabular Material 23
5.1 Tabbing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.2 Tabular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.2.1 A Simple Ruled Table . . . . . . . . . . . . . . . . . . . . . . . . 25
5.2.2 Using Paragraph Columns, Spanning Columns . . . . . . . . . . . 26
5.2.3 Aligning on the Decimal Point . . . . . . . . . . . . . . . . . . . . 27
5.2.4 Suppressing Leading or Trailing Space . . . . . . . . . . . . . . . 27
6. Mathematics 28
6.1 In-line Math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
6.2 Display Math (for unnumbered equations) . . . . . . . . . . . . . . . . . 29
6.3 Equation Environment (for numbered equations) . . . . . . . . . . . . . . 29
6.4 Eqnarray Environment (for multiline equations) . . . . . . . . . . . . . . 30
6.5 Array Environment (for matrices, etc.) . . . . . . . . . . . . . . . . . . . 31
6.6 Building Mathematical Expressions . . . . . . . . . . . . . . . . . . . . . 32
6.6.1 Superscripts and Subscripts . . . . . . . . . . . . . . . . . . . . . 32
6.6.2 Spaces in Math Mode . . . . . . . . . . . . . . . . . . . . . . . . . 32
6.6.3 Dots, Braces, and Bars . . . . . . . . . . . . . . . . . . . . . . . . 32
6.6.4 Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6.6.5 Radicals, Integrals, and Summations . . . . . . . . . . . . . . . . 33
6.6.6 Large Delimiters . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
7. Including Graphics 35
7.1 Creating the Graphics File . . . . . . . . . . . . . . . . . . . . . . . . . . 35
7.2 Importing the Graphic into your L
A
T
E
X Document . . . . . . . . . . . . . 35
7.3 Viewing the Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
8. Placing Figures & Tables (Floats) 37
8.1 Making a Caption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
8.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
8.3 Overcoming Problems with Float Placement . . . . . . . . . . . . . . . . 40
8.4 Landscape Figures and Tables . . . . . . . . . . . . . . . . . . . . . . . . 40
April 2007
Contents ♦ iii
9. Preparing a Bibliography 41
9.1 Using L
A
T
E
X’s built-in Method . . . . . . . . . . . . . . . . . . . . . . . . 41
9.2 Using BibT
E
X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
9.2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
9.2.2 Creating the .bib File . . . . . . . . . . . . . . . . . . . . . . . . 43
9.2.3 Running BibT
E
X . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
9.2.4 Bibliography Styles . . . . . . . . . . . . . . . . . . . . . . . . . . 44
9.2.5 For More Information . . . . . . . . . . . . . . . . . . . . . . . . . 45
10. Special Topics 46
10.1 Managing a Large Document . . . . . . . . . . . . . . . . . . . . . . . . . 46
10.2 Generating an Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
10.3 Including hyperlinks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
10.4 Accents and Special Characters . . . . . . . . . . . . . . . . . . . . . . . 49
Appendix A: Mathematical Symbols 50
Appendix B: Error Messages 53
Resources 55
General Information on L
A
T
E
X . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
L
A
T
E
X packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
L
A
T
E
X Thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Mathematical Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
BibT
E
X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Installing L
A
T
E
X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Academic and Research Computing, RPI
Text Formatting with L
A
T
E
X
This document describes the L
A
T
E
X language. For specifics of how to run
it on various platforms (e.g., Windows or unix), see the L
A
T
E
X Information
page (http://www.rpi.edu/dept/arc/training/latex/), and follow the
links for the on-line tutorials. The above web page also contains information
on preparing a thesis or a resume, as well as many examples and links to
other helpful information.
Chapter 1. L
A
T
E
X Basics
1.1 What is T
E
X?
• T
E
X is the typesetting language upon which L
A
T
E
X is built. It was designed and
written by Donald Knuth especially for math and science. T
E
X is pronounced
“Tech,” similar to “Bach.”
• T
E
X is portable. It is available for most computers and is used all over the world.
T
E
X documents can be moved easily from one system to another, as long as the
required fonts are on both systems.
• T
E
X comes with its own set of fonts, called “Computer Modern,” used by default.
These fonts exist in a variety of styles, including serif, sans serif, typewriter (fixed
pitch), and an extensive set of mathematical symbols. It’s also possible to use
other font families, such as Times, Palatino, etc.
• T
E
X is also a programming language, making it possible to create commands that
simplify its use.
1.2 What is L
A
T
E
X?
• L
A
T
E
X is a T
E
X macro package, originally written by Leslie Lamport, that simplifies
the use of T
E
X. All the above features of T
E
X, including portability, also apply to
L
A
T
E
X. L
A
T
E
X is pronounced either “Lay-tech” or “Lah-tech.”
• Most L
A
T
E
X commands are “high-level” (such as chapter and section) and specify
the logical structure of a document. The author rarely needs to be concerned with
the details of document layout, concentrating instead on the content. Most plain
T
E
X commands also work with L
A
T
E
X.
• The document class determines how the document will be formatted. L
A
T
E
X pro-
vides several standard document classes from which to choose.
• L
A
T
E
X is flexible, gives you complete control, handles big, complex documents with
ease, and never crashes or corrupts your files.
1
2 ♦ Chapter 1. L
A
T
E
X Basics
1.3 How L
A
T
E
X Works
To use L
A
T
E
X, you first create a plain ASCII text file with any text editor. In this file
you type both the text of your document and the L
A
T
E
X commands to format it. You
then typeset your document, usually by clicking a button on a toolbar or selecting a
menu item. Nowadays there are two routes for processing a L
A
T
E
X document:
• The traditional way is to run the latex program, which creates a DVI (Device
Independent) file. This file is in binary format and not viewed directly. You
then run a previewing program for viewing on screen and/or the dvips program
to create a PostScript file for viewing or for printing via the ghostview/GSView
program. GSView can also convert the document to PDF format.
• Alternatively you can run the relatively recent pdflatex program to create a PDF
file for viewing or printing, usually with Adobe’s Acrobat Reader.
The second method is more direct for PDF output, but the first is quicker and more
convenient for previewing.
1.4 The L
A
T
E
X Input File
L
A
T
E
X input files have names that end with the extension .tex: for example, an accept-
able file name might be myfile.tex. (Never use spaces in file names.) The input file
contains both the text of your document and the L
A
T
E
X commands needed to format it.
The first command in the file, \documentclass, defines the style of the document.
1.4.1 Entering L
A
T
E
X Commands
To distinguish them from text, all L
A
T
E
X commands (also called control sequences) start
with a backslash “\”. A command name consists of letters only and is ended by a space
or a non letter (such as a comma, period, brace, etc). If it ends with a space, the space
is “consumed” by L
A
T
E
X and does not appear in the output. An example is \today,
which prints the current date. To avoid having the space after the command disappear,
do the following:
\today\ is a good day. produces: April 16, 2007 is a good day.
There are also commands that consist of the backslash followed by exactly one non-
letter. They are most often used to put a special symbol in the text. For example \$
prints a $ (which cannot be entered directly because L
A
T
E
X uses it to begin math mode).
Spaces after these control symbols are not consumed.
L
A
T
E
X commands are case-sensitive. Most are all lowercase. A few commands use the
first letter in uppercase such as \Delta →∆. Fewer still use all uppercase.
April 2007
1.4 The L
A
T
E
X Input File ♦ 3
Some commands take an “argument,” placed within curly braces ¦ ¦ after the command
name. For example, \textbf{this text is bold} prints the text inside the braces in
boldface type: this text is bold
L
A
T
E
X uses grouping to limit the effect of certain commands. Braces ¦ ... ¦ are used to
begin and end groups. (An environment is also a group; see page 5.) For example, the
\large command is usually used inside a group:
{\large this is bigger than normal} produces: this is bigger than normal
A command such as \large is called a “declaration” because, unless it is given within
a group, its effect will continue until another declaration (in this case \normalsize)
counteracts it. Note the difference between a declaration used inside a group and a
command like \textbf{...}, which will not work unless an argument is provided inside
a pair of braces following the command name.
The symbol % can be used to put a comment in your input file. When L
A
T
E
X sees a %, it
ignores the rest of the line.
When you use commands that specify a length, such as a command to set the size of a
margin or a command to leave a certain amount of space, you will need to specify the
units of measurement. L
A
T
E
X recognizes the following units:
cm centimeter pt printer’s point, ≈ 72 per inch
mm millimeter em font-dependent width of “m”
in inch ex font-dependent height of “x”
1.4.2 Entering Text
In the input file, words are separated by leaving one or more blank spaces. Paragraphs
are separated by leaving one or more blank lines. (You can also use the command \par
to indicate a new paragraph.) L
A
T
E
X ignores multiple blank spaces and multiple blank
lines in input files.
Type single quotation marks by using the left (‘) and right (’) single quote marks on
your keyboard. Type left double quotation marks by using using two single left quotes
(‘‘), and type right double quotation marks by using either two single right quotes (’’)
or the double quote key (").
There are three kinds of dashes in typeset documents: the hyphen (for compound words),
the endash (for such things as page number ranges), and the emdash (used as a punc-
tuation mark in English prose). Since there is only one dash on the keyboard, type -,
--, and --- to get -, –, and — .
To prevent two words from being split at a line break, tie them together with the tilde
character: for example Mr.~Smith will never appear with “Mr.” at the end of one line
and “Smith” at the start of the next.
Note that some characters have special meaning to L
A
T
E
X and must be entered in a
special way, as described in the next section.
Academic and Research Computing, RPI
4 ♦ Chapter 1. L
A
T
E
X Basics
1.4.3 Special Characters
Certain characters have special meaning to L
A
T
E
X. An example is the % sign, which
indicates that the remainder of the line is a comment and should not be processed.
Below is the complete list of special characters. To have these characters print in your
output, you must type them in your input file as shown below.
Character Type in file Special L
A
T
E
X meaning
# ¸# Parameter in a macro; also used in tables
$ ¸$ Used to begin and end math mode
% ¸% Used for comments in the source file
& ¸& Tab mark, used in alignments
¸ Used in math mode for subscripts
ˆ ¸ˆ¦¦ Used in math mode for superscripts
˜ ¸˜¦¦ Tie character, used to produce a “hard” space
¦ ¸¦ Used to begin a group or an argument
¦ ¸¦ Used to end a group or an argument
¸ $¸backslash$ Used to begin a control sequence
< $<$ (or \textless) Otherwise, produces ¡
$$ (or \textgreater) Otherwise, produces ¿
1.4.4 Structure of the Input File
L
A
T
E
X input files must conform to a certain structure. They begin with the command
\documentclass, and all the text of the document must be contained between the
commands \begin{document} and \end{document}.
\documentclass[options]{class}
Preamble
\begin{document}
Document text
\end{document}
In the first command above, class specifies the type of document you intend to create.
You can choose from one of the L
A
T
E
X classes described in the next chapter. If you wish,
you can also include one or more options to modify the behavior of the document class.
The preamble is the section of the file between the \documentclass{...} command and
the \begin{document} command. This is the place to put commands that will influence
the style of your entire document and macro definitions that you will use later. You may
also load packages that add new features to L
A
T
E
X. Text is not allowed in the preamble.
April 2007
1.5 Some L
A
T
E
X Vocabulary ♦ 5
The \begin{document} command indicates the end of the preamble and the beginning
of your text. A corresponding \end{document} command always ends your files. A
really short L
A
T
E
X input file might look like:
\documentclass{article}
\begin{document}
This LaTeX file is short and sweet. It uses the article class,
a good all-purpose layout. There is nothing in the preamble, which
is perfectly acceptable.
This is a new paragraph. \textit{Here’s some italic text}
and \textbf{some bold text}.
{\small The text inside these braces is smaller than normal.}
Now the text size is back to normal.
\end{document}
this produces:
This LaTeX file is short and sweet. It uses the article class, a good all-purpose layout.
There is nothing in the preamble, which is perfectly acceptable.
This is a new paragraph. Here’s some italic text and some bold text. The text inside
these braces is smaller than normal. Now the text size is back to normal.
Longer examples, one using report class and one using letter class are included at the
end of the next chapter.
1.5 Some L
A
T
E
X Vocabulary
Commands produce text or space. For example, \hspace{2in} and \vspace{2in} are
commands that create 2 inches of horizontal and vertical space, respectively, and
\textit{some italic words} puts the contents of its argument in italic type.
Many commands take arguments, either mandatory or optional; some commands,
like \today don’t.
Mandatory arguments supply information required for a command to execute. For
example, \hspace{2in} needs the information provided by the argument to gen-
erate the horizontal space. Mandatory arguments are enclosed in braces: ¦ ¦.
Optional arguments are allowed on some commands and are enclosed in square brack-
ets: [ ]. For example, the size of type to be used for your main text is an optional
argument in the {\documentclass} command. To use the article class in 11-point
type, you would type \documentclass[11pt]{article}. Without this optional
argument, you would get the default 10-point type.
Academic and Research Computing, RPI
6 ♦ Chapter 1. L
A
T
E
X Basics
Declarations produce neither text nor space, but either affect the way L
A
T
E
X prints
the following text or provide information for later use. Font size changes are an
example of declarations. \large will cause any text that follows to appear in a
larger type size. Declarations are often used within a group to limit their scope. For
example: {\large Only the text inside these braces will be large.}
Environments are blocks of text that receive special processing. An environment is
defined by a matching \begin{environment name} ... \end{environment name}.
An environment is also a group, in the same way that a pair of braces delimits a
group. For example, a quotation might be formatted as follows:
\begin{quote}
\small
This text is set off from surrounding text and indented from
both margins. The font size of this quotation will be smaller
because of the "small" command inside the quote environment.
\end{quote}
Note that a blank line before an environment ends the previous paragraph. A blank
line following an environment indicates that the next line starts a new paragraph.
Environments can be nested, i.e., the first started is the last ended.
* Some commands can have a * appended to the name, which indicates a variation on a
command or environment. For example, \\ indicates a line break. \\* indicates a
line break with the restriction that L
A
T
E
X is not allowed to begin a new page at that
point. Space printed by \vspace and \hspace commands is normally dropped if
it appears at the beginning or end of a line or page. If you want the space printed
no matter where it falls, you would use \hspace* or \vspace*. Normally, section
headings are automatically numbered, but \section*{My Heading} will produce
an unnumbered section heading.
April 2007
Chapter 2. Creating A L
A
T
E
X Document
2.1 Document Classes
The document class determines the overall layout of the document. There are five
standard classes distributed with L
A
T
E
X:
article for simple or short documents, including journal articles, and short reports. A
good all-purpose class.
report for small books and longer reports containing chapters.
book for books.
letter for letters, either business or personal.
slides for making transparencies for projection on a screen.
These classes provide preset formats with default margins, paragraph formatting, and
special commands suitable for producing specific sections. For example, the article,
report, and book classes include a variety of commands to format section headings
(\part, \chapter, \section, \subsection, \subsubsection, etc.), as well as com-
mands to produce a title page and a table of contents. There are minor differences
between these three classes. The book class, for example, uses a smaller printed page
size—about 57.5 inches—and is formatted for two-sided printing by default. The
article class is intended for shorter works and does not have chapters (so articles can
be easily included in reports or books). The letter class provides special commands to
produce the salutation, address, and closing.
These four classes are single-spaced by default, and have 10, 11, and 12-point type sizes
available as options. 10 points is the default size.
The slides class uses sans-serif type fonts much larger than the usual ones and expects
the document to be divided up into 1-page sections.
At Rensselaer, there is an additional class called thesis, which may be used to produce
either a master’s or a doctoral thesis with a format that meets the requirements of the
Office of Graduate Education. It was written by Academic and Research Computing
(ARC) using the report class as a base. The file thesis.cls is available for download
from the thesis web page, http://helpdesk.rpi.edu/update.do?artcenterkey=325.
To use the thesis class, begin your document with the line:
¸documentclass¦thesis¦
Instructions are in ARC document, Preparing A Thesis with L
A
T
E
X, available from the
thesis web page.
2.2 Class Options
A document class may be modified by options, which are placed in square brackets after
the \documentclass command. Multiple options are separated by commas:
¸documentclass[option,option,option ]¦class ¦
7
8 ♦ Chapter 2. Creating A L
A
T
E
X Document
The standard class options include:
10pt, 11pt, 12pt Selects the point size of main font for the document. If no option is
specified, 10pt is assumed. This document uses 12-point type.
twocolumn Produces two-column pages.
titlepage Causes the \maketitle command to generate the title page on a separate
page for the article class. This option is not necessary for the book and report
classes, as they print separate title pages by default.
leqno Puts equation numbers on left side. (They are on the right by default.)
fleqn Left-aligns equations. (They are centered by default.)
twoside Formats for printing on both sides of paper. (Whether the document is actually
printed two-sided depends on the printer.) Twoside is the default for the book class,
but not for any of the other classes.
openright If the twoside option is in effect, chapters will begin on right hand pages.
This is the default for the book class. It does not apply to the article class,
which does not contain chapters. (The opposite of openright is openany.)
2.3 Packages
There are a large number of L
A
T
E
X packages available that provide a variety of additional
features. Many packages are considered part of L
A
T
E
X; others are provided by expert
users worldwide. If you sometimes find that the features of standard L
A
T
E
X do not
provide the special formatting you want, chances are good that you can find a package
to meet your needs. A package generally consists of one or more files that contain extra
definitions and macros. Some packages are simple; others are complex and can contain
options. The file names usually have the extension .sty.
You load a package with the \usepackage command, which should come immediately
after the \documentclass command in your input file. The command has the form:
¸usepackage[options ]¦package ¦
Each package may be included with its own \usepackage command, or you may use
one command to load several packages by separating their names with commas. For
example, if you are inserting graphics in your document (see chapter 7.), the package
graphicx provides the commands to do this. The beginning of your input file might
look like:
\documentclass[11pt]{article}
\usepackage{graphicx}
The \usepackage command above instructs L
A
T
E
X to read the file graphicx.sty.
April 2007
2.4 Making a Title Page ♦ 9
In addition to graphicx there are many other packages available, including packages to
rotate text, use PostScript fonts (e.g., Times, Palatino, etc), and customize such things
as headers and footers, citations and captions. Packages come with their own documen-
tation. Many packages are routinely distributed with L
A
T
E
X and will already be on your
system. You’ll find documentation for these packages in the doc subdirectory of your
installation. For example, if you are using the TeXLive 2005 distribution for Windows,
package documentation is in folders under C:\TeXLive2005\texmf-dist\doc\latex\.
To see a current list of all available packages with brief descriptions, look at the Com-
prehensive TeX Archive Network (CTAN) catalog,
http://texcatalogue.sarovar.org/brief.html.
2.4 Making a Title Page
If you are using the article, report, or book class, you may want a title page for your
document. To do this, you need to supply text for the title, author, and date, and then
tell L
A
T
E
X to generate the title page with the command \maketitle. In your L
A
T
E
X
input file, type commands such as the ones below. The \maketitle command, which
actually prints the title page, must follow the \begin{document} command; the other
commands, which just provide the information, can be placed in the preamble if you
prefer.
\title{This is the Title} % provide title info
\author{My Name} % provide author info
\date{the date} % provide date
\maketitle % format and print title page
This is illustrated in the example of using the report class later in this chapter. If there
are several authors, you can separate their names with \and, or you can separate them
with \\ if you would like each name centered on a separate line. If you omit the \date
command, L
A
T
E
X will use the current date. If you want no date at all, use \date{}.
In the report and book classes, the title information appears on its own page. In the
article class, it appears at the top of the first page of text. You can instruct the
article class to make a separate page by using the documentclass option titlepage.
2.5 Making a Table of Contents
The command \tableofcontents, usually placed in the input file right after the
\maketitle command, creates a table of contents using the information in the sec-
tion headings (part, chapter, section, etc.). Since this information is taken from the
previous run, you will need to run L
A
T
E
X twice on a new document for the entries in the
table of contents to show up.
Academic and Research Computing, RPI
10 ♦ Chapter 2. Creating A L
A
T
E
X Document
2.6 Behind the Scenes
2.6.1 Auxiliary Files
Part of the convenience of L
A
T
E
X is its ability to do cross references (see section 4.11)
and to create a table of contents, a list of tables, and a list of figures.
Forward reference numbers, as well as page numbers for sections, figures and tables, are
unknown when L
A
T
E
X is first processing the input file. L
A
T
E
X stores this information
in auxiliary files as it processes the job. A second run allows L
A
T
E
X to extract the
information from its auxiliary files and complete the table of contents, etc. Therefore all
information used by L
A
T
E
X for tables of contents, etc. is from the previous run. The only
way to be sure that all this material is correct is to format the file twice after making
any changes. Usually for drafts, the difference between runs is not enough to matter,
but for final versions you should remember to run L
A
T
E
X twice before printing.
The auxiliary files have the same “root” name as the L
A
T
E
X input file, but different
extensions. For example, all documents need an AUX file. If the input file is named
myfile.tex, the AUX file will be named myfile.aux. Other auxiliary files (see the list
below) are needed only if you are producing a table of contents, etc. Auxiliary files are
created automatically as they are needed.
filename.aux always needed
filename.toc for table of contents
filename.lot for list of tables
filename.lof for list of figures
2.6.2 How a Page is Built
When T
E
X or L
A
T
E
X builds a page, it considers all the parts (words, lines, paragraphs,
etc.) to be different sized boxes. It starts with a simple box, an individual letter, and
then builds words, which are considered to be hboxes (horizontal boxes). The words
are then put together with glue to form a line, which is a larger hbox. A group of
hboxes stacked together vertically (with glue between them) form a vbox (vertical box).
A page is a large vbox made up of several smaller ones. You do not normally need to be
concerned with this, but sometimes (such as when an error message refers to an “overfull
hbox,” meaning a line is too long and sticks out into the margin) it is helpful to know
how T
E
X works.
April 2007
2.7 Example: Report Class ♦ 11
2.7 Example: Report Class
\documentclass[11pt]{report} % Report class in 11 points
\raggedright % Do not right-justify
\parindent0pt \parskip8pt % make block paragraphs
\begin{document} % End of preamble, start of
% document text.
\title{\bf An Example of Report Class} % Supply information
\author{Yours Truly} % for the title page.
\date{\today} % Use current date.
\maketitle % Print title page.
\pagenumbering{roman} % Roman page number for toc
\setcounter{page}{2} % Make it start with "ii"
\tableofcontents % Print table of contents
\chapter{A Main Heading} % Make a "chapter" heading
\pagenumbering{arabic} % Start text with arabic 1
Most of this example applies to the article and book classes
as well as to the report class. In article class, however,
the default position for the title information is at the top
of the first text page rather than on a separate page. Also, article
class does not have a ‘‘chapter" command.
A blank line starts a new paragraph. \textit{Note this: it will be
printed in italic type.}
\section{A Subheading} % Make a "section" heading
The following sectioning commands are available:
\begin{quote} % Start "set off", indented text
part \\ % "\\" forces a new line
chapter \\ % not available in article class
section \\
subsection \\
subsubsection \\
paragraph \\
subparagraph
\end{quote} % End of indented text
The *-form (e.g., ‘‘section*") suppresses the section number and
does not make a TOC entry.
\end{document} % The required last line
Academic and Research Computing, RPI
12 ♦ Chapter 2. Creating A L
A
T
E
X Document
2.8 Example: Letter Class
\documentclass[12pt]{letter} % letter class, 12 points
\address{555 Main St.\\Sometown, NY 12345} % Return address
\signature{My Name\\My Title} % Name for signature
\begin{document} % End of preamble
\begin{letter}{Mr.~Smith\\ President, % Begin letter by giving
Big Name Co.\\Bigburg, MI 45678} % recipient’s address
\opening{Dear Mr.~Smith:} % Name for salutation
This is the letter class. It provides a format for standard parts
of a business letter. As you can see, it uses many commands that
do not exist in the article, report, and book classes.
This is a new paragraph.
\closing{Sincerely,} % Format for the closing.
% The name is taken from
% \signature command above.
\cc{My Boss} % Name(s) of those
% receiving copies
\end{letter} % End of letter
\end{document} % The required last line
April 2007
Chapter 3. Document Layout
Defaults for all aspects of the document layout are set by the document classes. However,
if you want to change the defaults, there are commands that enable you to do so.
Commands controlling features that apply to the whole document should be placed in
the preamble
1
.
3.1 Line Spacing
The default is single spacing. If you want larger interline spacing for your document, you
can use the \linespread command in the preamble. The following command produces
a document with double spacing:
\linespread{1.6}
For “line and a half” spacing, use the value 1.3. The default spread is 1.
An alternative and more flexible way to control the linespacing is to use the package
setspace. With this package, footnotes, figures, and tables remain single-spaced. The
package also defines a new environment called singlespace, which you can use to include
single-spaced sections within your document. To use the setspace package to produce
a double-spaced document, include after the \documentclass command:
\usepackage{setspace}
and, in addition, put the command
\doublespacing
somewhere in the preamble.
You could use \onehalfspacing instead of \doublespacing, or you could use the com-
mand \setstretch{n} (specifying your own value for n—usually between 1 and 2) to
set the spacing to whatever you want.
3.2 Paragraphs
To start a new paragraph, either leave a blank line or use the control sequence \par.
By default, paragraphs are indented by 1.5em, which means 1.5 times the point size
of the current font. (1 em is about the width of an “M”.) No extra blank space
is inserted between paragraphs. The commands \parindent and \parskip control
paragraph indentation and paragraph separation. To get block paragraphs, for example,
include in the preamble the commands:
\parindent=0in
\parskip=8pt % this is variable, choose the number you want
1
the section between the ¸documentclass command and the ¸begin¦document¦ command
13
14 ♦ Chapter 3. Document Layout
3.3 Text Justification
By default, L
A
T
E
X justifies your text horizontally so that both left and right margins are
smooth. If you prefer “ragged right” text, you can use the declaration:
\raggedright
Note that this has the side-effect of wiping out the paragraph indentation. (It assumes
you want everything flush left.) If you want indented paragraphs, you must specifically
request it (i.e., \parindent=1.5em) after the \raggedright declaration.
Vertical justification is controlled by using either \flushbottom or \raggedbottom.
\flushbottom makes all text pages the same height, adding extra vertical space if nec-
essary. \raggedbottom allows the height to vary a bit from page to page. \flushbottom
is the default for the book class and for the twoside option in the article and report
classes; otherwise \raggedbottom is the default.
3.4 Margins
Changing default margins, which depend on the class and the font size, is not as easy
as you might think. The best way to control margins is to use the geometry package.
This package has many options and extensive documentation in manual.pdf found in
your directory ...\doc\latex\geometry\. The following examples should be obvious:
\usepackage[margin=1in]{geometry} % 1 inch margins all around
\usepackage[left=1.2in,right=1in,top=1in,bottom=.8in]{geometry}
If you really want to do it manually, you need to know that internally top and left margins
are set in reference to a value of one inch (which means that setting these margins equal
to 0 produces one-inch margins). Therefore, setting topmargin to -.5in produces a top
margin of .5 inches. The opposite margins (bottom and right) are determined indirectly
by setting the height (textheight) and width (textwidth) of the text area.
to set margin change the command
top margin \topmargin
bottom margin \textheight
left margin (for odd pages or single sided) \oddsidemargin
left margin (for even pages, if using twoside) \evensidemargin
right margin \textwidth
L
A
T
E
X also leaves .5 inch at the top of the page for a header and about .6 inch at the
bottom of the page for a footer. You must take this into account when choosing values
for topmargin and textheight. The values below leave one inch between the paper
edge and the text on all four sides.
\setlength{\topmargin}{-.5in} % top margin is .5 in
\setlength{\oddsidemargin}{0in} % left margin is 1 in on right pages
\setlength{\evensidemargin}{0in} % same for left pages, 2-sided document
\setlength{\textwidth}{6.5in} % leaves 1 in for right margin
\setlength{\textheight}{9in} % 9 inches reserved for the text
April 2007
3.5 Headers, Footers, and Page Numbering ♦ 15
3.5 Headers, Footers, and Page Numbering
The output page consists of the head, the body and the foot. Header and footer material,
such as page numbers and/or section titles, appear in the head or the foot. All the
classes (except letter) print at least the page number by default.
If you don’t like the default action of the document class, you can determine what goes
into the head and foot by using the pagestyle command. This command is often placed
just after a \chapter or a similar command. There are four standard page styles:
\pagestyle{plain}: The page number is in the foot and the head is empty. This is
the default page style for the article and report document classes.
\pagestyle{empty}: The head and foot are both empty.
\pagestyle{headings}: The page number and current section heading (the level of
the heading is determined by the document class) is put in the head; the foot is
empty. This is the default for the book class.
\pagestyle{myheadings}: Similar to the headings page style, except you specify the
information (other than the page number) that goes in the head by using the
markboth and markright commands. markboth is used for two-sided docu-
ments, and markright is used for one-sided:
\markboth{leftheader}{rightheader}
\markright{rightheader}
\thispagestyle{style}: Changes the page style for the current page only. For example,
to have nothing in the head and foot for the current page without affecting the
style for the rest of the pages, use \thispagestyle{empty}.
You can also specify arabic (the default) or roman page numbering either in the preamble
or in the text. It is common to put \pagenumbering{roman} before the text begins and
\pagenumbering{arabic} after the first ¸chapter command. These commands also
set the page number to 1. You can change the page number counter yourself with a
command such as \setcounter{page}{2}.
If the above pagestyle commands don’t do what you want, there is a package called
fancyhdr that allows you to customize your headers and footers in an easy way. With
this package you can define three-part headers and footers (left, right, and center), multi-
line headers and footers, separate headers and footers for even and odd pages, and more.
To use it, include the following commands in the preamble:
\usepackage{fancyhdr}
\pagestyle{fancy}
For simple use, you need only to include the following 6 commands in your preamble, sup-
plying your text inside the {} in each case: \lhead{}, \chead{}, \rhead{}, \lfoot{},
cfoot{}, \rfoot{}. To suppress the horizontal line drawn by default under the header,
use \renewcommand{\headrulewidth}{0pt}. For more information, see fancyhdr.pdf
in your directory ...\doc\latex\fancyhdr\.
Academic and Research Computing, RPI
Chapter 4. Within the Text
Within the text, there will always be certain sections that require special treatment—
such as a different size of type, indentation, or special placement on the page. Some
specialized areas of text (particularly those that require indentation) are formatted with
the help of L
A
T
E
X environments.
4.1 Section Headings
Since documents of any length are usually divided into sections, the classes article,
report, and book have a set of commands which take the name of the section as an
argument. The author uses these commands in the proper order, providing the section
name, and L
A
T
E
X takes care of formatting the headings (boldface, larger typesize, etc.)
and numbering them appropriately. The sectioning commands are:
\part \section \paragraph
\chapter \subsection \subparagraph
\subsubsection
Note that the \chapter command is not available in article class. The \part heading
is rarely used. It divides a very large document into parts, and does not affect the
numbering used for the other headings. In most document classes, headings made with
the lowest level headings, \paragraph and \subparagraph, are not numbered by default.
If you include the command \tableofcontents at the beginning of your document,
L
A
T
E
X takes the section headings and page numbers from the previous run of the docu-
ment and inserts a table of contents at the place the command was issued. (Note that
you need to process the document through L
A
T
E
X twice to ensure an up-to-date table of
contents.)
Normally section headings appear in the table of contents exactly as they do in the text.
However, if a heading is too long to fit nicely into the table of contents, you can provide
a shorter version as an optional argument:
\section[A short heading for the TOC]{This is a much longer
heading that will appear in the text of the document}
You can make less formal headings by using the sectioning commands with a star (*)
appended to the command names listed above. In this case, the section headings will
not show up in the table of contents and will not be numbered. For example, to make a
section heading called “Introduction” that is not numbered and does not appear in the
table of contents, use the command:
\section*{Introduction}
16
4.2 Changing Type Style and Size ♦ 17
4.2 Changing Type Style and Size
Sometimes you may want to change the style or size of text that is not a section heading.
The following L
A
T
E
X commands change the style of the text you supply as an argument:
\textit{...} italic Italic shape, used mostly for emphasis
\textsl{...} slanted Slanted shape, a bit different from italic
\textsc{...} Small Caps Small caps shape, use sparingly
\textup{...} upright Upright shape, usually the default
\textbf{...} boldface Boldface series, often used for headings
\textmd{...} medium Medium series, usually the default
\textrm{...} roman Roman family, usually the default
\textsf{...} sans serif Sans Serif family, used for posters, etc.
\texttt{...} typewriter Typewriter family, fixed-pitch characters
\emph{...} emphasized Use for emphasis, usually changes to italic
These commands can be combined, provided the font thus requested actually exists. For
example, the command \textbf{\textit{This is bold italic}} produces: This is
bold italic.
The following commands cause subsequent output to be printed in a different type size.
The actual size produced by each command depends on the initial point size selected for
the document. The default document size is 10 points. Therefore \normalsize means
10 points for a document in which no size option has been included. This document
is printed in 12 points, so in this case, \normalsize is 12 points. (Note that when
normalsize is 12 points, there is no difference between huge and Huge. They are both
the largest size—25 points.)
¸normalsize normal size ¸large large
¸small small ¸Large larger
¸footnotesize smaller than small ¸LARGE larger still
¸scriptsize smaller still ¸huge huge
¸tiny tiny ¸Huge hugest
The size-changing commands are declarations, and therefore they are usually used within
a group (i.e., braces) to delimit the range of their action. For example:
{\small This type will be small} produces This type will be small.
To change both type size and style at the same time, commands can be used together.
For example, the command \textbf{\large This will be big and bold} produces:
This will be big and bold.
Academic and Research Computing, RPI
18 ♦ Chapter 4. Within the Text
4.3 Starting New Lines and New Pages
Normally L
A
T
E
X decides where to start a new line and a new page, always trying to pick
the most aesthetically pleasing break points. But sometimes you want to force the start
of a new line or page. The command \\ will force a new line. For example,
This will be on one line\\ this will be on the next line
If you want extra space between two lines, do not use two \\ commands in a row.
Instead use an optional parameter (given inside square brackets) to specify the amount
of blank space. For example, the following command will leave an extra space of 10
points between the lines:
This will be on one line\\[10pt] this will be on the next line
To force a new page, the simplest command is \newpage, which starts a new page
immediately. There is also the command \clearpage, which acts like \newpage except
that it also forces any leftover figures or tables to print before starting the new page.
With the twoside documentclass option, the command \cleardoublepage produces a
blank page, if necessary, to ensure that the new page starts on a new sheet of paper.
4.4 Leaving Horizontal and Vertical Space
The commands \hspace and \vspace leave horizontal and vertical space in your text.
Both commands take a mandatory parameter—the amount of blank space you want to
leave. For example, \vspace{3in} will leave 3 inches of blank space in your text. If
vertical space is requested in the middle of a paragraph, the space will appear after the
current line has ended.
Space requested by the \hspace and \vspace commands disappears if it falls at the
beginning or end of a line or page. To create space that remains no matter where it
falls, use the variations \hspace* and \vspace*. For example, the following lines:
This text starts at the left margin\\
\hspace*{1in}This text starts a new line after a one-inch space
produces:
This text starts at the left margin
This text starts a new line after a one-inch space
4.5 Drawing Rules
To draw a line (horizontal or vertical) on the page, use the \rule command:
\rule[lift]{width}{height}
width is the horizontal dimension, height is the vertical dimension, and the optional
parameter lift is the amount raised above the baseline. For example, the line below was
drawn with the command \rule{\textwidth}{1pt}.
April 2007
4.6 Footnotes ♦ 19
4.6 Footnotes
Footnotes are numbered automatically by L
A
T
E
X. The command \footnote{footnote
text¦ should be placed exactly where you want the footnote number to appear, with no
extra space between the ¸footnote command and the text before it. For example:
This is text with a note.\footnote{This is the note text.
Here it is at the bottom of the page.}
produces:
This is text with a note.
2
4.7 Centering
If you have only one line to center, it’s easiest to use the plain T
E
X command
\centerline; for example,
\centerline{This line will be centered}.
If you have several lines to be centered horizontally, the center environment is conve-
nient. The example below produces three lines, each horizontally centered.
\begin{center}
This is line one. \\
This is line two. \\
This is line three.
\end{center}
There is also the declaration \centering, which is always used within a group—either a
pair of braces or an environment. This is useful when you don’t want the extra vertical
space surrounding the center environment.
4.8 Quotations
The quote environment begins a new line and indents text from both sides. It
is delimited with \begin{quote} and \end{quote}. Any special effects (such
as changes to the type size or style) started within the quote environment
are terminated by \end{quote}.
New paragraphs are block style: that is, no indent and a blank line as sepa-
ration. This section is inside a quote environment.
There is also a very similar environment called quotation. The only difference is that
paragraphs in the quotation environment are indented with no blank line between.
2
This is the note text. Here it is at the bottom of the page.
Academic and Research Computing, RPI
20 ♦ Chapter 4. Within the Text
4.9 Reproducing Text As-Is
To reproduce new lines and spaces exactly as they are in your input file, you have a
choice of several methods.
The verbatim environment prints its text in typewriter-style type and sets it off from
the rest of the document with blank lines before and after. (It does not indent.) To use
it, surround the text with the commands \begin{verbatim} and \end{verbatim}. The
only L
A
T
E
X command obeyed inside this environment is \end{verbatim}. For example,
the following input
¸begin¦verbatim¦
All spacing is displayed in verbatim as entered.
So are special characters ! @ # & * ( ) _ } ] \ | > <
verbatim is used to display LaTeX commands in this document.
¸end¦verbatim¦
produces:
All spacing is displayed in verbatim as entered.
So are special characters ! @ # & * ( ) _ } ] \ | > <
verbatim is used to display LaTeX commands in this document.
A variation on the verbatim environment, called the alltt environment, is provided
by a package. It is used in the same way as the verbatim environment and works
the same, in that spaces and lines are retained from the input file. The difference is
that L
A
T
E
X commands are recognized inside this environment. It cannot be used to
reproduce L
A
T
E
X commands, but it is very useful if you want to print in roman or italic
type instead of typewriter. Before you can use this environment, you must include the
command \usepackage{alltt} following the \documentclass command.
If the text is short enough to be contained on one input line and should not be set off,
you can use the \verb command. For example,
\verb+This is inside the \verb command+
produces:
This is inside the \verb command
Note that the “+” is used here to delimit the verbatim text. Any character except the
“*” can be used as the delimiter.
April 2007
4.10 Lists ♦ 21
4.10 Lists
The three L
A
T
E
X list environments all use the \item command to start new items in the
list. The enumerate environment numbers items sequentially, the itemize environment
puts a bullet in front of each item, and the description environment puts a boldface
word or phrase in front of each item.
The following examples show both the output and the input used to create them.
Example of Enumerate
\begin{enumerate}
\item Sugar
\item Cream
\item Chocolate
\end{enumerate}
1. Sugar
2. Cream
3. Chocolate
Example of Itemize
\begin{itemize}
\item Mix all ingredients together.
\item Boil until the thermometer
reaches 112 $^\circ$C.
\item Stir and cool.
\end{itemize}
• Mix all ingredients together.
• Boil until the thermometer
reaches 112

C.
• Stir and cool.
Example of Description
\begin{description}
\item[dog] A loving animal that
likes to sleep on the furniture.
\item[cat] Aloof creature that can
warm your feet on a winter’s night
\item[horse] Large animal, gives
great rides. Eats a lot, luckily
doesn’t sleep on the furniture.
\end{description}
dog A loving animal that likes to
sleep on the furniture.
cat Aloof creature that can warm
your feet on a winter’s night
horse Large animal, gives great rides.
Eats a lot, luckily doesn’t sleep
on the furniture.
Below is an example of nesting list environments:
Here are some useful environments:
\begin{itemize}
\item center environment
\item quote environment
\item the three list environments:
\begin{enumerate}
\item enumerate (uses numbers)
\item itemize (uses bullets)
\item description (uses words)
\end{enumerate}
\end{itemize}
Here are some useful environments:
• center environment
• quote environment
• the three list environments:
1. enumerate (uses numbers)
2. itemize (uses bullets)
3. description (uses words)
Academic and Research Computing, RPI
22 ♦ Chapter 4. Within the Text
4.11 Cross References
In longer documents, there are often cross references to sections, figures, tables, or
equations. L
A
T
E
X provides the following commands for cross referencing:
\label¦marker¦ set a marker for future reference
\ref¦marker¦ include the number of the section, figure, etc. of the cor-
responding \label command
\pageref¦marker¦ include the page number of the corresponding \label com-
mand
marker is an identifier that you choose—it may contain letters, numbers, or other
characters (except for L
A
T
E
X’s special list of characters). It can be helpful, but not
necessary, to start the marker name with a tag that identifies what is being marked:
for example, sec: for sections, eqn: for equations, fig: for figures, etc. (See the
example below.) The \label command should be placed immediately after a sectioning
command, within an equation environment, or inside a figure or table environment
immediately following the caption command.
\label{sec:xrefs}
For information on cross references,
see section~\ref{sec:xrefs} on
page~\pageref{sec:xrefs}.
For information on cross references, see
section 4.11 on page 22.
Note that L
A
T
E
X uses the numbers from the .aux file produced by the previous run, so
it will take two runs (sometimes more) to get the cross references correct.
April 2007
Chapter 5. Tabular Material
There are two environments in L
A
T
E
X for formatting tabular material: the tabbing
environment, which uses \begin{tabbing}. . . \end{tabbing}, and the tabular envi-
ronment, which uses \begin{tabular}. . . \end{tabular}.
The tabbing environment works in a manner similar to a typewriter—you set the tabs
and then move from one to another. Tab stops may be reset on any line. Page breaks
within the tabbed material are allowed since each line is processed individually.
The tabular environment allows you to construct a much fancier looking table: for
example, you can specify the alignment of each column and use horizontal and vertical
lines. However, these tables cannot be broken across pages because L
A
T
E
X reads in the
entire table at once to establish correct column widths. Often material inside a tabular
environment is placed inside the table environment, which ensures that if it can’t fit at
the current location it will be “floated” to an appropriate location. For information on
using the table environment, see Chapter 8..
5.1 Tabbing
Tabbing uses the following commands:
\= Set a tab stop
\> Move right to the next tab stop
\\ Terminate a line
Tabs are usually set in the first line but may also be added in later lines. A special line
ending with the command \kill may be used to set tabs but not print the line. Below
are two examples of tabbing. Note that the last entry does not require a \\ to end the
line.
Example 1: A Very Simple Case
\begin{tabbing}
Column 1 \= Column 2 \= Column 3 \= Column4 \\
Col 1 \> Col 2 \> Col 3 \> Col 4 \\
one \> two \> three \> four
\end{tabbing}
Produces:
Column 1 Column 2 Column 3 Column 4
Col 1 Col 2 Col 3 Col 4
one two three four
23
24 ♦ Chapter 5. Tabular Material
Example 2: A Little More Complex
\begin{tabbing}
\hspace{2in} \= \hspace{2in} \= \kill
First column \> Second column \> Third column \\
\> Second \> Third \\
\hspace{1in} \\ % make a blank line
This Text extends past tab 1 \>\> Third column \\
\> Text spans columns two and three \\
xxxxxxxx \= xxxxxxxx \= xxxxxxxx \= \kill % set up new tab stops
Col 1 \> Col 2 \> Col 3 \> Col 4
\end{tabbing}
Produces:
First column Second column Third column
Second Third
This Text extends past tab 1 Third column
Text spans columns two and three
Col 1 Col 2 Col 3 Col 4
5.2 Tabular
The tabular environment requires an additional argument that specifies the alignment
of each column (centered, left justified, etc.):
\begin{tabular}{align}
You may substitute any combination of the following symbols for the align argument:
l Left-justified column entry
c Centered column entry
r Right-justified column entry
p Paragraph column entry
| Vertical rule column
|| Double vertical rule column
The width necessary for each column is determined automatically from the widest entry.
Inside the tabular environment, use the tab character (&) to move to the next column,
\\ to end each line (except the last one), and \hline to insert a horizontal line.
The following examples illustrate the tabular environment. Note that you can center
a table by enclosing the tabular environment inside a center environment.
April 2007
5.2 Tabular ♦ 25
5.2.1 A Simple Ruled Table
\begin{center}
\begin{tabular}{|l|c|r|} % 3 cols (left, ctr, right); vert. lines
\hline % draw horizontal line
Name & Oblateness & Diameter \\
\hline
Mercury & 0 & 3,100 \\
Venus & 0 & 7,700 \\
Earth & 1/297 & 7,927 \\
Mars & 1/192 & 4,200 \\
Jupiter & 1/15 & 88,700 \\
Saturn & 1/9.5 & 75,100 \\
Uranus & 1/14 & 32,100 \\
Neptune & 1/40 & 27,700 \\
Pluto & ? & 3,600\\
\hline
\end{tabular}
\end{center}
Produces:
Name Oblateness Diameter
Mercury 0 3,100
Venus 0 7,700
Earth 1/297 7,927
Mars 1/192 4,200
Jupiter 1/15 88,700
Saturn 1/9.5 75,100
Uranus 1/14 32,100
Neptune 1/40 27,700
Pluto ? 3,600
Academic and Research Computing, RPI
26 ♦ Chapter 5. Tabular Material
5.2.2 Using Paragraph Columns, Spanning Columns
The following example illustrates making paragraphs within a table and placing text
across multiple columns using the \multicolumn command. This command has the
form:
\multicolumn{n}{pos}{item}
where n is the number of columns to be spanned, pos specifies the alignment of the item,
and item is the text.
This example is inside the table environment, which ensures that the table will be
“floated” rather than broken across a page (see chapter 8. on page 37) and also provides
the opportunity to supply a caption. In this example, the optional parameter [hb]
specifies that the table should appear “here” or at the bottom of the page.
To center tabular material inside the table environment, you can use the declaration
\centering, which has the same effect as the center environment. (The centering
action will be confined to inside the table environment.)
\begin{table}[hb] % place table ‘‘here’’ or at bottom of page
\centering
\caption{More Things You can Do With Tabular}
\bigskip
\begin{tabular}{|l|l|p{2.5in}|}
\hline
\multicolumn{2}{|c|}{Text in columns 1 and 2}
& A paragraph 2.5 inches wide \\
\hline
Column 1 & Column 2 & This text is a paragraph. It will wrap
around to the next line if necessary. \\
Column 1 & Column 2 & The paragraph column \\
\hline
\end{tabular}
\end{table}
Table 1: More Things You can Do With Tabular
Text in columns 1 and 2 A paragraph 2.5 inches wide
Column 1 Column 2 This text is a paragraph. It will
wrap around to the next line if nec-
essary.
Column 1 Column 2 The paragraph column
April 2007
5.2 Tabular ♦ 27
5.2.3 Aligning on the Decimal Point
Although L
A
T
E
X does not provide a way to align numeric columns on a decimal point,
it is possible to accomplish this by using two columns (the first right-aligned and the
second left-aligned) and changing the column separator to be a decimal point.
3
L
A
T
E
X allows you to change the column separator with the command @{...}, which
replaces the usual intercolumn space with whatever you put inside the curly braces.
Therefore, if you use @{.} in the \begin{tabular} line, a “.” will be placed between
columns. When you enter the data, you must replace the decimal point in your numbers
with a column separator (&). The example below illustrates how to do this.
\begin{tabular}{c r @{.} l}
Pi expression &
\multicolumn{2}{c}{Value} \\
\hline
$\pi$ & 3&1416 \\
$\pi^{\pi}$ & 36&46 \\
$(\pi^{\pi})^{\pi}$ & 80662&7 \\
\end{tabular}
Pi expression Value
π 3.1416
π
π
36.46

π
)
π
80662.7
5.2.4 Suppressing Leading or Trailing Space
Another creative use of the @{...} command is to suppress leading or trailing space in
a table. In this case the command would be @{}, indicating no space should be inserted:
\begin{tabular}{@{} l @{}}
\hline
no leading or trailing space\\
\hline
\end{tabular}
no leading or trailing space
\begin{tabular}{l}
\hline
leading space left and right\\
\hline
\end{tabular}
leading space left and right
3
For an another method, see the dcolumn package, provided as part of the L
A
T
E
X “tools” bundle.
Academic and Research Computing, RPI
Chapter 6. Mathematics
One of the greatest strengths of L
A
T
E
X is its ability to typeset formulas and equations. To
make it easier to enter mathematical text, L
A
T
E
X has defined several hundred Greek sym-
bols, mathematical symbols, delimiters, and operators. These are listed in Appendix A
of this memo.
L
A
T
E
X has several modes for setting math text, which are described below. When in
math mode, L
A
T
E
X sets type differently than when in text mode. For example, all letters
are set in the math italic typeface, and spaces in the input are ignored because L
A
T
E
X
uses its own “mathematically correct” spacing. Therefore, if you want to use normal
text or retain spaces while in math mode, you must enclose this text with an “mbox”:
\mbox{this is normal text}. Also, new paragraphs are not allowed within math
mode, so be sure not to leave any blank lines.
If your mathematical expressions are particularly complex or sophisticated, you may
want to look at AMS-L
A
T
E
X, a collection of packages that provides extensions to
L
A
T
E
X’s mathematical capabilities. The amssymb package provides additional math-
ematical symbols; the amsmath package provides additional environments for build-
ing mathematical expressions. For help with using AMSL
A
T
E
X, see The Short Math
Guide for L
A
T
E
X, at: ftp://ftp.ams.org/pub/tex/doc/amsmath/short-math-guide.pdf.
The official documentation is amsldoc.pdf, which you can find on your system in
...\doc\latex\amslatex\.
6.1 In-line Math
L
A
T
E
X’s in-line math environment allows you to place mathematical formulas in the midst
of ordinary text. Typically such mathematical formulas are roughly the same size as the
text they’re embedded in. This environment can be invoked in one of three ways:
$ . . . $ (Used in plain T
E
X)
\( . . . \)
\begin{math} . . . \end{math}
The following paragraph is typical of the use of in-line math:
The quadratic equation $ax^2+bx+c = 0$ has two roots whose nature
depends on the sign of the discriminant $d = \sqrt{b^2 - 4ac}$.
If $d>0$, then there are two distinct real roots; if $d=0$,
then there are two real and equal roots; and if $d<0$,
then the two roots are conjugate complex numbers.
produces:
The quadratic equation cr
2
+ /r + c = 0 has two roots whose nature depends on the
sign of the discriminant d =

/
2
−4cc. If d 0, then there are two distinct real roots;
if d = 0, then there are two real and equal roots; and if d < 0, then the two roots are
conjugate complex numbers.
28
6.2 Display Math (for unnumbered equations) ♦ 29
6.2 Display Math (for unnumbered equations)
The displaymath environment puts space before and after equations and centers
them by default. For left-justified equations, include fleqn as an option in the
documentclass command: for example, \documentclass[fleqn]{article}. Like in-
line math, displaymath can be invoked in one of three ways:
$$ . . . $$ (Used in plain T
E
X)
\[ . . . \]
\begin{displaymath} . . . \end{displaymath}
The next paragraph illustrates the solution to the quadratic equation:
The quadratic equation $ax^2 + bx + c = 0$ has two roots
\[ x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} \]
where the nature of the roots is determined by the sign
of the discriminent $b^2 - 4ac$.
produces:
The quadratic equation cr
2
+ /r + c = 0 has two roots
r =
−/ ±

/
2
−4cc
2c
where the nature of the roots is determined by the sign of the discriminent /
2
−4cc.
6.3 Equation Environment (for numbered equations)
The equation environment is exactly like the displaymath environment except that an
equation number in parentheses is placed to the right of the displayed formula. (For
left-side numbering, include leqno as an option to the \documentclass command.)
The environment is invoked with \begin{equation}. . . \end{equation} as illustrated
below:
The derivative of the function $f(x)$ at the point $x_0$ is
\begin{equation}
f’(x_0) =
\lim_{x \rightarrow x_0}
\frac{f(x) - f(x_0)}{x - x_0}
\end{equation}
produces:
The derivative of the function )(r) at the point r
0
is
)

(r
0
) = lim
x→x
0
)(r) −)(r
0
)
r −r
0
(1)
Academic and Research Computing, RPI
30 ♦ Chapter 6. Mathematics
6.4 Eqnarray Environment (for multiline equations)
The eqnarray environment builds a three-column array of numbered equations, with
the first column right-justified, the second centered, and the third left-justified. It is
used mainly for displaying multi-line formulas. It numbers each line by default, but you
can include the command \nonumber on any line to suppress the equation number. (Or
you can use the alternative environment eqnarray*, which does not number any lines.)
The following example illustrates this environment. Note that you can use the \label
and \ref commands to refer to equation numbers in the text.
These three products can be expanded and simplified to
produce these equations:
\begin{eqnarray}
(a + b)(a + b) & = & a^2 + ab + ba + b^2 \nonumber \\
& = & a^2 + 2ab + b^2 \label{eq:simp1} \\
(a + b)(a - b) & = & a^2 - ab + ba - b^2 \nonumber \\
& = & a^2 - b^2 \label{eq:simp2} \\
(a + b)^3 & = & a^3 + 3a^2b + 3ab^2 + b^3 \label{eq:simp3}
\end{eqnarray}
The results after simplification are shown in equations
\ref{eq:simp1}, \ref{eq:simp2}, and \ref{eq:simp3}.
produces:
These three products can be expanded and simplified to produce these equations:
(c + /)(c + /) = c
2
+ c/ + /c + /
2
= c
2
+ 2c/ + /
2
(1)
(c + /)(c −/) = c
2
−c/ + /c −/
2
= c
2
−/
2
(2)
(c + /)
3
= c
3
+ 3c
2
/ + 3c/
2
+ /
3
(3)
The results after simplification are shown in equations 1, 2, and 3.
The amsmath package provides additional environments for formatting multiline equa-
tions (e.g., split, align, gather, etc) and is highly recommended.
April 2007
6.5 Array Environment (for matrices, etc.) ♦ 31
6.5 Array Environment (for matrices, etc.)
The array environment is not itself a math environment; it must be enclosed within a
math environment of your choosing. It is used for building rectangular arrays of numbers,
matrices, etc. array is the math equivalent of tabular and uses the same syntax.
Here is an example of the array environment used to build a 5 5 magic square:
\[
\begin{array}{ccccc}
17& 24& 1& 8& 15\\
23& 5& 7& 14& 16\\
4& 6& 13& 20& 22\\
10& 12& 19& 21& 3\\
11& 18& 25& 2& 9
\end{array}
\]
produces:
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
Here is an example for a general matrix:
\begin{equation}
A = \left(
\begin{array}{cccc}
a_{1,1} & a_{1,2} & \ldots & a_{1,n} \\
a_{2,1} & a_{2,2} & \ldots & a_{2,n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m,1} & a_{m,2} & \ldots & a_{m,n}
\end{array}
\right)
\end{equation}
produces:
¹ =
_
_
_
_
_
_
c
1,1
c
1,2
. . . c
1,n
c
2,1
c
2,2
. . . c
2,n
.
.
.
.
.
.
.
.
.
.
.
.
c
m,1
c
m,2
. . . c
m,n
_
_
_
_
_
_
(4)
Section 6.6.6 (Large Delimiters) on page 34 has more examples of arrays.
Academic and Research Computing, RPI
32 ♦ Chapter 6. Mathematics
6.6 Building Mathematical Expressions
6.6.1 Superscripts and Subscripts
In math mode, the symbols ‘ˆ’ and ‘ ’ are used to make superscripts and subscripts. If
more than one character is to be used as a superscript or subscript, enclose the characters
in braces. For example:
\[ 2^{2^2} = 2^4 = 4^2 \]
\[ a^2_{i_1} = b^2_{i,j} \]
\[ _2F^1_3 \]
\[ {}_2^1P{}^3_4 \]
produces:
2
2
2
= 2
4
= 4
2
c
2
i
1
= /
2
i,j
2
1
1
3
1
2
1
3
4
6.6.2 Spaces in Math Mode
In math mode, L
A
T
E
X ignores blanks typed in the input. However, the following symbols
allow you to add (or subtract) small amounts of space in your equations:
\; thick space \: medium space \, thin space \! negative space
In addition, you can make a larger space (about the width of an “M”) with the command
\quad. The command \qquad provides twice as much space.
6.6.3 Dots, Braces, and Bars
The commands \ldots, \cdots, \vdots, and \ddots are used to produce a string
of three dots on the base line, on the math centerline, vertically, or on the diagonal,
respectively. The commands \overline, \underline, \overbrace, and \underbrace
are used to build horizontal groups. For example:
\begin{eqnarray*}
2^n & = &\overbrace{2\times2\times\cdots\times 2}^{\mbox{n terms}}\\
k\cdot x & = &\underbrace{x + x + \cdots + x}_{\mbox{k terms}}
\end{eqnarray*}
produces:
2
n
=
n terms
¸ .. ¸
2 2 2
/ r = r + r + + r
. ¸¸ .
k terms
April 2007
6.6 Building Mathematical Expressions ♦ 33
6.6.4 Fractions
The ‘/’ can be used to make simple fractions, but the \frac commmand is used for most
fractions; its two arguments are the numerator and denominator. Two variations of a
fraction are provided by the plain T
E
X commands \atop and \choose.
$$ \frac{a}{b} \qquad \frac{a/b}{c/d}
\qquad {a\atop b} \qquad {a\choose b} $$
$$ 1 + 2 + 3 + \cdots + n = \frac{n(n+1)}{2} $$
$$ \lim_{n\rightarrow\infty}\frac{1}{n}=0
\qquad y’’=\frac{d^2y}{dx^2} $$
produces:
c
/
c,/
c,d
c
/
_
c
/
_
1 + 2 + 3 + + : =
:(: + 1)
2
lim
n→∞
1
:
= 0 µ

=
d
2
µ
dr
2
6.6.5 Radicals, Integrals, and Summations
The \sqrt command creates a square root sign for its mandatory argument. An optional
argument for the radicand allows you to construct cube roots, nth roots, etc. The sign
automatically grows to fit the argument, as these examples show:
$$ \sqrt{2}=1.4142 \qquad c=\sqrt{a^2+b^2}
\qquad \sqrt[3]{8}=2 \qquad \sqrt{\frac{n(n+1)}{2}} $$
produces:

2 = 1.4142 c =

c
2
+ /
2
3

8 = 2
¸
:(: + 1)
2
Integral signs are produced with the \int command, and summation signs are produced
with the \sum command. These symbols are often used with superscripts and subscripts:
$$\sum^{\infty}_{n=1} \qquad \int^b_a e^{x^2}\,dx $$
$$\sqrt{\sum_{i=1}^{n}i} \qquad \sum_{\stackrel{i=1}{j=2}}^{\infty}$$
$$\sum \Delta V=\int\!\!\!\int\!\!\!\int_V dv $$
produces:

n=1
_
b
a
c
x
2
dr
¸
¸
¸
_
n

i=1
i

i=1
j=2

∆\ =
___
V

Academic and Research Computing, RPI
34 ♦ Chapter 6. Mathematics
6.6.6 Large Delimiters
The commands \left and \right are used to put large delimiters (such as ( ) [ ]) in
displayed formulas. (For braces, use \{ and \}). See Appendix A for a complete list
of delimiters. There must be a \right for every \left and vice versa for each output
line, although the left and right delimiters need not be the same type. You can even
use a period to create an invisible delimiter—very useful if you need an odd number of
delimiters. Large delimiters are often used with the array environment. Below are two
examples of large delimiters. (For another example, see Section 6.5 on page 31.)
\[
\mbox{det} = \left|
\begin{array}{lllll}
c_0 & c_1 & c_2 & \ldots & c_n \\
c_1 & c_2 & c_3 & \ldots & c_{n+1} \\
c_2 & c_3 & c_4 & \ldots & c_{n+2} \\
\vdots & \vdots & \vdots && \vdots \\
c_n & c_{n+1} & c_{n+2} & \ldots & c_{2n}
\end{array}
\right| > 0.
\]
produces:
det =
¸
¸
¸
¸
¸
¸
¸
¸
¸
¸
¸
¸
¸
c
0
c
1
c
2
. . . c
n
c
1
c
2
c
3
. . . c
n+1
c
2
c
3
c
4
. . . c
n+2
.
.
.
.
.
.
.
.
.
.
.
.
c
n
c
n+1
c
n+2
. . . c
2n
¸
¸
¸
¸
¸
¸
¸
¸
¸
¸
¸
¸
¸
0.
\[
\mbox{signum}(x)=\left\{
\begin{array}{rl}
1 & \mbox{if $x>0$} \\
0 & \mbox{if $x=0$} \\
-1 & \mbox{otherwise}
\end{array} \right.
\]
produces:
signum(r) =
_
¸
_
¸
_
1 if r 0
0 if r = 0
−1 otherwise
April 2007
Chapter 7. Including Graphics
7.1 Creating the Graphics File
The easiest way to put graphics into your L
A
T
E
X document is to first create the graphic
using a software package, such as Maple, Matlab, CorelDRAW, Xfig, Gnuplot, etc. You
can also use a Windows application such as Word or Excel to create an eps (Encapsulated
PostScript) file by printing to a file following certain steps, described in
http://www.rpi.edu/dept/arc/training/latex/Examples/graphics.pdf .
If you are using L
A
T
E
X plus dvips to produce your final output, you should save the
graphic as encapsulated PostScript (eps), the only acceptable format. If you are using
pdfL
A
T
E
X (which produces a pdf file directly), acceptable formats are pdf, jpeg, or png,
but not eps. A general rule of thumb for graphics formats is to use pdf or eps for vector
graphics (line art, graphs, etc), jpeg for photographs, and png for screen shots.
If you are using pdfL
A
T
E
X and your graphics files are in eps format, you can convert
them to pdf using the epstopdf utility, which is most likely on your system. Run this
program from the command line (in Windows, open a command window and cd to the
appropriate folder):
epstopdf myfigure.eps generates myfigure.pdf
After doing this, you will have two files for your graphic, one eps and one pdf.
If you are using L
A
T
E
X plus dvips, the jpeg2ps utility is handy. It converts JPEG images
to eps files without uncompressing the images. The JPEG data is simply “wrapped”
with PostScript, yielding considerably smaller PostScript files. Use it from the command
line:
jpeg2ps -h image.jpg > image.eps
You may already have jpeg2ps on your system; if not, you can download it from:
http://www.ctan.org/tex-archive/support/jpeg2ps/.
7.2 Importing the Graphic into your L
A
T
E
X Document
LaTeX’s standard graphics bundle includes two packages for importing graphics:
graphics and graphicx. The extended package, graphicx, provides a more conve-
nient method of supplying parameters and is recommended. Therefore first step is to
put in your preamble the command:
\usepackage{graphicx}
This package defines a new command called \includegraphics, which allows you to
specify the name of the graphic file as well as supply optional arguments for scaling or ro-
tating. So, at the spot you want to insert the graphic (named for example, myfigure.eps
or myfigure.pdf) use the \includegraphics command, for example:
35
36 ♦ Chapter 7. Including Graphics
\includegraphics[width=4in]¦myfigure¦ note filename extension is omitted
If you want to be able to process your file using either latex or pdflatex, you’ll need
to have your graphics files in both eps format and one of the others, such as pdf. Then
omit the filename extension on the \includegraphics command: latex will look for
an eps file, and pdflatex will look for a pdf, jpg, or png file.
The \includegraphics command also provides optional arguments for scaling or ro-
tating the figure. Inside the [...], you can specify a number of optional arguments,
separated by commas. In the example above, width=4in will scale the width of graphic
to four inches. Since no height is specified, the height will be scaled so that the figure
remains in proportion. The most commonly used arguments are:
width scale graphic to the specified width (aspect ratio preserved)
height scale graphic to the specified height (aspect ratio preserved)
scale scale graphic by scale factor. (scale=2 makes the graphic twice as large
as its natural size; scale=.5 makes it half as large.)
angle rotate graphic by specified number of degrees. A positive number in-
dicates the counter-clockwise direction. (angle=90 rotates 90 degrees
counter-clockwise.)
Note that in the following example, the graphic is first rotated counter-clockwise by 90
degrees and then scaled to a width that will just fit within the margins:
\includegraphics[angle=90,width=\textwidth]{myfigure}
Usually the includegraphics command is put inside the figure environment, which
allows the image to move or “float” to another location so that it is never split between
pages. The figure environment is described in chapter 8..
7.3 Viewing the Output
If your graphics files are in pdf, jpeg or png formats, you can run pdfL
A
T
E
X and view
the result with Acrobat or GSView. If your files are eps, it is important to note that
after running L
A
T
E
X, the resulting .dvi file does not actually contain the eps graphics;
it only contains commands that the printer driver, dvips, subsequently uses to include
the graphics when making the PostScript file. Most dvi previewers try to display eps
files (ususually by calling on ghostscript), but rotated material may not display properly
in the dvi preview. To see a correct display, run dvips to make a PostScript file and
then use GSView/ghostview to view it.
Complete documentation for the graphics bundle is in the file grfguide.pdf; look for it
on your system. Information on the graphicx package is in section 4.4. For an extensive
treatment of including graphics, see Using Imported Graphics in L
A
T
E
X and pdfL
A
T
E
X by
Keith Reckdahl of Stanford University. It includes all you would ever want to know with
many examples: http://www.ctan.org/tex-archive/info/epslatex.pdf.
April 2007
Chapter 8. Placing Figures & Tables (Floats)
If you have figures or tables in your document, you’ll want to make sure that they are
not broken across pages. To accomplish this, L
A
T
E
X provides two environments, figure
and table, which move or “float” the material inside the environment to a location
where it all fits. Meanwhile, L
A
T
E
X fills the current page with text to avoid half empty
pages. The commands to use these two environments look like:
\begin{figure} \begin{table}
... figure material ... ... tabular material ...
\end{figure} \end{table}
There are also “starred” versions of these environments (table* and figure*), which,
in 2-column text, place floats across both columns.
Note that these environments have nothing to do with actually preparing your figures
or tabular material (discussed in chapters 5. and 7.); they only ensure that whatever
material is inside the environment gets “floated” and is not broken between pages.
To place the floated material, L
A
T
E
X first tries to put the figure or table at the top of
the current page. If it doesn’t fit there, it next tries the bottom of the current page,
then the top of the next page. Failing that, it will try to place the figure or table on
a page containing only floated material (no text). Usually, the default behavior places
the floats satisfactorily. However, if you wish, you can supply an optional parameter to
specify a list of preferred locations; for example, if you begin a table:
\begin{table}[htp]
L
A
T
E
X will first try to place the table “here”—that is, at the spot you gave the
\begin{table} command, then the top of the next page, and finally on a page con-
taining only floats (which often means on a page by itself). The possible positioning
parameters are:
h here: at the place in the text where the environment occurs.
t top: at the top of a text page.
b bottom: at the bottom of a text page.
p page: on a special page containing only floats.
8.1 Making a Caption
The floated material usually includes a numbered caption. Within the figure or table
environment, you can supply a caption with the command \caption{caption text}.
Usually the caption for a table is typed above the table and the caption for a figure
below the figure. The table environment prefixes the caption text with “Table n:”
(where n is the number of the table supplied by L
A
T
E
X); the figure environment prefixes
the text with “Figure n:”. In fact, the caption prefix is the only difference between the
figure and table environments. The \caption command also supplies information for
a List of Figures and/or a List of Tables. To print out such a list at the beginning of
37
38 ♦ Chapter 8. Placing Figures & Tables (Floats)
your document, simply place the command \listoftables or \listoffigures after
the \tableofcontents command.
If your caption is very long and you do not want the whole thing repeated in the list
of figures or tables, you can use an optional parameter (specified in square brackets) to
supply a shorter version for the List. For example, a table caption might look like:
\caption[A short caption for the list of tables]{This is a very
long caption for this table, requiring lots of explanation.
It could go on for several lines.}
You can also use the \label command (see section 4.11 on cross referencing) so that
you can refer to your figure or table elsewhere in the document. Note that the \label
command must immediately follow the caption command. If it precedes the caption,
the number used in the reference will be incorrect.
8.2 Examples
Note that you can put anything inside the figure environment: it can be text, a diagram,
an image (see chapter 7.) or any other kind of illustration. Likewise, a table environment
can contain any L
A
T
E
X commands or text, but usually contains tabular material inside
the tabular environment (see section 5.2).
The example below encloses tabular material in the table environment, which allows it
to to float to an appropriate spot in the text. This table is floated to the top of the next
page because there is not enough room for it to be placed “here”. Note the placement
of the \caption and \label commands in this example and the example figure on the
next page.
\begin{table}[htp]
\caption{Contract Expenses to Date}
\label{tab:exp}
\begin{center}
\begin{tabular}{lr}
Item & Amount\\
\hline
Salaries (research assistants, secretary) & \$24,000 \\
Travel expenses & \$8,000 \\
Software & \$2,000 \\
\cline{2-2} \\[-8pt]
Total & \$34,000
\end{tabular}
\end{center}
\end{table}
April 2007
8.2 Examples ♦ 39
Table 2: Contract Expenses to Date
Item Amount
Salaries (research assistants, secretary) $24,000
Travel expenses $8,000
Software $2,000
Total $34,000
The following example produces a figure that uses a line drawing of a cat, which L
A
T
E
X
places “here” because there happens to be room for it. There are two versions of the
image, cat.eps and cat.pdf, so that either L
A
T
E
X or pdfL
A
T
E
X can be used. Note that
the \includegraphics command below does not specify an extension on the file name,
leaving it up to L
A
T
E
X or pdfL
A
T
E
X to find the appropriate file.
\begin{figure}[htp]
\centering
\includegraphics[angle=30,width=.6\textwidth]{cat}
\caption{A Tipsy Cat}
\label{fig:cat}
\end{figure}
Figure 1: A Tipsy Cat
Academic and Research Computing, RPI
40 ♦ Chapter 8. Placing Figures & Tables (Floats)
8.3 Overcoming Problems with Float Placement
When placing floated material, L
A
T
E
X follows certain rules, explained in detail in Lam-
port’s L
A
T
E
X User’s Guide and Reference Manual, section C.9. If you find that your
table or figure is not appearing where you think it should, it could be that L
A
T
E
X’s con-
straints on how much of a text page can be taken up by floats are getting in the way.
You can override these constraints by including a ! in the optional argument containing
the positioning parameters. For example, if you use \begin{table}[!htp], L
A
T
E
X will
try extra hard to place the float where you want it.
Do NOT give only one possible placement parameter (e.g., h), because if the float cannot
be placed where you specified, it could be pushed to the end of the section or document
with all subsequent figures or tables behind it.
L
A
T
E
X has room in its memory to hold only a certain number of floats. If you want
to include many figures or tables together, without intervening text, you can avoid
problems by including the command \clearpage after every approximately 10 floats.
This command prints all queued floats and starts a new page.
8.4 Landscape Figures and Tables
To print an entire figure or table, including the caption, in landscape orientation, use
the rotating package (in addition to graphicx for images). Load it in the preamble as
usual with the \usepackage command:
\usepackage{rotating}
This package defines two new environments, sidewaysfigure and sidewaystable,
which you then use in place of the standard L
A
T
E
X environments figure and table.
The sideways environments always put the landscape table or figure on a page by itself.
For example, to make a landscape page containing a rotated graphic and caption, use
commands such as:
\begin{sidewaysfigure}
\includegraphics{myfigure}
\caption{Turn the page sideways to look at this figure.}
\end{sidewaysfigure}
The file http://www.rpi.edu/dept/arc/training/latex/Examples/exrotating.tex
contains examples of using both the graphicx and the rotating packages to include
landscape figures and tables. To see the results after running pdflatex, view the output
in the file
http://www.rpi.edu/dept/arc/training/latex/Examples/exrotating.pdf.
Full documentation for the rotating package is in the book, The L
A
T
E
X Companion by
Mittlebach and Goossens.
April 2007
Chapter 9. Preparing a Bibliography
L
A
T
E
X provides built-in support for citing references, which is straightforward and rel-
atively easy to use. However, it’s not very flexible. If your bibliography is large or if
you use the same references in several documents, you may prefer to use BibT
E
X, a
companion program to L
A
T
E
X that allows you to store all your references in an external
database file. You can then refer to this database in your L
A
T
E
X document, and cite any
reference within it. Both methods are described below.
9.1 Using L
A
T
E
X’s built-in Method
To prepare a bibliography the “standard” way, the first step is to cite various works
within your text using the \cite{key} command. key is a reference keyword of your
choosing that identifies the work. For example your document might include, at the
appropriate places, the commands: \cite{lamport} \cite{kopka} \cite{goossens}.
These commands place numbers (enclosed in square brackets) in the text that match the
numbers automatically generated in the bibliography. (Remember to run L
A
T
E
X twice
to get correct numbers in the text!)
To include an item in the bibliography without citing it in the text, use the \nocite
command; for example: \nocite{smith,jones}.
Then, at the end of the document, you format the bibliography, sorting the entries as
you wish them to appear, using the a special environment called thebibliography.
Below is an example of a thebibliography environment, followed by the output it
produces. On the \begin{thebibliography} line, the width of the item in the second
pair of braces determines the indent of the entries. This item is usually a dummy number
with as many digits as the highest-numbered entry. In this case, the “9” indicates there
are fewer than 10 entries. If there are 10 or more but less than 100, use the number 99.
Within this environment, each entry starts with the \bibitem command. The argument
for this command is the same keyword used in the corresponding \cite command in
the text. The \bibitem commands automatically generate a number in square brackets
before each entry. The first entry in the list will be numbered 1.
Note that in the book and report classes, Bibliography is used as the chapter title;
in the article class, References is used as the section heading.
\begin{thebibliography}{9}
\bibitem{lamport} Leslie Lamport. \textit{\LaTeX\ -- A Document
Preparation System}. Addison-Wesley, second edition, Reading, MA, 1994.
\bibitem{kopka} Helmut Kopka and Patrick W.~Daly. \textit{A Guide
to \LaTeX}. Addison-Wesley, fourth edition, Boston, MA, 2004.
\bibitem{goossens} Michel Goossens, Frank Mittelbach, et al. \textit{The
\LaTeX\ Companion}. Addison-Wesley, second edition, Boston, MA, 2004.
\end{thebibliography}
41
42 ♦ Chapter 9. Preparing a Bibliography
References
[1] Leslie Lamport. L
A
T
E
X – A Document Preparation System. Addison-Wesley,
Reading, MA, second edition, 1994.
[2] Helmut Kopka and Patrick W. Daly. A Guide to L
A
T
E
X. Addison-Wesley, fourth
edition, Boston, MA, 2004.
[3] Michel Goossens, Frank Mittelbach et al. The L
A
T
E
X Companion. Addison-
Wesley, second edition, Boston, MA, 2004.
If you want to change the heading for the reference listing, just change the value of
\refname (for article class) or \bibname (book or report class) by adding a line like this
in your preamble: \renewcommand{\bibname}{Literature Cited}.
If you like, you can choose a label to identify the work in both the text and in the
bibliography, instead of the number assigned by L
A
T
E
X. You do this by including an
optional label on the \bibitem command. (The \cite command doesn’t change.) For
example, to refer to the third book as “companion,” its entry in the thebibliography
environment would be:
\bibitem[companion]{goossens} Michel Goossens, Frank Mittelbach, et al.
\textit{The \LaTeX\ Companion}. Addison-Wesley, second edition,
Boston, MA, 2004.
9.2 Using BibT
E
X
9.2.1 Overview
BibT
E
X automatically generates a list of references from information contained in a
bibliographic database—a file you create whose name ends with the extension .bib.
The entries in your .bib file are called in your L
A
T
E
X file with various \cite commands,
just as in the built-in method described above. In your L
A
T
E
X file, you provide just two
more pieces of information: A bibliographystyle command to specify the formatting
style of the citations and the bibliography (this can appear anywhere in your L
A
T
E
X
file), and at the point you want the bibliography printed, a bibliography command to
provide the name of the .bib file.
After processing your document through L
A
T
E
X (or pdfL
A
T
E
X) you run BibT
E
X, which
will format the citations according to the style you’ve specified. You then need to run
L
A
T
E
X (or pdfL
A
T
E
X) again to process the output created by BibT
E
X, and finally once
more to resolve the references. Your resulting output will then contain your citations
and formatted bibliography.
April 2007
9.2 Using BibT
E
X ♦ 43
9.2.2 Creating the .bib File
The .bib file is a plain text file that you create and edit with any text editor. The
following example of a Bibtex entry illustrates the structure. Each entry begins with
the document type preceded by the “@” sign. This is followed by a unique label that
you make up and that you will use to cite the entry in your text. Then each field (in
any order) uses the format keyword = ¦data¦. Note that the data can be enclosed in
either quotation marks or braces, and each line except the last must end with a comma.
@article{Hefferon04,
author = "Jim Hefferon",
title = "{CTAN} for {S}tarters",
year = "2004",
journal = "{TUGB}oat",
volume = "25",
number = "2",
pages = "126--127"
}
The above example refers to an article within a journal. There are many different
document types: book, article (in a journal), article (in a collection), chapter (in a
book), thesis, report, paper (in a Proceedings), etc. There is a prescribed set of fields
for each type of document. A book entry might look like:
@book{Kopka04,
author = {Helmut Kopka and Patrick W.~Daly},
title = {Guide to {\LaTeX}},
edition = {fourth},
publisher = {Addison-Wesley},
address = {Boston, MA},
year = {2004}
}
If a work has more than one author, separate them with the keyword “and” so BibT
E
X
can distinguish the different names. If the BibT
E
X style does not preserve all your
capitalization (for example within titles), you can tell BibT
E
X to keep them by using
braces around the letters in question.
9.2.3 Running BibT
E
X
After processing your file with L
A
T
E
X (or pdfL
A
T
E
X), you run the BibT
E
X program by
clicking on the BibT
E
X toolbar icon (if your editor has one), or by typing the com-
mand bibtex followed by the name of your document without the .tex extension. The
information for every document you have cited will be extracted from your database,
formatted according to the style you specify, and stored in a bibliographic (.bbl) file
ready for L
A
T
E
X to use. When you run L
A
T
E
X again it will build the bibliography from
the .bbl file and generate warnings about unresolved references. Subsequent runs will
resolve the references, and the warnings will disappear.
Academic and Research Computing, RPI
44 ♦ Chapter 9. Preparing a Bibliography
Suppose you have a file called myrefs.bib that contains the two bibliographics entries
above, and the file testbib.tex contains the following:
\documentclass{article}
\begin{document}
We are testing the use of Bib\TeX\ using two entries.
One is a book \cite{kopka04}, and the other is an
article in a journal. \cite{hefferon04}
\bibliographystyle{plain} % use style plain.bst
\bibliography{myrefs} % find references in myrefs.bib
\end{document}
The result of running L
A
T
E
X, then BibT
E
X then L
A
T
E
X twice more would be:
We are testing the use of BibT
E
X using two entries. One is a book [2],
and the other is an article in a journal. [1]
References
[1] Jim Hefferon. CTAN for Starters. TUGBoat, 25(2):126–127, 2004.
[2] Helmut Kopka and Patrick W. Daly. Guide to L
A
T
E
X. Addison-Wesley,
Boston, MA, fourth edition, 2004.
9.2.4 Bibliography Styles
Bibliography styles are files (with the extension .bst), that tell BibT
E
X how to format
the information in the .bib file. The standard styles are:
plain entries are sorted alphabetically and are labelled with numbers.
unsrt the same as plain except entries appear in the order in which they were cited.
abbrv the same as plain except names, month names, journal names are abbreviated.
alpha entries are sorted alphabetically, and the labels are made from the author’s or
authors’ (or editor’s) name and the year of publication.
The .../bst subdirectory of your T
E
X installation contains the styles (.bst files) in-
stalled by default, and the The L
A
T
E
X Companion, chapter 12, describes others.
There are also various L
A
T
E
X packages that provide other styles, such as author-date
citations instead of numbers. To use one of these packages, you need to include its name
with the normal \usepackage command in your preamble. One highly recommended and
flexible package is Natbib. In addition to loading the Natbib package in the preamble,
you need to use a bibliography style that supports the author-date style. (Some possible
choices are “plainnat”, “unsrtnat”, “abbrvnat” and “apalike”.) Also, Natbib uses slight
variations of the \cite command: you just append a “t” (for textual) or “p” (for
parenthetical), to the basic \cite command, for example:
April 2007
9.2 Using BibT
E
X ♦ 45
Citation command Natbib output
\citet{hefferon04} Hefferon (2004)
\citep{hefferon04} (Hefferon, 2004)
\citet[chapter 4]{kopka04} Kopka and Daly (2004, chapter 4)
\citep[see][chap.~4]{kopka04} (see Kopka and Daly, 2004, chap. 4)
Using the same myrefs.bib file as in the previous example, and changing the
testbib.tex file to read:
\documentclass{article}
\usepackage{natbib}
\begin{document}
We are testing the use of Bib\TeX\ using two entries.
One is a book by \citet{kopka04}, and the second is an
article in a journal \citep{hefferon04}.
\bibliographystyle{apalike} % use style apalike.bst
\bibliography{myrefs} % find references in myrefs.bib
\end{document}
produces, after running L
A
T
E
X, then BibT
E
X, then L
A
T
E
X twice more:
We are testing the use of BibT
E
X using two entries. One is a book by Kopka
and Daly (2004); the second is an article in a journal (Hefferon, 2004).
References
Hefferon, J. (2004). CTAN for Starters. TUGBoat, 25(2):126–127.
Kopka, H. and Daly, P. W. (2004). Guide to L
A
T
E
X. Addison-Wesley, Boston,
MA, fourth edition.
9.2.5 For More Information
For more information on L
A
T
E
X’s built-in method and on using BibT
E
X, see any of the
three books in section 9.1.
For on-line information on BibT
E
X, there is an excellent tutorial by Andrew Roberts:
http://www.andy-roberts.net/misc/latex/latextutorial3.html
A longer, more complete document covering both LaTeX’s basic bibliography method
and BibT
E
X is Tame the BeaST by Nicolas Markey:
http://tug.ctan.org/tex-archive/info/bibtex/tamethebeast/ttb_en.pdf
An excellent, concise overview of the Natbib package is the file natnotes.pdf, and the
Natbib manual is in natbib.pdf. You can find both these files at:
http://www.ctan.org/tex-archive/macros/latex/contrib/natbib/
Academic and Research Computing, RPI
Chapter 10. Special Topics
10.1 Managing a Large Document
If you are preparing a book, thesis, or any document with multiple parts, it’s convenient
to work on the different chapters or sections separately. To do this, create a separate .tex
file for each section, and create a “root” .tex file that contains the \documentclass
command, the preamble material, the \begin{document} and \end{document} com-
mands, and multiple \include commands. The \include commands tell L
A
T
E
X to read
the separate .tex files that contain the text of the document. Each \include command
starts a new page in your output. Note that the individual section files do not include
\begin{document} and \end{document} commands.
The command, \includeonly, which must go in the preamble, can be used to select
from the \include list only certain file(s) to be processed.
As an example, the root file for a book with 6 chapters might be called mybook.tex,
and the files for the chapters might be named chap1.tex, chap2.tex, etc. The root file
mybook.tex, which is the file on which you run L
A
T
E
X, would look something like:
\documentclass{book}
\includeonly{chap1,chap2} % only these files will be processed
\begin{document}
\include{chap1}
\include{chap2}
\include{chap3}
\include{chap4}
\include{chap5}
\include{chap6}
\end{document}
10.2 Generating an Index
It is relatively easy to generate an index by using L
A
T
E
X commands combined with the
support program MakeIndex. This memo covers just the basics of MakeIndex; details
are in the documentation accompanying the program, makeindex.dvi, which should be
already on your system under the doc folder. For example, if you are using TeXLive
2005 on Windows, you’ll find the documentation in:
C:\TeXLive2005\texmf-dist\doc\makeindex\base\makeindex.dvi.
Suppose your L
A
T
E
X input file is called myfile.tex. To make an index, you need to do
the following things in that file:
1. Load the package makeidx with the command: \usepackage{makeidx}
2. In the preamble, place the command: \makeindex
46
10.3 Including hyperlinks ♦ 47
3. At the place you want the index to appear (usually the end of the document), put
the command: \printindex
4. Put index entries throughout the text (as close as possible to the actual word or
phrase being indexed) using the command \index{entry}, where entry is the index
entry. Examples of various index entries are shown in the table at the bottom of
the page.
Now, generate the index by running L
A
T
E
X, then running makeindex, and finally running
L
A
T
E
X once more. If you don’t have a “makeindex” button on the toolbar of your
editor/shell, you can run it from the command line or use the editor’s Help feature to
add it to the toolbar. Below is an example of doing the 3-step process from the command
line. Note that you should not include the filename extensions on your commands; the
programs will then do the right thing.
latex (or pdflatex) myfile In addition to producing the .dvi or pdf file, this generates
the file myfile.idx, which contains all the index entries
and page numbers.
makeindex myfile MakeIndex processes myfile.idx and produces the file
myfile.ind, which contains the L
A
T
E
X commands to for-
mat the index.
latex (or pdflatex) myfile When L
A
T
E
X or pdfL
A
T
E
X finds the \printindex com-
mand, it reads in the file myfile.ind. The resulting out-
put includes the formatted index.
If you change your document after producing the .ind file, be sure to run MakeIndex
again to create an up-to-date .ind file before running L
A
T
E
X for the final time.
The package showidx, which comes with L
A
T
E
X, prints all index entries in the margin of
the text. This is a useful tool for checking the index in draft copies.
Examples of Index Entries
L
A
T
E
X Input Index Entry Comments
\index{colors} colors, 14 Main entry
\index{colors!blue} blue, 14 Subentry under “colors”
\index{colors!blue!navy} navy, 15 Subsubentry
\index{gnu@\textsl{gnu}} gnu, 22 Formatted text
\index{gnat|\textbf} gnat, 25 Formatted page number
10.3 Including hyperlinks
Both L
A
T
E
X and pdfL
A
T
E
X can use the hyperref package to place live links in the PDF
file. By including \usepackage{hyperref} as the last package in your preamble, you
will automatically get bookmarks corresponding to your sections, and hyperlinks from
your tables of contents and \cite and \ref references. The package has a number of
options; some of the most useful are:
Academic and Research Computing, RPI
48 ♦ Chapter 10. Special Topics
colorlinks makes the text of the link colored instead of framed with a box. It’s also pos-
sible to choose the color of the links with the linkcolor, urlcolor, and citecolor
options.
plainpages=false distinguishes between frontmatter and mainmatter page numbers.
With this option, hyperref writes different anchors for pages “ii’ and “2”.
pdfpagelabels sets PDF page labels so that Acrobat Reader displays the page number
as (say) “iv (4 of 40)” rather than simply “4 of 40”. plainpages=false and
pdfpagelabels are usually used together.
breaklinks allows a line break in a long link (such as a TOC entry). Works with
pdfL
A
T
E
X only.
linktocpage makes the page number, not the text, the link in TOC, LOF, and LOT.
It’s especially useful if you use L
A
T
E
X and dvips to get your PDF file, as this method
cannot use breaklinks. If you also have long URLs in the body of the thesis, the
breakurl package can help. For documentation, look on your system for the file
breakurl.pdf.
The hyperref package also provides the command \url{URL} to link to a URL from the
text, for example: \url{http://www.ctan.org/} or \url{mailto:email@email.com}.
The command \href{URL}{text} provides a more sophisticated method, where
“URL” is the address and “text” is the text displayed in the document. For
example, to avoid having the text “mailto:” appear in the document, use
\href{mailto:myfriend@rpi.edu}{myfriend@rpi.edu}.
Be sure to run L
A
T
E
X or pdfL
A
T
E
X twice to ensure correct hyperlinks.
Abbreviated example file:
\documentclass{report}
\usepackage{ifpdf} % to use same .tex file for both latex & pdflatex
% the following specifies different options to hyperref depending on
% whether latex or pdflatex is being run.
\ifpdf
\usepackage[colorlinks,linkcolor=blue,urlcolor=blue,citecolor=blue,
plainpages=false,pdfpagelabels,breaklinks]{hyperref}
\else
\usepackage[colorlinks,linkcolor=blue,urlcolor=blue,citecolor=blue,
plainpages=false,pdfpagelabels,linktocpage]{hyperref}
\fi
\begin{document}
... body of your document goes here ...
\end{document}
The official documentation for hyperref is manual.pdf. Look for it on your system in
.../doc/latex/hyperref/.
April 2007
10.4 Accents and Special Characters ♦ 49
10.4 Accents and Special Characters
L
A
T
E
X provides commands that allow you to print accents required by many European
languages. The table below shows how to apply a variety of accents to the letter o. Of
course, any other letter can be used in place of o.
If you want to place an accent on top of an i or a j, however, you need to print them
without their dots. You can print a dotless i or j by typing \i and \j. For example, ˘ı is
formed by typing \u{\i}.
`o \‘¦o¦ ´o \’¦o¦ ˆo \^¦o¦ ˜o \~¦o¦
¯o \=¦o¦ ˙ o \.¦o¦ ¨o \"¦o¦ ˚o \r¦o¦
˘o \u¦o¦ ˇo \v¦o¦ ˝o \H¦o¦ ¸ o \c¦o¦
o
.
\d¦o¦ o
¯
\b¦o¦ ´ oo \t¦oo¦
Note that the accent commands that are control symbols (i.e., they consist of just one
non-letter) can also be used without braces. For example \^o and \^{o} both produce
ˆo.
The special letters that are part of European languages can be generated with the
following commands:
œ ¦\oe¦ Œ ¦\OE¦ æ ¦\ae¦ Æ ¦\AE¦
˚a ¦\aa¦
˚
A ¦\AA¦ ø ¦\o¦ Ø ¦\O¦
ß ¦\ss¦ SS ¦\SS¦ l ¦\l¦ L ¦\L¦
¡ !‘ ¿ ?‘
For example:
na\"{\i}ve, r\’esum\’e, {\AA}ngstr{\o}m, se\~norita, stra{\ss}e
produces:
na¨ıve, r´esum´e,
˚
Angstrøm, se˜ norita, straße
Academic and Research Computing, RPI
Appendix A
Mathematical Symbols
All the following symbols (except the “non-mathematical symbols” listed on the next
page) must be used in math mode. To use one of the symbols in ordinary text, put it
in math mode by surrounding it with dollar signs: $\alpha$ →α.
The AMSL
A
T
E
X package, amssymb, provides additional math symbols. For a list, see
http://www.rpi.edu/dept/arc/training/latex/amssymblist.pdf.
Greek Alphabet
α ¸alpha ι ¸iota ¸ ¸varrho
β ¸beta κ ¸kappa σ ¸sigma
γ ¸gamma λ ¸lambda ς ¸varsigma
δ ¸delta j ¸mu τ ¸tau
c ¸epsilon ν ¸nu υ ¸upsilon
ε ¸varepsilon ξ ¸xi φ ¸phi
ζ ¸zeta o o
1
ϕ ¸varphi
η ¸eta π ¸pi χ ¸chi
θ ¸theta ¬ ¸varpi ψ ¸psi
ϑ ¸vartheta ρ ¸rho ω ¸omega
Γ ¸Gamma Ξ ¸Xi Φ ¸Phi
∆ ¸Delta Π ¸Pi Ψ ¸Psi
Θ ¸Theta Σ ¸Sigma Ω ¸Omega
Λ ¸Lambda Υ ¸Upsilon
Capitals not shown are produced with English capital letters.
1
An ordinary “o” looks Greek when used in a math environment: $o$ →o.
Miscellaneous Symbols
ℵ ¸aleph / ¸prime ∀ ¸forall
¯ / ¸hbar ∅ ¸emptyset ∃ ¸exists
ı ¸imath ∇ ¸nabla ¸neg
, ¸jmath

¸surd : ¸flat
/ ¸ell · ¸top ¡ ¸natural
℘ ¸wp ⊥ ¸bot ; ¸sharp
' ¸Re | ¸Vert or ¸[ ♣ ¸clubsuit
· ¸Im

¸angle ♦ ¸diamondsuit
∂ ¸partial ´ ¸triangle ♥ ¸heartsuit
∞ ¸infty Q ¸Diamond ♠ ¸spadesuit
H ¸mho P ¸Box ¸ ¸backslash

¸sum

¸prod

¸coprod
_
¸int
_
¸oint I ¸Join
The symbols whose names are underlined require latexsym, a standard L
A
T
E
X package.
Load it with the command: \usepackage{latexsym}.
50
♦ 51
Non-Mathematical Symbols
These symbols can be used in either text mode or math mode:
† ¸dag ‡ ¸ddag ¸ ¸S ¶ ¸P c _ ¸copyright £ ¸pounds
Function Names
When using function names in a math environment, you can prefix them with a ¸ so
that they will print as normal text rather than in italics:
¸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
Delimiters
The following symbols can expand in size to “fit around” the expressions they delimit. To
make a delimiter the right size, use it with the \left ... \right commands described
in section 6.6.6.
( ( ) ) ¸ \lfloor | \rfloor
[ [ ] ] ¸ \lceil | \rceil
¦ \{ ¦ \} ¸ \langle ) \rangle
[ | | \| ↑ \uparrow ⇑ \Uparrow
, / ¸ \backslash ↓ \downarrow ⇓ \Downarrow
¡ \updownarrow ¸ \Updownarrow
Relational Operators
≤ ¸le or ¸leq ≥ ¸geq ≡ ¸equiv
≺ ¸prec ~ ¸succ ∼ ¸sim
_ ¸preceq _ ¸succeq · ¸simeq
¸ ¸ll ¸ ¸gg · ¸asymp
⊂ ¸subset ⊃ ¸supset ≈ ¸approx
⊆ ¸subseteq ⊇ ¸supseteq

= ¸cong
` ¸sqsubset a ¸sqsupset ⊥ ¸perp
_ ¸sqsubseteq _ ¸sqsupseteq ¸bowtie
∈ ¸in ÷ ¸ni ∝ ¸propto
¬ ¸vdash ¬ ¸dashv [= ¸models
¸smile [ ¸mid
.
= ¸doteq
· ¸frown | ¸parallel
,< ¸not< , ¸not ,= ¸not=
Note that \not before a relation will negate it.
The symbols whose names are underlined require the latexsym package.
Academic and Research Computing, RPI
52 ♦ Appendix A: Mathematical Symbols
Binary Operators
± ¸pm ∩ ¸cap ∨ ¸vee
∓ ¸mp ∪ ¸cup ∧ ¸wedge
¸ ¸setminus ¬ ¸uplus ⊕ ¸oplus
¸cdot ¯ ¸sqcap ¸ ¸ominus
¸times . ¸sqcup ⊗ ¸otimes
∗ ¸ast ¸triangleleft ¸ ¸oslash
- ¸star ¸triangleright ¸ ¸odot
¸diamond / ¸wr † ¸dagger
◦ ¸circ _ ¸bigcirc ‡ ¸ddagger
• ¸bullet ´ ¸bigtriangleup H ¸amalg
÷ ¸div _ ¸bigtriangledown ¡ ¸lhd
¢ ¸unlhd ¤ ¸unrhd £ ¸rhd
The symbols whose names are underlined require the latexsym package.
Math Accents
ˆ c ¸hat¦a¦ ˇ c ¸check¦a¦ ˘ c ¸breve¦a¦
´ c ¸acute¦a¦ ` c ¸grave¦a¦ ˜ c ¸tilde¦a¦
¯ c ¸bar¦a¦ c ¸vec¦a¦ ˙ c ¸dot¦a¦
¨ c ¸ddot¦a¦
¯
r −µ ¸widehat¦x-y¦ ¯ rµ. ¸widetilde¦xyz¦
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 Y ¸leadsto
The symbols whose names are underlined require the latexsym package.
April 2007
Appendix B
Error Messages
Most files need some debugging before they print properly. This section describes some
common errors and shows how to correct them.
Responding to Errors
When L
A
T
E
X finds an error, it generates a message such as:
! Undefined control sequence.
l.9 \secton
{Introduction}
?
This means the \section command was misspelled, and the error occurred on line 9 of
the input file.
You can respond with:
h for help
x for exit
press the Return key to ignore it and hope for the best. L
A
T
E
X will try to recover
from the error and continue processing. Sometimes you can tell from viewing the
output what went wrong.
If it stops with a * prompt, it often means you have forgotten \end{document}. Enter
it at the prompt (and fix the file later).
If you mistyped the file name or for some other reason L
A
T
E
X cannot find a file, it will
ask for another filename. If you don’t want to enter a new filename, quit the program
by typing Ctrl-d or Ctrl-c. Another handy “Emergency stop sequence” is Ctrl-z.
Windows users: Do not simply close the Command window without responding!
The window may disappear but L
A
T
E
X is still running, which will cause confusion when
you run it again.
Some Common Errors
• A command was misspelled and L
A
T
E
X doesn’t recognize it.
• You have a special character (e.g., &, $, #, %) in the text. Enter these as \&, \$,
\# or \%.
• Whatever you \begin{...}, you must \end{...}. This includes braces: ¦ ... ¦.
• You inserted too many tabs on the line before the \\.
• A command wasn’t given all its arguments and is trying to use the rest of the file
for an argument.
53
54 ♦ Appendix B: Error Messages
Errors About Boxes
Another common error (actually just a warning) refers to an underfull hbox (or vbox).
These errors are harmless and may be safely ignored. They mean there is more blank
space on a line (or page) than L
A
T
E
X thinks is aesthetically pleasing. (L
A
T
E
X is very
fussy.)
Sometimes underfull hbox messages are the result of using the linebreak command (\\)
inappropriately. L
A
T
E
X will generate this warning if you use \\ just before or after a new
paragraph or before starting an environment that begins on a new line anyway.
Errors that refer to “overfull hboxes” mean that a line is too long. For example, you
might get a message such as this one:
Overfull \textbf{hbox} (19.45158pt too wide) in paragraph at
lines 1206--1215
L
A
T
E
X is warning you that a line sticks out into the margin. It was forced to do this
because otherwise the line would contain unacceptably wide white spaces. Depending
on how the output actually looks, you may or may not want to correct the problem.
To correct it, you could reword the sentence so that it breaks better, or instruct L
A
T
E
X
how to hyphenate a certain word. Suppose L
A
T
E
X doesn’t know how to hyphenate the
word “environment” that occurs in the line. You can make L
A
T
E
X put the hyphens in
“environment” temporarily or permanently. To do it permanently, put the following
command in the preamble (note: more than one word can be added in the command if
words are separated by spaces):
\hyphenation{en-vi-ron-ment}
For a temporary fix, put discretionary hyphens \- in the offending word where it appears
in the text. This is a one-time fix, and unused discretionary hyphens do not show up in
the text:
en\-vi\-ron\-ment
Errors Relating to Memory
Sometimes L
A
T
E
X complains that it’s out of memory, but it usually isn’t. The symptoms
listed below can be fixed as described:
It won’t do all your tables or figures Put \clearpage between them.
It won’t do a three-page table That’s right, it must be broken up.
You just want one big paragraph Sorry, L
A
T
E
X needs breaks.
You are using tabular Did you leave out a \\
or have too many tabs on a line?
It won’t take the caption Use \caption[short list entry]¦Very long caption¦
to trim size for listoftables/figures entry
You have nested environments Are they in First-In, Last-Out order?
April 2007
Resources
General Information on L
A
T
E
X
Books
L
A
T
E
X – A Document Preparation System by Leslie Lamport. Addison-Wesley, second
edition, Reading, MA, 1994.
A Guide to L
A
T
E
X by Helmut Kopka and Patrick W. Daly. Addison-Wesley, fourth
edition, Boston, MA, 2004.
The L
A
T
E
X Companion by Michel Goossens, Frank Mittelbach, et al. Addison-Wesley,
second edition, Boston, MA, 2004.
On line
For on-line tutorials, example files, and links to other information, see the Rensselaer
L
A
T
E
X Information page: http://www.rpi.edu/dept/arc/training/latex/
A longer, more complete Introduction than this document is The Not So Short
Introduction to L
A
T
E
X2
ε
by Tobias Oetiker (150 pages):
http://www.ctan.org/tex-archive/info/lshort/english/lshort.pdf
A useful on-line command reference is:
http://computing.ee.ethz.ch/.soft/latex/green/ltx-2.html
The official L
A
T
E
X searchable FAQ is at: http://www.tex.ac.uk/faq
A good resource for all kinds of information is the T
E
X Users Group (TUG) at
http://tug.org.
You can also earch the Comprehensive TeX Archive Network (CTAN):
http://tug.ctan.org/search.html
L
A
T
E
X packages
For a list of available packages with brief descriptions, see the CTAN catalog:
http://texcatalogue.sarovar.org/brief.html.
When you find a package you think may help you, before downloading it from CTAN,
check first to see if you already have it installed. If not, you will need to download it
and then install it. The following, from the FAQ, describes how to install a new
package: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=instpackages
L
A
T
E
X Thesis
The Rensselaer thesis web page,
http://helpdesk.rpi.edu/update.do?artcenterkey=325, has links to download
Rensselaer’s thesis class and to several documents that will help you prepare your
thesis and create the PDF files necessary for electronic submission.
55
56 ♦ Resources
Mathematical Expressions
For information on using AMSLaTeX, see The Short Math Guide for L
A
T
E
X, at:
ftp://ftp.ams.org/pub/tex/doc/amsmath/short-math-guide.pdf
A detailed treatment of math, including both standard LaTeX and AMSLaTeX is
Math Mode by Herbert Voss (150 pages):
http://www.tex.ac.uk/tex-archive/info/math/voss/mathmode/Mathmode.pdf
Symbols
A list of AMS Font symbols is at:
http://www.rpi.edu/dept/arc/training/latex/amssymblist.pdf
A manageable list of many useful symbols is “The Great, Big List of L
A
T
E
X Symbols”
compiled by David Carlisle, Scott Pakin, and Alexander Holt,
http://www.rpi.edu/dept/arc/training/latex/LaTeX_symbols.pdf
The Comprehensive L
A
T
E
X Symbols List (Pakin) shows all the possible symbols and
the packages required to access them (100 pages):
http://tug.ctan.org/tex-archive/info/symbols/comprehensive/symbols-letter.pdf
Graphics
Rensselaer example files, input and output
Files that illustrate how to import graphics and also how to create eps files from
Windows applications:
http://www.rpi.edu/dept/arc/training/latex/Examples/graphics.tex (input)
http://www.rpi.edu/dept/arc/training/latex/Examples/graphics.pdf (output)
Examples of using both the graphicx and the rotating packages to include landscape
figures and tables:
http://www.rpi.edu/dept/arc/training/latex/Examples/exrotating.tex (input)
http://www.rpi.edu/dept/arc/training/latex/Examples/exrotating.pdf (output)
General graphics information
Complete documentation for the graphics bundle is in the file grfguide.pdf; look for
it on your system. Information on the graphicx package is in section 4.4.
A helpful discussion of graphics formats, inporting graphics, and tools for conversion is
Strategies for including graphics in LATEX documents by Klaus H¨oppner at
http://www.tug.org/pracjourn/2005-3/hoeppner/hoeppner.pdf
For an extensive treatment of including graphics, see Using Imported Graphics in
L
A
T
E
X and pdfL
A
T
E
X by Keith Reckdahl (∼120 pages):
http://www.ctan.org/tex-archive/info/epslatex.pdf
April 2007
♦ 57
Conversion utilities (see also page 35)
The epstopdf utility converts eps files to pdf files. It is very likely part of your
TeX/LaTeX distribution.
The jpeg2ps utility converts JPEG images to eps files without uncompressing the
images. If you don’t already have jpeg2ps on your system, you can get it from:
http://www.ctan.org/tex-archive/support/jpeg2ps/
BibT
E
X
There is extensive material on BibT
E
X in the three books mentioned in the first section.
For on-line information on BibT
E
X, there is a helpful tutorial by Andrew Roberts:
http://www.andy-roberts.net/misc/latex/latextutorial3.html
A longer, more complete document covering both L
A
T
E
X’s basic bibliography method
and BibT
E
X is Tame the BeaST by Nicolas Markey:
http://tug.ctan.org/tex-archive/info/bibtex/tamethebeast/ttb_en.pdf
An excellent, concise overview of the Natbib package is the file natnotes.pdf, and the
Natbib manual is in natbib.pdf. You can find both these files at:
http://www.ctan.org/tex-archive/macros/latex/contrib/natbib/
Installing L
A
T
E
X
The TeXLive distribution is a comprehensive TeX system with binaries for Windows
and most flavors of Unix, including GNU/Linux. It also provides the popular MacTeX
distribution and ProTeXt (see below). TeXLive is distributed each year on DVD and
CD by the TeX Users Group to its members. For more information on TeXLive, see
http://tug.org/texlive/. Downloading is free, but the download is huge.
Therefore, with the exception of TeXLive for Windows (see below), the best way to get
the distribution may be to join TUG (http://tug.org/join.html).
Windows
• TeXLive: Rensselaer has made TeXLive for Windows available on RCS space.
For general information see the Readme file,
http://www.rpi.edu/dept/arc/software/latex-doc/Readme-RPI.html.
To install the software, follow the detailed installation instructions at
http://www.rpi.edu/dept/arc/software/latex-doc/install-windows.pdf.
You should print these instruction for easier use when installing.
• MikTeX: This popular distribution can be downloaded free from
http://miktex.org/. It’s not quite as inclusive as TeXLive, but has a nice
“package manager” that makes it easy to install new packages. It uses its own
previewer, called Yap. An easy way to install MikTeX is to use ProTeXt
(http://tug.org/protext/), which guides the installation via an explanatory
Academic and Research Computing, RPI
58 ♦ Resources
pdf file with clickable links. ProTeXt is also included with recent TeXLive
distributions.
You will need an editor/shell to work with L
A
T
E
X on Windows. WinShell
(http://winshell.org) and WinEdt (http://winedt.com) are both highly
recommended.
UNIX systems
Linux and other UNIX-like systems usually have TeX/LaTeX as an installation option,
so you may already have it installed. To check if it’s on your system, just type latex
at a command prompt. If it’s not there, you may be able to install it easily using your
system administration package management tool. Another excellent option is TeXLive,
which is likely to be more up-to-date than the version that came with your system.
Macintosh
The highly recommended MacTeX distribution is a complete, easy-to-install TeX
distribution for Mac OS X users that requires Mac OS 10.3 or higher. Information and
installation instructions are at http://tug.org/mactex/. It is also included with
recent TeXLive distributions.
April 2007

ii ♦ Contents 4. Within the Text 4.1 Section Headings . . . . . . . . . . . . 4.2 Changing Type Style and Size . . . . . 4.3 Starting New Lines and New Pages . . 4.4 Leaving Horizontal and Vertical Space 4.5 Drawing Rules . . . . . . . . . . . . . . 4.6 Footnotes . . . . . . . . . . . . . . . . 4.7 Centering . . . . . . . . . . . . . . . . 4.8 Quotations . . . . . . . . . . . . . . . . 4.9 Reproducing Text As-Is . . . . . . . . 4.10 Lists . . . . . . . . . . . . . . . . . . . 4.11 Cross References . . . . . . . . . . . . 16 16 17 18 18 18 19 19 19 20 21 22 23 23 24 25 26 27 27 28 28 29 29 30 31 32 32 32 32 33 33 34

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

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

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

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

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

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

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

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

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

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

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

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

5. Tabular Material 5.1 Tabbing . . . . . . . . . . . . . . . . . . . . . . . . . 5.2 Tabular . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.1 A Simple Ruled Table . . . . . . . . . . . . . 5.2.2 Using Paragraph Columns, Spanning Columns 5.2.3 Aligning on the Decimal Point . . . . . . . . . 5.2.4 Suppressing Leading or Trailing Space . . . . 6. Mathematics 6.1 In-line Math . . . . . . . . . . . . . . . . . . . . . 6.2 Display Math (for unnumbered equations) . . . . 6.3 Equation Environment (for numbered equations) . 6.4 Eqnarray Environment (for multiline equations) . 6.5 Array Environment (for matrices, etc.) . . . . . . 6.6 Building Mathematical Expressions . . . . . . . . 6.6.1 Superscripts and Subscripts . . . . . . . . 6.6.2 Spaces in Math Mode . . . . . . . . . . . . 6.6.3 Dots, Braces, and Bars . . . . . . . . . . . 6.6.4 Fractions . . . . . . . . . . . . . . . . . . . 6.6.5 Radicals, Integrals, and Summations . . . 6.6.6 Large Delimiters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7. Including Graphics 35 7.1 Creating the Graphics File . . . . . . . . . . . . . . . . . . . . . . . . . . 35 A 7.2 Importing the Graphic into your L TEX Document . . . . . . . . . . . . . 35 7.3 Viewing the Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 8. Placing Figures & Tables (Floats) 8.1 Making a Caption . . . . . . . . . . . . . . . 8.2 Examples . . . . . . . . . . . . . . . . . . . 8.3 Overcoming Problems with Float Placement 8.4 Landscape Figures and Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 37 38 40 40

April 2007

Contents ♦ iii 9. Preparing a Bibliography A 9.1 Using L TEX’s built-in Method 9.2 Using BibTEX . . . . . . . . . 9.2.1 Overview . . . . . . . 9.2.2 Creating the .bib File 9.2.3 Running BibTEX . . . 9.2.4 Bibliography Styles . . 9.2.5 For More Information . 41 41 42 42 43 43 44 45 46 46 46 47 49 50 53 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 55 55 55 56 56 56 57 57

. . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

10. Special Topics 10.1 Managing a Large Document . . 10.2 Generating an Index . . . . . . 10.3 Including hyperlinks . . . . . . 10.4 Accents and Special Characters Appendix A: Mathematical Symbols Appendix B: Error Messages Resources A General Information on L TEX A L TEX packages . . . . . . . . A L TEX Thesis . . . . . . . . . Mathematical Expressions . . Symbols . . . . . . . . . . . . Graphics . . . . . . . . . . . . BibTEX . . . . . . . . . . . . A Installing L TEX . . . . . . . .

Academic and Research Computing, RPI

.

” A • Most L TEX commands are “high-level” (such as chapter and section) and specify the logical structure of a document. Windows or unix). Palatino. It is available for most computers and is used all over the world. • TEX comes with its own set of fonts.A Text Formatting with LTEX A This document describes the L TEX language.. 1 . For specifics of how to run A it on various platforms (e.edu/dept/arc/training/latex/). such as Times. All the above features of TEX. 1. L TEX is pronounced either “Lay-tech” or “Lah-tech. L TEX provides several standard document classes from which to choose. Most plain A TEX commands also work with L TEX.2 A What is L TEX? A • L TEX is a TEX macro package. originally written by Leslie Lamport. called “Computer Modern. 1. concentrating instead on the content. TEX documents can be moved easily from one system to another. sans serif.g. and never crashes or corrupts your files. Chapter 1. including portability.” • TEX is portable. as well as many examples and links to other helpful information. • TEX is also a programming language. A • The document class determines how the document will be formatted. gives you complete control.1 What is TEX? A LTEX Basics A • TEX is the typesetting language upon which L TEX is built. The author rarely needs to be concerned with the details of document layout. including serif. TEX is pronounced “Tech.rpi. These fonts exist in a variety of styles. It was designed and written by Donald Knuth especially for math and science. The above web page also contains information on preparing a thesis or a resume.” used by default. that simplifies the use of TEX. It’s also possible to use other font families. and an extensive set of mathematical symbols. also apply to A A L TEX. as long as the required fonts are on both systems. handles big. and follow the links for the on-line tutorials. typewriter (fixed pitch). etc. making it possible to create commands that simplify its use. A • L TEX is flexible.” similar to “Bach. complex documents with ease. see the L TEX Information page (http://www.

which prints the current date. you first create a plain ASCII text file with any text editor. produces: April 16. usually with Adobe’s Acrobat Reader. In this file A you type both the text of your document and the L TEX commands to format it. The second method is more direct for PDF output. Nowadays there are two routes for processing a L TEX document: • The traditional way is to run the latex program.1 A Entering L TEX Commands A To distinguish them from text. all L TEX commands (also called control sequences) start with a backslash “\”. They are most often used to put a special symbol in the text. 1. • Alternatively you can run the relatively recent pdflatex program to create a PDF file for viewing or printing.4 A The L TEX Input File A L TEX input files have names that end with the extension .3 A How L TEX Works A To use L TEX. An example is \today. Most are all lowercase. To avoid having the space after the command disappear.4. Spaces after these control symbols are not consumed. There are also commands that consist of the backslash followed by exactly one nonletter. L TEX Basics 1. which creates a DVI (Device Independent) file. You then run a previewing program for viewing on screen and/or the dvips program to create a PostScript file for viewing or for printing via the ghostview/GSView program.A 2 ♦ Chapter 1. If it ends with a space. You then typeset your document. 1. but the first is quicker and more convenient for previewing. do the following: \today\ is a good day. GSView can also convert the document to PDF format. Fewer still use all uppercase.) The input file A contains both the text of your document and the L TEX commands needed to format it.tex. brace. A L TEX commands are case-sensitive.tex: for example. A command name consists of letters only and is ended by a space or a non letter (such as a comma. A few commands use the first letter in uppercase such as \Delta → ∆. For example \$ A prints a $ (which cannot be entered directly because L TEX uses it to begin math mode). (Never use spaces in file names. etc). period. The first command in the file. defines the style of the document. the space A is “consumed” by L TEX and does not appear in the output. \documentclass. usually by clicking a button on a toolbar or selecting a A menu item. 2007 is a good day. an acceptable file name might be myfile. April 2007 . This file is in binary format and not viewed directly.

. unless it is given within a group.) For example. } are used to begin and end groups. Since there is only one dash on the keyboard. tie them together with the tilde character: for example Mr. Note the difference between a declaration used inside a group and a command like \textbf{. the endash (for such things as page number ranges).” placed within curly braces { } after the command name. When L TEX sees a %.}. ≈ 72 per inch mm millimeter em font-dependent width of “m” in inch ex font-dependent height of “x” 1. Braces { . such as a command to set the size of a margin or a command to leave a certain amount of space. \textbf{this text is bold} prints the text inside the braces in boldface type: this text is bold A L TEX uses grouping to limit the effect of certain commands. Type single quotation marks by using the left (‘) and right (’) single quote marks on your keyboard. the \large command is usually used inside a group: {\large this is bigger than normal} produces: this is bigger than normal A command such as \large is called a “declaration” because.4. you will need to specify the A units of measurement. as described in the next section. type -. and type right double quotation marks by using either two single right quotes (’’) or the double quote key ("). see page 5.) L TEX ignores multiple blank spaces and multiple blank lines in input files. (You can also use the command \par A to indicate a new paragraph.. its effect will continue until another declaration (in this case \normalsize) counteracts it. –. L TEX recognizes the following units: cm centimeter pt printer’s point. For example. which will not work unless an argument is provided inside a pair of braces following the command name. words are separated by leaving one or more blank spaces. and the emdash (used as a punctuation mark in English prose). A Note that some characters have special meaning to L TEX and must be entered in a special way. and — .4 The L TEX Input File ♦ 3 Some commands take an “argument.~Smith will never appear with “Mr. it ignores the rest of the line. (An environment is also a group. Paragraphs are separated by leaving one or more blank lines. RPI .to get -. --. Type left double quotation marks by using using two single left quotes (‘‘). A The symbol % can be used to put a comment in your input file. There are three kinds of dashes in typeset documents: the hyphen (for compound words). Academic and Research Computing. To prevent two words from being split at a line break.2 Entering Text In the input file. When you use commands that specify a length... and --.” at the end of one line and “Smith” at the start of the next.A 1.

The preamble is the section of the file between the \documentclass{. A You can choose from one of the L TEX classes described in the next chapter. which indicates that the remainder of the line is a comment and should not be processed. used to produce a “hard” space Used to begin a group or an argument Used to end a group or an argument Used to begin a control sequence Otherwise. Below is the complete list of special characters. \documentclass[options]{class} Preamble \begin{document} Document text \end{document} In the first command above. and all the text of the document must be contained between the commands \begin{document} and \end{document}.A 4 ♦ Chapter 1. L TEX Basics 1. April 2007 . You may A also load packages that add new features to L TEX. used in alignments Used in math mode for subscripts Used in math mode for superscripts Tie character.4. produces ¡ Otherwise. you must type them in your input file as shown below. This is the place to put commands that will influence the style of your entire document and macro definitions that you will use later..} command and the \begin{document} command.4 Structure of the Input File A L TEX input files must conform to a certain structure.3 Special Characters A Certain characters have special meaning to L TEX. If you wish. class specifies the type of document you intend to create.4. They begin with the command \documentclass. To have these characters print in your output. you can also include one or more options to modify the behavior of the document class. Text is not allowed in the preamble. produces ¿ 1. also used in tables Used to begin and end math mode Used for comments in the source file Tab mark.. An example is the % sign. Character # $ % & ˆ ˜ { } \ < > Type in file \# \$ \% \& \ \ˆ{} \˜{} \{ \} $\backslash$ $<$ (or \textless) $>$ (or \textgreater) A Special L TEX meaning Parameter in a macro.

RPI . which is perfectly acceptable. Longer examples. either mandatory or optional. you would get the default 10-point type. Optional arguments are allowed on some commands and are enclosed in square brackets: [ ]. and \textit{some italic words} puts the contents of its argument in italic type.} Now the text size is back to normal. The text inside these braces is smaller than normal. It uses the article class.5 Some L TEX Vocabulary ♦ 5 The \begin{document} command indicates the end of the preamble and the beginning of your text. respectively. For example. Mandatory arguments supply information required for a command to execute. There is nothing in the preamble. There is nothing in the preamble. the size of type to be used for your main text is an optional argument in the {\documentclass} command. For example. This is a new paragraph.5 A Some L TEX Vocabulary Commands produce text or space. a good all-purpose layout. Here’s some italic text and some bold text. For example. a good all-purpose layout. some commands. A corresponding \end{document} command always ends your files. \hspace{2in} and \vspace{2in} are commands that create 2 inches of horizontal and vertical space. Mandatory arguments are enclosed in braces: { }. Many commands take arguments. one using report class and one using letter class are included at the end of the next chapter. Now the text size is back to normal. A A really short L TEX input file might look like: \documentclass{article} \begin{document} This LaTeX file is short and sweet. \textit{Here’s some italic text} and \textbf{some bold text}. To use the article class in 11-point type. It uses the article class. Without this optional argument. {\small The text inside these braces is smaller than normal. This is a new paragraph. 1. \hspace{2in} needs the information provided by the argument to generate the horizontal space. you would type \documentclass[11pt]{article}. Academic and Research Computing. \end{document} this produces: This LaTeX file is short and sweet.A 1. which is perfectly acceptable. like \today don’t.

L TEX Basics A Declarations produce neither text nor space.. \large will cause any text that follows to appear in a larger type size. April 2007 . Normally. The font size of this quotation will be smaller because of the "small" command inside the quote environment.. * Some commands can have a * appended to the name.e. Font size changes are an example of declarations. \end{quote} Note that a blank line before an environment ends the previous paragraph. in the same way that a pair of braces delimits a group. but either affect the way L TEX prints the following text or provide information for later use. If you want the space printed no matter where it falls. Environments can be nested.A 6 ♦ Chapter 1. i. \\ indicates a line break.} Environments are blocks of text that receive special processing. Declarations are often used within a group to limit their scope. section headings are automatically numbered. Space printed by \vspace and \hspace commands is normally dropped if it appears at the beginning or end of a line or page. but \section*{My Heading} will produce an unnumbered section heading. a quotation might be formatted as follows: \begin{quote} \small This text is set off from surrounding text and indented from both margins. \end{environment name}. For example. the first started is the last ended. An environment is also a group. An environment is defined by a matching \begin{environment name} . you would use \hspace* or \vspace*. For example. A blank line following an environment indicates that the next line starts a new paragraph.. which indicates a variation on a command or environment. For example: {\large Only the text inside these braces will be large. \\* indicates a A line break with the restriction that L TEX is not allowed to begin a new page at that point.

letter for letters. for example. The file thesis. begin your document with the line: \documentclass{thesis} A Instructions are in ARC document. \subsubsection. These classes provide preset formats with default margins. as well as commands to produce a title page and a table of contents. There are minor differences between these three classes. \section.option. either business or personal.1 A Creating A LTEX Document Document Classes The document class determines the overall layout of the document. which may be used to produce either a master’s or a doctoral thesis with a format that meets the requirements of the Office of Graduate Education.). The article class is intended for shorter works and does not have chapters (so articles can be easily included in reports or books). and special commands suitable for producing specific sections. and 12-point type sizes available as options. and closing. which are placed in square brackets after the \documentclass command. The letter class provides special commands to produce the salutation. 2. including journal articles. \chapter. Preparing A Thesis with LTEX. A good all-purpose class. The book class.option ]{class } 7 .do?artcenterkey=325. Multiple options are separated by commas: \documentclass[option. paragraph formatting.cls is available for download from the thesis web page. It was written by Academic and Research Computing (ARC) using the report class as a base. address. report.edu/update. There are five A standard classes distributed with L TEX: article for simple or short documents. the article. The slides class uses sans-serif type fonts much larger than the usual ones and expects the document to be divided up into 1-page sections.rpi.Chapter 2. available from the thesis web page. At Rensselaer. These four classes are single-spaced by default. report for small books and longer reports containing chapters. book for books. etc. http://helpdesk. 10 points is the default size. and have 10. 11.2 Class Options A document class may be modified by options.5 inches—and is formatted for two-sided printing by default. slides for making transparencies for projection on a screen. there is an additional class called thesis. and book classes include a variety of commands to format section headings (\part. \subsection. 2. uses a smaller printed page size—about 5×7. To use the thesis class. For example. and short reports.

The command has the form: \usepackage[options ]{package } Each package may be included with its own \usepackage command. (The opposite of openright is openany. This document uses 12-point type.) twoside Formats for printing on both sides of paper. April 2007 . This option is not necessary for the book and report classes. Creating A L TEX Document The standard class options include: 10pt. titlepage Causes the \maketitle command to generate the title page on a separate page for the article class. chances are good that you can find a package to meet your needs.A 8 ♦ Chapter 2. or you may use one command to load several packages by separating their names with commas.) 2.3 Packages A There are a large number of L TEX packages available that provide a variety of additional A features. A package generally consists of one or more files that contain extra definitions and macros.sty.) Twoside is the default for the book class. 11pt. others are provided by expert A users worldwide. chapters will begin on right hand pages. twocolumn Produces two-column pages. This is the default for the book class. The file names usually have the extension . leqno Puts equation numbers on left side. The beginning of your input file might look like: \documentclass[11pt]{article} \usepackage{graphicx} A The \usepackage command above instructs L TEX to read the file graphicx. You load a package with the \usepackage command. If you sometimes find that the features of standard L TEX do not provide the special formatting you want. Some packages are simple. If no option is specified. which does not contain chapters. For example. but not for any of the other classes.sty. (Whether the document is actually printed two-sided depends on the printer. as they print separate title pages by default.). 12pt Selects the point size of main font for the document. Many packages are considered part of L TEX. It does not apply to the article class.) fleqn Left-aligns equations. which should come immediately after the \documentclass command in your input file. the package graphicx provides the commands to do this. (They are centered by default. (They are on the right by default. openright If the twoside option is in effect. 10pt is assumed. others are complex and can contain options. if you are inserting graphics in your document (see chapter 7.

you will need to run L TEX twice on a new document for the entries in the table of contents to show up. section. If there are several authors. chapter. you need to supply text for the title.5 Making a Table of Contents The command \tableofcontents. usually placed in the input file right after the \maketitle command. 2. must follow the \begin{document} command. RPI . In your L TEX input file. Since this information is taken from the A previous run. if you are using the TeXLive 2005 distribution for Windows. creates a table of contents using the information in the section headings (part.org/brief. you may want a title page for your document.html. 2. etc). including packages to rotate text. you can separate their names with \and. use PostScript fonts (e. You can instruct the article class to make a separate page by using the documentclass option titlepage. and then A A tell L TEX to generate the title page with the command \maketitle. L TEX will use the current date. For example. package documentation is in folders under C:\TeXLive2005\texmf-dist\doc\latex\. To see a current list of all available packages with brief descriptions. The \maketitle command. type commands such as the ones below. report.sarovar. To do this.. citations and captions. If you omit the \date A command. which actually prints the title page. Palatino.4 Making a Title Page If you are using the article. etc. http://texcatalogue. use \date{}. In the article class. and customize such things as headers and footers.).4 Making a Title Page ♦ 9 In addition to graphicx there are many other packages available. In the report and book classes. or book class. and date. You’ll find documentation for these packages in the doc subdirectory of your installation.2. the title information appears on its own page. author. Packages come with their own documenA tation. \title{This is the Title} % provide title info \author{My Name} % provide author info \date{the date} % provide date \maketitle % format and print title page This is illustrated in the example of using the report class later in this chapter. Many packages are routinely distributed with L TEX and will already be on your system. Times. look at the Comprehensive TeX Archive Network (CTAN) catalog. the other commands. If you want no date at all.g. Academic and Research Computing. it appears at the top of the first page of text. or you can separate them with \\ if you would like each name centered on a separate line. which just provide the information. can be placed in the preamble if you prefer.

A second run allows L TEX to extract the information from its auxiliary files and complete the table of contents. the difference between runs is not enough to matter. For example. etc. etc. figures and tables. which are considered to be hboxes (horizontal boxes). Usually for drafts. L TEX stores this information A in auxiliary files as it processes the job. but different extensions.) to be different sized boxes. Therefore all A information used by LTEX for tables of contents. A but for final versions you should remember to run L TEX twice before printing.2 How a Page is Built A When TEX or L TEX builds a page. Auxiliary files are created automatically as they are needed. A group of hboxes stacked together vertically (with glue between them) form a vbox (vertical box). a list of tables. filename. The only way to be sure that all this material is correct is to format the file twice after making any changes.11) and to create a table of contents. April 2007 . are A A unknown when L TEX is first processing the input file. and a list of figures.toc filename.aux. but sometimes (such as when an error message refers to an “overfull hbox. an individual letter.6. Other auxiliary files (see the list below) are needed only if you are producing a table of contents.tex.lof always needed for table of contents for list of tables for list of figures 2.lot filename. The words are then put together with glue to form a line. A The auxiliary files have the same “root” name as the L TEX input file.1 Behind the Scenes Auxiliary Files A Part of the convenience of L TEX is its ability to do cross references (see section 4.” meaning a line is too long and sticks out into the margin) it is helpful to know how TEX works.A 10 ♦ Chapter 2. which is a larger hbox. A page is a large vbox made up of several smaller ones. is from the previous run. the AUX file will be named myfile. as well as page numbers for sections. lines. Creating A L TEX Document 2. If the input file is named myfile. etc.6 2. it considers all the parts (words.aux filename. paragraphs. etc. and then builds words.6. You do not normally need to be concerned with this. It starts with a simple box. Forward reference numbers. all documents need an AUX file.

2. indented text part \\ % "\\" forces a new line chapter \\ % not available in article class section \\ subsection \\ subsubsection \\ paragraph \\ subparagraph \end{quote} % End of indented text The *-form (e. Roman page number for toc Make it start with "ii" Print table of contents \documentclass[11pt]{report} \raggedright \parindent0pt \parskip8pt \begin{document} \title{\bf An Example of Report Class} \author{Yours Truly} \date{\today} \maketitle \pagenumbering{roman} \setcounter{page}{2} \tableofcontents \chapter{A Main Heading} % Make a "chapter" heading \pagenumbering{arabic} % Start text with arabic 1 Most of this example applies to the article and book classes as well as to the report class. article class does not have a ‘‘chapter" command. start of document text. RPI . Supply information for the title page. Use current date. Print title page.} \textit{Note this: it will be \section{A Subheading} % Make a "section" heading The following sectioning commands are available: \begin{quote} % Start "set off".g. ‘‘section*") suppresses the section number and does not make a TOC entry.7 Example: Report Class % Report class in 11 points % Do not right-justify % make block paragraphs % % % % % % % % % End of preamble. printed in italic type. A blank line starts a new paragraph.7 Example: Report Class ♦ 11 2. however. \end{document} % The required last line Academic and Research Computing. Also.. the default position for the title information is at the top of the first text page rather than on a separate page. In article class.

NY 12345} % Return address \signature{My Name\\My Title} % Name for signature \begin{document} \begin{letter}{Mr.\\Sometown. 12 points \documentclass[12pt]{letter} \address{555 Main St. Name(s) of those receiving copies \cc{My Boss} \end{letter} \end{document} % End of letter % The required last line April 2007 .~Smith:} % End of preamble % Begin letter by giving % recipient’s address % Name for salutation This is the letter class. It provides a format for standard parts of a business letter. it uses many commands that do not exist in the article. Creating A L TEX Document 2. and book classes. Big Name Co. MI 45678} \opening{Dear Mr.8 Example: Letter Class % letter class.A 12 ♦ Chapter 2.\\Bigburg. The name is taken from \signature command above. As you can see.} % % % % % Format for the closing.~Smith\\ President. \closing{Sincerely. This is a new paragraph. report.

include after the \documentclass command: \usepackage{setspace} and. 3. footnotes. for example. To use the setspace package to produce a double-spaced document. The commands \parindent and \parskip control paragraph indentation and paragraph separation. figures. which means 1. You could use \onehalfspacing instead of \doublespacing. However.2 Paragraphs To start a new paragraph.3.1 Line Spacing The default is single spacing. and tables remain single-spaced.6} For “line and a half” spacing. choose the number you want 1 the section between the \documentclass command and the \begin{document} command 13 . (1 em is about the width of an “M”. Commands controlling features that apply to the whole document should be placed in the preamble1 . in addition.5em. 3. paragraphs are indented by 1.) No extra blank space is inserted between paragraphs.Chapter 3. With this package. By default. there are commands that enable you to do so. which you can use to include single-spaced sections within your document. or you could use the command \setstretch{n} (specifying your own value for n—usually between 1 and 2) to set the spacing to whatever you want. put the command \doublespacing somewhere in the preamble. if you want to change the defaults.5 times the point size of the current font. use the value 1. If you want larger interline spacing for your document. Document Layout Defaults for all aspects of the document layout are set by the document classes. The default spread is 1. The following command produces a document with double spacing: \linespread{1. you can use the \linespread command in the preamble. An alternative and more flexible way to control the linespacing is to use the package setspace. To get block paragraphs. either leave a blank line or use the control sequence \par. include in the preamble the commands: \parindent=0in \parskip=8pt % this is variable. The package also defines a new environment called singlespace.

\raggedbottom allows the height to vary a bit from page to page.right=1in. The following examples should be obvious: \usepackage[margin=1in]{geometry} % 1 inch margins all around \usepackage[left=1.\doc\latex\geometry\.) If you want indented paragraphs.5 inches. you must specifically request it (i..5 inch at the top of the page for a header and about . 3. Therefore. This package has many options and extensive documentation in manual.pdf found in your directory .6 inch at the bottom of the page for a footer.2in.. if using twoside) right margin change the command \topmargin \textheight \oddsidemargin \evensidemargin \textwidth A L TEX also leaves .14 ♦ Chapter 3. Vertical justification is controlled by using either \flushbottom or \raggedbottom. Document Layout 3.4 Margins Changing default margins. you need to know that internally top and left margins are set in reference to a value of one inch (which means that setting these margins equal to 0 produces one-inch margins). is not as easy as you might think. L TEX justifies your text horizontally so that both left and right margins are smooth. \setlength{\topmargin}{-. The opposite margins (bottom and right) are determined indirectly by setting the height (textheight) and width (textwidth) of the text area.top=1in.5 in \setlength{\oddsidemargin}{0in} % left margin is 1 in on right pages \setlength{\evensidemargin}{0in} % same for left pages. you can use the declaration: \raggedright Note that this has the side-effect of wiping out the paragraph indentation. 2-sided document \setlength{\textwidth}{6. The values below leave one inch between the paper edge and the text on all four sides. adding extra vertical space if necessary. (It assumes you want everything flush left. The best way to control margins is to use the geometry package. If you prefer “ragged right” text. You must take this into account when choosing values for topmargin and textheight. \parindent=1. \flushbottom is the default for the book class and for the twoside option in the article and report classes.5in} % leaves 1 in for right margin \setlength{\textheight}{9in} % 9 inches reserved for the text April 2007 .8in]{geometry} If you really want to do it manually. otherwise \raggedbottom is the default.bottom=. to set margin top margin bottom margin left margin (for odd pages or single sided) left margin (for even pages.5in} % top margin is .5em) after the \raggedright declaration. \flushbottom makes all text pages the same height. setting topmargin to -.e. which depend on the class and the font size.3 Text Justification A By default..5in produces a top margin of .

\doc\latex\fancyhdr\. This is the default page style for the article and report document classes. and markright is used for one-sided: \markboth{leftheader }{rightheader } \markright{rightheader } \thispagestyle{style}: Changes the page style for the current page only. include the following commands in the preamble: \usepackage{fancyhdr} \pagestyle{fancy} For simple use. there is a package called fancyhdr that allows you to customize your headers and footers in an easy way. If the above pagestyle commands don’t do what you want. To suppress the horizontal line drawn by default under the header. These commands also set the page number to 1. Academic and Research Computing. \pagestyle{headings}: The page number and current section heading (the level of the heading is determined by the document class) is put in the head. For example. There are four standard page styles: \pagestyle{plain}: The page number is in the foot and the head is empty. appear in the head or the foot. All the classes (except letter) print at least the page number by default. \chead{}. Footers. If you don’t like the default action of the document class. Header and footer material. RPI . It is common to put \pagenumbering{roman} before the text begins and \pagenumbering{arabic} after the first \chapter command. You can also specify arabic (the default) or roman page numbering either in the preamble or in the text. such as page numbers and/or section titles.3. This command is often placed just after a \chapter or a similar command. and center). multiline headers and footers. cfoot{}.. and more.5 Headers. \pagestyle{myheadings}: Similar to the headings page style. \lfoot{}. right. you can determine what goes into the head and foot by using the pagestyle command. use \renewcommand{\headrulewidth}{0pt}.5 Headers. This is the default for the book class..pdf in your directory . the body and the foot. You can change the page number counter yourself with a command such as \setcounter{page}{2}. \rfoot{}. the foot is empty. To use it. supplying your text inside the {} in each case: \lhead{}. Footers. \rhead{}. use \thispagestyle{empty}. and Page Numbering The output page consists of the head. With this package you can define three-part headers and footers (left. For more information. separate headers and footers for even and odd pages. to have nothing in the head and foot for the current page without affecting the style for the rest of the pages. \pagestyle{empty}: The head and foot are both empty. markboth is used for two-sided documents. see fancyhdr. and Page Numbering ♦ 15 3. except you specify the information (other than the page number) that goes in the head by using the markboth and markright commands. you need only to include the following 6 commands in your preamble.

headings made with the lowest level headings. if a heading is too long to fit nicely into the table of contents.Chapter 4. It divides a very large document into parts. The sectioning commands are: \part \chapter \section \subsection \subsubsection \paragraph \subparagraph Note that the \chapter command is not available in article class. you can provide a shorter version as an optional argument: \section[A short heading for the TOC]{This is a much longer heading that will appear in the text of the document} You can make less formal headings by using the sectioning commands with a star (*) appended to the command names listed above. In this case. 4. or special placement on the page. \paragraph and \subparagraph. and does not affect the numbering used for the other headings. larger typesize. For example. to make a section heading called “Introduction” that is not numbered and does not appear in the table of contents. However. are not numbered by default. providing the section A name. If you include the command \tableofcontents at the beginning of your document.1 Section Headings Since documents of any length are usually divided into sections. the classes article. The \part heading is rarely used.) Normally section headings appear in the table of contents exactly as they do in the text. indentation. report.) and numbering them appropriately. the section headings will not show up in the table of contents and will not be numbered. The author uses these commands in the proper order. A L TEX takes the section headings and page numbers from the previous run of the document and inserts a table of contents at the place the command was issued. (Note that A you need to process the document through L TEX twice to ensure an up-to-date table of contents. there will always be certain sections that require special treatment— such as a different size of type. and L TEX takes care of formatting the headings (boldface. In most document classes. and book have a set of commands which take the name of the section as an argument. Within the Text Within the text. Some specialized areas of text (particularly those that require indentation) are formatted with A the help of L TEX environments. etc. use the command: \section*{Introduction} 16 .

Academic and Research Computing. usually the default Roman family... use sparingly Upright shape. For example: {\small This type will be small} produces This type will be small... \normalsize is 12 points. used for posters.. usually changes to italic \textbf{.} \textsl{.. braces) to delimit the range of their action. fixed-pitch characters Use for emphasis.} boldface \textmd{.} typewriter \emph{. Therefore \normalsize means 10 points for a document in which no size option has been included. etc.} roman \textsf{. the command \textbf{\textit{This is bold italic}} produces: This is bold italic. and therefore they are usually used within a group (i. often used for headings Medium series. Typewriter family. a bit different from italic Small caps shape.2 Changing Type Style and Size ♦ 17 4. provided the font thus requested actually exists. To change both type size and style at the same time... RPI . The following commands cause subsequent output to be printed in a different type size.. usually the default Boldface series. This document is printed in 12 points.} italic slanted Small Caps upright Italic shape.} emphasized These commands can be combined..) \normalsize \small \footnotesize \scriptsize \tiny normal size small smaller than small smaller still tiny \large \Large \LARGE \huge \Huge large larger larger still huge hugest The size-changing commands are declarations.. commands can be used together. so in this case. used mostly for emphasis Slanted shape.} \textup{.. For example..2 Changing Type Style and Size Sometimes you may want to change the style or size of text that is not a section heading..} \textsc{..4. They are both the largest size—25 points.} sans serif \texttt{.. For example... the command \textbf{\large This will be big and bold} produces: This will be big and bold. there is no difference between huge and Huge. A The following L TEX commands change the style of the text you supply as an argument: \textit{.. usually the default Sans Serif family. The actual size produced by each command depends on the initial point size selected for the document. The default document size is 10 points.. (Note that when normalsize is 12 points.} medium \textrm{.e..

18 ♦ Chapter 4. Within the Text

4.3

Starting New Lines and New Pages

A Normally L TEX decides where to start a new line and a new page, always trying to pick the most aesthetically pleasing break points. But sometimes you want to force the start of a new line or page. The command \\ will force a new line. For example,

This will be on one line\\ this will be on the next line If you want extra space between two lines, do not use two \\ commands in a row. Instead use an optional parameter (given inside square brackets) to specify the amount of blank space. For example, the following command will leave an extra space of 10 points between the lines: This will be on one line\\[10pt] this will be on the next line To force a new page, the simplest command is \newpage, which starts a new page immediately. There is also the command \clearpage, which acts like \newpage except that it also forces any leftover figures or tables to print before starting the new page. With the twoside documentclass option, the command \cleardoublepage produces a blank page, if necessary, to ensure that the new page starts on a new sheet of paper.

4.4

Leaving Horizontal and Vertical Space

The commands \hspace and \vspace leave horizontal and vertical space in your text. Both commands take a mandatory parameter—the amount of blank space you want to leave. For example, \vspace{3in} will leave 3 inches of blank space in your text. If vertical space is requested in the middle of a paragraph, the space will appear after the current line has ended. Space requested by the \hspace and \vspace commands disappears if it falls at the beginning or end of a line or page. To create space that remains no matter where it falls, use the variations \hspace* and \vspace*. For example, the following lines: This text starts at the left margin\\ \hspace*{1in}This text starts a new line after a one-inch space produces: This text starts at the left margin This text starts a new line after a one-inch space

4.5

Drawing Rules
\rule[lift]{width}{height}

To draw a line (horizontal or vertical) on the page, use the \rule command:

width is the horizontal dimension, height is the vertical dimension, and the optional parameter lift is the amount raised above the baseline. For example, the line below was drawn with the command \rule{\textwidth}{1pt}. April 2007

4.6 Footnotes ♦ 19

4.6

Footnotes

A Footnotes are numbered automatically by L TEX. The command \footnote{footnote text} should be placed exactly where you want the footnote number to appear, with no extra space between the \footnote command and the text before it. For example:

This is text with a note.\footnote{This is the note text. Here it is at the bottom of the page.} produces: This is text with a note.2

4.7

Centering

If you have only one line to center, it’s easiest to use the plain TEX command \centerline; for example, \centerline{This line will be centered}. If you have several lines to be centered horizontally, the center environment is convenient. The example below produces three lines, each horizontally centered. \begin{center} This is line one. \\ This is line two. \\ This is line three. \end{center} There is also the declaration \centering, which is always used within a group—either a pair of braces or an environment. This is useful when you don’t want the extra vertical space surrounding the center environment.

4.8

Quotations
The quote environment begins a new line and indents text from both sides. It is delimited with \begin{quote} and \end{quote}. Any special effects (such as changes to the type size or style) started within the quote environment are terminated by \end{quote}. New paragraphs are block style: that is, no indent and a blank line as separation. This section is inside a quote environment.

There is also a very similar environment called quotation. The only difference is that paragraphs in the quotation environment are indented with no blank line between.
2

This is the note text. Here it is at the bottom of the page.

Academic and Research Computing, RPI

20 ♦ Chapter 4. Within the Text

4.9

Reproducing Text As-Is

To reproduce new lines and spaces exactly as they are in your input file, you have a choice of several methods. The verbatim environment prints its text in typewriter-style type and sets it off from the rest of the document with blank lines before and after. (It does not indent.) To use it, surround the text with the commands \begin{verbatim} and \end{verbatim}. The A only L TEX command obeyed inside this environment is \end{verbatim}. For example, the following input \begin{verbatim} All spacing is displayed in verbatim as entered. So are special characters ! @ # & * ( ) _ } ] \ | > < verbatim is used to display LaTeX commands in this document. \end{verbatim} produces: All spacing is displayed in verbatim as entered. So are special characters ! @ # & * ( ) _ } ] \ | > < verbatim is used to display LaTeX commands in this document. A variation on the verbatim environment, called the alltt environment, is provided by a package. It is used in the same way as the verbatim environment and works the same, in that spaces and lines are retained from the input file. The difference is A that L TEX commands are recognized inside this environment. It cannot be used to A reproduce L TEX commands, but it is very useful if you want to print in roman or italic type instead of typewriter. Before you can use this environment, you must include the command \usepackage{alltt} following the \documentclass command. If the text is short enough to be contained on one input line and should not be set off, you can use the \verb command. For example, \verb+This is inside the \verb command+ produces: This is inside the \verb command Note that the “+” is used here to delimit the verbatim text. Any character except the “*” can be used as the delimiter.

April 2007

RPI . the itemize environment puts a bullet in front of each item. Example of Enumerate \begin{enumerate} \item Sugar \item Cream \item Chocolate \end{enumerate} Example of Itemize \begin{itemize} \item Mix all ingredients together. The following examples show both the output and the input used to create them. \end{itemize} Example of Description \begin{description} \item[dog] A loving animal that likes to sleep on the furniture. • Stir and cool.10 Lists A The three L TEX list environments all use the \item command to start new items in the list. description (uses words) Academic and Research Computing.10 Lists ♦ 21 4. gives great rides. enumerate (uses numbers) 2. \end{description} 1. Below is an example of nesting list environments: Here are some useful environments: \begin{itemize} \item center environment \item quote environment \item the three list environments: \begin{enumerate} \item enumerate (uses numbers) \item itemize (uses bullets) \item description (uses words) \end{enumerate} \end{itemize} Here are some useful environments: • center environment • quote environment • the three list environments: 1. Cream 3. cat Aloof creature that can warm your feet on a winter’s night horse Large animal. \item Stir and cool. luckily doesn’t sleep on the furniture. \item Boil until the thermometer reaches 112 $^\circ$C. itemize (uses bullets) 3. Chocolate • Mix all ingredients together. • Boil until the thermometer reaches 112 ◦ C.4. luckily doesn’t sleep on the furniture. The enumerate environment numbers items sequentially. dog A loving animal that likes to sleep on the furniture. Sugar 2. Eats a lot. gives great rides. \item[cat] Aloof creature that can warm your feet on a winter’s night \item[horse] Large animal. Eats a lot. and the description environment puts a boldface word or phrase in front of each item.

or A equations. numbers. see section~\ref{sec:xrefs} on page~\pageref{sec:xrefs}. It can be helpful. within an equation environment. fig: for figures. or other A characters (except for L TEX’s special list of characters). tables. there are often cross references to sections.11 on page 22. Within the Text 4. but not necessary. figure.) The \label command should be placed immediately after a sectioning command. etc. or inside a figure or table environment immediately following the caption command. \label{marker } \ref{marker } A Note that L TEX uses the numbers from the . of the corresponding \label command \pageref{marker } include the page number of the corresponding \label command marker is an identifier that you choose—it may contain letters.22 ♦ Chapter 4.11 Cross References In longer documents. L TEX provides the following commands for cross referencing: set a marker for future reference include the number of the section.aux file produced by the previous run. For information on cross references. so it will take two runs (sometimes more) to get the cross references correct. figures. see section 4. etc. to start the marker name with a tag that identifies what is being marked: for example. \label{sec:xrefs} For information on cross references. (See the example below. April 2007 . eqn: for equations. sec: for sections.

these tables cannot be broken across pages because L TEX reads in the entire table at once to establish correct column widths. Often material inside a tabular environment is placed inside the table environment.1 Tabbing \= Set a tab stop \> Move right to the next tab stop \\ Terminate a line Tabbing uses the following commands: Tabs are usually set in the first line but may also be added in later lines. which uses \begin{tabular}.Chapter 5. 5. . see Chapter 8. . \end{tabbing}. Tabular Material A There are two environments in L TEX for formatting tabular material: the tabbing environment. you can specify the alignment of each column and use horizontal and vertical A lines. Note that the last entry does not require a \\ to end the line. Example 1: A Very Simple Case \begin{tabbing} Column 1 \= Column 2 \= Column 3 \= Col 1 \> Col 2 \> Col 3 \> Col 4 \\ one \> two \> three \> four \end{tabbing} Produces: Column 1 Column 2 Column 3 Column 4 Col 1 Col 2 Col 3 Col 4 one two three four 23 Column4 \\ . The tabular environment allows you to construct a much fancier looking table: for example. However. Page breaks within the tabbed material are allowed since each line is processed individually. \end{tabular}.. Tab stops may be reset on any line. which ensures that if it can’t fit at the current location it will be “floated” to an appropriate location. Below are two examples of tabbing. For information on using the table environment. The tabbing environment works in a manner similar to a typewriter—you set the tabs and then move from one to another. . . and the tabular environment. which uses \begin{tabbing}. A special line ending with the command \kill may be used to set tabs but not print the line.

): \begin{tabular}{align} You may substitute any combination of the following symbols for the align argument: l c r p | || Left-justified column entry Centered column entry Right-justified column entry Paragraph column entry Vertical rule column Double vertical rule column The width necessary for each column is determined automatically from the widest entry. etc. and \hline to insert a horizontal line. April 2007 . Tabular Material Example 2: A Little More Complex \begin{tabbing} \hspace{2in} \= \hspace{2in} \= \kill First column \> Second column \> Third column \\ \> Second \> Third \\ \hspace{1in} \\ % make a blank line This Text extends past tab 1 \>\> Third column \\ \> Text spans columns two and three \\ xxxxxxxx \= xxxxxxxx \= xxxxxxxx \= \kill % set up new tab stops Col 1 \> Col 2 \> Col 3 \> Col 4 \end{tabbing} Produces: First column Second column Second Third column Third This Text extends past tab 1 Third column Text spans columns two and three Col 1 Col 2 Col 3 Col 4 5. Note that you can center a table by enclosing the tabular environment inside a center environment.2 Tabular The tabular environment requires an additional argument that specifies the alignment of each column (centered. The following examples illustrate the tabular environment.24 ♦ Chapter 5. \\ to end each line (except the last one). left justified. Inside the tabular environment. use the tab character (&) to move to the next column.

lines \hline % draw horizontal line Name & Oblateness & Diameter \\ \hline Mercury & 0 & 3.100 1/14 32.700 \\ Saturn & 1/9.700 1/297 7.700 1/9.100 1/40 27.5 75.600\\ \hline \end{tabular} \end{center} Produces: Name Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune Pluto Oblateness Diameter 0 3.200 \\ Jupiter & 1/15 & 88.100 \\ Uranus & 1/14 & 32. RPI . ctr.700 ? 3.927 \\ Mars & 1/192 & 4.100 \\ Neptune & 1/40 & 27.200 1/15 88.100 \\ Venus & 0 & 7.600 Academic and Research Computing.2 Tabular ♦ 25 5.700 \\ Earth & 1/297 & 7. right).927 1/192 4.100 0 7.2.5.700 \\ Pluto & ? & 3. vert.5 & 75.1 A Simple Ruled Table \begin{center} \begin{tabular}{|l|c|r|} % 3 cols (left.

It will wrap around to the next line if necessary.2 Using Paragraph Columns. which has the same effect as the center environment. pos specifies the alignment of the item.5 inches wide \\ \hline Column 1 & Column 2 & This text is a paragraph. This example is inside the table environment. Column 1 Column 2 The paragraph column April 2007 . (The centering action will be confined to inside the table environment. Tabular Material 5. This command has the form: \multicolumn{n}{pos}{item} where n is the number of columns to be spanned. In this example. Spanning Columns The following example illustrates making paragraphs within a table and placing text across multiple columns using the \multicolumn command. you can use the declaration \centering. \\ Column 1 & Column 2 & The paragraph column \\ \hline \end{tabular} \end{table} Table 1: More Things You can Do With Tabular Text in columns 1 and 2 A paragraph 2. on page 37) and also provides the opportunity to supply a caption. and item is the text. To center tabular material inside the table environment.) \begin{table}[hb] % place table ‘‘here’’ or at bottom of page \centering \caption{More Things You can Do With Tabular} \bigskip \begin{tabular}{|l|l|p{2.26 ♦ Chapter 5. the optional parameter [hb] specifies that the table should appear “here” or at the bottom of the page.5in}|} \hline \multicolumn{2}{|c|}{Text in columns 1 and 2} & A paragraph 2. It will wrap around to the next line if necessary. which ensures that the table will be “floated” rather than broken across a page (see chapter 8.5 inches wide Column 1 Column 2 This text is a paragraph.2.

which replaces the usual intercolumn space with whatever you put inside the curly braces. Therefore.” will be placed between columns.3 A L TEX allows you to change the column separator with the command @{...2.5. When you enter the data..3 Aligning on the Decimal Point A Although L TEX does not provide a way to align numeric columns on a decimal point. indicating no space should be inserted: \begin{tabular}{@{} l @{}} \hline no leading or trailing space\\ \hline \end{tabular} no leading or trailing space \begin{tabular}{l} \hline leading space left and right\\ \hline \end{tabular} leading space left and right 3 A For an another method. if you use @{.46 π π (π ) 80662.1416 π π 36. The example below illustrates how to do this.7 Suppressing Leading or Trailing Space Another creative use of the @{.} command is to suppress leading or trailing space in a table.}.2 Tabular ♦ 27 5.2..4 Pi expression Value π 3. RPI . Academic and Research Computing. it is possible to accomplish this by using two columns (the first right-aligned and the second left-aligned) and changing the column separator to be a decimal point.} in the \begin{tabular} line. see the dcolumn package. In this case the command would be @{}.} l} Pi expression & \multicolumn{2}{c}{Value} \\ \hline $\pi$ & 3&1416 \\ $\pi^{\pi}$ & 36&46 \\ $(\pi^{\pi})^{\pi}$ & 80662&7 \\ \end{tabular} 5. a “. provided as part of the L TEX “tools” bundle. you must replace the decimal point in your numbers with a column separator (&). \begin{tabular}{c r @{.

28 .\doc\latex\amslatex\.. This environment can be invoked in one of three ways: $ .. the amsmath package provides additional environments for buildA ing mathematical expressions. then the two roots are conjugate complex numbers. then there are two real and equal roots.org/pub/tex/doc/amsmath/short-math-guide. If $d>0$. you may A want to look at AMS-L TEX. \) \begin{math} . mathematical symbols. so be sure not to leave any blank lines. then the two roots are conjugate complex numbers. These are listed in Appendix A of this memo. To A make it easier to enter mathematical text. If your mathematical expressions are particularly complex or sophisticated.ams.pdf. if you want to use normal text or retain spaces while in math mode. which are described below. all letters A are set in the math italic typeface. Also. if $d=0$. L TEX sets type differently than when in text mode. Mathematics A One of the greatest strengths of L TEX is its ability to typeset formulas and equations. The official documentation is amsldoc. a collection of packages that provides extensions to A L TEX’s mathematical capabilities.pdf. Typically such mathematical formulas are roughly the same size as the text they’re embedded in. .Chapter 6. delimiters. . $ (Used in plain TEX) \( . The amssymb package provides additional mathematical symbols. which you can find on your system in . then there are two distinct real roots. If d > 0. A L TEX has several modes for setting math text. For example. and operators. Therefore.1 In-line Math A L TEX’s in-line math environment allows you to place mathematical formulas in the midst of ordinary text. if d = 0. at: ftp://ftp. L TEX has defined several hundred Greek symbols. then there are two distinct real roots. and if d < 0. see The Short Math A Guide for LTEX.. .4ac}$. For help with using AMSL TEX. produces: The quadratic equation ax2 + bx + c = 0 has two roots whose nature depends on the √ sign of the discriminant d = b2 − 4ac. \end{math} The following paragraph is typical of the use of in-line math: The quadratic equation $ax^2+bx+c = 0$ has two roots whose nature depends on the sign of the discriminant $d = \sqrt{b^2 . and if $d<0$. then there are two real and equal roots. When in A math mode. 6. you must enclose this text with an “mbox”: \mbox{this is normal text}. new paragraphs are not allowed within math mode. and spaces in the input are ignored because L TEX uses its own “mathematically correct” spacing.. .

Like inline math. . . \documentclass[fleqn]{article}. . \end{equation} as illustrated below: The derivative of the function $f(x)$ at the point $x_0$ is \begin{equation} f’(x_0) = \lim_{x \rightarrow x_0} \frac{f(x) . \] \begin{displaymath} . (For left-side numbering. . produces: The quadratic equation ax2 + bx + c = 0 has two roots √ −b ± b2 − 4ac x= 2a where the nature of the roots is determined by the sign of the discriminent b2 − 4ac. displaymath can be invoked in one of three ways: $$ . .f(x_0)}{x .) The environment is invoked with \begin{equation}. $$ (Used in plain TEX) \[ .x_0} \end{equation} produces: The derivative of the function f (x) at the point x0 is f (x0 ) = x→x lim 0 f (x) − f (x0 ) x − x0 (1) Academic and Research Computing. \end{displaymath} The next paragraph illustrates the solution to the quadratic equation: The quadratic equation $ax^2 + bx + c = 0$ has two roots \[ x = \frac{-b \pm \sqrt{b^2 .2 Display Math (for unnumbered equations) The displaymath environment puts space before and after equations and centers them by default. RPI . . .4ac}}{2a} \] where the nature of the roots is determined by the sign of the discriminent $b^2 .6. include leqno as an option to the \documentclass command. . 6.2 Display Math (for unnumbered equations) ♦ 29 6. include fleqn as an option in the documentclass command: for example.3 Equation Environment (for numbered equations) The equation environment is exactly like the displaymath environment except that an equation number in parentheses is placed to the right of the displayed formula. For left-justified equations.4ac$.

split. etc) and is highly recommended.30 ♦ Chapter 6.g. gather. The amsmath package provides additional environments for formatting multiline equations (e. and the third left-justified. Mathematics 6. 2. It is used mainly for displaying multi-line formulas. (Or you can use the alternative environment eqnarray*.b^2 \label{eq:simp2} \\ (a + b)^3 & = & a^3 + 3a^2b + 3ab^2 + b^3 \label{eq:simp3} \end{eqnarray} The results after simplification are shown in equations \ref{eq:simp1}.b) & = & a^2 . produces: These three products can be expanded and simplified to produce these equations: (a + b)(a + b) = = (a + b)(a − b) = = 3 (a + b) = a2 + ab + ba + b2 a2 + 2ab + b2 a2 − ab + ba − b2 a2 − b 2 a3 + 3a2 b + 3ab2 + b3 (1) (2) (3) The results after simplification are shown in equations 1. \ref{eq:simp2}.ab + ba . These three products can be expanded and simplified to produce these equations: \begin{eqnarray} (a + b)(a + b) & = & a^2 + ab + ba + b^2 \nonumber \\ & = & a^2 + 2ab + b^2 \label{eq:simp1} \\ (a + b)(a . Note that you can use the \label and \ref commands to refer to equation numbers in the text.) The following example illustrates this environment. the second centered. align. with the first column right-justified. It numbers each line by default. April 2007 .b^2 \nonumber \\ & = & a^2 . but you can include the command \nonumber on any line to suppress the equation number. which does not number any lines.. and \ref{eq:simp3}. and 3.4 Eqnarray Environment (for multiline equations) The eqnarray environment builds a three-column array of numbered equations.

n} a1.2} & a_{2.) ♦ 31 6. RPI . matrices. . etc. etc.1 a2.1} & a_{1.n .n       (4) Section 6.2 . . .2} & \vdots & \vdots & a_{m. array is the math equivalent of tabular and uses the same syntax. Here is an example of the array environment used to build a 5 × 5 magic square: \[ \begin{array}{ccccc} 17& 24& 1& 8& 15\\ 23& 5& 7& 14& 16\\ 4& 6& 13& 20& 22\\ 10& 12& 19& 21& 3\\ 11& 18& 25& 2& 9 \end{array} \] produces: 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 Here is an example for a general matrix: \begin{equation} A = \left( \begin{array}{cccc} a_{1.1} & a_{m. . . etc.6. . am. .6.) The array environment is not itself a math environment. . .n} \\ a_{2.n .1 .n} \\ \vdots \\ a_{m. it must be enclosed within a math environment of your choosing..1 am.6 (Large Delimiters) on page 34 has more examples of arrays. . Academic and Research Computing. It is used for building rectangular arrays of numbers. . a1. .2 a2. .2 .5 Array Environment (for matrices.2} & \end{array} \right) \end{equation} produces:    A=   \ldots \ldots \ddots \ldots & & & & a_{1. . a2. a1.1} & a_{2.5 Array Environment (for matrices. am. .

6.6. Mathematics 6. and \underbrace are used to build horizontal groups. the symbols ‘ˆ’ and ‘ ’ are used to make superscripts and subscripts. thick space \: medium space \. vertically.3 Dots. the following symbols allow you to add (or subtract) small amounts of space in your equations: \. enclose the characters in braces.32 ♦ Chapter 6. respectively. thin space \! negative space In addition. and \ddots are used to produce a string of three dots on the base line.6 6.j 1 2 F3 1 3 2P 4 2 produces: 6. For example: \begin{eqnarray*} 2^n & = &\overbrace{2\times2\times\cdots\times 2}^{\mbox{n terms}}\\ k\cdot x & = &\underbrace{x + x + \cdots + x}_{\mbox{k terms}} \end{eqnarray*} produces: n terms 2 = 2 × 2 × ··· × 2 k · x = x + x + ··· + x n k terms April 2007 . \cdots. The command \qquad provides twice as much space. Braces. \overbrace. 6. \underline. However. you can make a larger space (about the width of an “M”) with the command \quad. or on the diagonal.1 Building Mathematical Expressions Superscripts and Subscripts In math mode.j} \] _2F^1_3 \] {}_2^1P{}^3_4 \] 22 = 24 = 42 a21 = b2 i i.6. The commands \overline. For example: \[ \[ \[ \[ 2^{2^2} = 2^4 = 4^2 \] a^2_{i_1} = b^2_{i. \vdots.2 Spaces in Math Mode A In math mode. and Bars The commands \ldots. L TEX ignores blanks typed in the input. If more than one character is to be used as a superscript or subscript. on the math centerline.

4142 \qquad c=\sqrt{a^2+b^2} \qquad \sqrt[3]{8}=2 \qquad \sqrt{\frac{n(n+1)}{2}} $$ produces: √ √ a2 + b 2 √ 3 n(n + 1) 2 2 = 1.5 Radicals.6. An optional argument for the radicand allows you to construct cube roots. etc. The sign automatically grows to fit the argument. $$ \frac{a}{b} \qquad \frac{a/b}{c/d} \qquad {a\atop b} \qquad {a\choose b} $$ $$ 1 + 2 + 3 + \cdots + n = \frac{n(n+1)}{2} $$ $$ \lim_{n\rightarrow\infty}\frac{1}{n}=0 \qquad y’’=\frac{d^2y}{dx^2} $$ produces: a b a/b c/d a b a b 1 + 2 + 3 + ··· + n = 1 =0 n→∞ n lim n(n + 1) 2 2 dy y = 2 dx 6. Integrals. These symbols are often used with superscripts and subscripts: $$\sum^{\infty}_{n=1} \qquad \int^b_a e^{x^2}\. its two arguments are the numerator and denominator. and Summations The \sqrt command creates a square root sign for its mandatory argument. nth roots.dx $$ $$\sqrt{\sum_{i=1}^{n}i} \qquad \sum_{\stackrel{i=1}{j=2}}^{\infty}$$ $$\sum \Delta V=\int\!\!\!\int\!\!\!\int_V dv $$ produces: ∞ n=1 n b a ∞ 2 ex dx i i=1 i=1 j=2 ∆V = V dv Academic and Research Computing.6 Building Mathematical Expressions ♦ 33 6. RPI . Two variations of a fraction are provided by the plain TEX commands \atop and \choose.4 Fractions The ‘/’ can be used to make simple fractions.6. and summation signs are produced with the \sum command.6. but the \frac commmand is used for most fractions. as these examples show: $$ \sqrt{2}=1.4142 c= 8=2 Integral signs are produced with the \int command.

. use \{ and \}). . Below are two examples of large delimiters. \] produces: signum(x) =    c1 c2 c3 . You can even use a period to create an invisible delimiter—very useful if you need an odd number of delimiters. . . . .5 on page 31. Mathematics 6. (For another example. c2n 1 if x > 0 0 if x = 0   −1 otherwise April 2007 . . . .6. . \] produces: c0 c1 det = c2 . c2 c3 c4 . See Appendix A for a complete list of delimiters. . see Section 6. .6 Large Delimiters The commands \left and \right are used to put large delimiters (such as ( ) [ ]) in displayed formulas. (For braces. > 0. cn . cn cn+1 cn+2 . although the left and right delimiters need not be the same type.) \[ \mbox{det} = \left| \begin{array}{lllll} c_0 & c_1 & c_2 & \ldots & c_n \\ c_1 & c_2 & c_3 & \ldots & c_{n+1} \\ c_2 & c_3 & c_4 & \ldots & c_{n+2} \\ \vdots & \vdots & \vdots && \vdots \\ c_n & c_{n+1} & c_{n+2} & \ldots & c_{2n} \end{array} \right| > 0. . \[ \mbox{signum}(x)=\left\{ \begin{array}{rl} 1 & \mbox{if $x>0$} \\ 0 & \mbox{if $x=0$} \\ -1 & \mbox{otherwise} \end{array} \right. . cn+1 . . . . Large delimiters are often used with the array environment.34 ♦ Chapter 6. cn+2 . There must be a \right for every \left and vice versa for each output line.

acceptable formats are pdf. such as Maple.1 Including Graphics Creating the Graphics File A The easiest way to put graphics into your L TEX document is to first create the graphic using a software package. If you are using A pdfL TEX (which produces a pdf file directly). 7. you should save the graphic as encapsulated PostScript (eps).jpg > image. the only acceptable format. you will have two files for your graphic. graphs. jpeg. but not eps. The extended package. which is most likely on your system. if not. A general rule of thumb for graphics formats is to use pdf or eps for vector graphics (line art. etc). A If you are using L TEX plus dvips to produce your final output. graphicx. 7. the jpeg2ps utility is handy. Gnuplot. A If you are using L TEX plus dvips.eps or myfigure. A If you are using pdfL TEX and your graphics files are in eps format.ctan. CorelDRAW. you can download it from: http://www. It converts JPEG images to eps files without uncompressing the images.2 A Importing the Graphic into your L TEX Document LaTeX’s standard graphics bundle includes two packages for importing graphics: graphics and graphicx. provides a more convenient method of supplying parameters and is recommended.org/tex-archive/support/jpeg2ps/. open a command window and cd to the appropriate folder): epstopdf myfigure. at the spot you want to insert the graphic (named for example. Matlab.eps You may already have jpeg2ps on your system. for example: 35 . and png for screen shots. So.edu/dept/arc/training/latex/Examples/graphics. or png.eps generates myfigure. jpeg for photographs. The JPEG data is simply “wrapped” with PostScript. etc. you can convert them to pdf using the epstopdf utility. yielding considerably smaller PostScript files. Xfig.pdf) use the \includegraphics command.rpi.pdf . You can also use a Windows application such as Word or Excel to create an eps (Encapsulated PostScript) file by printing to a file following certain steps. described in http://www. which allows you to specify the name of the graphic file as well as supply optional arguments for scaling or rotating. Use it from the command line: jpeg2ps -h image.pdf After doing this. myfigure. Run this program from the command line (in Windows. Therefore first step is to put in your preamble the command: \usepackage{graphicx} This package defines a new command called \includegraphics. one eps and one pdf.Chapter 7.

pdf.4. it only contains commands that the printer driver. Complete documentation for the graphics bundle is in the file grfguide. see Using Imported Graphics in LTEX and pdfLTEX by Keith Reckdahl of Stanford University. you can specify a number of optional arguments. To see a correct display. but rotated material may not display properly in the dvi preview. scale=. it is important to note that A after running L TEX. Information on the graphicx package is in section 4. run dvips to make a PostScript file and then use GSView/ghostview to view it.org/tex-archive/info/epslatex. look for it on your system. The \includegraphics command also provides optional arguments for scaling or rotating the figure.ctan. subsequently uses to include the graphics when making the PostScript file.3 Viewing the Output A If your graphics files are in pdf..pdf. the height will be scaled so that the figure remains in proportion. In the example above. Including Graphics note filename extension is omitted \includegraphics[width=4in]{myfigure} If you want to be able to process your file using either latex or pdflatex. or png file. (angle=90 rotates 90 degrees counter-clockwise.dvi file does not actually contain the eps graphics. you’ll need to have your graphics files in both eps format and one of the others. Inside the [.. such as pdf. Then omit the filename extension on the \includegraphics command: latex will look for an eps file. (scale=2 makes the graphic twice as large as its natural size. The most commonly used arguments are: width scale graphic to the specified width (aspect ratio preserved) height scale graphic to the specified height (aspect ratio preserved) scale scale graphic by scale factor.. 7. April 2007 . separated by commas.width=\textwidth]{myfigure} Usually the includegraphics command is put inside the figure environment.) Note that in the following example. The figure environment is described in chapter 8. Since no height is specified. It includes all you would ever want to know with many examples: http://www. width=4in will scale the width of graphic to four inches.36 ♦ Chapter 7. Most dvi previewers try to display eps files (ususually by calling on ghostscript). A positive number indicates the counter-clockwise direction. which allows the image to move or “float” to another location so that it is never split between pages. you can run pdfL TEX and view the result with Acrobat or GSView.5 makes it half as large. If your files are eps.) angle rotate graphic by specified number of degrees. and pdflatex will look for a pdf. jpeg or png formats. jpg. the resulting . the graphic is first rotated counter-clockwise by 90 degrees and then scaled to a width that will just fit within the margins: \includegraphics[angle=90.]. For an extensive A A treatment of including graphics. dvips.

figure material . .).. which move or “float” the material inside the environment to a location A where it all fits. page: on a special page containing only floats.. bottom: at the bottom of a text page. To accomplish this. it will try to place the figure or table on a page containing only floated material (no text). In fact.1 Making a Caption The floated material usually includes a numbered caption. However.. To print out such a list at the beginning of 37 .. you’ll want to make sure that they are A not broken across pages. top: at the top of a text page. Placing Figures & Tables (Floats) If you have figures or tables in your document. they only ensure that whatever material is inside the environment gets “floated” and is not broken between pages. \end{figure} \end{table} There are also “starred” versions of these environments (table* and figure*). in 2-column text. you can supply a caption with the command \caption{caption text}. the caption prefix is the only difference between the figure and table environments. The table environment prefixes the caption text with “Table n:” A (where n is the number of the table supplied by L TEX). then the top of the next page.. figure and table. Note that these environments have nothing to do with actually preparing your figures or tabular material (discussed in chapters 5.. The possible positioning parameters are: h t b p here: at the place in the text where the environment occurs.. for example. then the top of the next page. L TEX first tries to put the figure or table at the top of the current page. L TEX fills the current page with text to avoid half empty pages. A To place the floated material. and 7. if you begin a table: \begin{table}[htp] A L TEX will first try to place the table “here”—that is. Usually the caption for a table is typed above the table and the caption for a figure below the figure. which.. Within the figure or table environment. at the spot you gave the \begin{table} command. If it doesn’t fit there.Chapter 8. Failing that. Usually. Meanwhile. 8. if you wish. it next tries the bottom of the current page. place floats across both columns. The commands to use these two environments look like: \begin{figure} \begin{table} . and finally on a page containing only floats (which often means on a page by itself). tabular material . The \caption command also supplies information for a List of Figures and/or a List of Tables. the default behavior places the floats satisfactorily. the figure environment prefixes the text with “Figure n:”. L TEX provides two environments. you can supply an optional parameter to specify a list of preferred locations.

38 ♦ Chapter 8. requiring lots of explanation. \begin{table}[htp] \caption{Contract Expenses to Date} \label{tab:exp} \begin{center} \begin{tabular}{lr} Item & Amount\\ \hline Salaries (research assistants.000 \\ Software & \$2.000 \\ Travel expenses & \$8. Placing Figures & Tables (Floats) your document. a table environment A can contain any L TEX commands or text. which allows it to to float to an appropriate spot in the text.000 \\ \cline{2-2} \\[-8pt] Total & \$34. 8.) or any other kind of illustration. a table caption might look like: \caption[A short caption for the list of tables]{This is a very long caption for this table.2 Examples Note that you can put anything inside the figure environment: it can be text. secretary) & \$24. but usually contains tabular material inside the tabular environment (see section 5. If your caption is very long and you do not want the whole thing repeated in the list of figures or tables. Likewise. Note that the \label command must immediately follow the caption command. Note the placement of the \caption and \label commands in this example and the example figure on the next page.2). If it precedes the caption. For example.11 on cross referencing) so that you can refer to your figure or table elsewhere in the document.} You can also use the \label command (see section 4.000 \end{tabular} \end{center} \end{table} April 2007 . the number used in the reference will be incorrect. a diagram. an image (see chapter 7. This table is floated to the top of the next page because there is not enough room for it to be placed “here”. simply place the command \listoftables or \listoffigures after the \tableofcontents command. you can use an optional parameter (specified in square brackets) to supply a shorter version for the List. The example below encloses tabular material in the table environment. It could go on for several lines.

which L TEX places “here” because there happens to be room for it.000 Total $34.eps and cat. A A leaving it up to L TEX or pdfL TEX to find the appropriate file.width=. so that either L TEX or pdfL TEX can be used. There are two versions of the A A image. RPI . cat.6\textwidth]{cat} \caption{A Tipsy Cat} \label{fig:cat} \end{figure} Figure 1: A Tipsy Cat Academic and Research Computing.2 Examples ♦ 39 Table 2: Contract Expenses to Date Item Amount Salaries (research assistants.000 Travel expenses $8.pdf.000 A The following example produces a figure that uses a line drawing of a cat. \begin{figure}[htp] \centering \includegraphics[angle=30.000 Software $2. Note that the \includegraphics command below does not specify an extension on the file name. secretary) $24.8.

it could be pushed to the end of the section or document with all subsequent figures or tables behind it. use the rotating package (in addition to graphicx for images).40 ♦ Chapter 8. section C. This command prints all queued floats and starts a new page. April 2007 . A which you then use in place of the standard L TEX environments figure and table.edu/dept/arc/training/latex/Examples/exrotating. L TEX will try extra hard to place the float where you want it. view the output in the file http://www. The sideways environments always put the landscape table or figure on a page by itself. If you want to include many figures or tables together.g.pdf. If you find that your A table or figure is not appearing where you think it should. including the caption.edu/dept/arc/training/latex/Examples/exrotating. A Full documentation for the rotating package is in the book. without intervening text. because if the float cannot be placed where you specified. For example.rpi.tex contains examples of using both the graphicx and the rotating packages to include landscape figures and tables. sidewaysfigure and sidewaystable. you can avoid problems by including the command \clearpage after every approximately 10 floats.4 Landscape Figures and Tables To print an entire figure or table. You can override these constraints by including a ! in the optional argument containing A the positioning parameters. L TEX follows certain rules.} \end{sidewaysfigure} The file http://www.rpi. in landscape orientation. Load it in the preamble as usual with the \usepackage command: \usepackage{rotating} This package defines two new environments.9. To see the results after running pdflatex. it could be that L TEX’s constraints on how much of a text page can be taken up by floats are getting in the way. if you use \begin{table}[!htp]. Do NOT give only one possible placement parameter (e. h).3 Overcoming Problems with Float Placement A When placing floated material. A L TEX has room in its memory to hold only a certain number of floats. Placing Figures & Tables (Floats) 8. explained in detail in LamA port’s LTEX User’s Guide and Reference Manual. 8. For example.. to make a landscape page containing a rotated graphic and caption. The LTEX Companion by Mittlebach and Goossens. use commands such as: \begin{sidewaysfigure} \includegraphics{myfigure} \caption{Turn the page sideways to look at this figure.

(Remember to run L TEX twice to get correct numbers in the text!) To include an item in the bibliography without citing it in the text. at the appropriate places. 2004. the commands: \cite{lamport} \cite{kopka} \cite{goossens}. 9. and cite any reference within it.Chapter 9. for example: \nocite{smith. This item is usually a dummy number with as many digits as the highest-numbered entry. For example your document might include. the width of the item in the second pair of braces determines the indent of the entries. However. use the \nocite command. The first entry in the list will be numbered 1. Preparing a Bibliography A L TEX provides built-in support for citing references. Boston. each entry starts with the \bibitem command. \end{thebibliography} 41 . \bibitem{kopka} Helmut Kopka and Patrick W. you may prefer to use BibTEX. \textit{\LaTeX\ -. fourth edition. the first step is to cite various works within your text using the \cite{key} command. MA. Addison-Wesley. using the a special environment called thebibliography. 1994. Addison-Wesley. Note that in the book and report classes.jones}. If your bibliography is large or if you use the same references in several documents. Below is an example of a thebibliography environment. the “9” indicates there are fewer than 10 entries. \textit{The \LaTeX\ Companion}. at the end of the document. a A companion program to L TEX that allows you to store all your references in an external A database file. followed by the output it produces. Both methods are described below. \textit{A Guide to \LaTeX}. et al. use the number 99. you format the bibliography. Boston. Bibliography is used as the chapter title. Within this environment. second edition. 2004. MA. Addison-Wesley. References is used as the section heading.~Daly. The \bibitem commands automatically generate a number in square brackets before each entry.A Document Preparation System}. Reading. which is straightforward and relatively easy to use. key is a reference keyword of your choosing that identifies the work. it’s not very flexible. \bibitem{goossens} Michel Goossens. These commands place numbers (enclosed in square brackets) in the text that match the A numbers automatically generated in the bibliography. In this case. Then. You can then refer to this database in your L TEX document. in the article class. \begin{thebibliography}{9} \bibitem{lamport} Leslie Lamport. sorting the entries as you wish them to appear. MA. If there are 10 or more but less than 100.1 A Using L TEX’s built-in Method To prepare a bibliography the “standard” way. On the \begin{thebibliography} line. second edition. The argument for this command is the same keyword used in the corresponding \cite command in the text. Frank Mittelbach.

L TEX – A Document Preparation System. 2004. which will format the citations according to the style you’ve specified. Frank Mittelbach et al. You do this by including an optional label on the \bibitem command. 2004. A Guide to L TEX. MA. April 2007 .2 9. Frank Mittelbach.bib file are called in your L TEX file with various \cite commands. MA. et al. A [3] Michel Goossens.bib file. fourth edition. If you want to change the heading for the reference listing. just change the value of \refname (for article class) or \bibname (book or report class) by adding a line like this in your preamble: \renewcommand{\bibname}{Literature Cited}. MA. Addison-Wesley. and finally once more to resolve the references.bib.) For example. If you like. AddisonWesley. A just as in the built-in method described above. MA. Addison-Wesley.42 ♦ Chapter 9. Your resulting output will then contain your citations and formatted bibliography.1 Using BibTEX Overview BibTEX automatically generates a list of references from information contained in a bibliographic database—a file you create whose name ends with the extension . Reading. In your L TEX file. A A After processing your document through L TEX (or pdfL TEX) you run BibTEX.2. Boston. and at the point you want the bibliography printed. second edition. Boston. The L TEX Companion. instead of the number assigned by L TEX. Boston. A The entries in your . Addison-Wesley.” its entry in the thebibliography environment would be: \bibitem[companion]{goossens} Michel Goossens. A [2] Helmut Kopka and Patrick W. \textit{The \LaTeX\ Companion}. 1994. 9. You then need to run A A L TEX (or pdfL TEX) again to process the output created by BibTEX. Preparing a Bibliography References A [1] Leslie Lamport. (The \cite command doesn’t change. 2004. Daly. you provide just two more pieces of information: A bibliographystyle command to specify the formatting A style of the citations and the bibliography (this can appear anywhere in your L TEX file). a bibliography command to provide the name of the . you can choose a label to identify the work in both the text and in the A bibliography. to refer to the third book as “companion. second edition. second edition.

Then each field (in any order) uses the format keyword = {data}. When you run L TEX again it will build the bibliography from the . author = {Helmut Kopka and Patrick W. you can tell BibTEX to keep them by using braces around the letters in question. you run the BibTEX program by clicking on the BibTEX toolbar icon (if your editor has one).2.bbl) file A A ready for L TEX to use. There is a prescribed set of fields for each type of document. chapter (in a book). separate them with the keyword “and” so BibTEX can distinguish the different names.bbl file and generate warnings about unresolved references. There are many different document types: book. etc. Academic and Research Computing. address = {Boston.2. title = {Guide to {\LaTeX}}. formatted according to the style you specify. Subsequent runs will resolve the references. volume = "25". @article{Hefferon04.bib File The .2 Using BibTEX ♦ 43 9. paper (in a Proceedings). and each line except the last must end with a comma.tex extension. RPI 9.9. Running BibTEX A A After processing your file with L TEX (or pdfL TEX). Note that the data can be enclosed in either quotation marks or braces. A book entry might look like: @book{Kopka04. pages = "126--127" } The above example refers to an article within a journal.~Daly}. article (in a journal). author = "Jim Hefferon". edition = {fourth}. If the BibTEX style does not preserve all your capitalization (for example within titles).3 . article (in a collection). number = "2". and the warnings will disappear. thesis. year = {2004} } If a work has more than one author. Each entry begins with the document type preceded by the “@” sign.2 Creating the . This is followed by a unique label that you make up and that you will use to cite the entry in your text. title = "{CTAN} for {S}tarters". year = "2004". MA}. The following example of a Bibtex entry illustrates the structure.bib file is a plain text file that you create and edit with any text editor. or by typing the command bibtex followed by the name of your document without the . and stored in a bibliographic (. report. journal = "{TUGB}oat". publisher = {Addison-Wesley}. The information for every document you have cited will be extracted from your database.

One is a book \cite{kopka04}. MA. Guide to L TEX. fourth edition. and the The LTEX Companion. The . that tell BibTEX how to format the information in the . Boston. entries are sorted alphabetically. Preparing a Bibliography Suppose you have a file called myrefs. you need to include its name with the normal \usepackage command in your preamble.bst \bibliography{myrefs} % find references in myrefs. One is a book [2]. and the other is an article in a journal. A There are also various L TEX packages that provide other styles. TUGBoat. In addition to loading the Natbib package in the preamble. journal names are abbreviated. 2004. 9. the same as plain except names. To use one of these packages. [1] References [1] Jim Hefferon. (Some possible choices are “plainnat”.. Daly. you need to use a bibliography style that supports the author-date style. \cite{hefferon04} \bibliographystyle{plain} % use style plain. Addison-Wesley. to the basic \cite command. One highly recommended and flexible package is Natbib. “unsrtnat”. “abbrvnat” and “apalike”. CTAN for Starters.4 Bibliography Styles Bibliography styles are files (with the extension . A [2] Helmut Kopka and Patrick W.. and the labels are made from the author’s or authors’ (or editor’s) name and the year of publication.) Also.bst). month names. then BibTEX then L TEX twice more would be: We are testing the use of BibTEX using two entries. for example: April 2007 . and the file testbib. Natbib uses slight variations of the \cite command: you just append a “t” (for textual) or “p” (for parenthetical). chapter 12.tex contains the following: \documentclass{article} \begin{document} We are testing the use of Bib\TeX\ using two entries. The standard styles are: plain unsrt abbrv alpha entries are sorted alphabetically and are labelled with numbers. such as author-date citations instead of numbers. the same as plain except entries appear in the order in which they were cited.44 ♦ Chapter 9. describes others./bst subdirectory of your TEX installation contains the styles (. 2004. 25(2):126–127.bib that contains the two bibliographics entries above.bib file.bib \end{document} A A The result of running L TEX.2.bst files) inA stalled by default. and the other is an article in a journal.

ctan. J. fourth edition. \bibliographystyle{apalike} % use style apalike.1.bib \end{document} A A produces. You can find both these files at: http://www. W. 25(2):126–127.html A longer. 2004. RPI . after running L TEX.tex file to read: \documentclass{article} \usepackage{natbib} \begin{document} We are testing the use of Bib\TeX\ using two entries. H. chap. then L TEX twice more: We are testing the use of BibTEX using two entries. there is an excellent tutorial by Andrew Roberts: http://www. (2004).pdf An excellent.pdf. Addison-Wesley. Guide to L TEX.~4]{kopka04} Natbib output Hefferon (2004) (Hefferon. 4) Using the same myrefs.net/misc/latex/latextutorial3. One is a book by \citet{kopka04}. 2004) Kopka and Daly (2004. 9. 2004). concise overview of the Natbib package is the file natnotes. more complete document covering both LaTeX’s basic bibliography method and BibTEX is Tame the BeaST by Nicolas Markey: http://tug. and the Natbib manual is in natbib. and the second is an article in a journal \citep{hefferon04}.ctan. A Kopka.bib file as in the previous example. For on-line information on BibTEX.9.5 For More Information A For more information on L TEX’s built-in method and on using BibTEX. see any of the three books in section 9.org/tex-archive/info/bibtex/tamethebeast/ttb_en.2. chapter 4) (see Kopka and Daly. CTAN for Starters. Boston.org/tex-archive/macros/latex/contrib/natbib/ Academic and Research Computing. P.bst \bibliography{myrefs} % find references in myrefs.2 Using BibTEX ♦ 45 Citation command \citet{hefferon04} \citep{hefferon04} \citet[chapter 4]{kopka04} \citep[see][chap. One is a book by Kopka and Daly (2004).pdf. MA. References Hefferon. TUGBoat. and changing the testbib. and Daly. then BibTEX. the second is an article in a journal (Hefferon.andy-roberts. (2004).

and the files for the chapters might be named chap1. it’s convenient to work on the different chapters or sections separately. \includeonly.tex file that contains the \documentclass command. or any document with multiple parts. if you are using TeXLive 2005 on Windows. makeindex.tex file for each section. In the preamble. you’ll find the documentation in: C:\TeXLive2005\texmf-dist\doc\makeindex\base\makeindex. To make an index.tex files that contain the text of the document.chap2} \begin{document} \include{chap1} \include{chap2} \include{chap3} \include{chap4} \include{chap5} \include{chap6} \end{document} % only these files will be processed 10. would look something like: \documentclass{book} \includeonly{chap1. the root file for a book with 6 chapters might be called mybook. For example. To do this. Note that the individual section files do not include \begin{document} and \end{document} commands. and create a “root” . and multiple \include commands. the preamble material.tex.tex. Each \include command starts a new page in your output. place the command: \makeindex 46 . As an example. This memo covers just the basics of MakeIndex.Chapter 10. can be used to select from the \include list only certain file(s) to be processed. 10. create a separate .dvi. thesis.2 Generating an Index A It is relatively easy to generate an index by using L TEX commands combined with the support program MakeIndex.tex.tex. The root file A mybook.dvi.tex. which should be already on your system under the doc folder. the \begin{document} and \end{document} comA mands. which is the file on which you run LTEX. etc. A Suppose your L TEX input file is called myfile. Load the package makeidx with the command: \usepackage{makeidx} 2. chap2.1 Special Topics Managing a Large Document If you are preparing a book. details are in the documentation accompanying the program. which must go in the preamble. you need to do the following things in that file: 1. The \include commands tell L TEX to read the separate . The command.

prints all index entries in the margin of the text. Below is an example of doing the 3-step process from the command line. generate the index by running L TEX.3 Including hyperlinks ♦ 47 3. and hyperlinks from your tables of contents and \cite and \ref references. A The package showidx.idx and produces the file A myfile. it reads in the file myfile.10. which contains all the index entries and page numbers. Put index entries throughout the text (as close as possible to the actual word or phrase being indexed) using the command \index{entry}. this generates the file myfile. makeindex myfile MakeIndex processes myfile. Note that you should not include the filename extensions on your commands. If you change your document after producing the . and finally running A L TEX once more.ind file before running L TEX for the final time. 15 gnu. the programs will then do the right thing.ind. A A latex (or pdflatex) myfile When L TEX or pdfL TEX finds the \printindex command.dvi or pdf file. latex (or pdflatex) myfile In addition to producing the . some of the most useful are: Academic and Research Computing. RPI . At the place you want the index to appear (usually the end of the document).idx. be sure to run MakeIndex A again to create an up-to-date . Examples of Index Entries A L TEX Input \index{colors} \index{colors!blue} \index{colors!blue!navy} \index{gnu@\textsl{gnu}} \index{gnat|\textbf} Index Entry colors. 14 blue. By including \usepackage{hyperref} as the last package in your preamble. you can run it from the command line or use the editor’s Help feature to add it to the toolbar.3 Including hyperlinks A A Both L TEX and pdfL TEX can use the hyperref package to place live links in the PDF file. If you don’t have a “makeindex” button on the toolbar of your editor/shell. This is a useful tool for checking the index in draft copies.ind. which contains the L TEX commands to format the index. then running makeindex. Examples of various index entries are shown in the table at the bottom of the page. 25 Comments Main entry Subentry under “colors” Subsubentry Formatted text Formatted page number 10. where entry is the index entry. A Now. 22 gnat. you will automatically get bookmarks corresponding to your sections. 14 navy. which comes with L TEX. put the command: \printindex 4. The resulting output includes the formatted index. The package has a number of options.ind file.

pdf. as this method cannot use breaklinks. plainpages=false and pdfpagelabels are usually used together. plainpages=false. the link in TOC.pdfpagelabels.pdfpagelabels.. plainpages=false distinguishes between frontmatter and mainmatter page numbers. The hyperref package also provides the command \url{URL} to link to a URL from the text. breaklinks allows a line break in a long link (such as a TOC entry). \ifpdf \usepackage[colorlinks. hyperref writes different anchors for pages “ii’ and “2”. the breakurl package can help. for example: \url{http://www. With this option. If you also have long URLs in the body of the thesis. A A Be sure to run L TEX or pdfL TEX twice to ensure correct hyperlinks.. A It’s especially useful if you use L TEX and dvips to get your PDF file.breaklinks]{hyperref} \else \usepackage[colorlinks. April 2007 . pdfpagelabels sets PDF page labels so that Acrobat Reader displays the page number as (say) “iv (4 of 40)” rather than simply “4 of 40”.linktocpage]{hyperref} \fi \begin{document} .urlcolor=blue. linktocpage makes the page number..edu}{myfriend@rpi.. LOF.urlcolor=blue.com}./doc/latex/hyperref/. and LOT. urlcolor.citecolor=blue. Abbreviated example file: \documentclass{report} \usepackage{ifpdf} % to use same . Look for it on your system in . For documentation.pdf.48 ♦ Chapter 10. Works with A pdfLTEX only. use \href{mailto:myfriend@rpi. \end{document} The official documentation for hyperref is manual. look on your system for the file breakurl.linkcolor=blue.linkcolor=blue. For example.edu}. and citecolor options.. Special Topics colorlinks makes the text of the link colored instead of framed with a box.org/} or \url{mailto:email@email.ctan.. not the text. plainpages=false. to avoid having the text “mailto:” appear in the document. where “URL” is the address and “text” is the text displayed in the document. body of your document goes here . The command \href{URL}{text} provides a more sophisticated method. It’s also possible to choose the color of the links with the linkcolor.citecolor=blue.tex file for both latex & pdflatex % the following specifies different options to hyperref depending on % whether latex or pdflatex is being run.

se˜orita. ˘ is ı formed by typing \u{\i}. e e A n Academic and Research Computing. straße ıve. For example. you need to print them without their dots. For example: na\"{\i}ve. For example \^o and \^{o} both produce o ˆ. \‘{o} \={o} \u{o} \d{o} The special letters that are part of European languages can be generated with the following commands: œ ˚ a ß ¡ {\oe} {\aa} {\ss} !‘ Œ ˚ A SS ¿ {\OE} {\AA} {\SS} ?‘ æ ø l {\ae} {\o} {\l} Æ {\AE} Ø {\O} L {\L} o ` o ¯ o ˘ o . ˚ngstrøm.. stra{\ss}e produces: na¨ r´sum´.10. Of course. r\’esum\’e.4 Accents and Special Characters ♦ 49 10. The table below shows how to apply a variety of accents to the letter o.{o} ˙ o ¨ \"{o} ˚ \r{o} o o ˇ \v{o} o ˝ \H{o} o \c{o} ¸ o \b{o} oo \t{oo} ¯ Note that the accent commands that are control symbols (i. they consist of just one non-letter) can also be used without braces.4 Accents and Special Characters A L TEX provides commands that allow you to print accents required by many European languages. however. any other letter can be used in place of o. If you want to place an accent on top of an i or a j. RPI . You can print a dotless i or j by typing \i and \j. o ´ \’{o} o ˆ \^{o} o ˜ \~{o} o \. se\~norita.e. {\AA}ngstr{\o}m.

Load it with the command: \usepackage{latexsym}. A The AMSL TEX package. a standard L TEX package.pdf. provides additional math symbols. 50 . For a list.rpi. Miscellaneous Symbols ℵ h ¯ ı  \aleph \hbar \imath \jmath \ell ℘ \wp \Re \Im ∂ \partial ∞ \infty H \mho \sum \int ∅ √ ⊥ \prime \emptyset \nabla \surd \top \bot \Vert or \| \angle \triangle \Diamond \Box \prod \oint ∀ ∃ ¬ \forall \exists \neg \flat \natural \sharp \clubsuit \diamondsuit \heartsuit \spadesuit \backslash \coprod \Join Q P ♣ ♦ ♥ ♠ \ I A The symbols whose names are underlined require latexsym. amssymb. see http://www. 1 An ordinary “o” looks Greek when used in a math environment: $o$ → o. Greek Alphabet α β γ δ ε ζ η θ ϑ Γ ∆ Θ Λ \alpha \beta \gamma \delta \epsilon \varepsilon \zeta \eta \theta \vartheta \Gamma \Delta \Theta \Lambda ι κ λ µ ν ξ o π ρ Ξ Π Σ Υ \iota \kappa \lambda \mu \nu \xi o1 \pi \varpi \rho \Xi \Pi \Sigma \Upsilon σ ς τ υ φ ϕ χ ψ ω Φ Ψ Ω \varrho \sigma \varsigma \tau \upsilon \phi \varphi \chi \psi \omega \Phi \Psi \Omega Capitals not shown are produced with English capital letters. To use one of the symbols in ordinary text.edu/dept/arc/training/latex/amssymblist. put it in math mode by surrounding it with dollar signs: $\alpha$ → α.Appendix A Mathematical Symbols All the following symbols (except the “non-mathematical symbols” listed on the next page) must be used in math mode.

you can prefix them with a \ so that they will print as normal text rather than in italics: \arccos \cot \exp \lim \min \tan \arcsin \coth \gcd \liminf \Pr \tanh \arctan \csc \hom \limsup \sec \arg \deg \inf \ln \sin \cos \det \ker \log \sinh \cosh \dim \lg \max \sup Delimiters The following symbols can expand in size to “fit around” the expressions they delimit. ( [ { | / ( [ \{ | / ) ] } \ ) ] \} \| \backslash \lfloor \lceil \langle ↑ \uparrow ↓ \downarrow \updownarrow ≡ ∼ \equiv \sim \simeq \asymp \approx \cong \perp \bowtie \propto \models \doteq \not= \rfloor \rceil \rangle \Uparrow \Downarrow \Updownarrow ⇑ ⇓ Relational Operators ≤ \le or \leq \prec \preceq \ll \subset \subseteq \sqsubset \sqsubseteq \in \vdash \smile \frown \not< ≥ \geq \succ \succeq \gg \supset \supseteq \sqsupset \sqsupseteq \ni \dashv \mid \parallel \not> ⊂ ⊆ ` ∈ ⊃ ⊇ a ≈ ∼ = ⊥ ∝ |= .. \right commands described in section 6.. To make a delimiter the right size. = = | > < Note that \not before a relation will negate it. Academic and Research Computing. use it with the \left . RPI . The symbols whose names are underlined require the latexsym package.♦ 51 Non-Mathematical Symbols These symbols can be used in either text mode or math mode: † \dag ‡ \ddag § \S ¶ \P c \copyright £ \pounds Function Names When using function names in a math environment.6.6.

52 ♦ Appendix A: Mathematical Symbols Binary Operators ± \ · × ∗ \pm \mp \setminus \cdot \times \ast \star \diamond \circ \bullet \div \unlhd ∩ ∪ \cap \cup \uplus \sqcap \sqcup \triangleleft \triangleright \wr \bigcirc \bigtriangleup \bigtriangledown \unrhd ∨ ∧ ⊕ ⊗ \vee \wedge \oplus \ominus \otimes \oslash \odot \dagger \ddagger \amalg \lhd \rhd ◦ • ÷ ¢ † ‡ ¡ £ ¤ The symbols whose names are underlined require the latexsym package. Math Accents a ˆ a ´ a ¯ a ¨ \hat{a} \acute{a} \bar{a} \ddot{a} a ˇ a ` a x−y \check{a} \grave{a} \vec{a} \widehat{x-y} a ˘ a ˜ a ˙ xyz \breve{a} \tilde{a} \dot{a} \widetilde{xyz} Arrows ← ⇐ → ⇒ ↔ ⇔ → ← \leftarrow \Leftarrow \rightarrow \Rightarrow \leftrightarrow \Leftrightarrow \mapsto \hookleftarrow \leftharpoonup \leftharpoondown \rightleftharpoons ←− \longleftarrow ⇐= \Longleftarrow −→ \longrightarrow =⇒ \Longrightarrow ←→\longleftrightarrow ⇐⇒\Longleftrightarrow −→ \longmapsto → \hookrightarrow \rightharpoonup \rightharpoondown Y \leadsto ↑ ⇑ ↓ ⇓ \uparrow \Uparrow \downarrow \Downarrow \updownarrow \Updownarrow \nearrow \searrow \swarrow \nwarrow The symbols whose names are underlined require the latexsym package. April 2007 .

A If you mistyped the file name or for some other reason L TEX cannot find a file. 53 .. \# or \%. you must \end{. If it stops with a * prompt. #.9 \secton {Introduction} ? This means the \section command was misspelled. Some Common Errors A • A command was misspelled and L TEX doesn’t recognize it. L TEX will try to recover from the error and continue processing. quit the program by typing Ctrl-d or Ctrl-c. it often means you have forgotten \end{document}. Another handy “Emergency stop sequence” is Ctrl-z. Responding to Errors A When L TEX finds an error.}.. $. and the error occurred on line 9 of the input file. You can respond with: h for help x for exit A press the Return key to ignore it and hope for the best. it generates a message such as: ! Undefined control sequence. &. This section describes some common errors and shows how to correct them. • You have a special character (e.. If you don’t want to enter a new filename. it will ask for another filename. Sometimes you can tell from viewing the output what went wrong. This includes braces: { . which will cause confusion when you run it again.}.. }.Appendix B Error Messages Most files need some debugging before they print properly. \$. l. • Whatever you \begin{. Enter these as \&. Windows users: Do not simply close the Command window without responding! A The window may disappear but L TEX is still running. %) in the text. Enter it at the prompt (and fix the file later).g. • You inserted too many tabs on the line before the \\.. • A command wasn’t given all its arguments and is trying to use the rest of the file for an argument...

It was forced to do this because otherwise the line would contain unacceptably wide white spaces. You can make L TEX put the hyphens in “environment” temporarily or permanently. put the following command in the preamble (note: more than one word can be added in the command if words are separated by spaces): \hyphenation{en-vi-ron-ment} For a temporary fix. put discretionary hyphens \.54 ♦ Appendix B: Error Messages Errors About Boxes Another common error (actually just a warning) refers to an underfull hbox (or vbox). (L TEX is very fussy. or instruct L TEX A how to hyphenate a certain word. and unused discretionary hyphens do not show up in the text: en\-vi\-ron\-ment Errors Relating to Memory A Sometimes L TEX complains that it’s out of memory. A To correct it. you might get a message such as this one: Overfull \textbf{hbox} (19.45158pt too wide) in paragraph at lines 1206--1215 A L TEX is warning you that a line sticks out into the margin. For example. They mean there is more blank A A space on a line (or page) than L TEX thinks is aesthetically pleasing. you may or may not want to correct the problem. Depending on how the output actually looks. Errors that refer to “overfull hboxes” mean that a line is too long. Suppose L TEX doesn’t know how to hyphenate the A word “environment” that occurs in the line. Last-Out order? . This is a one-time fix. A Sorry.) Sometimes underfull hbox messages are the result of using the linebreak command (\\) A inappropriately. To do it permanently. L TEX needs breaks. L TEX will generate this warning if you use \\ just before or after a new paragraph or before starting an environment that begins on a new line anyway. but it usually isn’t.in the offending word where it appears in the text. The symptoms listed below can be fixed as described: It won’t do all your tables or figures It won’t do a three-page table You just want one big paragraph You are using tabular It won’t take the caption You have nested environments April 2007 Put \clearpage between them. you could reword the sentence so that it breaks better. Did you leave out a \\ or have too many tabs on a line? Use \caption[short list entry]{Very long caption} to trim size for listoftables/figures entry Are they in First-In. These errors are harmless and may be safely ignored. it must be broken up. That’s right.

sarovar. MA.tex. see the CTAN catalog: http://texcatalogue.uk/faq A good resource for all kinds of information is the TEX Users Group (TUG) at http://tug.rpi. Daly. before downloading it from CTAN. fourth edition. describes how to install a new package: http://www. Reading. second edition.org/brief. MA. you will need to download it and then install it. MA.edu/update.ctan.org/search. more complete Introduction than this document is The Not So Short A Introduction to LTEX 2ε by Tobias Oetiker (150 pages): http://www. http://helpdesk.pdf A useful on-line command reference is: http://computing.ac.ethz.soft/latex/green/ltx-2. A The LTEX Companion by Michel Goossens.edu/dept/arc/training/latex/ A longer. 2004.html A The official L TEX searchable FAQ is at: http://www. check first to see if you already have it installed.uk/cgi-bin/texfaq2html?label=instpackages A LTEX Thesis The Rensselaer thesis web page.org/tex-archive/info/lshort/english/lshort. second edition. and links to other information. When you find a package you think may help you.org. A A Guide to LTEX by Helmut Kopka and Patrick W. example files. 55 . If not.ctan.Resources A General Information on L TEX Books A LTEX – A Document Preparation System by Leslie Lamport.html A LTEX packages For a list of available packages with brief descriptions. has links to download Rensselaer’s thesis class and to several documents that will help you prepare your thesis and create the PDF files necessary for electronic submission. Addison-Wesley. The following.ch/. Boston. Addison-Wesley. 1994. 2004. You can also earch the Comprehensive TeX Archive Network (CTAN): http://tug. et al. from the FAQ.rpi.tex.do?artcenterkey=325. On line For on-line tutorials.html.ee. see the Rensselaer A L TEX Information page: http://www. Frank Mittelbach. Addison-Wesley. Boston.ac.

see Using Imported Graphics in A A LTEX and pdfLTEX by Keith Reckdahl (∼120 pages): http://www.org/tex-archive/info/epslatex.tug. A helpful discussion of graphics formats. input and output Files that illustrate how to import graphics and also how to create eps files from Windows applications: http://www.pdf (output) Examples of using both the graphicx and the rotating packages to include landscape figures and tables: http://www. at: ftp://ftp.ac. Big List of L TEX Symbols” compiled by David Carlisle. look for it on your system. Scott Pakin.edu/dept/arc/training/latex/amssymblist. including both standard LaTeX and AMSLaTeX is Math Mode by Herbert Voss (150 pages): http://www.uk/tex-archive/info/math/voss/mathmode/Mathmode.org/pub/tex/doc/amsmath/short-math-guide.4.edu/dept/arc/training/latex/LaTeX_symbols.pdf (output) General graphics information Complete documentation for the graphics bundle is in the file grfguide.pdf April 2007 .rpi.edu/dept/arc/training/latex/Examples/graphics.rpi. and tools for conversion is Strategies for including graphics in LATEX documents by Klaus H¨ppner at o http://www.ams.pdf A The Comprehensive L TEX Symbols List (Pakin) shows all the possible symbols and the packages required to access them (>100 pages): http://tug.ctan.56 ♦ Resources Mathematical Expressions A For information on using AMSLaTeX.pdf For an extensive treatment of including graphics.edu/dept/arc/training/latex/Examples/exrotating.tex.ctan.pdf Graphics Rensselaer example files.tex (input) http://www.org/tex-archive/info/symbols/comprehensive/symbols-letter. inporting graphics.pdf.pdf Symbols A list of AMS Font symbols is at: http://www.pdf A A manageable list of many useful symbols is “The Great. Information on the graphicx package is in section 4. http://www.rpi. see The Short Math Guide for LTEX. and Alexander Holt.rpi.org/pracjourn/2005-3/hoeppner/hoeppner.rpi.pdf A detailed treatment of math.rpi.edu/dept/arc/training/latex/Examples/exrotating.tex (input) http://www.edu/dept/arc/training/latex/Examples/graphics.

and the Natbib manual is in natbib.pdf.org/. see http://tug. It uses its own previewer. An easy way to install MikTeX is to use ProTeXt (http://tug. including GNU/Linux.org/protext/). For on-line information on BibTEX. the best way to get the distribution may be to join TUG (http://tug. To install the software. It’s not quite as inclusive as TeXLive. • MikTeX: This popular distribution can be downloaded free from http://miktex.rpi.edu/dept/arc/software/latex-doc/install-windows.pdf. which guides the installation via an explanatory Academic and Research Computing. with the exception of TeXLive for Windows (see below). You can find both these files at: http://www. Therefore. You should print these instruction for easier use when installing.rpi. you can get it from: http://www. If you don’t already have jpeg2ps on your system. http://www.♦ 57 Conversion utilities (see also page 35) The epstopdf utility converts eps files to pdf files.html).org/tex-archive/support/jpeg2ps/ BibTEX There is extensive material on BibTEX in the three books mentioned in the first section. Windows • TeXLive: Rensselaer has made TeXLive for Windows available on RCS space.org/texlive/. more complete document covering both L TEX’s basic bibliography method and BibTEX is Tame the BeaST by Nicolas Markey: http://tug.html A A longer.net/misc/latex/latextutorial3.andy-roberts. TeXLive is distributed each year on DVD and CD by the TeX Users Group to its members.pdf. For more information on TeXLive. there is a helpful tutorial by Andrew Roberts: http://www.ctan. The jpeg2ps utility converts JPEG images to eps files without uncompressing the images.org/join.org/tex-archive/macros/latex/contrib/natbib/ A Installing L TEX The TeXLive distribution is a comprehensive TeX system with binaries for Windows and most flavors of Unix.html. concise overview of the Natbib package is the file natnotes. but the download is huge.pdf An excellent.org/tex-archive/info/bibtex/tamethebeast/ttb_en.ctan. It also provides the popular MacTeX distribution and ProTeXt (see below). RPI . For general information see the Readme file.edu/dept/arc/software/latex-doc/Readme-RPI. follow the detailed installation instructions at http://www. It is very likely part of your TeX/LaTeX distribution. Downloading is free. called Yap.ctan. but has a nice “package manager” that makes it easy to install new packages.

WinShell (http://winshell.com) are both highly recommended. If it’s not there. which is likely to be more up-to-date than the version that came with your system. you may be able to install it easily using your system administration package management tool. ProTeXt is also included with recent TeXLive distributions. so you may already have it installed. A You will need an editor/shell to work with L TEX on Windows. April 2007 . Information and installation instructions are at http://tug.org) and WinEdt (http://winedt. easy-to-install TeX distribution for Mac OS X users that requires Mac OS 10. just type latex at a command prompt.org/mactex/.58 ♦ Resources pdf file with clickable links. To check if it’s on your system. Macintosh The highly recommended MacTeX distribution is a complete. UNIX systems Linux and other UNIX-like systems usually have TeX/LaTeX as an installation option. It is also included with recent TeXLive distributions.3 or higher. Another excellent option is TeXLive.

Sign up to vote on this title
UsefulNot useful