Document Fundamentals

Document Structure

Learn how to structure LaTeX documents with classes, environments, sections, and table of contents.

The main point of writing a text is to convey ideas, information, or knowledge to the reader. The reader will understand the text better if these ideas are well-structured, and will see and feel this structure much better if the typographical form reflects the logical and semantic structure of the content.

Given only the logical and semantical structure of a text, LaTeX derives the typographical form of the text according to the "rules" given in the document class file and in various style files. LaTeX allows users to structure their documents with a variety of hierarchical constructs, including chapters, sections, subsections and paragraphs.

Global Structure

When LaTeX processes an input file, it expects it to follow a certain structure. Thus every input file must contain the commands:

\documentclass{...}

\begin{document}
...
\end{document}

The area between \documentclass{...} and \begin{document} is called the preamble. It normally contains commands that affect the entire document.

After the preamble, the text of your document is enclosed between two commands which identify the beginning and end of the actual document:

\begin{document}
...
\end{document}

You would put your text where the dots are. The reason for marking off the beginning of your text is that LaTeX allows you to insert extra setup specifications before it. The reason for marking off the end of your text is to provide a place for LaTeX to be programmed to do extra stuff automatically at the end of the document, like making an index.

A useful side-effect of marking the end of the document text is that you can store comments or temporary text underneath the \end{document} in the knowledge that LaTeX will never try to typeset them:

\end{document}
...

Preamble

Document Classes

When processing an input file, LaTeX needs to know which layout standard to use. Layout standards are contained within class files which have .cls as their filename extension.

\documentclass[options]{class}

Here, the class parameter for the command \documentclass specifies the .cls file to use for the document. It is recommended to put this declaration at the very beginning. The LaTeX distribution provides additional classes for other layouts, including letters and slides. It is also possible to create your own, as is often done by journal publishers, who simply provide you with their own class file, which tells LaTeX how to format your content. The options parameter customizes the behavior of the document class. The options have to be separated by commas.

Example: an input file for a LaTeX document could start with the line:

\documentclass[11pt,twoside,a4paper]{article}

which instructs LaTeX to typeset the document as an article with a base font size of 11 points, and to produce a layout suitable for double sided printing on A4 paper.

Common Document Classes:

ClassDescription
articleFor articles in scientific journals, presentations, short reports, program documentation, invitations, ...
IEEEtranFor articles with the IEEE Transactions format.
procA class for proceedings based on the article class.
minimalAs small as it can get. Only sets a page size and a base font. Mainly used for debugging purposes.
reportFor longer reports containing several chapters, small books, thesis, ...
bookFor books.
slidesFor slides. Uses big sans serif letters.
memoirFor sensibly changing the output of the document. Based on the book class.
letterFor writing letters.
beamerFor writing presentations.

Common Document Class Options:

OptionsDescription
10pt, 11pt, 12ptSets the size of the main font in the document. If no option is specified, 10pt is assumed.
a4paper, letterpaper,...Defines the paper size. The default size is letterpaper.
fleqnTypesets displayed formulas left-aligned instead of centered.
leqnoPlaces the numbering of formulas on the left hand side instead of the right.
titlepage, notitlepageSpecifies whether a new page should be started after the document title or not.
twocolumnInstructs LaTeX to typeset the document in two columns instead of one.
twoside, onesideSpecifies whether double or single sided output should be generated.
landscapeChanges the layout of the document to print in landscape mode.
openright, openanyMakes chapters begin either only on right hand pages or on the next page available.
draft, finalfinal is default. draft makes LaTeX indicate hyphenation and justification problems.

For example, if you want a report to be in 12pt type on A4, but printed one-sided in draft mode, you would use:

\documentclass[12pt,a4paper,oneside,draft]{report}

Packages

While writing your document, you will probably find that there are some areas where basic LaTeX cannot solve your problem. If you want to include graphics, colored text or source code from a file into your document, you need to enhance the capabilities of LaTeX. Such enhancements are called packages. The command to use a package is:

\usepackage[options]{package}

where package is the name of the package and options is a list of keywords that trigger special features in the package. For example, to use the color package:

\documentclass{report}
\usepackage{color}

\begin{document}
...
\end{document}

You can pass several options to a package, each separated by a comma:

\usepackage[option1,option2,option3]{package_name}

The Document Environment

Top Matter

At the beginning of most documents there will be information about the document itself, such as the title and date, and also information about the authors, such as name, address, email etc. All of this type of information within LaTeX is collectively referred to as top matter.

A simple example:

\documentclass[11pt,a4paper]{report}

\begin{document}
\title{How to Structure a LaTeX Document}
\author{Andrew Roberts}
\date{December 2004}
\maketitle
\end{document}

The \title, \author, and \date commands are self-explanatory. You put the title, author name, and date in curly braces after the relevant command. The title and author are usually compulsory (at least if you want LaTeX to write the title automatically); if you omit the \date command, LaTeX uses today's date by default. You always finish the top matter with the \maketitle command, which tells LaTeX that it's complete and it can typeset the title according to the information you have provided and the class (style) you are using. If you omit \maketitle, the title will never be typeset.

