3

Where is my table of contents? I looked at Table of contents using article and report classes and here's my MWE. According to the commentators, everything down three levels should appear--but the ToC file (yes, I ran LaTeX twice) is a zero byte file, hence no ToC is being generated.

\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{ulem}
\usepackage{amsmath}
%\usepackage{tocloft}  didn't do anything. 
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{\footnotesize{important info}}
\chead{}
\rhead{}
\lfoot{}
\cfoot{}
\rfoot{\footnotesize{less-important info}}
\title{boring article}
\author{troubled author}
\date{}
%\setcounter{tocdepth}{3} this is the default. I've tried other values.
\usepackage{mathpazo} nice fonts.
\begin{document}
\maketitle
\tableofcontents
\begin{center}\textbf{Part $[$1$]$: General Provisions}\end{center}
\section*{Article $[$1$]$ Definitions}
 Blah blah blah
\section*{Article $[$2$]$ More Definitions} 
Blah blah
\end{document}

What am I missing? Is the fancyheader package interfering?

  • 6
    You are trying hard to avoid to get a table of contents by using the starred version of \section. Remove the *. If you want unnumbered sections change the secnumdepth counter. – Ulrike Fischer Mar 7 '16 at 11:53
  • @UlrikeFischer If I change \section* to \section then I do get a ToC. But I have to suppress the automatically-generated section numbers. So I changed \section back to \section* and the automatically generated numbers disappeared. Then I added \setcounter{tocdepth}{3} both before and after \begin{document}. In both cases, no ToC was generated. – user26732 Mar 7 '16 at 12:04
  • 1
    If i may quote Ulrike: If you want unnumbered sections change the secnumdepth counter. \setcounter{secnumdepth}{-1} – Johannes_B Mar 7 '16 at 12:08
  • 1
    How can I mark these as answers? – user26732 Mar 7 '16 at 12:17
  • 1
    I converted the comment to an answer. – Ulrike Fischer Mar 7 '16 at 12:35
7

To summarize the tips in the comments:

\documentclass[12pt,a4paper]{article}
\begin{document}

\tableofcontents

\section*{I'm not in the toc}
 Blah blah blah
\section{I'm in the toc and I'm numbered}
Blah blah blah

\setcounter{secnumdepth}{-1}
\section{I'm in the toc and I'm not numbered}

Blah blah blah
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.