A Quick Guide to LaTex

Contents

Preamble Margins Table of Contents Begin/End Documents
Title Page Abstract Font and Size Bibliography
Tables Lists Sections/Paragraphs Breaks
Spaces Footnotes Greek Symbols Subscripts/Superscripts
Math in Text Fractions Numbered Equations Un-numbered Equations
Group of Equations Arrays Graphics Math Symbols

Preamble

The commands in the preamble are applied to the entire document.

  1. \documentstyle[options]{style}
    style: article report book slides
    options: 11pt 12pt twoside twocolumn
  2. \pagestyle{style}
    style: plain empty headings myheadings
  3. \pagenumbering{style}
    style: arabic roman alph Roman Alph
  4. For doublespacing
    \renewcommand{\baselinestretch}{2}
    For other spacing (i.e. triple) just change the 2 to 3.
  5. For landscape page
    \special{landscape}

Margins at Top, Bottom, and Left

You can choose the margin sizes yourself by changing the following dimensions before the \begin{document} line.

\setlength{\topmargin}{-0.4in} ( produces a topmargin 0.4in less than the default )

\setlength{\textheight}{9.5in} ( height of main text )

\setlength{\textwidth}{6in} ( width of text )

\setlength{\oddsidemargin}{0.75in} ( odd page left margin is 0.75in more than the default )

\setlength{\evensidemargin}{0.6in} ( even page left margin is 0.6in more than the default )

Table of Contents

A table of contents is produced with the

\tableofcontents

command. You put the command right where you want the table of contents to go; LaTeX does the rest for you. It produces a heading, but it does not automatically start a new page. If you want a new page after the table of contents, include a \newpage command after the \tableofcontents command.

Beginning and Ending the Document

\begin{document}
.........the document goes here........
\end{document}

Getting a Title Page

\begin{titlepage} ... title page text... \end{titlepage}

Getting an Abstract

\begin{abstract} ...abstract text... \end{abstract}

Font and Sizes

Bibliography and Citation

Let's say that in one place of your document, you want to write, "Aardvark nesting habits are well-documented in the literature[67]." In another place of your document you want, "Knudson[67, page 222-223] gives a list of favorite foods of Aardvarks."

This is what you should type in the document.

Aardvark nesting habits are well-documented in the literature \cite{vark:knud}.

and

Knudson \cite[page 222-223]{vark:knud} gives a list of favorite foods of Aardvarks.

Note that {vark:knud} is an identifier you chose for the Aardvark article written by Knudson.

That is the citation part in the next. Now, let's create the bibliography item by using the following commands.

\begin{thebibliography}{99}
... list of items
\bibitem{vark:knud} D.E. Knudson, Memoirs of an Aardvark Lover
...more items
\end{thebibliography}

LaTex keeps a count of bibliography items. The Knudson article happens to be #67 in this list.

Making Tables

Try the following table

\begin{tabular}{|l|r|c|}
\multicolumn{2}{c}Item & Price \\ \hline
water mellon & each & \$ 2.59 \\ \hline
banana & pound & \$ 1.25 \\ \hline
butter-milk & bottle & \$ 1.65 \\ \hline
\end{tabular}

Things to notice:

  1. l, r, c in the tabular command force left-adjusted, right-adjusted, and centered, respectively.
  2. the column entries are separated by the ampersand '&'
  3. the \\ force the line break
  4. remember that '$' is a naughty character, and must have a \ ahead of it
  5. the \hline adds a horizontal line at the end of a row; for double horizontal line use \hline\hline
  6. you can get rid of the vertical lines by deleting the '|' symbols at the top in the tabular command; you can make double vertical line by using ||
  7. \multicolumn{n} makes rows that span multiple columns, {n} defines the column span

Lists

There are two basic list-making environments: itemize and enumerate. Try the following lines in a LaTex file and test.

\begin{itemize}
\item Itemize makes bulleted items
\item within each item, you can start a new list
\begin{enumerate}
\item The item labels in enumerate are letters or numbers
\item Enumerate and Itemize can be nested
\begin{itemize}
\item All begin enumerate
\item and begin itemize must be closed
\end{itemize}
\end{enumerate}
end{itemize}

A third kind of list is invoked through the "description" command. Try the following lines in a LaTex file.

