Latex Guide

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 31

DownloadLatex Guide
Open PDF In BrowserView PDF
LATEX quick reference
Mark Gates
November 19, 2012
This guide is available from http://web.eecs.utk.edu/∼mgates3/
Copyright ©2007–2011 by Mark Gates.
You may freely copy and modify this document under the Creative
Commons Attribution-ShareAlike license. When distributing modified
versions, please include your Latex file.
Purpose. This document was initially made as a quick reference to all the commands that
I typically use, organized so I can understand it, with examples and without clutter. It also
includes many shortcuts that I have defined in my mgates.sty file. It is not intended to be
exhaustive, nor overly descriptive. Most of the general LATEXcommands can be found in the
Not So Short Introduction to LATEX 2ε [4]; most of the math in the Short Math Guide to
LATEX [2]; most of the bibliography information in the BibTeX tutorial [3] and the natbib
documentation [1].
I also wrote a separate Latex fonts guide.

1

Contents
1 Commands
1.1 Document structure . . . . . . .
1.2 Page format . . . . . . . . . . .
1.3 Chapters and Sections . . . . .
1.4 Fonts . . . . . . . . . . . . . . .
1.5 Reserved characters . . . . . . .
1.6 Special characters . . . . . . . .
1.7 Accented characters . . . . . . .
1.8 Special spaces . . . . . . . . . .
1.9 Special phrases . . . . . . . . .
1.10 Line and page breaks . . . . . .
1.11 References, citations, footnotes
1.12 Hyperlinks . . . . . . . . . . . .
2 Environments
2.1 Text alignment . .
2.2 Boxes . . . . . . .
2.3 Block quotes . . . .
2.4 Verse . . . . . . . .
2.5 Verbatim . . . . . .
2.6 Lists . . . . . . . .
2.7 Tables (tabular) . .
2.8 Figures and Tables

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

.
.
.
.
.
.
.
.

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

3
3
4
5
6
7
7
8
8
8
9
10
10

.
.
.
.
.
.
.
.

11
11
11
12
12
12
13
13
14

3 Math
3.1 Equation numbering . . . . . . . .
3.2 Sub/superscripts . . . . . . . . . .
3.3 Fractions and binomial coefficient .
3.4 Math Fonts . . . . . . . . . . . . .
3.5 Functions . . . . . . . . . . . . . .
3.6 Accents and over/under commands
3.7 Greek . . . . . . . . . . . . . . . .
3.8 Hebrew . . . . . . . . . . . . . . .
3.9 Symbols . . . . . . . . . . . . . . .
3.10 Brackets and delimiters . . . . . . .
3.11 Matrices . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.

16
17
17
18
18
19
20
21
21
22
24
25

4 Bibliography using BibTeX
4.1 Enabling BibTeX . . . . . . . . . .
4.2 Bibliography formats . . . . . . . .
4.3 Citation formats and natbib . . . .
4.4 BibTeX database . . . . . . . . . .
4.5 Manually formatted bibliographies .

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

.
.
.
.
.

26
26
27
28
29
29

2

1
1.1

Commands
Document structure

\documentclass[options]{class}
Common classes
article
articles without chapters
proc
proceedings, based on article
minimal minimal formatting
report
reports with chapters
book
real books
Common options
10pt, 11pt, 12pt
a4paper, letterpaper, ...
fleqn
leqno
titlepage, notitlepage
onecolumn, twocolumn
twoside, oneside
landscape
openright, openany

main font size
paper size
equations left-aligned instead of centered
equation numbers on left instead of right
start new page after title
one or two columns
paper orientation
chapters begin on right page, or any page

Preamble
\usepackage[options]{package}
\includeonly{filenames}
skip \include with listed files

Document
\begin{document}
\include{filename}
start new page with contents of file
\input{filename}
include contents of file, without starting a new page
\end{document}
3

1.2

Page format

\pagestyle{ plain | headings | empty }
plain
page number in footer
headings page number and chapter in header
empty
no header or footer
\thispagestyle{ plain | headings | empty }
override \pagestyle on a single page
% set 1" margins on 8.5" x 11" paper
% top left is measured from 1", 1"
\topmargin
0in
\oddsidemargin
0in
\evensidemargin 0in
\headheight
0in
\headsep
0in
\topskip
0in
\textheight
9in
\textwidth
6.5in
% set these after the TOC
\setlength{\parindent}{0em}
\setlength{\parskip}{1em}
\setlength\arraycolsep{2pt}

4

1.3

Chapters and Sections

\title{...}
\author{John Doe \and Jane Doe}
\date{\today}
\maketitle
\frontmatter

% (book only) starts roman numeral page numbering, unnumbered sections

\setcounter{tocdepth}{1}
\tableofcontents
\mainmatter

% (book only) starts arabic page & section numbering

\part{...}
\chapter{...}
\section{...}
\subsection{...}
\subsubsection{...}
\paragraph{...}
\subparagraph{...}
\appendix

% whether to display sub- or subsubsections in toc

