# LaTeX document classes and packages

## The article/book and amsart/amsbook document classes

These are the standard document classes that are part of any current TeX installation. While intended for (scientific) articles and books, they can also be used as general purpose document classes to typeset a great variety of documents: letters, class notes, exams, etc. I recommend that you use one of these standard classes unless you have a good reason to use something else, such as a university-specific thesis class, or a publisher's in-house class. However, even if you have to submit a document with a nonstandard document class, I would suggest to use a standard class throughout the draft stage, and change to a nonstandard class only when the paper is in final form and ready for submission. The advantage of doing this is that it's easy to change back to a standard class, which you might have to do if the paper gets rejected.

### Differences between the article/book classes and the amsart/amsbook classes

The main difference between the "article/book" classes and the "amsart/amsbook" classes (which are part of the amslatex package) is in the "look" of the document. The non-ams classes set the title matter and section headings in a larger font, which some people (including myself) find more attractive.

From a TeXnical point of view, the two pairs of classes are largely interchangeable, so it is easy to switch from one class to another after a paper is finished. The only editing that may be needed is in the title matter since this is handled differently by the two classes. Here are the main differences:

• In the ams classes, the abstract goes before the \maketitle command; in the article/book classes, it goes after \maketitle.
• When using article/book, add \usepackage{amsmath, amsthm} to make the amslatex commands available. The ams document classes load these packages automatically, so no explicit loading is needed.
• The article/book classes allow footnotes in the title matter, the ams classes do not. In the "article/book" class, one can put footnotes to the author or title containing, for example, a grant acknowledgement, a subject classification, or the author's address. With the ams classes you have to use the commands "\thanks{...}" (for acknowledgements), "\subjclass{...}", and "\address{...}" to provide this information. The \thanks{...} command is particularly versatile. While intended for things like acknowledgements of grant support, can be used to generate arbitrary (unnumbered) footnotes on the title page. Moreover, you can have multiple instances of \thanks{...}.
• In the article/book classes equation numbers are set by default on the right of the page; in the ams classes they are set on the left of the page. This behavior can be changed by specifying the option "reqno" or "leqno" (see below).

### Useful document class options

Options to document classes are placed brackets between the "\documentclass" command and the name of the document class; multiple options should be placed in a single pair of brackets, separated by commas; for example:
\documentclass[leqno,11pt,draft]{article}

Here are some useful options that work with all of the mentioned paper and book classes:
• [draft] The main effect of this option is to indicate overfull hbox by a vertical bar in the margin; this helps locating overfull hboxes reported in the log file. Another effect of the "draft" option is that embedded pictures do not get displayed; instead, only an outline of the box taken up by the picture is shown.
• [11pt], [12pt]. These options change the font size from the default of 10pt to 11pt or 12pt, and cause other size parameters to be similarly increased; the effect of this option is similar to that of the "\magnification" command in plain tex. ("\magnification" does not work in latex.) Using this option is the proper way to "magnify" a document. Don't try to magnify fonts manually, using fontsizing commands like "\larger"; since such commands only affect a single font and leave other fonts as well as spacing parameters unchanged, this results in a poor looking document.
• [leqno], [reqno]. Use one of these options to change the placement of equation numbers from the default, namely left in the "amsart/amsbook" classes, right in the "article/book" classes. If you use the article/book classes, I suggest to use the "leqno" option so that the equation numbers appear on the left. This is the most appropriate choice for formula-heavy documents, and most mathematical journals use the "equation number on the left" convention.
• [a4paper]. This sets the paper size to A4, the standard in most European countries. The default (at least in our TeX installation) is US letter size, so it's unlikely you'll need this option, but papers originating in Europe often are prepared with this option turned on, and processing a tex file with this option may cause difficulties when trying to print it since pages may to be too long to be long to fit on letter size paper. This is easily fixed by deleting the a4paper option in the source file.

## The slides document class

The slides document class is one of two standard ways to typeset material in a form that is appropriate for putting on transparencies (the other being foiltex). It causes the document to be substantially magnified (while keeping the overall dimensions of the page), so that it is suitable for copying onto transparencies. In most respects, the "slides" class works like the "article" class, but there is one major difference to be aware of: The "\pagestyle" commands do not work in the "slides" class; if you want to use customized headers or footers, use the "fancyhdr" package (see below).

## LaTeX packages

LaTeX "packages" serve the same function as libraries for programming languages: a package contains a set of commands that are not built into the core of LaTeX, but useful for special purposes. There exist hundreds of packages; many (including all of those listed below) are part of any standard TeX installation, while others can be downloaded from the CTAN (Comprehensive TeX Archive Network) depository at http://ctan.tug.org.

