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.

4
  • 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, 2017 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, 2017 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, 2017 at 20:20
  • I added the template I used. That's all I have.
    – ypleong
    Oct 4, 2017 at 23:49

2 Answers 2

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.

1
  • This works great! Thank you for the quick responses.
    – ypleong
    Oct 5, 2017 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.
https://tex.stackexchange.com/questions/394561/toc-and-memoir-class
tex.stackexchange.com
crawl=CC-MAIN-2022-40
238739
application/http; msgtype=response
sha1:H3BN5XWBD5F5GHUMF3I24EZD3QRAA6L5
<urn:uuid:5058f3fc-1042-4b7b-8902-10bb889c5413>
2022-09-26T18:56:54Z
151.101.1.69
text/html
sha1:37OTRJNIZWLC62TD2XZ6NVJ5U2FIS4HV
<urn:uuid:8ac77c46-60f7-447a-9352-5221b9dc0687>
https://tex.stackexchange.com/questions/394561/toc-and-memoir-class
response
<urn:uuid:ff24ddf4-f8b0-4fb2-9b30-db610df18519>
isPartOf: CC-MAIN-2022-40
publisher: Common Crawl
description: Wide crawl of the web for September/October 2022
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-96
software: Apache Nutch 1.19 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.4-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/