\chapter*{...}
\section*{...}
\subsection*{...}
\subsubsection*{...}
\paragraph*{...}
\subparagraph*{...}

% (book only)

% (book only) starts alphabetic section numbering

\backmatter
* Starred versions are unnumbered and not in the table of contents.
Examples:

1

section

1.1

subsection

1.1.1

subsubsection

paragraph Run-in paragraph header. Lorem ipsum dolar blah blah blah blah blah blah
blah blah blah blah blah blah blah blah
subparagraph Run-in paragraph header. Lorem ipsum dolar blah blah blah blah blah
blah blah blah blah blah blah blah blah blah

5

1.4

Fonts

Font sizes
Point size
5
6
7
8
8
10
9
11
10 12
12 14
14 17

Latex cmd
\tiny
\scriptsize
\footnotesize
\small
\normal
\large
\Large

User-defined *
\xxxsmall
\xxsmall
\xsmall
\small
\normal
\large
\xlarge

17

20

\LARGE

\xxlarge

20

25

\huge

\xxxlarge

25

25

\Huge

\xxxxlarge

Sample
the quick brown fox

the quick brown fox

the quick brown fox

the quick brown fox

the quick brown fox

the quick brown fox

the quick brown fox

the quick brown fox

the quick brown fox
the quick brown fox

* see mgates.sty file
Fonts
Command
\textrm
\textsf
\texttt
\textup
\textsl
\emph
\underline
\textit
\textmd
\textbf
\textsc
\textnormal

Sample
roman
sans serif
typewriter
upright
slanted
emphasized
underline
italic
medium
bold font
Small Caps
normal

In math mode (e.g. inside $...$), use the math fonts listed in the math section.

6

1.5

Reserved characters

Char
#
$
%
^
&
_
{
}
~
\

Special meaning
?
math mode
comment
math superscript
tab stop
math subscript
start parameter
end parameter
nonbreaking space
start command

