Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

changing tocdepth middle of document

386 views
Skip to first unread message

nojb

unread,
Jun 6, 2010, 2:35:51 PM6/6/10
to
Hello,

Is there a way to change the \tocdepth in the middle of a document?
I'm using memoir.

Thanks!
N

Alan Munn

unread,
Jun 6, 2010, 2:42:37 PM6/6/10
to
In article
<820936e6-c41e-4363...@y4g2000yqy.googlegroups.com>,
nojb <no...@uchicago.edu> wrote:

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

nojb

unread,
Jun 6, 2010, 3:54:38 PM6/6/10
to
On Jun 6, 2:42 pm, Alan Munn <am...@msu.edu> wrote:
> In article
> <820936e6-c41e-4363-a46c-fcfcc2def...@y4g2000yqy.googlegroups.com>,

>
>  nojb <n...@uchicago.edu> wrote:
> > Hello,
>
> > Is there a way to change the \tocdepth in the middle of a document?
> > I'm using memoir.
>
> 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

Alan Munn

unread,
Jun 6, 2010, 5:39:42 PM6/6/10
to
In article
<30a74da0-3338-4213...@c10g2000yqi.googlegroups.com>,
nojb <n.oj...@gmail.com> wrote:

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

nojb

unread,
Jun 6, 2010, 6:36:32 PM6/6/10
to
On Jun 6, 5:39 pm, Alan Munn <am...@msu.edu> wrote:
> In article
> <30a74da0-3338-4213-a934-70f5f5027...@c10g2000yqi.googlegroups.com>,

Thanks! I had tried with \renewcommand{\tocdepth} and it wasn't
working.

Best,
N

Donald Arseneau

unread,
Jun 7, 2010, 12:46:45 PM6/7/10
to
On Jun 6, 3:36 pm, nojb <n.oje....@gmail.com> wrote:
> > > > > Is there a way to change the \tocdepth in the middle of a document?
> > > > > I'm using memoir.

> > \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}}

Lars Madsen

unread,
Jun 8, 2010, 4:17:45 AM6/8/10
to

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

GL

unread,
Jun 8, 2010, 5:36:55 AM6/8/10
to

I think \setcounter does not require \protection... however.
Am I wrong ?

Lars Madsen

unread,
Jun 8, 2010, 5:50:13 AM6/8/10
to
Lars Madsen wrote:
> Donald Arseneau wrote:
>> On Jun 6, 3:36 pm, nojb <n.oje....@gmail.com> wrote:
>>>>>>> Is there a way to change the \tocdepth in the middle of a document?
>>>>>>> I'm using memoir.
>>
>>>> \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}}
>>
>>
>>

Sorray Donald, I misread your post

Heiko Oberdiek

unread,
Jun 8, 2010, 7:41:12 AM6/8/10
to
GL <goua...@gmail.com> wrote:

> > \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

0 new messages