I'm trying to use the memoir
class such that a document with the following structure:
\section{A section}
\subsection{A subsection}
\subsection{Another subsection}
\subsubsection{A subsubsection}
\subsubsection{Another subsubsection}
\subsection{Yet another subsection}
\section{Another section}
gives headers such as
1 A section
1 A section >> 1.1 A subsection
1 A section >> 1.2 Another subsection
1 A section >> 1.2 Another subsection >> 1.2.1 A subsubsection
1 A section >> 1.2 Another subsection >> 1.2.2 Another subsubsection
1 A section >> 1.3 Yet another subsection
2 Another section
To this end, I have the following in my preamble:
\def\sectionmark#1{\markright{\thesection \hskip.25cm #1}}
\def\subsectionmark#1{\markright{\rightmark \hskip.25cm >> \hskip.25cm \thesubsection \hskip.25cm #1}}
\def\subsubsectionmark#1{\markright{\rightmark \hskip.25cm >> \hskip.25cm \thesubsubsection \hskip.25cm #1}}
which almost works, but not quite. In particular, it will generate the following headers:
1 A section
1 A section >> 1.1 A subsection
1 A section >> 1.1 A subsection >> 1.2 Another subsection
1 A section >> 1.1 A subsection >> 1.2 Another subsection >> 1.2.1 A subsubsection
1 A section >> 1.1 A subsection >> 1.2 Another subsection >> 1.2.1 A subsubsection >> 1.2.2 Another subsection
1 A section >> 1.1 A subsection >> 1.2 Another subsection >> 1.2.1 A subsubsection >> 1.2.2 Another subsection >> 1.3. Yet another subsection
2 Another section
as the subsectionmark and subsubsectionmark commands nest. What can I do to prevent this?