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
ma501th
General ⇒ hide subsection from table of contents
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
hide subsection from table of contents
Hi,
you can hide all subsections inside the toc if you set the counter tocdepth to 1:
Just in case if you mean just one certain subsection, but other should appear in the toc, that possible too, example:
But if you want to hide all subsections, forget the second, the single line above is the right then.
Stefan
you can hide all subsections inside the toc if you set the counter tocdepth to 1:
Code: Select all
\setcounter{tocdepth}{1}
Code: Select all
\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}
Stefan
Re: hide subsection from table of contents
Hi im abit confused on the above code.
if i just want to hide ONE particular subsection of the toc but the number to appear in the report of that particlaur subsection, which code of line should i apply and where
thanks
if i just want to hide ONE particular subsection of the toc but the number to appear in the report of that particlaur subsection, which code of line should i apply and where
thanks
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
hide subsection from table of contents
Hi ma501th,
then try to use my second example.
Stefan
then try to use my second example.
Code: Select all
% hide subsections in the toc:
\addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
\subsection{This subsection is numbered but not shown in the toc}
\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
%from now on subsections are shown like usual
Re: hide subsection from table of contents
what does the numbers in curly brackets indicate?
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
hide subsection from table of contents
That's the value I'm setting to tocdepth. tocdepth=1 means, parts and chapters and sections will be shown inside the toc. tocdepth=2 means subsections too. tocdepth=3 means subsubsections too etc.
You will find further explanation here.
Stefan
You will find further explanation here.
Stefan