Hey all,
I have an \appendix which is part of my \mainmatter. I have set the normal tocdepth at 2; however, I don't want the countless sections and subsection of the appendix mentioned in the ToC, so there I need tocdepth 0.
How to do this? I tried resetting the tocdepth-counter just before the appendix, and that clearly doesn't work. Any other ideas?
best,
Niels
Document Classes ⇒ different tocdepth for chapters in mainmatter
different tocdepth for chapters in mainmatter
Hi,
the code below illustrates a possible solution. I defined the two commands \mysection and \mysubsection that behave like the standard \section and \subsection commands, but without generating entries in the ToC:
the code below illustrates a possible solution. I defined the two commands \mysection and \mysubsection that behave like the standard \section and \subsection commands, but without generating entries in the ToC:
Code: Select all
\documentclass{book}
\makeatletter
\newcounter{mysection}[chapter]
\renewcommand\themysection{\thechapter.\@arabic\c@mysection}
\newcounter{mysubsection}[mysection]
\renewcommand\themysubsection{\themysection.\@arabic\c@mysubsection}
\newcommand\mysection{\@startsection {mysection}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\Large\bfseries}}
\newcommand\mysubsection{\@startsection{mysubsection}{2}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\large\bfseries}}
\newcommand*\l@mysection{\@dottedtocline{1}{0em}{0em}}
\newcommand*\l@mysubsection{\@dottedtocline{2}{0em}{0em}}
\makeatother
\begin{document}
\tableofcontents
\chapter{Test chapter one}
\section{Test section one one}
\subsection{Test subsection one one one}
\chapter{Test chapter two}
\section{Test section two one}
\subsection{Test subsection two one one}
\appendix
\chapter{Test Appendix}
\mysection[]{Test section in the appendix}
\mysubsection[]{Test subsection in the appendix}
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...