\begin{description}
\item[gnat] A small animal found in Minnesota.
\item[gnu] A large animal found in crossword puzzles.
\item[armadillo] A medium sized animal named after a Texas town.
\end{description}

Sections, Paragraphs, etc.

Breaks

  1. Line Breaking:
  2. Page Breaking:

Spaces

\hspace[*]{length}

command adds horizontal space. The length of the space can be expressed in any terms that LaTeX understands, i.e., points, inches, etc. You can add negative as well as positive space with this command. Adding negative space is like backspacing. LaTeX removes horizontal space that comes at the end of a line. If you don't want LaTeX to remove this space, include the optional * argument.

\vspace[*]{length}

command adds vertical space. The length of the space can be expressed in any terms that LaTeX understands, i.e., points, inches, etc. You can add negative as well as positive space with this command. LaTeX removes vertical space that comes at the end of a page. If you don't want LaTeX to remove this space, include the optional * argument.

Footnotes

\footnote[number]{text}

command places the numbered footnote "text" at the bottom of the current page. The optional argument, "number", is used to change the default footnote number. This command can only be used in outer paragraph mode.

Greek Symbols

LaTeX can typeset the entire Greek alphabet in both lowercase and uppercase characters. Prefix the name of the Greek letter with a \ to make the letter. For example,

\alpha \beta \gamma \delta etc., it's very intuitive.

To get uppercase letters, capitalize the first letter of the command. For example:

\Theta \Lambda \Xi \Sigma

Subscripts and Superscripts

To create subscripts and super scripts, use the _ (subscript text) and ^ (superscript) commands in math mode.

Math Included in Running Text

For example, to print

... assuming that x2 + y2 = z2, then ...

type the following LaTeX line:

... assuming that $x^{2} + y^{2} = z^{2}$, then ...

See how the math mode is invoked with the $ symbol.

Fractions

To get the fraction
Fraction

type the LaTex line:

\frac{x^{2} - y^{2}}{x^{2} + y^{2}}

Un-numbered Equation

Try the following LaTex lines:

\begin{displaymath}
x = \frac{-b \pm \sqrt{b^{2} - 4ac}}{2a}
\end{displaymath}

Numbered Equation

Try the following LaTex lines:

\begin{equation}
E = mc^{2}
\end{equation}

Group of Equations

Try the following LaTex lines:

\begin{eqnarray}
\epsilon_{0}\oint{\bf E} \cdot{d}{\bf S} &=&q\nonumber\\
\oint{\bf B} \cdot{d}{\bf S} &=&0\nonumber\\
\oint{\bf B} \cdot{d}{\bf l} &=&\mu_{0}
\left(\epsilon_{0}\frac {d\Phi_{E}}{dt} + i \right)\\
\oint{\bf E} \cdot{d}{\bf l} &=&-\frac{d\Phi_{B}}{dt}\nonumber
\end{eqnarray}

Arrays

Try the following LaTex lines:

\begin{displaymath}
\left(
\begin{array}{ccc}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{array}
\right)
\end{displaymath}

Including Graphics

A figure in a separate PostScript file can be included in a LaTeX document using the epsfig package. Most mathematical/scientific graphics software allows you to save graphics (figures, diagrams, graphs) in PostScript form; this includes Mathematica, Maple, Matlab, IDL, and xfig. GIF and JPEG images can be converted to PostScript form with ``xv'', among other methods.

The epsfig package is read if you put the line

\usepackage{epsfig}

near the top of the LaTeX file. Then, where you want the PostScript image to appear, use commands like this:

\epsfysize=35mm \epsfbox{graph.eps}

where ``epsfysize'' is used to indicate the desired height of the figure in your document (you could instead indicate a desired width by using epsfxsize), and \epsfbox{...} encloses the name of the PostScript file.

Two characteristics which the (Encapsulated) PostScript file must have are

If the PostScript file does not include a bounding box line, you can indicate the bounding box numbers manually as options to the epsfbox command, e.g.

\begin{center}
\epsfxsize=5.5in
\epsfbox[72 144 540 544]{graph.eps}
\end{center}

Binary Operation Symbols

Binary

Relation Symbols

Relation

Miscellaneous Symbols

Misc

Arrow Symbols

Arrow

Variable Size Symbols

VarSize

Function Symbols

Function

Delimiter Symbols

Delimiter