3

So it seems like this question has been asked many times over, however, I have found none of the existing solutions are particularly satisfactory for my situation, as they either force other unneeded functionality, or they break existing aspects of my TeX document.

I am using the report class and I simply want to be able to add a single, separate page (i.e. starting on its own page) to list out the appendices. I want the page to have a left-justified title "List of Appendices", followed by each appendix item which has dots leading to the page number (the same look and feel of the List of Tables and List of Figures). In addition, I also want to have only the ToC item "Appendices" listed in the Table of Contents, and not each of the actual Appendix sub-items.

Here is what I have so far for creating an appendix and trying to hide the sub-items from the ToC. I really need some guidance on how to create a \listofappendices. I'm also noticing the Appendix page numbering in the rendered PDF is not alphabetic like the package documentation suggests it should be; see here.

\documentclass{report}

\usepackage{appendix}
\usepackage{hyperref}

\title{Here is my title}
\author{Name Name}
\date{October 1, 2019}

\begin{document}

\maketitle
\tableofcontents
\listoftables
\listoffigures
% what I want \listofappendices

\chapter{Introduction}
Here is some content...

\appendix
\addappheadtotoc
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}

\chapter{First Appendix}
Here is my appendix content...

\chapter{Second Appendix}
Here is my appendix content...

\end{document}

I am not very expert when it comes to LaTeX, so any and all help is much appreciated.

  • BTW, you need to restore tocdepth before the \listoftables etc. – John Kormylo Oct 2 '19 at 14:42
0

Here is a suggestion using package scrwfile:

\documentclass{report}
\usepackage{blindtext}% only for dummy text
\usepackage{scrwfile}

\usepackage{hyperref}

\TOCclone[List of Appendices]{toc}{atoc}
\addtocontents{atoc}{\protect\value{tocdepth}=-1}
\newcommand\listofappendices{\listofatoc}

\newcommand*\savedtocdepth{}
\AtBeginDocument{%
  \edef\savedtocdepth{\the\value{tocdepth}}%
}

\let\originalappendix\appendix
\renewcommand\appendix{%
  \originalappendix
  \cleardoublepage
  \addcontentsline{toc}{chapter}{\appendixname}%
  \addtocontents{toc}{\protect\value{tocdepth}=-1}%
  \addtocontents{atoc}{\protect\value{tocdepth}=\savedtocdepth}%
}

\title{Here is my title}
\author{Name Name}
\date{October 1, 2019}

\begin{document}
\maketitle
\tableofcontents
\listoftables
\listoffigures
\listofappendices

\blinddocument

\appendix
\chapter{First Appendix}
Here is my appendix content
\chapter{Second Appendix}
Here is my appendix content
\blinddocument
\end{document}

Result:

enter image description here

enter image description here

| improve this answer | |
  • This is amazing. Thanks for the solution. Is it possible to change the ToC entry to say "Appendices" rather than "Appendix"? – Matt Oct 2 '19 at 14:58
  • @Matt Replace \addcontentsline{toc}{chapter}{\appendixname}% by \addcontentsline{toc}{chapter}{Appendices}%. – esdd Oct 2 '19 at 18:34
  • Thanks. This worked perfectly. I noticed that the List of Appendices includes the \chapter{} name along with \sections{}, while the List of Tables/Figures only lists the Figure or Table itself. Is there a way to have the Chapter included in the LoT and LoF so one can see which figures belong to which chapters? Thank you for all of your help. – Matt Oct 2 '19 at 19:22
1

Here is a minimal solution. It creates a new lop file for the List Of Appendices. (Note, loa used by List of Algorithms.)

\documentclass{report}

\usepackage{appendix}
\usepackage{hyperref}

\title{Here is my title}
\author{Name Name}
\date{October 1, 2019}

\makeatletter
\newcommand*{\lopname}{List of Appendices}
\newcommand{\listofappendices}{% I removed all the \twocolumn stuff
\chapter*{\lopname\@mkboth{%
           \MakeUppercase\lopname}{\MakeUppercase\lopname}}%
    \@starttoc{lop}%
}
\makeatother

\begin{document}

\maketitle
\tableofcontents
\setcounter{tocdepth}{2}% restore default
\listoftables
\listoffigures
\listofappendices

\chapter{Introduction}
Here is some content...
\section{Test}

\appendix
\addappheadtotoc
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}

\chapter{First Appendix}
\addcontentsline{lop}{chapter}{\numberline{\thechapter}First Appendix}
Here is my appendix content...

\chapter{Second Appendix}
\addcontentsline{lop}{chapter}{\numberline{\thechapter}Second Appendix}
Here is my appendix content...

\end{document}
| improve this answer | |
  • Thanks for the reply. Much appreciated. – Matt Oct 2 '19 at 14:59
0

You can patch \@chapter to write on a different file as soon as the appendix starts. The appropriate changes are done by \appendix, to which we add some code.

No explicit markup is needed in the document.

\documentclass{report}

\usepackage{etoolbox}
\usepackage{hyperref}

\title{Here is my title}
\author{Name Name}
\date{October 1, 2019}

\makeatletter
\ifdefined\Hy@org@chapter
  \patchcmd{\Hy@org@chapter}{toc}{\TocOrToa}{}{}
  \patchcmd{\Hy@org@chapter}{toc}{\TocOrToa}{}{} % twice is necessary
\else
  \patchcmd{\@chapter}{toc}{\TocOrToa}{}{}
  \patchcmd{\@chapter}{toc}{\TocOrToa}{}{} % twice is necessary
\fi
\newcommand{\TocOrToa}{toc} % initial value
\apptocmd{\appendix}
 {%
  \addcontentsline{toc}{chapter}{\appendixname}%
  \renewcommand{\TocOrToa}{toa}% now we want to write the list of appendices
  \addtocontents{toc}{\protect\setcounter{tocdepth}{-2}}% sections won't appear in toc
  \AtEndDocument{\addtocontents{toc}{\protect\setcounter{tocdepth}{3}}}% get back to normal
  \addtocontents{toa}{\protect\setcounter{tocdepth}{0}}% only chapters
 }
 {}{}
\newcommand*{\toaname}{List of Appendices}
\newcommand{\listofappendices}{% I removed all the \twocolumn stuff
 \chapter*{\toaname\@mkboth{\MakeUppercase\toaname}{\MakeUppercase\toaname}}%
 \@starttoc{toa}%
}
\makeatother

\begin{document}

\pagenumbering{Alph} % to avoid hyperref complaints
\maketitle
\clearpage
\pagenumbering{arabic}

\tableofcontents
%\listoftables
%\listoffigures
\listofappendices

\chapter{Introduction}
Here is some content...

\appendix

\chapter{First Appendix}
Here is my appendix content...

\chapter{Second Appendix}
Here is my appendix content...

\end{document}

Some juggling with tocdepth is necessary.

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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