A well-structured LaTeX document is easier to read, edit, and maintain. This guide explains how to organize your document with sections, chapters, and automatically generate a table of contents.
Document classes
The first line of any LaTeX document defines its class. It determines the overall layout, available commands, and document style.
| Class | Usage | Structure levels |
|---|---|---|
article |
Short articles, simple reports | section, subsection, subsubsection |
report |
Long reports, dissertations | chapter, section, subsection... |
book |
Books, theses | part, chapter, section... |
beamer |
Presentations (slides) | frame, block |
% Article type document
\documentclass[12pt, a4paper]{article}
% Report type document (with chapters)
\documentclass[12pt, a4paper]{report}
% Book type document
\documentclass[12pt, a4paper, twoside]{book}
12pt (font size), a4paper (paper format), twoside (double-sided printing). Sections and subsections
LaTeX offers several levels of hierarchical structuring. Numbering is automatic.
Command hierarchy
| Command | Level | Available in |
|---|---|---|
\part{} |
-1 | book, report |
\chapter{} |
0 | book, report |
\section{} |
1 | all |
\subsection{} |
2 | all |
\subsubsection{} |
3 | all |
\paragraph{} |
4 | all |
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\begin{document}
\section{Introduction}
Introduction text...
\section{Methodology}
\subsection{Data collection}
Description of data collection...
\subsection{Analysis}
\subsubsection{Quantitative analysis}
Quantitative analysis details...
\subsubsection{Qualitative analysis}
Qualitative analysis details...
\section{Results}
Presentation of results...
\end{document}
Unnumbered sections
Add an asterisk * to remove numbering:
\section*{Acknowledgements}
I thank all the people who contributed...
\section*{Appendices}
Supplementary documents...
* are not automatically included in the table of contents. Use \addcontentsline{toc}{section}{Title} to add them manually. Table of contents
LaTeX automatically generates the table of contents from your sections. A single command is all you need:
\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\title{My report}
\author{John Smith}
\begin{document}
\maketitle
\tableofcontents % Generates the table of contents
\newpage % New page after the table
\chapter{Introduction}
...
\chapter{Development}
\section{First part}
...
\end{document}
.toc file, the second uses it to generate the table. Table of contents depth
By default, the table includes up to subsection. Change the depth with tocdepth:
% In the preamble
\setcounter{tocdepth}{3} % Includes up to subsubsection
% Possible values:
% 0 = chapter only
% 1 = chapter + section
% 2 = chapter + section + subsection (default)
% 3 = up to subsubsection
The preamble
The preamble is the part between \documentclass and \begin{document}. This is where you configure your document.
\documentclass[12pt, a4paper]{article}
% === PREAMBLE ===
% Encoding and language
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
% Margins
\usepackage[margin=2.5cm]{geometry}
% Mathematics
\usepackage{amsmath, amssymb}
% Images
\usepackage{graphicx}
% Clickable links
\usepackage{hyperref}
% Metadata
\title{My document}
\author{First Last}
\date{\today}
% === END OF PREAMBLE ===
\begin{document}
\maketitle
\section{Introduction}
Here is a document using the packages configured in the preamble.
\section{Formula}
Einstein's equation: $E = mc^2$
\end{document}
Special pages
Title page
The \maketitle command generates a title page based on information from the preamble:
\title{Document title}
\author{Main Author \and Co-author}
\date{January 15, 2025} % or \today for the current date
\begin{document}
\maketitle % Generates the title page
\end{document}
Abstract
\begin{abstract}
This document presents a complete analysis of...\nThe results show that...
\end{abstract}
Appendices
\appendix % Changes numbering (A, B, C...)
\section{Raw data}
Data table...
\section{Source code}
Code listing...
Complete example
Here is a complete structured report template:
\documentclass[12pt, a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[margin=2.5cm]{geometry}
\usepackage{hyperref}
\title{Internship report}
\author{Mary Smith}
\date{June 2025}
\begin{document}
% Title page
\maketitle
% Abstract
\begin{abstract}
This report presents the work carried out during my three-month\ninternship at company XYZ...
\end{abstract}
% Table of contents
\tableofcontents
\newpage
% Content
\chapter{Introduction}
\section{Context}
Presentation of the context...
\section{Objectives}
The internship objectives were...
\chapter{Work carried out}
\section{First task}
\subsection{Description}
...
\subsection{Results}
...
\section{Second task}
...
\chapter{Conclusion}
In conclusion, this internship allowed me to...
% Appendices
\appendix
\chapter{Supplementary documents}
...
\end{document}
Ready to structure your document?
Create a professional report with Sarmate.net
Create a free account