1

I'm converting a book from FrameMaker to the memoir class using XeLaTeX and am having to design my own chapter and page styles to suit the publisher's requirements. Mostly it works fine, except that my attempt to pull 'Chapter' or 'Appendix' as the case may be by placing \@chapapp into the left mark doesn't seem to work: instead of giving me the correct literal I just get 'chapapp'.

MWE follows:

% !TEX TS-program = xelatexmk
 \documentclass[%
    a4paper,            % minus margins = A5
    11pt,               % reduce to 10 if required
    twoside,            % two-sided printing
    one column,         % single column of text on a page
    openright,          % chapters/lessons begin on odd pages only; review later
%   draft               % mark overfull lines and provide change bars; change later
    ]{memoir}

% CHAPTER STYLE
\makechapterstyle{olms}{%
    \setlength{\beforechapskip}{50pt}
    \setlength{\midchapskip}{20pt}% unused
    \setlength{\afterchapskip}{40pt}
    \renewcommand{\chapnamefont}{\sffamily\LARGE\bfseries}
    \renewcommand{\chapnumfont}{\sffamily\LARGE\bfseries}
    \renewcommand{\afterchapternum}{:\space}
    \renewcommand{\chaptitlefont}{\sffamily\LARGE\bfseries}
}
\chapterstyle{olms}

% PAGE STYLE
\makepagestyle{olms}
\makeevenhead{olms}{\thepage}{\leftmark}{}
\makeoddhead{olms}{}{\rightmark}{\thepage}
\makepsmarks{olms}{%
    \createmark{chapter}{both}{shownumber}{\@chapapp\space}{:\space}
    \createmark{section}{right}{shownumber}{}{\space}
\createplainmark{toc}{both}{\contentsname}
\createplainmark{lof}{both}{\listfigurename}
\createplainmark{lot}{both}{\listtablename}
\createplainmark{bib}{both}{\bibname}
\createplainmark{index}{both}{\indexname}
\createplainmark{glossary}{both}{\glossaryname}
}

\pagestyle{olms}
\nouppercaseheads

\usepackage{lipsum}

\begin{document}
\frontmatter
\setcounter{page}{5}
\tableofcontents

\mainmatter
\chapter{First Chapter}
\lipsum[1]
\section{First section}\lipsum[3-5]

\appendix
\chapter{First Appendix}
\lipsum[1]
\section{First section}\lipsum[3-5]

\end{document}

The header on page 2 looks like this:

enter image description here

I'm stumped, so any help would be appreciated.

1

1 Answer 1

1

You need

\makeatletter
\makepsmarks{olms}{%
  \createmark{chapter}{both}{shownumber}{\@chapapp\space}{:\space}
  \createmark{section}{right}{shownumber}{}{\space}
\makeatother

because you're using \@chapapp - a macro with an @ in it (outside of a .style file/class). See What do \makeatletter and \makeatother do? that explains what happens within this pair.

enter image description here

If you're not using an appendix, you can get away with using \chaptername instead of \@chapapp:

\makepsmarks{olms}{%
  \createmark{chapter}{both}{shownumber}{\chaptername\space}{:\space}
  \createmark{section}{right}{shownumber}{}{\space}
1
  • Curious. I wouldn't have thought of that from any of the examples I've seen. I wonder about the placement of \makeatletter? It seems it has to be outside the \makepsmarks to work, rather than just before the pertinent \createmark, which seems uninituitive. I wonder why? Thanks for the fix. Oct 11, 2017 at 11:56

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.