# Your Guide to documentclass LaTeX: Types and options

## What is documentclass LaTeX?

Every LaTeX document starts with a \begin{document} command and ends with an \end{document} command. LaTeX ignores anything that follows the \end{document}. The part of the source code file that precedes the \begin{document} declaration is called the preamble.

The first command of the preamble has to be \docummentclass (although technically it can be preceded with prepended files). This command takes a single mandatory argument that is one of the predefined classes of document that LaTeX has built-in. In this tutorial, we are going to explain and see the differences and similarities of these document classes, and what should each one be used for. We will also talk about the multiple optional arguments that the \documentclass command takes, and that can be used to customize the appearance of our document.

There are also third-party document classes that are written and distributed as external packages. Some of these classes, like beamer to make presentations and memoir to extend the functionalities of the book class, are very popular and useful, but we won’t cover them here, since they are much more sophisticated and complex than the predefined classes.

## LaTeX document classes and their use

The document classes available in plain LaTeX are reported in the following table:

• The first two document classes are the basic ones; if you don’t know what document class you should use, always start with article.
• The report class is very similar, the main difference with the article being that you can insert chapters with \chapter, while in the article class the highest element in the hierarchy of titles is the \section command.

## LaTeX book class

In typographical standards, books differ from reports mainly in their front and back matter. The front matter of a book usually includes:

• a half-title page,
• a main title page,

It may also contain:

• acknowledgments,
• a dedication,
• a list of figures,
• a list of tables,
• a list of other books in the same series, and other editorial or promotional content.

The back matter usually includes an index and may contain an afterword, also acknowledgments, a bibliography, a colophon, and so on.

The book document class provides some commands to produce the logical structures previously discussed, that the report class isn’t able to deal with by default. However, it does not try to yield tools to all of them. Individual publishers usually have their own packages with additional commands to typeset the structures according to their manual of style.

### Front matter, main matter and back matter commands

The front matter, main matter (which contains the main body of the book, starting at the first chapter or part and ending at the appendices), and back matter are begun with the three commands \frontmatter, \mainmatter, and
\backmatter, respectively.

In the standard book class, front matter pages are numbered with roman numerals; main and back matter pages are numbered with arabic numerals.

In the front and back matter, the \chapter command does not produce a chapter number, but it does make a table of contents entry; this can be used, for example, to produce a preface or acknowledgments section. Inside these kind of chapters, only the starred versions of other sectioning commands (mainly \section* and \subsection*) should be used.

### Illustrative example of Book class

For example, this could be a standard book structure:

% Book document class
\documentclass{book}

\title{My first book}
\author{Me}
\date{\today}

\begin{document}

\maketitle

\frontmatter
\chapter{Dedication}
\chapter{Acknowledgements}

\tableofcontents

\listoffigures
\listoftables

\mainmatter
\part{The first part}
\chapter{Chapter one}
\chapter{Chapter two}

\part{Last part}
\chapter{Chapter three}

\appendix
\chapter{First and only appendix}

\backmatter
\chapter{Bibliography}
\chapter{Other titles in this collection}

\end{document}

You can see the table of contents produced by the previous book in Figure 1. Observe how the numbering of the pages and the sectioning commands change according to the part of the book we are in.

### Odd and even pages in Book class

When printing books, odd and even pages are not structured in the same way. Margins, and usually also headers and footers, change to provide better readability when the book is bound. This is taken into account in the book document class, where you will see that:

• left pages have a larger left margin, the page number at the top left of the page, and the title of the current chapter at the right, while
• right pages have a larger right margin and only the page number at the top right of the page. Also, new chapters start always at the right page and the page head is emptied, leaving only the page numb er at the center on the foot of the page.

### No built-in abstract

There is one more difference between the book class and the article and report classes: it doesn’t have a built-in abstract environment.

This environment is used in academic articles, and also reports, to give a brief description of the contents that will be treated along with the document. It is customary for this introduction to have special typesetting, with “Abstract” written in bold over it, and also it is common to find it printed just after the title and before the table of contents. As said, this environment is not implemented in the book document class.

### Memoir class

It is worth mentioning here that there is a popular extension of the book document class, called memoir, written by Peter Wilson.

This package aims to integrate multiple design-related packages with the LaTeX book class. It provides:

• a larger range of permissible font sizes,
• a large number of page styles, and well
• over a dozen chapter styles to choose from, as well as
• methods for specifying your own layouts and designs.
• It also integrates the functionality of over thirty popular packages.

So it is an extensive and complex document class, whose capabilities are incomparable to those of the book class. In case all of this made you curious, you can look at their official documentation to learn much more.

