9

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?

2
  • Have you looked at memoir's subappendices environment and the \namedsubappendices command?
    – gusbrs
    May 4, 2018 at 13:19
  • 1
    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, 2018 at 7:21

2 Answers 2

2

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.

0

To get a section to be treated as an appendix and have it display as "Appendix A" when cross-referencing, you can use the cleveref package to customize the cross-referencing format.

Here's a modified version of your MWE. I've added the cleveref package and used the \cref command instead of \autoref. I've also used the \setsecheadstyle command to customize the section heading format in the appendix. Additionally, I have defined the custom reference format for sections using the \crefname and \Crefname commands from the cleveref package.

\documentclass{memoir}
\usepackage{hyperref}
\usepackage{cleveref}

\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 \cref{app:numden}

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

% Custom section format
\setsecheadstyle{\Large\bfseries Appendix\space}

% Custom reference format for sections
\crefname{section}{Appendix}{Appendices}
\Crefname{section}{Appendix}{Appendices}

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

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .