4

I am currently using memoir for a longer document with only sections and subsections (and subsubsections and paragraphs). If I wanted chapter title and section title to appear alternately in the header, I could write

\makeevenhead{plain}{}{\rightmark}{}
\makeoddhead{plain}{}{\leftmark}{}

But since I have no chapters in my document, I want to use section title and subsection title alternately instead. How do I do this?

Here's a MWE:

\documentclass[twoside]{memoir}
\makepagestyle{plain}
\makeevenhead{plain}{}{\thesubsection want subsection title here}{}
\makeoddhead{plain}{}{\rightmark}{}
\makeheadrule{plain}{\textwidth}{0.5pt}

\usepackage[usehighlevels]{alnumsec}
\alnumsectionlevels{1}{section,subsection,subsubsection,paragraph}
\alnumsecstyle{aaaa}
\surroundarabic[{.}][]{}{}
\otherseparators{1}
\alnumsecstyle{aaaa}

\usepackage{lipsum}

\begin{document}
\pagestyle{plain}
\section{This appears in the header properly}
\subsection{How to get this into the header?}
\lipsum
\end{document}

MWE

Big thanks in advance!

1

1 Answer 1

2

It's a question of those \mark* commands. I think this is what you're hoping for (MWE exanded slightly):

\documentclass[twoside]{memoir}

\makepagestyle{plain}
\makeevenhead{plain}{}{\rightmark}{}
\makeoddhead{plain}{}{\leftmark}{}
\makeheadrule{plain}{\textwidth}{0.5pt}
\renewcommand*{\sectionmark}[1]{%
  \markboth%
  {\thesection.\ \MakeTextUppercase{#1}}%
  {\thesection.\ \MakeTextUppercase{#1}}}
\renewcommand*{\subsectionmark}[1]{\markright{\thesubsection.\ #1}}

\usepackage[usehighlevels]{alnumsec}
\alnumsectionlevels{1}{section,subsection,subsubsection,paragraph}
\alnumsecstyle{aaaa}
\surroundarabic[{.}][]{}{}
\otherseparators{1}
\alnumsecstyle{aaaa}

\usepackage{lipsum}

\begin{document}
\pagestyle{plain}
\tableofcontents

\section{This appears in the header properly}
\subsection{How to get this into the header?}
\lipsum[1-20]

\section{This appears in the header properly --- TOO}
\lipsum[1-20]
\subsection{How to get this into the header? --- TOO}
\lipsum[1-20]
\end{document}

Basically, you want to "markboth" for \sections so that if there's no subsection, the information from the \section is used, but you want to "markright" with the \subsection information so it is used when available. I gather also that you want to keep the \section information in uppercase in the header.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .