# Multiple Sectional divisions in a Memoir header

How would you have a page heading so that on the Left hand page you might have the Book the Part and the Chapter and on the right hand page have a Section any existing subsection.

From reading the Memoir manual and http://tug.org/pracjourn/2008-2/madsen/madsen.pdf it appears you can only put one item into the header at a time via the \rightmark \leftmark.

so just to be clear I would like something like:

Page Number • Part Title • Chapter Title | Section Title • Subsection Title • Page Number

where the vertical bar is the page gutter

• Yes, it is possible. – cfr Mar 3 '15 at 1:46
• No: you use the \...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. – jon Mar 3 '15 at 2:01
• I realize this, I was just trying to show the result I was after... so I edited the question in an attempt to make it clearer – theobear Mar 3 '15 at 2:38

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.


% We also need to save the section title, so we can use it when we start
% each subsection

% 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

{\thepage}{\savepart}{\savechapter}
{\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}