I wrote the following TeX program. This is copied straight from page 8 (Figure 1.2) of lshort.pdf.
\documentclass[a4paper,11pt]{article}
% define the title
\author{H.~Partl}
\title{Minimalism}
\begin{document}
% generates the title
\maketitle
% insert the table of contents
\tableofcontents
\section{Some Interesting Words}
Well, and here begins my lovely article.
\section{Good Bye World}
\ldots{} and here it ends.
\end{document}
But when I convert it to pdf using the pdflatex foo.tex command, I see
the following output in the PDF.
Why doesn't the \tableofcontents command generate any content under
the "Contents" heading?

pdflatex foo.texgeneratesfoo.tocandfoo.pdfwith an empty table of contents. Then the secondpdflatex foo.texperhaps uses the generatedfoo.tocand createsfoo.pdfwith a populated table of contents. Is there a way to generate onlyfoo.tocseparately in the first compilation without generatingfoo.pdf? – Lone Learner Jun 15 '16 at 04:38latex foo.tex && latex foo.tex && dvipdf foo.dvi. – Lone Learner Jun 15 '16 at 07:21.auxfile and this is read again at the second run (and creates the.tocetc. files, so two runs are necessary! – Jun 15 '16 at 07:40pdflatex foo.tex && pdflatex foo.tex:) – cgnieder Jun 15 '16 at 07:47