Let
X
Journal

Add a Table of Contents, List of Figures in LaTeX

SPECIMEN IDLETX-SPEC-LATE
DATE RECORDEDMay 7, 2026
READING COMPLEXITY2 min read
TAG INDEX
latexstructuretutorial
Document Abstract

To add a table of contents in LaTeX, place \tableofcontents after your title and compile twice. Add \listoffigures and \listoftables the same way.

To add a table of contents in LaTeX, place \tableofcontents where you want it — usually right after \maketitle — and compile the document twice. LaTeX reads your \section, \subsection, and chapter commands, writes them to a .toc file, and typesets a formatted, page-numbered, clickable contents list. Lists of figures and tables work identically.

1. The one-line table of contents

\documentclass{report}
\begin{document}
\maketitle
\tableofcontents

\chapter{Introduction}
\section{Background}
\section{Goals}
\chapter{Method}
\end{document}

Nothing else is required — every sectioning command is added automatically. Compile twice: the first pass records the structure, the second inserts it with correct page numbers.

2. Add lists of figures and tables

\listoffigures
\listoftables

These collect every \caption{} inside figure and table floats. Each entry shows the caption text and page number, so write captions that read well out of context.

3. Control the depth

Two counters govern how deep numbering and the TOC go:

| Counter | Controls | Common value | |---|---|---| | secnumdepth | How deep sections are numbered | 2 or 3 | | tocdepth | How deep the TOC lists entries | 2 |

\setcounter{tocdepth}{2}     % sections + subsections only
\setcounter{secnumdepth}{3}  % number down to subsubsection

4. Include unnumbered sections

Starred sections (\section*) are skipped. Add them manually:

\section*{Acknowledgements}
\addcontentsline{toc}{section}{Acknowledgements}

This is how the abstract, preface, or acknowledgements appear in the TOC without a number.

5. Clickable contents

Load hyperref (last in your preamble) and every TOC entry becomes a clickable link to its page in the PDF, plus a bookmark sidebar — see hyperref: Clickable Links & Bookmarks. For where the TOC fits in a long document, see LaTeX Thesis Template.

→ See your contents list update live as you add sections in LetX.


Written by Shihab Shahriar Antor — AI Engineer & Founder of Shahriar Labs, maker of LetX.

Frequently Asked Questions

Why is my table of contents empty or out of date?

The table of contents is built from an auxiliary .toc file that LaTeX writes during one compile and reads on the next, so you must compile at least twice. After the first run the .toc is created but not yet inserted; the second run fills it in. If you add or rename sections, compile twice again. Online editors like LetX run the extra pass automatically, so the TOC is always current.

How do I control which heading levels appear in the TOC?

Set the tocdepth counter. \setcounter{tocdepth}{2} includes sections and subsections but not subsubsections; a value of 1 shows only sections; 3 includes subsubsections. This is independent of secnumdepth, which controls how deep the numbering goes. Set both in the preamble to keep numbering and the TOC consistent.

How do I add an unnumbered section to the table of contents?

Starred sections like \section*{Acknowledgements} are skipped by the TOC. To list one anyway, follow it with \addcontentsline{toc}{section}{Acknowledgements}. This is the standard trick for front-matter items such as the abstract or a preface that should appear in the TOC without a section number.