To load a package, add a "\usepackage{...}" instruction after "\documentclass", with the name of the package in braces. Multiple packages can be included in a single "\usepackage{...}" statement, separated by commas; for example, "\usepackage{amsmath, amsthm}".

Here are some packages that are commonly used in mathematical writing.

• amsmath, amsthm: These packages, which are part of amslatex, are needed to make the amslatex enhancements for typesetting equations and theorems available. The packages are loaded automatically if you use one of the ams document classes; if you use a standard LaTeX document class, load the packages explicitly with
\usepackage{amsmath, amsthm}


Documentation. Gratzer's book "Math into LaTeX" provides complete documentation for these and other amslatex packages, and is the only book to do so. Online documentation is available at the AMS LaTeX page; see, in particular, the Short Math Guide for LaTeX.

• amssymb: This package is part of the amslatex distribution and loads additional fonts and symbols. In particular, it loads the "amsfonts" package which, among other things, makes blackboard bold ("\mathbb") and fraktur ("\mathfrak") fonts available. The "amssymb" also includes a number of additional symbols or variants of standard LaTeX symbols, such as a slanted "less than or equal" sign. (However, I would recommend using the standard versions, unless there is a particular reason to use the variant.)

Documentation: A complete listing of the symbols provided by "amssymb", is given in Appendix A of Gratzer's book, and in the Short Math Guide for LaTeX, mentioned above.

• amscd: Also part of the amslatex distribution, this is a package for typesetting simple commutative diagrams. It is a lightweight, easy-to-use package, but it cannot handle diagrams with diagonal arrows; if you need to draw diagrams with diagonal arrows, use the "xy" package described below.

Documentation: Section 5.8 of Gratzer's book.

• xy: This is the name of the package that loads the "xy-pic" program, a general drawing package for TeX that is especially useful for drawing complex commutative diagrams. This is a real heavyweight among drawing packages, and amazingly powerful and versatile; it can do all sorts of tricks, including looping around nodes in a commutative diagram, looping an arrow over or under another arrow to create the impression of a 3D like image, and much more. It is hard to image a commutative diagram that "xy" wouldn't be able to handle.

Documentation. There is a short guide, "xyguide", and an 80 page reference manual, "xyrefer". On most TeX installations you can access these locally with "texdoc xyguide" and "texdoc xyrefer". Despite the size of the reference manual, for simple diagrams "xy" is fairly easy to use, and you will likely get by using just the short guide.

• url: A small, but extremely useful package that facilitates the coding of email addresses and URL's. I use this package all the time, and I usually simply tack "url" on to the "\usepackage{amsmath,amsthm} instruction that I have in most of my documents:
\usepackage{amsmath,amsthm,url}

