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

\setcounter{tocdepth}{0} doesn't work?

1,813 views
Skip to first unread message

Arnoud Galactus Engelfriet

unread,
Mar 2, 1999, 3:00:00 AM3/2/99
to
For a report I'm writing, some technical information is presented in
an appendix. The appendices should only be listed with their chapter
titles in the table of contents, even though they have sections,
subsections and even subsubsections.

To achieve this, I have modified the \appendix definition to read

\newcommand\appendix{\cleardoublepage\par
\setcounter{chapter}{0}%
\setcounter{section}{0}%
\renewcommand\@chapapp{\appendixname}%
\renewcommand\thechapter{\@Alph\c@chapter}%
\setcounter{tocdepth}{0}%
\@appendixtrue}
in my own .cls file (based on the standard book.cls). The main .tex
file contains the flag \appendix before the appendices are \include'd.

However, in the .dvi file, I still get all sections and subsections
in my table of contents. This is the default, but I would have
expected that once \appendix is processed, the counter is reset to
zero and so no more (sub)sections are included in the document.

Am I doing something wrong here? Is it at all possible to change
the tocdepth on the fly like this, or is there another way to do
this? I don't want to use section*, since I need the numbering
in the actual appendix itself.

Thanks for any suggestions!

Greetings,

Arnoud

--
\/ Arnoud "Galactus" Engelfriet - gala...@stack.nl This space
5th year Business & Computing Science student left blank
URL: http://www.stack.nl/~galactus/ PGP: 0x416A1A35 intentionally.


Bernd Schandl

unread,
Mar 2, 1999, 3:00:00 AM3/2/99
to Arnoud Galactus Engelfriet
Arnoud Galactus Engelfriet wrote:
> However, in the .dvi file, I still get all sections and subsections
> in my table of contents. This is the default, but I would have
> expected that once \appendix is processed, the counter is reset to
> zero and so no more (sub)sections are included in the document.
>
> Am I doing something wrong here? Is it at all possible to change
> the tocdepth on the fly like this, or is there another way to do
> this? I don't want to use section*, since I need the numbering
> in the actual appendix itself.

The problem is that tocdepth is evaluated in the table of contents,
NOT when the \section (or whatever) is called. You can solve this by
writing the new definition of tocdepth to the toc file. So instead of
your line
\setcounter{tecdepth}{0}
write
\addtocontents{toc}{\setcounter{tocdepth}{0}}
--
Bernd Schandl
Department of Mathematical Sciences
Clemson University
Clemson, SC 29634-1907

Javier Bezos

unread,
Mar 3, 1999, 3:00:00 AM3/3/99
to
Arnoud "Galactus" Engelfriet <gala...@stack.nl> wrote:

> \newcommand\appendix{\cleardoublepage\par
> \setcounter{chapter}{0}%
> \setcounter{section}{0}%
> \renewcommand\@chapapp{\appendixname}%
> \renewcommand\thechapter{\@Alph\c@chapter}%
> \setcounter{tocdepth}{0}%
> \@appendixtrue}
> in my own .cls file (based on the standard book.cls). The main .tex
> file contains the flag \appendix before the appendices are \include'd.
>

> However, in the .dvi file, I still get all sections and subsections
> in my table of contents. This is the default, but I would have
> expected that once \appendix is processed, the counter is reset to
> zero and so no more (sub)sections are included in the document.

You must write the new value to the toc file:

\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}

That's all.
________________________________
Javier Bezos
jbezos at mx3 dot redestb dot es

Peter R. Wilson

unread,
Mar 3, 1999, 3:00:00 AM3/3/99
to Arnoud Galactus Engelfriet
Arnoud Galactus Engelfriet wrote:
>
> For a report I'm writing, some technical information is presented in
> an appendix. The appendices should only be listed with their chapter
> titles in the table of contents, even though they have sections,
> subsections and even subsubsections.
>
> <snip>
>

The tocvsec2 package (CTAN macros/latex/contrib/supported) enables
you to change the ToC contents (and the sectional numbering level) at
any point in the document.

Peter W.
peter.r...@boeing.com

0 new messages