Is there a way to change the \tocdepth in the middle of a document?
I'm using memoir.
Thanks!
N
What would this mean? What do you hope to achieve by doing this? (I'm
not questioning your motives, just I don't know what effect you actually
want to have happen to your document output.)
Alan
I want sections to be listed for chapters in the toc, but not for
appendices, even though I want
sections in the appendices to be numbered. So I would like to have
\tocdepth=1 for the chapters
and \tocdepth=0 for appendices.
Thanks!
N
Ok. This makes perfect sense. You didn't try the obvious? :-)
\documentclass{memoir}
\begin{document}
\tableofcontents
\chapter{A chapter}
\section{A section}
\subsection{A subsection}
\chapter{Another chapter}
\section{Another section}
\appendix
\settocdepth{chapter}
\chapter{An appendix}
\section{An appendix section}
\subsection{An appendix subsection}
\end{document}
Alan
Thanks! I had tried with \renewcommand{\tocdepth} and it wasn't
working.
Best,
N
> > \settocdepth{chapter}
> Thanks! I had tried with \renewcommand{\tocdepth}
Gag! That is \setcounter{tocdepth}{0}
For those not using memoir, the answer includes a trick:
the setting is put in the toc.
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
well even easier in memoir
\settocdepth{section-name}
say you want to remove sections from the toc from some point. Just add
\settocdepth{chapter}
at that point in the text, this will automatically add the change to the
toc.
--
/daleif (remove RTFSIGNATURE from email address)
LaTeX FAQ: http://www.tex.ac.uk/faq
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal examples, see URL below
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl
http://www.minimalbeispiel.de/mini-en.html
I think \setcounter does not require \protection... however.
Am I wrong ?
Sorray Donald, I misread your post
> > \addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
>
> I think \setcounter does not require \protection... however.
> Am I wrong ?
Yes:
* \setcounter can be fragile, e.g. package calc redefines \setcounter.
* If the counter exists, then \c@<counter name> is written
into the .aux file. But <counter name> might contain
characters with other catcode than letter (11).
Examples:
binomexp.sty: \newcounter{binomexp@variable1}
rjlpshap.sty: \newcounter{rjlpshap@ctr2}
--
Heiko Oberdiek