I am trying to make a table of contents exactly as instructed on the tutorial, but it does not show up, even when I compile 2 times. The tutorial uses this code as an example:

\documentclass{article}

\begin{document}

\tableofcontents
\newpage

\section{Section}

Dummy text

\subsection{Subsection}

Dummy text

\end{document}


And it should output this:

But in my document after compiling twice, only the "Contents" header shows up on the first page and sections I added on the second page.

I also tried using the \addtocontents{toc} and \setcounter{tocdepth}{3} commands but they don't do anything. How do I make the contents appear, including the page numbers of each section as shown in the tutorial?

• I clarified that this is happening after I compiled it twice. – Random Stuff Jun 26 '19 at 13:04
• The MWE that you have provided worked well on my system. Which TeX-engine are you using? – Niranjan Jun 26 '19 at 13:05

I'll let LaTeX answer the question:

\documentclass{article}
\begin{document}
\latexbase
\makeatletter
\immediate\write\@auxout
\makeatother
\end{document}


(as always, compile twice).

LaTeXbase doesn't seem to keep track of auxiliary files, such as the .toc for the Table of Contents, or even the .aux file. Plus, the log file there says:

This is pdfTeX, Version 3.1415926-1.40.11 (TeX Live 2010)


so for those who complain that Overleaf's TeXLive distribution is outdated (2017)...

The solution is to move to another platform (Overleaf, for example), or better, have a local installation.

• Thank you. I just tried it in Overleaf and it worked. – Random Stuff Jun 26 '19 at 13:22
• Note they are not using an off the shelf texlive distribution but compiling the tex sources to javascript and running it in a browser so they can perhaps be forgiven not for updating too often (aux files ought to work though....) – David Carlisle Jun 26 '19 at 13:48