$\LaTeX$ document structure

Structural overview of a document

When a $\LaTeX$ input file is parsed, the compiler expects a certain structure in order to process it correctly.

🤔 Parsing? Compilers? More on that later
\documentclass{...}
... % Preamble
\begin{document}
... % Document
\end{document}

The syntax for a basic macro call in the $\LaTeX$ language is \command{arguments}, this will be presented more clearly in the syntax section.

$\LaTeX$ global structure

The preamble

The area between the \documentclass{...} and the \begin{document} is called preamble and can be seen as the "initialization" of our document as it contains:

$\LaTeX$ global structure

The document

Inside the \begin{document} and \end{document} commands it's possible to write text that is going to be printed on the final output.

The first commands inside the document delimiters are usually referred as "top matter" and don't have
a strict structure.

For most documents the titling information is located in the top matter section.

Notes on document structure

Most of the default document types are structured using the section hierarchy:

Document structure

Sectioning

All of the section commands that we have seen before belong to a class of sectioning commands used to subdivide our document.

They can be called in the following way:

\sectiontype{Section title}
... %Contents

There are a total of 7 levels of sectioning depth by default; some of them are available only in the book document classes (more on that in the themes section).

Document structure

Here's an example

document sections