[Tex/LaTex] Appendices title in ToC without appendices list

appendicesnumberingsectioningtable of contents

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.

Best Answer

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.