0

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:

  1. Why is \pagestyle{main} seemingly ignored starting on output pages 2 and 3? The headings produced seem to be defaults.

  2. 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:

Wrong even chapter head

Wrong odd chapter head

The correct even- and odd-numbered page heads for the frontmatter (and backmatter) are printed like this:

OK even front/back head

OK odd front/back head

Note: See also memoir: headers for short and detailed tables of contents

  • (1) there is no need to use several page styles to do this, I do not see the point in your \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, so chapter and section. And for chapter I recommend using both not left – daleif Oct 17 '19 at 16:48
2

I'd drop the \frontheads and \backheads and define a proper main style and activate it in the preamble.

The main problem is your psmarks:

\makepsmarks{main}{%
  \createmark{chapter}{both}{shownumber}{}{\enspace} % use both not left
  \createmark{section}{right}{shownumber}{}{\enspace}
  \createplainmark{toc}{both}{\contentsname}
  \createplainmark{lof}{both}{\listfigurename}
  \createplainmark{lot}{both}{\listtablename}
  \createplainmark{bib}{both}{\bibname}
  \createplainmark{index}{both}{\indexname}
  \createplainmark{glossary}{both}{\glossaryname}
}

Then by activating this in the preamble and getting rid of your \frontheads and \backheads I seem to be getting exactly the same output as you get with those two macros

The error you made in the MWE is this:

\addtopsmarks{main}{}{%
  % insert "Chapter\space" & "Section\space" if desired as 4th argument:
  \createmark{main}{left}{shownumber}{}{\,\space }% <-- main is wrong here
  \createmark{main}{right}{shownumber}{}{\,\space}% <-- and here
}
  • Of course I thought of doing that. The problem is that I have, in frontmatter, both a short table of contents and a long table of contents. And in backmatter: an index of names, an index of symbols (NOT a glossary), and regular index, the latter two with special types of headers giving the first and last item on that index page; two different bibliography "chapters" with titles "References" and "Additional Readings" to be included in the special headers; as well as other "chapters" such as "Guide to Exercises". (The source above is greatly simplified from my actual book source.) – murray Oct 17 '19 at 17:04
  • @murray I still do not get the idea behind using those two macros, why should the be messing with headings when your document is not using headings? Your example is using headings in the front matter as it is the default, as soon as you activate main \backheads does nothing. Make a specific pagestyle for the indices and use that for the index. \frontheads and \backheads makes no sense at all. – daleif Oct 17 '19 at 17:08
  • Exactly what is it that is wrong in my two \createmark commands? If it's the comment signs, eliminating those leaves the same problems in the main headings -- even if I eliminate \frontheads and \backheads definitions and use and actually eliminate all frontmatter & backmatter. – murray Oct 17 '19 at 17:39
  • @murray see who I use them in the answer. For example the in your case you end up creating \mainmark which is never called. On the other hand \createmark{chapter}... creates \chaptermark which is executed by each \chapter command where it is given the title as an argument. – daleif Oct 17 '19 at 18:01
  • The method of using such page styles fails when I have both a short and a detailed table of contents: see the addition to my original question. – murray Oct 18 '19 at 0: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.