For a memoir document, I'm trying to get even and odd page headings for ordinary chapters to have the forms such as
2 1 One
and
1.1 A section 3
where "2" and "3" are page numbers, "1 One" is the number and name of the chapter without the word "Chapter" or a period after its number, and in "1.1 A Section" there is no period after the section number.
I thought I'm doing what was shown in https://tex.stackexchange.com/a/512366/13492.
I'm also using special headings for frontmatter and backmatter, as shown in the source below.
Questions:
Why is
\pagestyle{main}
seemingly ignored starting on output pages 2 and 3? The headings produced seem to be defaults.Why does "Guide to the Literature" in the back headings disappear from the final page?
Sample source:
\documentclass{memoir}
\setsecnumdepth{subsection}
\settocdepth{subsection}
\nouppercaseheads
\makepagestyle{main}
\makeheadrule{main}{\textwidth}{\normalrulethickness}
\makeevenhead{main}{\bfseries\sffamily\thepage}{}{\bfseries\sffamily\leftmark}
\makeoddhead{main}{\bfseries\sffamily\rightmark}{}{\bfseries\sffamily\thepage}
\addtopsmarks{main}{}{%
% insert "Chapter\space" & "Section\space" if desired as 4th argument:
\createmark{main}{left}{shownumber}{}{\,\space }%
\createmark{main}{right}{shownumber}{}{\,\space}%
}
\makeevenfoot{main}{}{\bfseries\sffamily\thepage}{}
\makeoddfoot{main}{}{\bfseries\sffamily\thepage}{}
\renewcommand{\contentsname}{Table of Contents}
\newcommand{\frontheads}[1]{%
\makeheadrule{headings}{\textwidth}{\normalrulethickness}
\makeevenhead{headings}{\bfseries\sffamily\thepage}{}{\bfseries\sffamily{#1}}
\makeoddhead{headings}{\bfseries\sffamily{#1}}{}{\bfseries\sffamily\thepage}
\makeevenfoot{headings}{}{\bfseries\sffamily\thepage}{}
\makeoddfoot{headings}{}{\bfseries\sffamily\thepage}{}
}
\newcommand{\backheads}[1]{%
\makeheadrule{headings}{\textwidth}{\normalrulethickness}
\makeevenhead{headings}{\bfseries\sffamily\thepage}{\bfseries\sffamily{#1}}{}
\makeoddhead{headings}{}{\bfseries\sffamily}{\bfseries\sffamily\thepage}
\makeevenfoot{headings}{}{\bfseries\sffamily\thepage}{}
\makeoddfoot{headings}{}{\bfseries\sffamily\thepage}{}
}
\chapterstyle{default}
\usepackage{lipsum}
\begin{document}
\frontmatter
\frontheads{Table of Contents}
\tableofcontents\cleardoublepage
\frontheads{Preface}
\chapter{Preface}
\lipsum[1-9]\cleardoublepage
\pagestyle{main} % <--- SEEMS TO BE IGNORED!
\mainmatter
\chapter{One}
\lipsum[1]
\section{A section}
\subsection{First}
\lipsum[1-7]
% Many (sub-)sections to force multi-page TOC
\subsection{Second}
\subsection{Third}\subsection{Four}\subsection{Five}\subsection{Six}
\subsection{Seven}\subsection{Eight}\subsection{Nine}
\subsection{Ten}\subsection{Eleven}\subsection{Twelve}
\subsection{Thirteen}\subsection{Fourteen}\subsection{Fifteen}
\subsection{Sixteen}\subsection{Seventeen}\subsection{Eighteen}
\subsection{Nineteen}\subsection{Twenty}\subsection{Twenty-one}
\subsection{Twenty-two}\subsection{Twenty-three}\subsection{Twenty-four}
\section{B section}\section{C section}\section{D section}
\section{E section}\section{F section}\section{G section}\section{H section}
\section{I section}\section{J section}\section{K section}\section{L section}
\section{M section}\section{N section}\section{O section}\section{P section}
\section{Q section}\section{R section}\section{S section}\section{T section}
\section{U section}\section{V section}\section{W section}\section{X section}
\section{Y section}\section{Z section}\section{AA section}\section{BB section}
\section{CC section}\section{DD section}\section{EE section}\section{FF section}
\section{GG section}\section{HH section}\section{II section}\section{JJ section}
\section{KK section}\section{LL section}\section{MM section}\section{NN section}
\section{OO section}\section{PP section}\section{QQ section}\section{RR section}
\section{SS section}\section{TT section}\section{UU section}\section{VV section}
\section{WW section}\section{XX section}\section{YY section}\section{ZZ section}
\chapter{Two}
\backmatter
\backheads{Guide to the Literature}
\chapter{Guide to the Literature}
\lipsum[1-10]
\end{document}
The wrong even- and odd-numbered page heads for the mainmatter are being printed like this:
The correct even- and odd-numbered page heads for the frontmatter (and backmatter) are printed like this:
Note: See also memoir: headers for short and detailed tables of contents
\frontheads
and\backheads
macros, (2) you are using\createmark
wrong, the first argument is not the style name, it is the name of the sectional macro it belogs to, sochapter
andsection
. And forchapter
I recommend usingboth
not left