Question

Hi,

I was wondering if there is any way the subsection be hidden in toc but still appear in the report with the numerical number i.e 1.2.1

I have tried inserting \subsection*{test}

The heading hides from the ToC but appears with no numbers in the report.

Do you if there is a way?

Thanks

Solution

You can hide all subsections inside the ToC if you set the counter tocdepth to 1:

1
2
3
4
5
6
7
8
9
10
11
\documentclass[a4paper,10pt]{book}
\begin{document}
\tableofcontents
\chapter{One}
\section{One}
\subsection{One}
\addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
\subsection{Two}
\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
\subsection{Three}
\end{document}

But if you want to hide all subsections, forget the second, the single line above is the right then.

Stefan

Reference