Table of Contents in LaTeX

LaTeX generates a table of contents automatically with \tableofcontents — no manual formatting needed.

Quick Answer

latex
\documentclass{article}
\begin{document}

\tableofcontents
\newpage

\section{Introduction}
\subsection{Background}

\end{document}

How It Works

On the first compile, LaTeX writes section data to a .toc file. The second compile reads it to render the TOC. Always compile twice (or use latexmk which handles this automatically).

Controlling Depth

By default, the TOC includes up to subsubsection level. Reduce depth to keep it concise.

latex
% Show only sections and subsections:
\setcounter{tocdepth}{2}

% Show sections only:
\setcounter{tocdepth}{1}

% Depth values:
% 1 = \section
% 2 = \subsection
% 3 = \subsubsection

Writing your thesis in LaTeX?

MonsterWriter's LaTeX Workspace gives you real-time PDF preview with no compile limits — at a fraction of Overleaf's price. Works just like Overleaf, costs 11× less.

Try MonsterWriter free

List of Figures / Tables

latex
\tableofcontents
\listoffigures
\listoftables

Clickable TOC with hyperref

Load hyperref to make every TOC entry a clickable link in the PDF.

latex
\usepackage{hyperref}
% No other changes needed — \tableofcontents is automatically linked.

Custom TOC Title

latex
% Rename "Contents" to something else:
\renewcommand{\contentsname}{Table of Contents}

% For book/report class (chapters use \chaptername):
\renewcommand{\contentsname}{Contents}

Adding an Entry Manually

latex
% Add an unnumbered section to the TOC:
\section*{Acknowledgements}
\addcontentsline{toc}{section}{Acknowledgements}

Related Topics