Welcome to the UK List of
TeX Frequently Asked Questions
on the Web

Searching

The index of Frequently Asked Questions about TeX is searchable.

Please enter your keyword here:   then press here: ,    or:
Google

Unnumbered sections in the Table of Contents

The way the relevant parts of sectioning commands work is exemplified by the way the \chapter command uses the counter secnumdepth (described in Appendix C of the LaTeX manual):

  1. put something in the .aux file, which will appear in the .toc;
  2. if the secnumdepth counter is greater than or equal to zero, increase the counter for the chapter and write it out.
  3. write the chapter title.

Other sectioning commands are similar, but with other values used in the test.

So a simple way to get headings of funny ‘sections’ such as prefaces in the table of contents is to use the counter:

\setcounter{secnumdepth}{-1}
\chapter{Preface}

Unfortunately, you have to set secnumdepth back to its usual value (which is 2 in the standard styles) before you do any ‘section’ which you want to be numbered.

Similar settings are made, automatically, in the LaTeX book class by the \frontmatter and \backmatter commands.

The value of the counter tocdepth controls which headings will be finally printed in the table of contents; it is normally set in the preamble and is a constant for the document. The package tocvsec2 package takes the tedium out of changing the secnumdepth and/or the tocdepth counter values at any point in the body of the document; the commands (respectively) \setsecnumdepth and \settocdepth make the changes based on the name of the sectional unit (chapter, section, etc.).

The package abstract (see one-column abstracts) includes an option to add the abstract to the table of contents, while the package tocbibind has options to include the table of contents itself, the bibliography, index, etc., to the table of contents.

The KOMA-Script classes have commands \addchap and \addled, which work like \chapter and \section but aren’t numbered. The memoir class incorporates the facilities of all three of the abstract, tocbibind and tocvsec2 packages.

abstract.sty
macros/latex/contrib/abstract (or browse the directory); catalogue entry
KOMA script bundle
macros/latex/contrib/koma-script (or browse the directory); catalogue entry
memoir.cls
macros/latex/contrib/memoir (or browse the directory); catalogue entry
tocbibind.sty
macros/latex/contrib/tocbibind (or browse the directory); catalogue entry
tocvsec2.sty
macros/latex/contrib/tocvsec2 (or browse the directory); catalogue entry


Go to previous question, or next question

Go to FAQ home.

URL for this question: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=secnumdep

Comments, suggestions, or error reports? - see “how to improve the FAQ”.

This is FAQ version 3.28, released on 2014-06-10.