LaTeX guide · Overleaf and desktop

LaTeX table of contents, list of figures and list of tables

To make a LaTeX table of contents, put \tableofcontents where the contents should appear and compile twice. LaTeX builds it from your \chapter, \section and \subsection headings, with page numbers. \listoffigures and \listoftables work the same way, from the captions of your figures and tables. You never type the entries yourself.

By André Antão Published 12 min read
The short answer
  1. Write your headings with \chapter{…}, \section{…} and \subsection{…}. Every numbered heading goes into the contents by itself.
  2. After the abstract, add \tableofcontents, then \listoffigures and \listoftables if you have captioned figures and tables.
  3. Compile twice (Overleaf and latexmk do this for you). The first run writes the entries to a .toc file; the second prints them.
  4. To list fewer or more levels, put \setcounter{tocdepth}{1} (chapters and sections) or {3} in the preamble.

01Insert the table of contents

The command \tableofcontents prints the contents page wherever you place it. In the report and book classes it starts a new page headed "Contents"; in article it prints a "Contents" heading in place. Most theses put it after the abstract, followed by \listoffigures and \listoftables, and the entries appear on the second compile.

A thesis is usually written in the report or book class, because both have \chapter. The skeleton below is the front of my fictional thesis, Brand trust and customer loyalty in subscription services. It gives roman page numbers to the front matter, then starts Chapter 1 on page 1.

main.tex
\documentclass[12pt,a4paper]{report}
\usepackage[british]{babel}
\usepackage[nottoc]{tocbibind}
\usepackage[hidelinks]{hyperref} % last

\begin{document}
\pagenumbering{roman}

\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
...

\tableofcontents
\listoffigures
\listoftables

\clearpage
\pagenumbering{arabic}
\chapter{Introduction}
\section{Background and motivation}
\chapter{Literature review}
\section{Brand trust}
\subsection{Defining trust}
...
\end{document}

tocbibind puts the lists and the references in the contents (section 03), and hyperref makes the entries clickable (section 06). Neither is needed for a basic contents page.

  1. Put \tableofcontents where the contents page belongs. In report and book it starts on a new page with the heading "Contents".
  2. Add \listoffigures and \listoftables after it, if your guide asks for them.
  3. Compile. On Overleaf, click Recompile. On your own computer, run latexmk -pdf main.tex, or run pdflatex main.tex twice.
  4. Check the contents page in the PDF. If it shows only the heading, compile once more.
Figure 1How LaTeX builds the contents. On the first run every heading writes one line to main.toc: its level, its number, its title and its page (with hyperref, a link target is added at the end of each line). On the next run \tableofcontents reads that file and typesets it. In the standard report class, chapter entries are bold with no dots; sections and subsections get dot leaders.

That two-step process explains most contents problems. LaTeX stores the entries in an auxiliary file, a helper file it writes next to your PDF, named after your main file (main.toc, and main.lof and main.lot for the lists) and reads them back on the following run. So the very first compile of a new document gives a contents page with nothing but its heading, and any change to a heading shows up one run late. Overleaf compiles with latexmk, which runs the whole sequence for you, so you rarely notice.

02Choose how many levels appear: tocdepth

Each sectioning command has a level number. The counter tocdepth sets the deepest level the contents lists, and a separate counter, secnumdepth, sets the deepest level that gets a number.

  • \part is level −1 in report and book (0 in article)
  • \chapter is level 0
  • \section is level 1
  • \subsection is level 2
  • \subsubsection is level 3, \paragraph 4, \subparagraph 5

In report and book both counters default to 2, so chapters, sections and subsections are numbered and listed. In article both default to 3. To change them, put these lines in the preamble, the part of main.tex between \documentclass and \begin{document}:

  • \setcounter{tocdepth}{1} lists chapters and sections only, a common requirement in thesis guides.
  • \setcounter{tocdepth}{3} also lists subsubsections. Add \setcounter{secnumdepth}{3} as well, or they appear in the contents without their number (such as 2.1.1.1).

The two counters are independent. Raising tocdepth alone gives you unnumbered lines in the contents, and raising secnumdepth alone gives you numbered headings that the contents ignores.

Tip

A long heading can have a shorter version for the contents. Write \section[Customer loyalty]{Customer loyalty in subscription services: attitudinal and behavioural views}. The text in square brackets goes into the contents and the running head; the full title stays in the text.

The heading levels themselves, and how deep a thesis should go, are covered in my guide to writing a thesis in LaTeX.

03Abstract, references and other unnumbered entries

The starred commands, such as \chapter*{Abstract}, print a heading without a number and leave it out of the contents. Thesis guides usually want the abstract, acknowledgements, lists and references in the contents anyway, so each one needs a line added.

Add an unnumbered chapter

  1. Write the heading with the star: \chapter*{Acknowledgements}.
  2. On the next line, add \addcontentsline{toc}{chapter}{Acknowledgements}. The three arguments are the file (toc), the level the entry should look like (chapter), and the text.
  3. Compile twice. LaTeX takes the page number from the point where \addcontentsline stands, so keep it right after the heading.

For a section-level entry, use \section* and \addcontentsline{toc}{section}{…}. If the entry should line up with the chapter titles rather than flush left, add an empty number box: \addcontentsline{toc}{chapter}{\protect\numberline{}Preface}.

Roman numbers for the front matter

The contents copies each page's number as it is, so the numbering has to be right first. In report, put \pagenumbering{roman} at the start of the document and \clearpage followed by \pagenumbering{arabic} just before Chapter 1, as in the skeleton above. \pagenumbering restarts the count at once, so the \clearpage keeps the last front page from becoming page 1. In book, \frontmatter and \mainmatter do both jobs. My guide to LaTeX page numbering covers the title page and the cases that go wrong.

List the lists, the bibliography and the index

The standard classes print the lists of figures and tables and the bibliography with starred headings, so they aren't in the contents either. Which fix you use depends on your class and bibliography package:

  • Standard classes (report, book, article): load \usepackage[nottoc]{tocbibind}. It adds the list of figures, list of tables, bibliography and index to the contents. Without nottoc it also adds the contents page to itself, which a contents page normally does not show. notlof, notlot, notbib and notindex leave out the others.
  • biblatex: print the references with \printbibliography[heading=bibintoc].
  • KOMA-Script (scrreprt, scrbook): use the class options toc=listof and toc=bibliography.
  • memoir: \tableofcontents, \listoffigures and \listoftables already add themselves. The starred forms (\tableofcontents*) leave them out.

Abstract, declaration, glossary and six appendices to list in the right order?I can set up the front matter for you

04List of figures and list of tables

\listoffigures and \listoftables work like the contents, but they read the captions. Each \caption inside a figure or table environment writes one entry to main.lof or main.lot. A figure without \caption, or with a title typed as ordinary text, isn't listed.

chapters/literature-review.tex
\begin{figure}[htbp]
  \centering
  \includegraphics[width=0.8\textwidth]{research-model}
  \caption[Research model]{Research model linking brand
    trust, satisfaction and perceived value to loyalty
    and word of mouth}
  \label{fig:model}
\end{figure}

The text in square brackets is the short caption. It is what the list of figures shows; the full caption stays under the figure. Use it whenever a caption runs to more than a line, or has a source note or citation in it.

Figure 2The short caption in square brackets goes into the list of figures; the long caption stays under the figure. The report class numbers figures by chapter (2.1 is the first figure in Chapter 2) and leaves a little space between chapters in the list.

Lists of tables work the same way with \caption inside table. To change the headings, write \renewcommand{\listfigurename}{List of Illustrations} or \renewcommand{\listtablename}{…} (with babel, see renaming the headings). How the captions themselves should look, above or below, numbered by chapter or straight through, is in my guide to captions in LaTeX, and placing the figures is in figures in LaTeX.

05Dots, fonts and spacing with tocloft

The standard classes set the look of the contents and offer no options to change it. A dot leader is the row of dots that runs from an entry's title to its page number. If your guide wants dots after the chapter titles, a different font or more space between entries, load the tocloft package. Each kind of entry gets its own commands, with a short name in the middle: chap, sec, subsec, fig and tab.

preamble
\usepackage{tocloft}

% dot leaders after chapter titles too
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}

% chapter entries not bold (title and page number)
\renewcommand{\cftchapfont}{\normalfont}
\renewcommand{\cftchappagefont}{\normalfont}

% more room before each chapter entry
\setlength{\cftbeforechapskip}{8pt}

% wider number box for sections such as 10.12
\setlength{\cftsecnumwidth}{3em}
\setlength{\cftsubsecindent}{4.5em}
Figure 3Left: the report class default, with bold chapter entries and no dots after them. Right: the same contents with the tocloft settings above, where chapter entries are in regular weight and have the same dot leader as sections.

Two things catch people out with tocloft:

  • With tocloft, the contents and lists no longer start on a new page by themselves. Put \clearpage before \tableofcontents, \listoffigures and \listoftables.
  • tocloft's manual says it is not compatible with the KOMA-Script classes (KOMA-Script itself warns against loading it), and the memoir class has the same commands built in. In KOMA-Script, use its own \DeclareTOCStyleEntry; in memoir, use the commands without loading the package.

If you change the number width of one level, move the next level's indent by the same amount (above: 1.5em indent + 3em number box = 4.5em), or the subsections stop lining up under the section titles.

Rename the LaTeX contents heading

The heading comes from \contentsname ("Contents"), \listfigurename and \listtablename. To call it "Table of Contents", write \renewcommand{\contentsname}{Table of Contents} in the preamble. If you load babel, that line is overwritten when the document starts, and you still get "Contents". Wrap it in the hook for your babel language instead:

\addto\captionsbritish{\renewcommand{\contentsname}{Table of Contents}}

Use \captionsenglish, \captionsamerican or \captionsportuguese to match the language you gave babel.

Your guide wants the LaTeX contents to match its Word template line for line?I can match it for you

06Clickable entries with hyperref

Load hyperref and every entry in the contents and lists becomes a link to its page in the PDF, and the headings become PDF bookmarks. Load it after your other packages, as the last one in most preambles.

  • \usepackage[hidelinks]{hyperref} keeps the links but removes the coloured boxes around them, so the PDF looks the same on screen and on paper.
  • \usepackage[linktocpage]{hyperref} makes the page number the link instead of the title.
  • If a link from an \addcontentsline entry lands on the wrong page, put \phantomsection just before \addcontentsline. It sets a link target at that point. This matters most for entries that have no heading command of their own, such as an index printed with \printindex.

Maths or formatting in a heading gives the warning "Token not allowed in a PDF string", because a bookmark can only hold plain text. Give hyperref a plain version: \chapter{Effect of \texorpdfstring{$\beta$}{beta} on loyalty}. The contents shows β; the bookmark shows "beta".

07Table of contents empty or wrong? Fixes

These are the problems I see most in theses that arrive in LaTeX. After each fix, compile twice before you judge the result.

Figure 4The same contents page after one compile and after two. On the first run LaTeX has no main.toc to read, so the page holds only its heading; the second run fills it in. A contents page that stays empty after several runs points to an error that stops LaTeX before it can write the file.

The contents page is empty

Compile again. If it stays empty, look at the log for an error that stops the run: LaTeX only finishes writing main.toc when it reaches the end of the document. In Overleaf, open the logs, fix the first error, and recompile.

Old or duplicated entries that won't go away

The auxiliary files can keep stale entries after an error or a renamed file. On Overleaf, choose Recompile › Recompile from scratch (the arrow next to the Recompile button), or click Logs and output files and then Clear cached files. On your own computer, delete main.aux, main.toc, main.lof and main.lot, and compile twice.

Subsubsections or sections are missing

Their level is deeper than tocdepth. In report and book, subsubsections are level 3 and the default depth is 2. Set \setcounter{tocdepth}{3} (and secnumdepth to 3 if they should be numbered), as in section 02.

The abstract or acknowledgements are missing

They use \chapter*, which never writes an entry. Add \addcontentsline{toc}{chapter}{Abstract} right after the heading (section 03).

An entry has the wrong page number

If it is an \addcontentsline entry, the line probably sits before a page break: before \chapter* rather than after it, or before a \clearpage. Move it to just after the heading. If the front matter shows 1, 2, 3 instead of i, ii, iii, fix the page numbering, not the contents.

Entries come out in the wrong order

An \addcontentsline or \addtocontents written in main.tex just before \include{chapter3} can land in the wrong place in the contents. Move the line into the included file.

Numbers run into the titles

"12.12Brand trust" means the number is wider than its box. Widen it with tocloft: \setlength{\cftsecnumwidth}{3em}, or \cftsubsecnumwidth for subsections, and move the next level's indent to match (section 05).

The heading says "Contents" after you renamed it

babel is resetting it. Put the \renewcommand inside \addto\captionsbritish{…} for your language, as shown under renaming the heading.

The references aren't in the contents

Use tocbibind with the standard classes and BibTeX or natbib, heading=bibintoc with biblatex, or toc=bibliography in KOMA-Script. My guide to the LaTeX bibliography explains which package you are using.

Fighting LaTeX the week before submission?Send it to me and I'll fix it

08What your university decides

LaTeX gives you a working contents page with no settings at all, but no university asks for exactly the default. Their guides differ on all of these, so check yours before you submit:

  • Which front pages are listed (abstract, acknowledgements, lists, abbreviations) and whether the contents lists itself.
  • How many levels to show: two (chapters and sections) or three.
  • Whether chapter entries are bold, in capitals, or have dot leaders.
  • Roman numbers for the front matter, and page 1 on the first page of Chapter 1.
  • How appendices are listed: each one by letter, or a single "Appendices" line.

What a dissertation contents page usually contains, with a sample page, is in my guide to the dissertation table of contents. Margins and binding offset, which change where every line of the contents sits, are in my guide to LaTeX margins.

If your university supplies a LaTeX class, it usually sets most of this already: change it only where the written guide disagrees. The full list of checks before submission is in my thesis formatting checklist. Writing in Word instead? The same job there is in how to make a table of contents in Word.

09Questions people ask

How do I add a table of contents in Overleaf?

Type \tableofcontents where it should go and click Recompile. Overleaf compiles with latexmk, which reruns LaTeX until the cross-references settle (latexmk's manual says it runs LaTeX "enough times to resolve cross-references"), so the entries normally appear after one click. If they don't, use Recompile › Recompile from scratch.

Why is my LaTeX table of contents empty?

LaTeX reads the entries from the .toc file written on the previous run. After the first compile the file doesn't exist yet, so compile again. If it stays empty, an error is stopping the run before the end of the document.

How do I show only chapters and sections?

Put \setcounter{tocdepth}{1} in the preamble. Level 1 is \section, so subsections and anything deeper are left out.

How do I stop the contents from listing itself?

With tocbibind, load it as \usepackage[nottoc]{tocbibind}. In memoir, use \tableofcontents*. The standard classes on their own never list the contents page.

How do I put "Page" above the page numbers?

Right after \tableofcontents, add \addtocontents{toc}{~\hfill\textbf{Page}\par}. It writes a line with "Page" at the right margin into the contents.

How are appendices listed?

After \appendix, each \chapter is lettered (A, B, C) and listed like a chapter. For a single "Appendices" line instead, add \addcontentsline{toc}{chapter}{Appendices} and use starred headings for the appendices themselves.

Can I make a table of contents in an article?

Yes. \tableofcontents works in article too, listing sections, subsections and subsubsections. It doesn't start a new page, so add \newpage after it if you want one.

How this was checked

I compiled every example on this page with TeX Live 2025 (pdfTeX 1.40.27, latexmk) on Windows 11 in October 2026, and checked the commands against the LaTeX2e unofficial reference manual, Overleaf's documentation and the manuals of tocloft, tocbibind, hyperref, biblatex, KOMA-Script, memoir and latexmk. The KOMA-Script toc= options, biblatex's heading=bibintoc and memoir's starred commands come from their manuals and were not compiled. All pages are listed under Sources.

André Antão is a university lecturer in Management and Marketing at the Polytechnic University of Portalegre and a PhD candidate in Management. He has formatted theses in Word and LaTeX for 8 years.

Sources

  1. Table of contents, list of figures, list of tables LaTeX2e unofficial reference manual
  2. Sectioning (tocdepth and secnumdepth) LaTeX2e unofficial reference manual
  3. \addcontentsline LaTeX2e unofficial reference manual
  4. \addtocontents LaTeX2e unofficial reference manual
  5. figure (short captions) LaTeX2e unofficial reference manual
  6. Table of contents Overleaf
  7. Lists of tables and figures Overleaf
  8. Sections and chapters Overleaf
  9. Page numbering Overleaf
  10. Hyperlinks Overleaf
  11. Clearing the project cache Overleaf docs
  12. The latexmkrc file Overleaf docs
  13. The tocloft package (manual, v3.0c) CTAN
  14. The tocbibind package (manual) CTAN
  15. The hyperref package (manual) CTAN
  16. The biblatex package (manual: heading=bibintoc) CTAN
  17. KOMA-Script (scrguide: toc= options) CTAN
  18. The memoir class (memman: \tableofcontents*) CTAN
  19. latexmk CTAN
  20. latexmk (manual) CTAN