4

We have an in-house document class which is based on memoir. For some smaller documents we don't want chapters so we effectively promote sections to be chapters as in my MWE. My question is how can I create an Appendix in this case? The \appendix command formats subsequent chapters as appendices, but I don't have chapters and I want subsequent sections to become appendices.

My MWE gets some of the way there (for simplicity using memoir itself, not our class based on it):

\documentclass{memoir}
\usepackage{hyperref}
\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Change the section commands because we don't have chapters           %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}
\renewcommand{\thesubsubsection}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.}
\renewcommand{\thechapter}{\thesection}

\mainmatter

\section{Helium}

\section{Alpha particles}

See \autoref{app:numden}

\appendix
\renewcommand{\thesection}{\Alph{section}}

\section{Number densities}
\label{app:numden}

\end{document}

The \appendix command restarts the section numbering from 1, and I can change this to "A" using \renewcommand{\thesection}{\Alph{section}}. However, when I reference the appendix, as I do with \autoref{app:numden}, It says "section A" where I want this to say "Appendix A". Of course I could faff around with how I typeset the cross-reference at that point, but how do I get a section to be properly treated as an appendix as it would in the article class?

  • Have you looked at memoir's subappendices environment and the \namedsubappendices command? – gusbrs May 4 '18 at 13:19
  • Just as a matter of style, memoir allows to use the class option 'article'. With this option, chapters are styled as section headers. Maybe that solves your problem, that seems like a mix between visual appeareance and meaning of instructions. – djnavas Jul 29 '18 at 7:21
0

I'm not sure if it's bad form to answer my own question, but on the specific point of referencing the appendix as "Appendix A" a solution is to define a new command:

\newcommand{\appref}[1]{\hyperref[#1]{Appendix~\ref{#1}}}

and us this in place of \autoref. However, if anyone has a more elegant solution to the issue of getting \appendix to treat \section as an appendix in memoir (or I guess any class with chapters) I would still be interested.

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.