## LaTeX letter class

As with the slide document class, the letter is slightly old-fashioned. This class is used to make traditional letters, the ones that are put in an envelope and mailed, a somewhat obsolete way of communication (since the email was invented and generalized) but still used in certain official matters. Although the class was designed for traditional letters, still today there are certain documents that have the structure of a letter such as:

• a letter of recommendation, or
• a letter of presentation

and for which this document class may be useful. So let’s briefly discuss the details that characterize this particular document class!

With it, you can make any number of letters with a single input file:

• Your name and address, which are likely to be the same for all letters, are specified by special declarations.
• The return address is declared by an \address command, with multiple output lines separated by \\ commands (which is the common line-breaking command in LaTeX).
• The \signature command declares your name, as it appears at the end of the letter, with the usual \\ separating multiple lines.

These declarations are usually put in the preamble because they are common to all letters, but they are normal declarations with the customary scoping rules and can appear anywhere in the document. In particular, this means that you can change the return address and signature at any point.

Each letter is produced by a separate letter environment, having the name and address of the recipient as its mandatory argument.

• The letter itself begins with an \opening command that is used to generate the salutation.
• The main body of the lecture is ordinary LaTeX input.
• The letter closes with a \closing command that is passed the closing sentence and automatically generates the signature.

These may seem a lot of commands, but they are all very easy to use, and also very powerful since LaTeX automatically will take care of the formatting of the letter, without you having to worry about it at all.

In case you are not convinced yet, let me show you a clarifying example where all the commands are put into practice so that you can use it as a template for your letters:

% Example of a letter document class
\documentclass{letter}

\begin{document}

\begin{letter}
{Dr.~Anything \\ University of Nowhere\\ 66 Sesame Street\\ Wonderland, 45888}

\opening{Appreciated Anything,}

I write you a letter, and this is the body of the
letter.

\end{letter}

\end{document}

You can see the letter generated in Figure 2. Note how LaTeX automatically formates everything, and even inserts the current date without you asking for it. I find generating letters with LaTeX easier than doing it by hand!

We said that the date on the letters is automatically inserted by LaTeX and that it uses today’s date. We can, however, change this behavior by redefining the \today command, which is where LaTeX saves the name of the day. For example:

\renewcommand{\today}{12th of October of 1492}

will make \today print the content “12th of October of 1492”. This declaration can either be used on the preamble, to affect all letters or inside a certain letter environment, to only affect that letter.

## documentclass latex options

As was stated in the introduction, there are some optional arguments that can be passed to the \documentclass command. Here we are going to explain these options:

### Font size:

The options 10pt, 11pt, and 12pt choose the normal type size of the document. The default value is 10pt. This option is not recognized by the slides class.

### Paper size

The paper size can be selected between the following options:

• letterpaper (8.5in × 11in)
• legalpaper (8.5in × 14in)
• executivepaper (7.25in × 10.5in)
• A4 (210mm × 297mm)
• A5 (148mm × 210mm)
• B5 (176mm × 250mm)

By default, the paper size is letterpaper.

### Landscape

The landscape option causes the output to be formatted for landscape printing on the selected paper size. Effectively, this option interchanges the width and the height dimensions of the paper size.

### Draft

If TeX has trouble finding good places to break lines, it can produce lines that extend past the right margin (which produce the output warnings called “overfull hboxes”). The draft option causes such lines to be marked by black boxes in the output. The final option, which does not mark these lines, is the default.

### Two sides printing

The oneside and twoside options format the output to be printed on one side or both sides of a page, respectively. The default is oneside, except for the book class, for which it is twoside. However, the twoside option is not available with the slides document class.

### Opening page of chapters

If the openright option is used, then all chapters will begin on a right-hand page. Instead, with the openany option
you can make them start on any page. These options apply only to the report class (whose default is openany) and the book class (whose default is openright).

### Two column pages

The option twocolumn specifies two-column pages. The default is onecolumn, for one-column pages. The twocolumn option cannot be used with the letter or slides classes.

### Page for the title

The titlepage option causes the \maketitle command to make a separate title page and the abstract environment to put the abstract on a separate page. The default is titlepage for all classes except article, for which it is notitlepage. hese options, however, are not recognized by the letter class.

### Open bibliography style

openbib causes the bibliography to be formatted in an open style. This option is not recognized by the letter and slides classes.

### Numbered formulas

The option leqno puts formula numbers on the left side, instead of the right, which is the default.

### Formulas alignment

The option fleqn left-aligns formulas, which by default are centered.