[Tex/LaTex] How to manage appendix with TOC heading Appendices

appendicestable of contentsthesis

I need a heading Appendices in my Table of Content (TOC) with two subheadings. For example:

Appendices

  A. First appendix    
  B. Second appendix

In my case, there is TOC headings: A Appendix; It should be Appendices. Subheadings were A.1 and A.2; it should be A and B.

enter image description here

Best Answer

In your main.tex, you can use

%----------------------------------------------------------------------------------------
%   THESIS CONTENT - APPENDICES
%----------------------------------------------------------------------------------------

\cleardoublepage

\phantomsection

\appendix % Cue to tell LaTeX that the following 'chapters' are Appendices

\addtocontents{toc}{\vspace{2em}} % Add a gap in the Contents, for aesthetics

\addcontentsline{toc}{chapter}{Appendices}

% Include the appendices of the thesis as separate files from the Appendices folder
% Uncomment the lines as you write the Appendices

\let\oldchapter\chapter
\renewcommand{\chapter}[1]{%
  \refstepcounter{chapter}%
  \oldchapter*{Appendix \thechapter: #1}%
  \addcontentsline{toc}{chapter}{\texorpdfstring
    {\makebox[1.5em][l]{\thechapter}}% in main document
    {\thechapter\space}#1}% in PDF bookmarks
}
\apptocmd{\backmatter}{\let\chapter\oldchapter}{}{}

\chapter{First appendix}
\section{A section}
\section{Another section}

\chapter{Second appendix}
\section{A section}
\section{Another section}

\chapter{Third appendix}
\section{A section}
\section{Another section}

The above definitions insert Appendices into the ToC to match the formatting of a \chapter. Subsequent \chapters are forced to match \chapter* and corrected at \backmatter. I've inserted \chapters and \sections verbatim in the above code, but you can include them via \input as suggested in the template.

Appendix \chapters are titled as Appendix X: <title> within the document and X <title> in the ToC. The use of \texorpdfstring{<TeX>}{<PDF>} allows for proper setting of the bookmarks that result in the PDF.

enter image description here