51

I am required to insert the word Appendix before the letter A in my dissertation Table of Contents as follows:

Appendix A (title for appendix A)

but the latex thesis cls file I use generates only the letter A followed by the appendix title:

A (title for appendix A)

The thesis cls file defines a "backmatter" command and the appendix is treated as a chapter.

\newcommand\backmatter{\appendix
\def\chaptermark##1{\markboth{%
\ifnum  \c@secnumdepth > \m@ne  \@chapapp\ \thechapter:  \fi  ##1}{%
\ifnum  \c@secnumdepth > \m@ne  \@chapapp\ \thechapter:  \fi  ##1}}%
\def\sectionmark##1{\relax}}

Is there a simple fix to the above code that will add the word Appendix before the letter A in the TOC for Appendix A? There is a related question, How to make 'appendix' appear in toc in Latex?, but the answers did not appear to help in this case.

Community
  • 1
  • 1
Carey
  • 1,137
  • 3
  • 11
  • 18

1 Answers1

87

You can easily achieve what you want using the appendix package. Here's a sample file that shows you how. The key is the titletoc option when calling the package. It takes whatever value you've defined in \appendixname and the default value is Appendix.

\documentclass{report}
\usepackage[titletoc]{appendix}
\begin{document}
\tableofcontents

\chapter{Lorem ipsum}
\section{Dolor sit amet}
\begin{appendices}
  \chapter{Consectetur adipiscing elit}
  \chapter{Mauris euismod}
\end{appendices}
\end{document}

The output looks like

enter image description here

abcd
  • 41,765
  • 7
  • 81
  • 98
  • I used your solution and it looks the same, but clicking a hyperlink on an appendix brings me to the document's first page. Hyperlinks on other chapters - generated by `\tableofcontents` - work fine. Could you please help me? – Kit Ostrihon May 12 '16 at 15:55
  • 1
    Sorry, I did not know, that I am supposed to add `\appendix` before the actual chapter, ehm. – Kit Ostrihon May 12 '16 at 16:20
  • Sometimes `hypertexnames=false` as parameter at `hyperref` helps. – koppor Jun 14 '16 at 19:45
  • 9
    This only adds Appendix before A in the TOC, but not where the section actually starts – smihael Jun 08 '18 at 20:06
  • 1
    @smihael In order to add Appendix before A in the section as well, use \usepackage[titletoc,title]{appendix} instead of only \usepackage[titletoc]{appendix} – Clapham May 25 '21 at 09:13