# How to set two types of appendixes on memoir class?

I need to set up two types of appendixes: Appendixes and Annexes

They must appear as "Appendix A - Title of Appendix A", etc, and "Annex A - Title of Annex A", etc. in the chapter head (which I managed to do with a \renewcommand{\appendixname}{Annex}.)

I also need that they appear that way in the table of contents... but a \renewcommand{\cftappendixname}{Annex} works globally...

-
Welcome to tex.sx! A tip: you can use backticks  to mark your inline code as I did in my edit – Gonzalo Medina Jun 1 '11 at 0:12

My browser does not like the forms on this site, so I'll answer here.

\cftinserthook{toc}{AAA}


inserts a hook command into the toc file at the time where the command is placed in the document. The corersponding hook code does not need to be defined, if not it is silently ignored.

In our case we could simply define the hook in the preamble as

\cftinsertcode{AAA}{\renewcommand*{\cftappendixname}{Annex}}


The nice thing about this is that then one does not need to worry about \protect

-
Thanks, it worked fine! I just messed myself up at first (my bad), adding \cftinserhookto the preamble... The solution was to add \cftinsertcodein the preamble and telling the \annex command I mentioned before to \cftinserthook – henrique Jun 1 '11 at 15:01
I just forgot to mention that the hyperref problem persisted... I managed to "fix" it, so to speak, by adding a \phantomsection to the chapter style (with \renewcommand{\printchaptername}{\phantomsection\chapnamefont \@chapapp}) – henrique Jun 1 '11 at 15:15

This sort of thing is often awkward, because you need the change to occur while \tableofcontents is doing its work. A dirty trick is to put the command that changes the appendix name used by the table of contents inside the .toc file.

\documentclass{memoir}
%
\makeatletter
\newcommand{\switchchapname}[1]{ \protected@write \@auxout {}{\string\@switch{#1} }}
\makeatother
%
\begin{document}
\renewcommand*{\cftappendixname}{Appendix \space}
\tableofcontents
\chapter{A chapter}
text.
\appendix
\chapter{An appendix}
more text.
\switchchapname{Annex}% Corrected from \switchapname → \switchchapname
\renewcommand{\appendixname}{Annex}
\chapter{An annex}
Yet more text.
\switchchapname{Another name}% Corrected from \switchapname → \switchchapname
\renewcommand{\appendixname}{Another name}
\chapter{Something else}
Yet more text.
\end{document}

-
you might need to add more \appendix in order to reset the chapter counter. Also note the it may not work well with hyperref. Also \cftinsertcode and \cftinserthook might be useful in this case. – daleif Jun 1 '11 at 11:01
@Ian-Thompson: It did work, thanks. I've created a command \annexthat comprises both changes: \cftappendixnameand \switchchapname, besides starting a new \appendix. @daleif: About hyperref, it wasn't working well already... But I wouldn't know how to use \cftinsertcode` to do so. – henrique Jun 1 '11 at 12:28