2

Of course, one can include individual elements into a table of contents by inclusion of addcontentsline at the element to be included. I'm seeking the opposite: I want to prevent selected individual elements from appearing in the table of contents when they otherwise would be.

Note that changing the depth of element to be included will not work for my case. I may want some subsections to appear in the table of contents and not others. Changing the depth will permit or prevent all subsections from appearing in the table of contents.

Is there a command (e.g., deletecontentsline) that will allow me to selectively prevent individual items from otherwise appearing in the TOC?

For my case, there will be no problems with numbering. In particular, I want subsections just in one section to not appear in the table of contents. So, even though there is section 1, subsection 1.1, 1.2, etc., and section 2, subsection 2.1, 2.2, etc. I want my table of contents to have only 1, 1.1., 1.2, and 2. (not 2.1, 2.2, etc.).

1 Answers1

0

One way, with etoc. Works the same with or without hyperref.

\documentclass{article}
\usepackage{etoc}

\begin{document}

\tableofcontents

%\part{ONE}
\section{Section one}
\subsection{Subsection one one}
\subsection{Subsection one two}

\section{Section two}
\subsection{Subsection two one}
\subsection{Subsection two two}

\etocsettocdepth.toc {section}
\section{Section three DO NOT SHOW SUBSECTIONS}
\subsection{Subsection three one}
\subsection{Subsection three two}

\etocsettocdepth.toc {subsection}
\section{Section four}
\subsection{Subsection four one}
\subsection{Subsection four two}

\end{document}

TOC with etoc