it appears you can only put one item into the header at a time via the
\rightmark \leftmark.
That is true, but not the whole truth. You can work round it by concatenating several data items into a mark, and then selecting the appropriate item when you print the header.
Since parts and chapters are unlikely to be less than 2 pages long, you can remember the titles in normal macro definitions, or you could pack them into \leftmark
in the same way this packs the section and subsection titles into \rightmark
This is the bare bones of a solution to show the basic idea. Adding the functionality cleanly to the standard \part
, \chapter
, etc, commands is an independent sub-problem.
\documentclass{memoir}
\usepackage{xstring}
\makeatletter
% Define some commands so we can renew them later
\newcommand{\savepart}{}
\newcommand{\savechapter}{}
\newcommand{\savesection}{}
% This is intentionally over-simple code, but packaging the additions cleanly into
% \part, \section, etc doesn't add value to explainng what to do.
% Assuming that chapters will cover at least two pages, we can just save the
% part and chapter titles withouut using marks.
\newcommand{\mypart}[1]{\renewcommand{\savepart}{#1}\part{#1}}
\newcommand{\mychapter}[1]{\renewcommand{\savechapter}{#1}\chapter{#1}}
% We also need to save the section title, so we can use it when we start
% each subsection
\newcommand{\mysection}[1]{\renewcommand{\savesection}{#1}\section{#1}}
% In the subsection, pack the two titles into the mark, with a unique separator @@@
% Note: you probably want to add a \markright commmand to \mysection as well,
% in case you have a section with no subsections.
\newcommand{\mysubsection}[1]
{\subsection{#1}\markright{\savesection @@@#1}}
% Finally, define the headings, and extract the two substrings from the \rightmark
\makeevenhead{headings}%
{\thepage}{\savepart}{\savechapter}
\makeoddhead{headings}%
{\StrBefore{\rightmark}{@@@}}{\StrBehind{\rightmark}{@@@}}{\thepage}
\makeatother
\begin{document}
\mypart{Part A}
\mychapter{Chapter One}
\newpage
\mysection{Sec 11}
\mysubsection{SubSec aaa}
\newpage
\mysubsection{SubSec bbb}
\newpage
\mysubsection{SubSec ccc}
\newpage
\mypart{Part B}
\mychapter{Chapter Two}
\newpage
\mysection{Sec 22}
\mysubsection{SubSec ddd}
\newpage
\mysubsection{SubSec eee}
\newpage
\mysubsection{SubSec fff}
\end{document}
\...mark
commands in your\make...head
commands. The former only contain one 'thing', but you can put all sorts of arbitrary stuff in the latter.