In contrast to heavy-duty packages like "graphicx", "url" is a very small, benign package that does not interfere with other packages. The following illustrates the typical usage of "url":
For more information, check out the website
\url{https://faculty.math.illinois.edu/~hildebr/tex}
or email \url{hildebr@math.uiuc.edu}.

By enclosing a web or email address in \url{...}, the address gets printed in the appropriate font. Moreover, linebreaking and hyphenation is handled correctly. Finally, and perhaps most importantly, one doesn't have to worry about addresses containing a tilde symbol or an underline. The "url" package ensures that these symbols get handled properly.

• showkeys: If your document has a large number of labelled items, remembering all the labels becomes difficult. The "showkeys" package shows these labels explicitly by putting the name of the label referenced in a small box placed on the margin of the page, or directly above the reference. The labels displayed in this manner include citation labels ("\cite{...}"), equation labels ("\eqref{...}"), and ordinary labels ("\ref{...}"). A great tool when working on a complex document.

Documentation. The documentation file is "showkeys"; it can usually be accessed with "texdoc showkeys".

• fancyhdr: The "Fancy header" package. Allows customizations of footers and headers. This greatly extends the capabilities of the "\pagestyle{...}" command in standard LaTeX. The package distinguishes between even and odd numbered pages, and for each allows specifying a left/center/right header, and a left/center/right footer.

Documentation: The documentation can be accessed with "texdoc fancyhdr".

Here is an example:

\documentstyle{book}

\usepackage{fancyhdr}
\pagestyle{fancy}

%% L/C/R denote left/center/right header (or footer) elements
%% E/O denote even/odd pages

%% \leftmark, \rightmark are chapter/section headings generated by the
%% book document class

\fancyfoot[LO,LE]{\slshape Short Course on Asymptotics}
\fancyfoot[C]{}
\fancyfoot[RO,RE]{\slshape 7/15/2002}


• verbatim: This package is primarily intended to typeset text, such as a source code for a program, "verbatim", i.e., literally, with no formatting and all spacing preserved. However, its most useful feature is a "comment" environment that allows one to comment out entire sections of text, in much the same way as the "\* ... *\" comment construct in the C language. This is much safer than commenting out multiline chunks of text by preceding each line with a TeX comment symbol (%).

Documentation: The documentation files are named "verbatim.*", and can be accessed in the usual way, with "texdoc verbatim".

Here is a typical usage of the verbatim package:

\usepackage{verbatim}

[....]

\begin{proof}
The result can be proved in the same way as Proposition 3.
We omit the details.
\end{proof}

%% detailed proof placed inside comment environment

\begin{comment}
Let
[...]
This proves the assertion.
\end{comment}



• graphicx: The "graphicx" package allows inclusion of graphics files produced by other aplications (such as the free program "xfig", available on Unix systems, Mathematica/Maple, or commercial software like CorelDraw). (Note the "x" at the end; the precursor to "graphicx" is a package called "graphics", but this package is obsolete and should not be used.) The graphics files must be in eps (encapsulated postscript) format, so be sure to save the files in this format. (All of the mentioned applications can do this.)

Documentation. The main source of documentation is the document "Using imported graphics in LaTeX2e", which, despite its hefty size (86 pages), provides an excellent introduction to the "graphicx" package, and to the issues involved in using graphical material in TeX files. The name of this document is "epslatex", and you can usually access it on your local installation with the command "texdoc epslatex". The "graphicx" package is also documented in the "LaTeX graphics companion".

Usage. The "graphicx" package has numerous features and options, but the basic use is very simple: First load the "graphicx" package with "\usepackage{graphicx}", and then use the "\includegraphics{...}" command (note the "s" at the end!) for every file you want to import into your LaTeX file. In its simplest form, you just use the "\includegraphics" command with the file name given inside the braces. However, you will usually want to place this command inside a "figure" environment, and probably also wrap it inside "\begin{center} ... \end{center}" so that the graphics is horizontally centered. Furthermore, you may need to scale the graphics so that it fits the page; this can be accomplished with an optional "width" argument, which sets the width to a specific length (and also scales the height proportionally).

Here is a simple, complete example, showing how to include a file, plot.eps, in a document. Note that the .eps extension need not be specified.


\documentclass{article}
\usepackage{graphicx}

\begin{document}

\begin{figure}[tbh]
\begin{center}
\includegraphics[width=.8\textwidth]{plot}
\end{center}
\caption{Plot of the function $\sin x$}
\label{sineplot}
\end{figure}

\end{document}

Here are some additional hints when using this package.

• graphicx under the draft mode. When the "draft" option in the "\documentclass" command is turned on, the graphics files are not displayed; only an outline of the rectangular boxes containing the graphics is shown. This is useful in order to determine the proper sizing and placement of the graphics. To override this behavior, use the option "final" when loading the package: "\usepackage[final]{graphicx}." With this option, all graphics will be displayed, regardless of whether or not the draft option is turned on.

• Graphics file extensions. The .eps extension in the eps files need not be specified (but be sure that there is a file with this extension in the current directory). In fact, leaving out the .eps extension has the advantage that the same LaTeX source file can be used by the pdflatex program to create a pdf version of the document. This requires that the graphics are available in both eps and pdf formats. (You can use conversion programs, such as "epstopdf", for that purpose.) The pdflatex program expects graphics files to be in pdf format, whereas latex expects the files to be in eps format. Making graphics files in both versions available, but not specifying a file extension, when including the graphics in the document, ensures that each of the two programs picks and finds the version appropriate for that program.

• Placement of figures. Figures and tables placed inside "figure" or "table" environment are so-called "floats"; this means that they may be moved further down in the document in order to avoid overlong pages and similar problems. LaTeX tries hard to optimize the placement, but sometimes this can result in a poor placement, such as in the middle of a bibliography. This occurs mainly in documents containing lots of figures. There are several things one can do to improve the placement of figures. The first thing to try is to add an option like "[tbh]" to the "\begin{figure}" command, as in the example above. This instructs Tex to try to place the figure at the top (t) or bottom (b) of the page, or "here" (h), meaning the place where the figure occurs in the source code. If this does not help, try the more emphatic version "[tbh!]". As a last resort, you could remove the "\begin{figure} ... \end{figure}" wrapper and use manual spacing commands before and after the figure to achieve the proper spacing. However, this is a drastic measure that is only recommended if other attempts fail.

Back to the LaTeX Tips Page

Last modified: Tue 23 Aug 2011 05:48:09 PM CDT A.J. Hildebrand