Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can I make that the appendices list (numbered with \chapter{}) not appear in ToC, but appears the title "Appendices" instead. I'm using the book documentclass, and the default \appendix command to begin the appendices.

In ToC, I have this:

1. CHAPTER ...
   1.1 Section ...

A. Appendix A ...
   A.1 Section ...

B. Appendix B ...
   B.1 Section ...

I need this:

1. CHAPTER ...
   1.1 Section ...

Appendices ...

But, I also need the Appendix A and B numbered in document.

Some solutions raise change the tocdepth counter after the declaration of the start of the appendices, but can interfere with other lists (LoT, LoF) and the package hyperref and PDF bookmarks.

Here a MWE:

\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage{blindtext}
\usepackage{hyperref}
   \hypersetup{hidelinks}

\begin{document}
  \tableofcontents
  \listoftables
  \blinddocument
  \begin{table}\centering
      \begin{tabular}{|c|c|c|}
        \hline
        1 & 2 & 3 \\
        4 & 5 & 6 \\
        7 & 8 & 9 \\
        \hline
      \end{tabular}
      \caption{Test}
  \end{table}
  \appendix
    \blinddocument
    \blinddocument
\end{document}

The solution should not affect the other lists and PDF bookmarks.

share|improve this question
    
\chapter*{Appendices}? –  You Nov 9 '13 at 18:32
    
@You No, I need that numbering at the document. –  OSjerick Nov 9 '13 at 18:35

2 Answers 2

up vote 5 down vote accepted

This approach by the »appendix« package and the decreased counter tocdepth written to the ToC results in a ToC entry for the appendices without disabling the numbering of the single appendix chapters in the document.

\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage[toc]{appendix}
\usepackage{blindtext}  % drop in actual document

\begin{document}
  \tableofcontents

  \blinddocument  % drop in actual document

  \begin{appendices}
    \addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
    \blinddocument  % drop in actual document
    \blinddocument  % drop in actual document
  \end{appendices}
\end{document}

According to the mentioned demands I can only offer a quick hack of the involved macros that write content to the ToC and the LoT.

\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage{caption}
\usepackage[toc]{appendix}
\usepackage{blindtext}  % drop in actual document
\usepackage{hyperref}

\begin{document}
  \tableofcontents
  \listoftables
  \blinddocument

  \begin{table}[!htb]
    \caption{Dummy table}
    \label{tab:dummy}
    \centering
    \rule{4in}{2.25in}
  \end{table}

\makeatletter
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
%                          \addcontentsline{toc}{chapter}%
%                                    {\protect\numberline{\thechapter}#1}%
%                     \else
%                       \addcontentsline{toc}{chapter}{#1}%
                    \fi
                    \chaptermark{#1}%
%                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
%                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}
\def\@sect#1#2#3#4#5#6[#7]#8{%
  \ifnum #2>\c@secnumdepth
    \let\@svsec\@empty
  \else
    \refstepcounter{#1}%
    \protected@edef\@svsec{\@seccntformat{#1}\relax}%
  \fi
  \@tempskipa #5\relax
  \ifdim \@tempskipa>\z@
    \begingroup
      #6{%
        \@hangfrom{\hskip #3\relax\@svsec}%
          \interlinepenalty \@M #8\@@par}%
    \endgroup
    \csname #1mark\endcsname{#7}%
%     \addcontentsline{toc}{#1}{%
%       \ifnum #2>\c@secnumdepth \else
%         \protect\numberline{\csname the#1\endcsname}%
%       \fi
%       #7}%
  \else
    \def\@svsechd{%
      #6{\hskip #3\relax
      \@svsec #8}%
      \csname #1mark\endcsname{#7}%
%       \addcontentsline{toc}{#1}{%
%         \ifnum #2>\c@secnumdepth \else
%           \protect\numberline{\csname the#1\endcsname}%
%         \fi
%         #7}
    }%
  \fi
  \@xsect{#5}}
\makeatother

  \begin{appendices}
    \blinddocument  % drop in actual document
    \blinddocument  % drop in actual document
  \end{appendices}
\end{document}

The critical parts are commented to prevent corresponding entries.

share|improve this answer
    
Thanks. It's nice, but this solution seems to be interfering with other lists (LoT, Lof), and also with bookmarks of the hyperref package. –  OSjerick Nov 9 '13 at 19:38
    
@osjerick: Perhaps the second example is useful. –  Thorsten Donig Nov 10 '13 at 11:53
    
since the lof and lot are triggered separately, why not just restore the original tocdepth before the \tableof... instructions? –  barbara beeton Nov 10 '13 at 13:31
    
@barbarabeeton It's not too easy. :) –  OSjerick Nov 10 '13 at 14:31
    
@ThorstenDonig Great solution! Thanks! I prefer this kind of solutions instead the use of many packages. –  OSjerick Nov 10 '13 at 14:33

this is a riff on @Thorsten's example, which really provides the mechanism for modifying the tocdepth. this is presented as an answer only because i didn't want to pollute his example with code that he might not understand. (in a comment, he requested an elaboration, and this is too extensive for a comment.)

\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage[toc]{appendix}
\usepackage{blindtext}  % drop in actual document

\begin{document}
  \tableofcontents
  \setcounter{tocdepth}{+1}
  \listoffigures
  \listoftables

  \blinddocument  % drop in actual document

  \begin{figure}
    this is a figure.
    \caption{dummy figure}
  \end{figure}

  \begin{table}
    \caption{dummy table}
    this is a table.
  \end{table}

  \begin{appendices}
    \addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
    \blinddocument  % drop in actual document
    \begin{figure}
      this is a figure.
      \caption{dummy figure}
    \end{figure}
    \blinddocument  % drop in actual document
    \begin{table}
      \caption{dummy table}
      this is a table.
    \end{table}
  \end{appendices}
\end{document}

in order to suppress the listing of separate appendices in the toc, Thorsten reduced the tocdepth by one. to restore the full listing of figures and tables, here the reverse of that technique is used to negate the change before calling \listoffigures and \listoftables.

no modification of definitions necessary. all potential information is automatically written to the .toc, .lof and .lot files, and \tocdepth just specifies which entries to ignore, so it's not necessary to modify what is written to these files.

share|improve this answer
    
Ah, yes. Many thanks for that. I knew that there must be something trivial. –  Thorsten Donig Dec 8 '13 at 12:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.