[Tex/LaTex] Specify level of contents table

chapterssectioningtable of contents

In my document I have several chapters with sections and subsections. In the generated contents table, it would look like

1. Chapter
1.1 Section
1.1.1 Subsection
1.1.2 Subsection
2. Chapter
2.1 Section
2.1.1 Subsection

How can I specify, that the contents table only shows up to the sections level and excludes everything deeper (subsection, etc.).

So that it looks like:

1. Chapter
1.1 Section
2. Chapter
2.1 Section

Best Answer

The counter tocdepth controls the depth of sectioning levels appearing in the ToC

Setting the tocdepth to the value -2 is the usual way to hide everything (unless memoir class is used, then it's -3).

From part down to subparagraph the levels are -1, 0, 1,2, 3, 4 and 5.

Here, subsections shouldn't be entering the ToC, use \setcounter{tocdepth}{1} (preferably in the preamble).

Don't forget to compile twice, as usual with ToC related - 'problems'

\documentclass{book}

\setcounter{tocdepth}{1}
\begin{document}
\tableofcontents
\chapter{How to be seen}

\section{You see me}

\subsection{You won't see me in the Toc}

\end{document}

enter image description here

Related Question