3

I have a deep title structure (until subsubsubsection) and want to show for the whole document only sections and subsections – this is easy so far. But for one section only, I want to have also subsubsections and subsubsubsections to appear in the TOC – is there any chance to do this?

4

here is a simplified example, extending only to the subsection level.

the idea is to reset the reporting level in the .toc file itself. this is done by inserting suitable commands with \addtocontents at appropriate points.

\documentclass{article}
\setcounter{tocdepth}{1}
\begin{document}
\tableofcontents
\section{First}
\subsection{One-first}
text
\subsection{One-second}
text
\section{Second}
\addtocontents{toc}{\setcounter{tocdepth}{2}}
\subsection{Two-first}
text
\subsection{Two-second}
text
\addtocontents{toc}{\setcounter{tocdepth}{1}}
\section{Third}
\subsection{Three-first}
text
\subsection{Three-second}
text
\end{document}
  • 1
    Nice! I didn't know that it would be possible to pass that kind of argument to \addtocontents. – Sigur Feb 20 '15 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.