Command
\#
\$
\%
\^{}
\&
\_
\{
\
\~{}
$\backslash$

These can also be typed in the verbatim environment or with \verb.

1.6

Special characters

Symbol
“
‘
in-law
yes . . . no
†
§
©
£

Command
‘‘
‘
in-law
yes \ldots no
\dag
\S
\copyright
\pounds

Symbol
”
’
13–67 (en)
¿No?
‡
¶
®
€

Command
Symbol
Command
" or ’’
’
13--67
yes—no (em) yes---no
?‘No?
¡No!
!‘No!
\ddag
\P
\textregistered
\texteuro *

* in textcomp package

7

1.7

Accented characters

Char
ò
ō
ŏ
o.
œ
å
ø

Command
\‘o
\=o
\u o
\d o
\oe
\aa
\o

Char
ó
ȯ
ǒ
o
¯
Œ
Å
Ø

Command
\’o
\.o
\v o
\b o
\OE
\AA
\O

Char
ô
ö
ő

oo
æ

Command
\^o
\"o
\H o
\t oo
\ae

Char Command
õ
\~o
ç
\c c

Æ

\AE

l

\l

L

\L

The first 4 lines can be applied to appropriate characters.
To put accent over i or j, use \i (ı) or \j ().

1.8

Special spaces

Command
\,
\:
\;
\
\quad
\qquad
\!

Size
1 space 10 spaces
3/8 quad
()
[
]
4/8 quad
()
[
]
5/8 quad
()
[
]
en? space
()
[
]
em space
( )
[
2 quad
(
) [
−3/8 quad ()
] [

]
]

In math mode, phantom reserves space for text without printing it, for example
x1
+ x3 = 2,
x1 + x2
= 5,
x1 + x2 + x3 = 7.

1.9

x_1 \phantom{+ x_2} + x_3 = 2,
x_1 + x_2 \phantom{+ x_3} = 5,
x_1 + x_2 + x_3 = 7.

Special phrases

Command
\today
\TeX
\LaTeX
\LaTeXe

Sample
November 19, 2012
TEX
LATEX
LATEX 2ε

8

\\
\\

1.10

Line and page breaks

\\ or \newline
line break, without new paragraph. \\* also prohibts page break.
\linebreak[n]
\nolinebreak[n]
line break, keeping line justified. n ranges from 0 to 4 (most insistent).
For example, here is a paragraph with a newline in it, lorem ipsum dolar blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah, \newline.
It also has a linebreak in it for comparison, lorem ipsum dolar blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah, \linebreak[4].
Notice the difference in justification. Using \linebreak can cause “underfull hbox” warnings.
\newpage
page break
\pagebreak[n]
\nopagebreak[n]
page break, keeping line justified. n ranges from 0 to 4 (most insistent).
\hyphenation{ fortran hy-phen-a-tion }
list of words and where they may be hyphenated (in preamble).
\where a word may be hyphenated (in text). Example: su\-per\-scal\-ar
\ space not to enlarge
~ space not to enlarge or line break
“Mr. Smith” (Mr.\ Smith) or
“Mr. Smith” (Mr.~Smith) instead of
“Mr. Smith” (Mr. Smith)
\@ between capital letter and punctuation that really does end a sentance
“. . . FORTRAN. But. . . ” (FORTRAN\@. But) instead of
“. . . FORTRAN. But. . . ” (FORTRAN. But)

9

1.11

References, citations, footnotes

\label{name} assigns a unique name to an equation, figure, table, or section. For figures
and tables, label must be after the caption.
\eqref{name} inserts reference to the labeled equation; equivalent to (\ref{name}).
\ref{name} inserts reference to the label. You must add the descriptive text such as
“figure.”
\pageref{name} inserts page number of the label.
\cite{name} inserts reference to bibliography citation. Name is assigned by bibitem, not
label.
\footnote{text} generates a footnote.
See also equation numbering on page 17.

1.12

Hyperlinks

\usepackage[options]{hyperref}
\usepackage[colorlinks, urlcolor=blue, linkcolor=black]{hyperref}
To color links, use the colorlinks option. To override default colors, specify
linkcolor red
internal links (sections, pages, etc.)
citecolor green
citation links (bibliography)
filecolor magenta file links
urlcolor cyan
URL links (mail, web)
\href{url }{text}
\href{http://www.ctan.org/}{CTAN}

CTAN

\href{mailto:noone@example.com}{noone@example.com}

10

noone@example.com

2
2.1

Environments
Text alignment
\begin{flushleft}
this paragraph \\
is flush left.
\end{flushleft}

this paragraph is
flush left.

\begin{flushright}
this paragraph \\
is flush right.
\end{flushright}

this paragraph is
flush right.

\begin{center}
this paragraph \\
is centered.
\end{center}

this paragraph is
centered.

2.2

Boxes

Only minipage is an environment, but these are all related.
\mbox{...}
\makebox[width][t|b|c]{...}
groups items in a box. Everything must be on one line (?).
\fbox{...}
\framebox[width][t|b|c]{...}
framed box. Everything must be on one line (?).
\parbox[t|b|c]{width}{...}
paragraph box that wraps text.
\begin{minipage}[t|b|c]{width} ... \end{minipage}
minipage box, similar to parbox but can contain almost anything.
\begin{boxedminipage}[t|b|c]{width} ... \end{boxedminipage}
with \usepackage{boxedminipage}.
\rule{width}{height}
\raisebox
page and other parameters to tweak
11

2.3

Block quotes
Martin Luther King Jr. said,
\begin{quote}
I have a dream that someday\ldots
\end{quote}

Martin Luther King Jr. said,
I have a dream that someday. . .

For multiple paragraph quotations, use quotation instead of quote, to indent the first line
of each paragraph.

2.4

Verse

Reverse indents if line wraps.
\textbf{Humpty Dumpty}
\begin{verse}
Humpty Dumpty sat on a wall:\\
Humpty Dumpty had a great fall.\\
All the King’s horses and all the
King’s men\\
Couldn’t put Humpty together again.
\end{verse}

Humpty Dumpty
Humpty Dumpty sat on a
wall:
Humpty Dumpty had a great
fall.
All the King’s horses and all
the King’s men
Couldn’t put Humpty together again.

2.5

Verbatim

verbatim reproduces text exactly as you type it, not interpretting any characters or commands. It was used here for all the LaTeX code listings.
\begin{verbatim}
text can include special characters # $ <
and \textbf{commands}.
\end{verbatim}
\verb+text+
where the delimiter ‘+’ is any character except letters, *, and space.
Adding a star highlights spaces.
\begin{verbatim*} ... \end{verbatim*}
\verb*+text with spaces+
text with spaces

12

2.6

Lists
\begin{enumerate}
\item One
\item[3.] Two (with special number)
\item Three
\end{enumerate}

1. One
3. Two (with special number)
2. Three

\begin{itemize}
\item One
\item[-] Two (with special bullet)
\end{itemize}

• One
- Two (with special bullet)

\begin{description}
\item[One] Description of one
\item[Two] Description of two
\end{description}

One Description of one
Two Description of two

2.7

Tables (tabular)

col1 col2
col1 col2
col1 col2

\begin{tabular}{l|ll}
col1 & col2 & col3 \\
\hline
col1 & col2 & col3 \\
col1 & col2 & col3 \\
\end{tabular}

col3
col3
col3

In general:
\begin{tabular}[t|b|c]{column spec}
col1 & col2 & ... & coln \\
col1 & col2 & ... & coln \\
\end{tabular}
In column spec, for each column use l, r, c for a left, right, or centered column, p{width} for
a column of given width that wraps text. Use | (pipe) for a vertical line between columns.
Use @{...} to specify the delimiter between columns. An empty @{} deletes the gutter or
left indent.
Between lines, use \hline for a horizontal line.
Use \multicolumn{n}{column spec}{text} to have text span multiple columns.

13

2.8

Figures and Tables

A figure typically includes 1 or more graphics. Example:

1.0
0.5
0.0
0.5
1.0
0

1

2

3

4

5

\begin{figure}[h]
\centering
\includegraphics[scale=0.8]{sine}
\caption{$\sin(x)$}
\label{sine}
\end{figure}

6

Figure 1: sin(x)
A table typically includes a tabular environment; see previous section. Example:

2000
2001

\begin{table}[h]
\centering
\begin{tabular}{ccc}
& sales
& growth \\
2000 & 10,000 & 15\% \\
2001 & 12,000 & 20\% \\
\end{tabular}
\caption{Sales growth}
\label{sales-growth}
\end{table}

sales growth
10,000
15%
12,000
20%

Table 1: Sales growth

figure and table take an optional placement specifier:
h here in the text
t top of a page
b bottom of a page
p on a special page of only floats
! be insistent
To use includegraphics, include \usepackage[driver ]{graphicx} in the preamble. The
driver should normally be omitted; if necesary, it is dvips for latex and pdftex for pdflatex.
Files must be eps for dvips, while pdftex takes pdf, jpg, tif, or png. It’s convenient to leave off
the extension; latex/pdflatex will look for the appropriate file. (In this example, spring.pdf
or spring.eps.) Since many journals want eps files instead of pdf files, I often generate eps
files first, then convert them to pdf using epstopdf.
includegraphics options

14

width=width
height=height
angle=degrees
scale=scale

scale to width, maintaining aspect ratio if no height
scale to height, maintaining aspect ratio if no width
rotate counterclockwise
resize image by scalar value

15

3

Math

Surround inline equations with dollar signs, for example $x=2$ produces x = 2. For equations
in their own block, use one of the environments below. For unnumbered equations append
a * star to the environment name. As a shortcut for unnumbered equations, \[...\] is the
same as \begin{equation*}...\end{equation*}.

equation sets a single equation (1).
x = a + b.

\begin{equation} \label{x1}
x = a + b.
\end{equation}

(1)

gather sets multiple equations (2,3), centered on each other.
x = a + b,
y = c + d + e + f.

\begin{gather}
x = a + b,
\label{x2} \\
y = c + d + e + f. \label{y2}
\end{gather}

(2)
(3)

align sets multiple equations (4,5), aligned
typically on = sign.
x = a + b,
y = c + d + e + f,

\begin{align}
x &= a + b,
\label{x3} \\
y &= c + d + e + f, \label{y3}
\end{align}

(4)
(5)

multline splits a long equation (6) over multiple lines, distributing the space.

\begin{multline} \label{x6}
x = a + b + c + d + e + f \\
+ g + h + i + j + k. \\
+ l + m + n.
\end{multline}

x=a+b+c+d+e+f
+ g + h + i + j + k.
+ l + m + n. (6)
split splits a long equation (7) over multiple lines, aligning it. Use inside equation,
align, or gather.
x=a+b
= c + d + e.

\begin{equation}
\begin{split} \label{x5}
x &= a + b
\\
&= c + d + e.
\end{split}
\end{equation}

(7)

subequations assigns all enclosed equations
subordinate equation numbering, so (8a,8b)
are parts of (8).
x = a + b,
y = c + d + e + f.

\begin{subequations} \label{group4}
\begin{align}
x &= a + b,
\label{x4} \\
y &= c + d + e + f. \label{y4}
\end{align}
\end{subequations}

(8a)
(8b)
16

align can also have several columns of
equations or descriptions. The intertext
command is useful to insert text while preserving alignment.
x = 1,
z = 3,

y = 2,
w = 4,

initialize

\begin{align*}
x &= 1, & y &= 2, && \text{initialize}
\\
z &= 3, & w &= 4,
\intertext{some more text, and}
a &= 5, & b &= 5.
\end{align*}

some more text, and
a = 5,

b = 5.

The non-AMS command for aligning equations is eqnarray, but it produces rather
poor spacing and is not recommended.
x = a + b,
y = c + d + e + f.

3.1

\begin{eqnarray}
x &=& a + b,
\label{x7} \\
y &=& c + d + e + f. \label{y7}
\end{eqnarray}

(9)
(10)

Equation numbering

\label{name} assigns a unique name to an equation.
\eqref{name} generates reference to equation; equivalent to (\ref{name})
For subequations, both the whole group and individial equations can have labels.
To get equation numbers of form m.n where m is the section number and n is the equation
number within section, use \numberwithin{equation}{section} in preamble.
See also references on page 10.

3.2

Sub/superscripts

Subscripts are done with underbar, like x_{1} for x1 .
Superscripts are done with ˆ caret, like x^{1} for x1 .
R
Use braces for double sub/superscripts, like {B^a}^T for B a T or \int_{x_1} for x1 .

17

3.3

Fractions and binomial coefficient

\frac{numerator }{denominator } makes fractions in either display or text style, depending
on context.
\dfrac forces display (big) style.
\tfrac forces text (small) style.
1
Inline: frac 12 , dfrac , tfrac 12 .
2
In equation:
frac

1
,
2

dfrac

1
,
2

\frac{1}{2}
\dfrac{1}{2}
\tfrac{1}{2}

tfrac 12 .

Similarly, \binom, \dbinom, \tbinom for binomial coefficient (i.e. n choose k)
 
n
binom
,
k

3.4

 
n
dbinom
,
k

tbinom


n
k

\binom{n}{k}
\dbinom{n}{k}
\tbinom{n}{k}

.

Math Fonts

Command
\mathrm
\mathsf
\mathtt
\mathit
\mathbf
\bm
\mathbb
\mathcal
\mathfrak
\mathnormal

Name
roman
sans serif
typewriter
italic
bold font
bold symbol
blackboard
calligraphic
frak
normal

Samples
ABCDE
ABCDE
ABCDE
ABCDE
ABCDE
ABCDE
ABCDE
ABCDE
ABCDE
ABCDE

abcde 12345
abcde 12345
abcde 12345
abcde
12345
abcde 12345
abcde 12345

abcde
abcde

18

12345


Package
αωΩ
αωΩ
αωΩ
αωΩ
αωΩ
αωΩ bm

αωΩ

amsfonts, amssymb
amsfonts, amssymb

3.5

Functions

Functions to typeset in roman
\sin
\cos
\tan
\sec
\csc
\sinh
\cosh
\tanh
\arcsin \arccos \arctan
\exp
\lg
\ln
\log
\min
\max
\arg
\inf
\sup
\liminf \limsup \lim
\det
\ker
\dim
\gcd
\deg
\hom
\Pr
User-defined (see mgates.sty file)
\sech
\cond
\range
\rank

\cot
\coth

Limits specified in subscript: \lim_{n \to 0} is limn→0 .
To add new functions, for example rank(A), use \DeclareMathOperator{\rank}{rank}.
The starred version \DeclareMathOperator* makes functions with limits like lim.
Modular arithmetic has 4 variants. This expression means “5 is congruent to 1, modulo 2.”
5≡1
5≡1
5≡1

5 &\equiv 1 \pmod 2
5 &\equiv 1 \mod 2
5 &\equiv 1 \pod 2

(mod 2)
mod 2
(2)

\\
\\

Denote the modulo operation of finding the remainder with = equals and the binary bmod,
1 = 5 \bmod 2.

1 = 5 mod 2.

19

3.6

Accents and over/under commands

x̂ \hat{x}
x̃
x̌ \check{x} x̄

\tilde{x} ẋ
\bar{x}
ẍ

\dot{x}
x́ \acute{x} ~x \vec{x}
\ddot{x} x̀ \grave{x} x̆ \breve{x}

The wide and over/under commands span multiple elements. The over/underbrace also
take super/subscripts for a description. Note the over/underset take two arguments, not a
super/subscript, and are backwards of over/underbrace.
xd
yz
xyz
←
−−
xyz
−
−→
xyz
←
→
xyz
a

xg
yz
xyz
xyz
←−−
\overrightarrow{xyz}
xyz
−−→
\overleftrightarrow{xyz} xyz
←→

\widehat{xyz}
\overline{xyz}
\overleftarrow{xyz}

z}|{
xyz \overbrace{xyz}^{a}
a

xyz

\widetilde{xyz}
\underline{xyz}
\underleftarrow{xyz}
\underrightarrow{xyz}
\underleftrightarrow{xyz}

xyz
|{z}

\underbrace{xyz}_{a}

xyz

\underset{a}{xyz}

a

\overset{a}{xyz}

a

20

3.7
In
α
β
χ
δ

η
γ
ι
κ
λ
µ
ν
ω
o
φ
π
ψ
ρ
σ
τ
θ
υ
ξ
ζ

Greek

English alphabetic order
\alpha
A A
\beta
B B
\chi
C C
\delta
∆ \Delta
\epsilon E E
H H
\eta
\gamma
Γ \Gamma
\iota
I
I
\kappa
K K
\lambda
Λ \Lambda
\mu
M M
\nu
N N
\omega
Ω \Omega
o
O O (omicron)
\phi
Φ \Phi
Π \Pi
\pi
\psi
Ψ \Psi
\rho
P P
\sigma
Σ \Sigma
\tau
T T
\theta
Θ \Theta
\upsilon Υ \Upsilon
\xi
Ξ \Xi
\zeta
Z Z

Greek alphabetic order is
α β γ δ  ζ η
A B Γ ∆ E Z H

3.8
ℵ
i
‫ג‬
k

ε

\varepsilon

z

\digamma

ϕ
$

\varphi
\varpi

%
ς

\varrho
\varsigma

ϑ

\vartheta

θ ι
Θ I

κ
K

λ
Λ

µ
M

Hebrew

\aleph
\beth
\gimel
\daleth

21

ν
N

ξ
Ξ

π
Π

o
O

ρ
P

σ τ
Σ T

υ
Υ

φ χ
Φ C

ψ
Ψ

ω
Ω.

3.9

Symbols

(A selective list. See the AMS Short Math Guide and the Not So Short Introduction for
more exhaustive lists.)
Relationships (negate
< <
>
≤ \le
≥

 \ll
⊂ \subset
⊃
⊆ \subseteq ⊇
∈ \in
3
∈
/ \notin
k \parallel ⊥
Operators
+
+
±
\pm
⊕
\oplus
∪
\cup
S
\bigcup
∨
\vee
∨
P \lor
\sum
R
\int
∂
\partial
User-defined
(see
R
\intO
RΩ
\intG
Γ
dx \dx
dΩ \dO
∂f \p f
∪
\union

using \not)
>
\ge
\gg
\supset
\supseteq
\ni, \owns

=
≡
∼
≈

∝ \propto
6
=
\ne
∼
= \cong

\perp

−
∓

\mp
\ominus
∩
\cap
T
\bigcap
∧
\wedge
∧
Q \land
\prod
H
\oint
∇
\nabla
mgates.sty)

·
?

R

R

\intGg
dy \dy
dΓ \dG
∇f \del f
∩
\inter
Γg

=
\equiv
\sim
\approx

\U
¬
¬
`
RR

Γh

dz
dθ
∇f
f ◦g

\cdot
\star
\odot
\setminus
\biguplus
\neg
\lnot
\coprod
\iint

\intGh
\dz
\dT
\grad f
\compose

×
∗
⊗

\times
÷
*, \ast
\otimes

RRR

\iiint

R

R
RΩe
dr

\intOe
\intGhe
\dr

dt

∇·f

\divr f ∇ × f

Γeh

Limits are specified as sub- and superscripts: \sum_{i=0}^{n} is
Roots use \sqrt, with optional radix
√
√
2 \sqrt{2} 3 2 \sqrt[3]{2}

22

Pn

i=0 .

\div
\oslash

···

R

\idotsint

\dt
\curl f

Misc symbols
← \gets
. . . \dots
<
\Re
∀
\forall
∅
\emptyset
∠
\angle
User-defined (see
x
\xx
A \A
R
\Real
N
\Natural
∆t \Dt
Arrows
\leftarrow
\Leftarrow
\hookleftarrow
\leftharpoonup
\leftharpoondown

→

\to

· · · \cdots
=
\Im
∃
\exists
∞ \infty
4 \triangle
mgates.sty file)
y
\yy
I
\I
C
\Complex
Z
\Integer
1
\half
2
L
←
⇐
←(
)

R LR
→ ↔
⇒ ⇔
,→
*
+

7→
..
.

\mapsto

\iff

\vdots

⇐⇒
...

@
~


\nexists
\hbar
\square

∴
℘
♦

\therefore ∵
\wp
\Diamond

f
J
I
Q
⇒

\ff
\J
\Imag
\Rational
\implies

0
K
Re(x)
P

\0 (zero)
\K
\re{x}
\Poly

U
↑
⇑

UD
l
m

LL LR LLR
←− −→ ←→
⇐= =⇒ ⇐⇒

D
↓
⇓

\ddots

·

M
Im(x)

\cdot
\because

\M
\im{x}

Substitute
left,
right,
leftright,
longleft, longright, longleftright,
up,
down,
updown
for left in the command to get the desired direction and length. Note \leftrightharpoons
is plural. There are many more variants available; see the AMS Short Math Guide.
For putting super/subscripts on arrows, use
a+b

a−b

A ←−− B −−→ C
c−d

A \xleftarrow{a+b} B \xrightarrow[c-d]{a-b} C
See also accents on page 20 for arrows above/below elements.

23

3.10

Brackets and delimiters

Left

Right

(

(

)

)

[

[

]

]

}

\}

{ \{

Common

User-defined
pairing (see mgates.sty)
 
x
\parens{...}
y
h i
x
y

n o
x
y

D E
x
y

h

\langle i

\rangle

b

\lfloor c

\rfloor

d

\lceil

e

\rceil

|

\lvert

|

\rvert

|

|, \vert

k \lVert

k

\rVert

k

\|, \Vert

/

\

\backslash

/

j k
x
y

l m

\brackets{...}
\braces{...}
\angles{...}
\floor{...}

x
y

\ceil{...}

x
y

\abs{...}

x
y

\norm{...}

Use paired \leftdelimiter and \rightdelimiter to resize delimiters to fit their contents. To
use delimiter on only one side, use invisible \left. or \right. for other side. (Doesn’t work
across lines in multiline equations.)
AMS provides cases for piecewise function:
(
0, i = j,
δij =
1, else.

\delta_{ij} = \begin{cases}
0, & i=j, \\
1, & \text{else}.
\end{cases}

Non-AMS convention is to use an array:

δij =

0, i = j,
1, else.

\delta_{ij} = \left\{ \begin{array}{ll}
0, & i=j, \\
1, & \text{else}.
\end{array} \right.

24

3.11

Matrices

AMS provides 4 matrix environments differing in delimiters, and 1 for small inline matrices.
Example

AMS command

1 2
3 4

\begin{matrix}
1 & 2 \\
3 & 4
\end{matrix}

User-defined shortcut

\begin{bmatrix}
1 & 2 \\
3 & 4
\end{bmatrix}

\mat{
1 & 2 \\
3 & 4
}



1 2
3 4

\begin{pmatrix}
1 & 2 \\
3 & 4
\end{pmatrix}

\pmat{
1 & 2 \\
3 & 4
}



1 2
3 4

\begin{Bmatrix}
1 & 2 \\
3 & 4
\end{Bmatrix}

\qmat{
1 & 2 \\
3 & 4
}

Inline [ 13 24 ] matrix.

\left[
\begin{smallmatrix}
1 & 2 \\
3 & 4
\end{smallmatrix}
\right]

\smat{
1 & 2 \\
3 & 4
}



1 2
3 4



Non-AMS convention is to use an array. This has the advantage of allowing vetical and
horizontal lines to partition the matrix.



1 2 3 4
3 4 5 6



\left[ \begin{array}{cc|cc}
1 & 2 \\
\hline
3 & 4
\end{array} \right]

array is similar to tabular but in the math environment.

25

4

Bibliography using BibTeX

There are 2 ways to make a bibliography: create a BibTeX database, or manually format
it. BibTeX can automatically format various citation and bibliography styles, eliminating
tedious manual re-formatting. Multiple tex files can use the same BibTeX database, eliminating redundant data entry. I’ll give notes for BibTeX first, but include manual formatting
at the end for completeness.

4.1

Enabling BibTeX

In your .tex file set the bibliography style (e.g. plain) and BibTeX database (e.g. references.bib). For plainnat, abbrvnat, unsrtnat, and custom-bib styles add \usepackage{natbib}.
For apalike add \usepackage{apalike}.
\bibliographystyle{plain}
\bibliography{references.bib}
Style
plain
plainnat
abbrv
abbrvnat
alpha
unsrt
unsrtnat
apalike
custom-bib

Sort
Labels
Notes
by author numeric, like [1]
by author numeric or author-year
\usepackage{natbib}
by author numeric
abbreviates authors and journals
by author numeric or author-year
\usepackage{natbib}
by author alphanumeric, like [SJL05]
as cited
numeric
as cited
numeric or author-year
\usepackage{natbib}
by author author-year, like [Smith 2005] \usepackage{apalike}
asks questions to generate custom bibliography style

To change the title of the bibliography section (e.g. to “References”) use
\renewcommand{\refname}{References} (for articles)
\renewcommand{\bibname}{References} (for reports and books)
To compile the bibliography, run latex, then bibtex, then latex twice more! (What were they
thinking when they designed this program?)
latex
bibtex
latex
latex

file.tex
file.tex
file.tex
file.tex

26

4.2

Bibliography formats

These are common styles. Many more are available, or use custom-bib to build one to
match your needs or a journal’s demands.

References, for style plain
[1] Nicolas Markey. Tame the BeaST, 2005.
[2] Mark Smith, Adam Jones, and Wei Lee. Caffeine usage in Chicago. Journal of Coffee
Drinkers, 6:121–142, 2005.

References, for style unsrt
[1] Mark Smith, Adam Jones, and Wei Lee. Caffeine usage in Chicago. Journal of Coffee
Drinkers, 6:121–142, 2005.
[2] Nicolas Markey. Tame the BeaST, 2005.

References, for style abbrv
[1] N. Markey. Tame the BeaST, 2005.
[2] M. Smith, A. Jones, and W. Lee. Caffeine usage in Chicago. Journal of Coffee Drinkers,
6:121–142, 2005.

References, for style alpha
[Mar05] Nicolas Markey. Tame the BeaST, 2005.
[SJL05] Mark Smith, Adam Jones, and Wei Lee. Caffeine usage in Chicago. Journal of
Coffee Drinkers, 6:121–142, 2005.

References, for style apalike
Markey, N. (2005). Tame the BeaST.
Smith, M., Jones, A., and Lee, W. (2005). Caffeine usage in Chicago. Journal of Coffee
Drinkers, 6:121–142.

27

4.3

Citation formats and natbib

\cite makes a citation and includes its entry in the bibliography. Natbib recommends
using \citep and \citet instead.
\citep makes a parenthetical citation such as [2] or (Gates, 2011).
\citet makes a textual citation such as Gates [2] or Gates (2011).
\nocite{name} includes an entry in the bibliography without citing it.
\nocite{*} includes all BibTeX entries in the bibliography.
The natbib package provides the \citet, \citep, and other variants. To use natbib, add
it to the preamble, and choose a natbib-compatible style. It has extensive commands and
options; see the natbib documentation.
\usepackage[options]{natbib}
\bibliographystyle{plainnat}
Some natbib package options:
Option
round
square
authoryear
numbers
super

Description
round parenthesis ( )
square brackets [ ]
author-year citations
numeric citations
superscript numeric citations

The original plain, unsrt, abbrv make the top 3 numeric citations. Depending on its options,
natbib can generates author-year, numeric citations, or superscript citations (not shown).
Command
\cite{Smith05}
\cite{Smith05,Markey05}
\cite[p. 135]{Smith05}
\citet{Smith05}
\citet*{Smith05}
\citep{Smith05}
\citep*{Smith05}
\citeauthor{Smith05}
\citeyear{Smith05}
\citeyearpar{Smith05}

author-year citation
Smith et al. (2005)
Smith et al. (2005); Markey (2005)
(Smith et al., 2005, p. 135)
Smith et al. (2005)
Smith, Jones, and Lee (2005)
(Smith et al., 2005)
(Smith, Jones, and Lee, 2005)
Smith et al.
2005
(2005)

Command
\cite{Smith05}
\cite{Smith05,Markey05}
\cite[p. 135]{Smith05}

apalike citation
alpha citation
(Smith et al., 2005)
[SJL05]
(Smith et al., 2005; Markey, 2005) [SJL05, Mar05]
(Smith et al., 2005, p. 135)
[SJL05, p. 135]
28

numeric citation
[3]
[3, 2]
[3, p. 135]
Smith et al. [3]
Smith, Jones, and Lee [3]
[3]
[3]
Smith et al.
2005
[2005]

4.4

BibTeX database

A .bib file contains the bibliography database. Each entry has a unique name that is referenced by \cite, and multiple field=value pairs terminated with commas. Values should
be in "..." quotes. Acronyms and proper names that must be capitalized in titles, put in
{...} braces. Abbreviations can be made using @STRING.
Author and editor names are either “First von Last” or “von Last, First”, separated by
“and”. For et al. use “and others”.
Various other peculiarities are dealt with in [3].
See table 2 for entry types and fields. Here is an example:
@STRING{ JCD = "Journal of Coffee Drinkers" }
@Article{ Smith05,
author = "Mark Smith and Adam Jones and Wei Lee",
title
= "Caffeine usage in {Chicago}",
journal = JCD
year
= 2005,
volume = 6,
pages
= "121--142",
}

4.5

Manually formatted bibliographies

For manual formatting, instead of \bibliographystyle and \bibliography, use thebibliography
environment. The argument is the widest label, here “SJL05”, so it can be indented properly.
\bibitem takes the label as an optional argument; otherwise the label is just numeric.
\begin{thebibliography}{SJL05}
\bibitem[SJL05]{Smith05}
M. Smith, A. Jones, and W. Lee.
\newblock{Caffeine usage in Chicago.}
\newblock \emph{Journal of Coffee Drinkers} 2005; \textbf{6}:121--142.
\end{thebibliography}
(BibTeX builds thebibliography in a .bbl file, based on the current style. Thus if a BibTeX
style is not quite right, you can use BibTeX to build the bibliography until the final edits,
then copy the .bbl file into the .tex file and make final tweaks manually.)
29

or
o
or

o
or

o

o
x

o

@Unpublished

o
o

@TechReport

o
x
x

@Proceedings

o
x
x
o
o
o

@PhdThesis / @MastersThesis

o
or

@Misc

@InBook

o
o

@Manual

@Booklet

o
or

@InProceedings

@Book

x

@InCollection

@Article

Field
address
author
booktitle
chapter
edition
editor
institution
journal
month
note
number
organization
pages
publisher
school
series
title
type
volume
year
howpublished
url

o

o
x

x

o
x

x
o
o
o

o
o
o

o
o

o
x

o
o
o

o
o
o

or
x

o
x

o
x
o
o
x

o
x
o
o
x

o
o
o
o
o
o

o
o

o
o

o
o

o

o
o
o
o
o
o

o
o

o
x

x
o

x

x

o
o

o
x

o
x

o
x

o
x

x

o
o

o
x
o
x

x

o

o

o
o

x
o
x

o
x
o
x

Example
"New York, NY"
"Mark Smith"
"Multigrid Methods"
"2.1"
"Second"
"Mark Smith"
"Intel"
"Acta Numerica"
5 (e.g. May)
"In press"
1
"SIAM"
"73--130"
"Wiley"
"Yale University"
"In a Nutshell"
"Algebraic Multigrid"
"Research note"
3
1987
"http://example.com"

Table 2: BibTeX entry types and associated fields. x is required, or is choice between
2 required fields, o is optional. url is not recognized by the classical plain, alpha, unsrt
styles, but is supported by some newer styles.

30

Todo
theorems, lemmas, proofs, etc.

References
[1] Patrick Daly. Natural Sciences Citations and References, 2006.
[2] Michael Downes. Short Math Guide for LaTeX. American Mathematical Society, 2002.
[3] Nicolas Markey. Tame the BeaST: the B to X of BibTeX, 2005.
[4] Tobiaus Oetiker, Hubert Partl, Irene Hyna, and Elisabeth Schlegl. Not So Short Introduction to LaTeX2e, 2008.

31



Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.5
Linearized                      : No
Page Count                      : 31
Page Mode                       : UseOutlines
Author                          : 
Title                           : 
Subject                         : 
Creator                         : LaTeX with hyperref package
Producer                        : pdfTeX-1.40.12
Create Date                     : 2012:11:19 14:14:05-05:00
Modify Date                     : 2012:11:19 14:14:05-05:00
Trapped                         : False
PTEX Fullbanner                 : This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011) kpathsea version 6.0.1
EXIF Metadata provided by EXIF.tools

Navigation menu