Note: Using this approach, you can only create a title with a fixed layout. If you want to create your title freely, see the Title Creation section. You should remember, however, that the goal of LaTeX is to leave formatting to the documentclass designer.

Abstract

As most research papers have an abstract, there are predefined commands for telling LaTeX which part of the content makes up the abstract. This should appear in its logical order, therefore, after the top matter, but before the main sections of the body. This command is available for the document classes article and report, but not book.

\documentclass{article}

\begin{document}

\begin{abstract}
Your abstract goes here...
...
\end{abstract}
...
\end{document}

By default, LaTeX will use the word "Abstract" as a title for your abstract. If you want to change it into anything else, e.g. "Executive Summary", add the following line before you begin the abstract environment (but after the \begin{document} command):

\renewcommand{\abstractname}{Executive Summary}

Sectioning Commands

The commands for inserting sections are fairly intuitive. Of course, certain commands are appropriate to different document classes. For example, a book has chapters but an article doesn't.

\chapter{Introduction}
This chapter's content...

\section{Structure}
This section's content...

\subsection{Top Matter}
This subsection's content...

\subsubsection{Article Information}
This subsubsection's content...

Notice that you do not need to specify section numbers; LaTeX will sort that out for you. Also, for sections, you do not need to use \begin and \end commands to indicate which content belongs to a given block.

LaTeX provides 7 levels of depth for defining sections:

CommandLevelComment
\part{part}-1not in letters
\chapter{chapter}0only books and reports
\section{section}1not in letters
\subsection{subsection}2not in letters
\subsubsection{subsubsection}3not in letters
\paragraph{paragraph}4not in letters
\subparagraph{subparagraph}5not in letters

All the titles of the sections are added automatically to the table of contents. If you make manual styling changes to your heading, LaTeX allows you to give an optional extra version of the heading text which only gets used in the Table of Contents:

\section[Effect on staff turnover]{An analysis of the
effect of the revised recruitment policies on staff
turnover at divisional headquarters}

Section Numbering

Numbering of the sections is performed automatically by LaTeX. You can change the depth to which section numbering occurs using the \setcounter command:

\setcounter{secnumdepth}{1}

A related counter is tocdepth, which specifies what depth to take the Table of Contents to:

\setcounter{tocdepth}{3}

To get an unnumbered section heading, follow the command name with an asterisk:

\subsection*{Introduction}

Section Number Style

See Counters.

Ordinary Paragraphs

Paragraphs of text come after section headings. Simply type the text and leave a blank line between paragraphs. The blank line means "start a new paragraph here": it does not mean you get a blank line in the typeset output.

Table of Contents

All auto-numbered headings get entered in the Table of Contents automatically. You don't have to print a ToC, but if you want to, just add the command \tableofcontents at the point where you want it printed (usually after the Abstract or Summary).

The commands \listoffigures and \listoftables work in exactly the same way as \tableofcontents to automatically list all your tables and figures.

To add an unnumbered section to the Table of Contents:

\subsection*{Preface}
\addcontentsline{toc}{subsection}{Preface}

Depth

The default ToC will list headings of level 3 and above. To change how deep the table of contents displays:

\setcounter{tocdepth}{4}

This will make the table of contents include everything down to paragraphs.

Book Structure

The standard LaTeX book class follows the same layout with some additions:

\begin{document}
\frontmatter

\maketitle

% Introductory chapters
\chapter{Preface}
% ...

\mainmatter
\chapter{First chapter}
% ...

\appendix
\chapter{First Appendix}

\backmatter
\chapter{Last note}
  • frontmatter: chapters will not be numbered. Page numbers will be printed in roman numerals.
  • mainmatter: works as usual. Resets the page numbering. Page numbers will be printed in arabic numerals.
  • appendix: indicates that following sections or chapters are to be numbered as appendices.
  • backmatter: chapters will not be numbered, but unlike frontmatter, page numbering is left as-is (it keeps counting up in arabic from wherever mainmatter left it).

Page Order

This is one traditional page order for books:

Frontmatter:

  1. Half-title
  2. Empty
  3. Title page
  4. Information (copyright notice, ISBN, etc.)
  5. Dedication if any, else empty
  6. Table of contents
  7. List of figures
  8. Preface chapter

Mainmatter:

  1. Main topic

Appendix:

  1. Some subordinate chapters

Backmatter:

  1. Bibliography
  2. Glossary / Index

Special Pages

Bibliography

Any good research paper will have a complete list of references. LaTeX has two ways of inserting your references into a document:

  • You can embed them within the document itself. It's simpler, but it can be time-consuming.
  • You can store them in an external BibTeX file and then link them via a command to your current document and use a BibTeX style to define how they appear.

To learn how to add a bibliography to your document, see the Bibliography Management section.

Copyright © 2026