2

I am using a memoir class with this thesis template: Caltech thesis template

When I used \begin{appendices} text \end{appendices}, in the main text, the chapter name is Appendix A but in the ToC it shows Chapter A.

For example,

\chapter{text1}
\begin{appendices}
\chapter{text2}
\end{appendices}
\chapter{text3}

In the main text, I get

Chapter 1 text1
Appendix A text2
Chapter 2 text3

In the ToC, I get

Chapter 1 text1
Chapter A text2
Chapter 2 text3

What should I do to fix that?

I want to use the appendices environment because I want to have the appendix to show up in between regular chapters.

I can modify \appendix to make it work by

\apptocmd{\appendix}{%
  \addtocontents{toc}{%
    \protect\renewcommand{\protect\chaptername}{Appendix}
  }%
}{}{}

But, if I place \appendix in the main text, the rest of the chapters becomes appendix, and I only want some subset of chapters after \appendix to have the Appendix label.

Note: The appendix package with titletoc option does not work with memoir class.

  • How do you add Chapter to your ToC? Here is a minimal example that you can use to start showing us what you're doing. – Werner Oct 4 '17 at 17:53
  • Here is how \chapter{text1} \begin{appendices} \chapter{text2} \end{appendices} \chapter{text3} So, the final result should have Chapter 1 text1, Appendix A text2, Chapter 2 text3 in the TOC. Instead, it has Chapter 1 text1, Chapter A text2, Chapter 2 text3 in the TOC. – ypleong Oct 4 '17 at 19:09
  • (1) please make a full minimal example, (2) as far as I remember memoir does not prefix anything in the toc by default, so you are not giving all information. (3) \cftchapternane and \cftappendixname are the normal go to macros in memoir for this. – daleif Oct 4 '17 at 20:20
  • I added the template I used. That's all I have. – ypleong Oct 4 '17 at 23:49
1

The following patches should correct your ToC display, using Appendix within the appendices environment and Chapter elsewhere:

\AtBeginEnvironment{appendices}{\addtocontents{toc}{\protect\anappendixtrue}}
\AtEndEnvironment{appendices}{\addtocontents{toc}{\protect\anappendixfalse}}
\renewcommand{\chapternumberline}[1]{%
  \ifanappendix
    Appendix% or \appendixname
  \else
    Chapter% or \chaptername
  \fi
  \space\formatchapternumber{#1}:\space}

Add the above code somewhere in your preamble.

  • This works great! Thank you for the quick responses. – ypleong Oct 5 '17 at 7:14
2

As I mentioned in the comments, I do not understand the problem. The normal memoir methods works fine:

\documentclass{memoir}

\renewcommand\cftchaptername{\chaptername~}
\renewcommand\cftappendixname{\appendixname~}
\begin{document}

\tableofcontents*

\chapter{text1}
\begin{appendices}
\chapter{text2}
\end{appendices}
\chapter{text3}
\end{document}

Whether that template is doing stuff that is should not is out of my hands.

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.