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?

5
  • 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. Commented Mar 7, 2016 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
    Commented Mar 7, 2016 at 12:04
  • 1
    If i may quote Ulrike: If you want unnumbered sections change the secnumdepth counter. \setcounter{secnumdepth}{-1}
    – Johannes_B
    Commented Mar 7, 2016 at 12:08
  • 1
    How can I mark these as answers?
    – user26732
    Commented Mar 7, 2016 at 12:17
  • 1
    I converted the comment to an answer. Commented Mar 7, 2016 at 12:35

1 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .