2

I want to set the header with the page number and the chapter number on the even pages and the chapter title and the page number on the odd pages. That is, as is shown in this image:

enter image description here

Here is as far as I've gotten. This gives me the chapter title in the right place, but not the chapter number.

\documentclass[10pt]{memoir}
\usepackage{lipsum}

\makepagestyle{myheadings}
\makepsmarks {myheadings}{
\nouppercaseheads
\createmark {chapter} {left} {nonumber}{\@chapapp\ }{. \ }
%\createmark {chapter} {right} {notitle}{\@chapapp\ }{ }

\createplainmark {toc} {both} {\contentsname}
\createplainmark {lof} {both} {\listfigurename}
\createplainmark {lot} {both} {\listtablename}
\createplainmark {bib} {both} {\bibname}
\createplainmark {index} {both} {\indexname}
\createplainmark {glossary} {both} {\glossaryname}
}
\makeoddhead{myheadings}{\footnotesize\sffamily\leftmark}{}{\footnotesize\sffamily\thepage}
\makeevenhead{myheadings}{\footnotesize\sffamily\thepage}{}{\footnotesize\sffamily\rightmark}
\pagestyle{myheadings}

\begin{document}
\chapter{Chapter title}
\section{Introduction}
\lipsum[1-5]
\section{Section title}
\lipsum[6-10]
\end{document}

I have been trying to include something like this: \createmark {chapter} {right} {notitle}{\@chapapp\ }{ }, but that hasn't worked.

I've also tried \makeevenhead{myheadings}{\footnotesize\sffamily\thepage}{}{\footnotesize\sffamily{Chapter~\thechapter}}. That works for most of the book, but not for the toc, preface, and appendices (which become Chapter 0, Chapter A, and Chapter B in the header).

1
  • Note that this cannot be done using the simple \createmark interface as it is only made for cases where we write the same thing to either the left, right or both marks. Here you want to write different things to the left and right marks meaning you'll have to code \chaptermark manually using \markboth
    – daleif
    Jul 8, 2021 at 5:12

1 Answer 1

2

Here's how I'd solve it

\documentclass[10pt]{memoir}
\usepackage{lipsum}
\makeatletter
\makepagestyle{myheadings}
\makepsmarks{myheadings}{
  \nouppercaseheads
  % remove any marks for sections (might be left over from default pagestyle)
  \clearmark{section}
  \clearmark{subsection}
  \clearmark{subsubsection}
  % hand code \chaptermark, the code is taken from the definition of
  % \createmark for the 'both' version, and cleaned a little
  \renewcommand\chaptermark[1]{
    \@setclcnt{chapter}{@memmarkcntra}%
    \advance\c@@memmarkcntra\m@ne
    \markboth{%
      \memUChead{%
        \ifnum\c@secnumdepth > \c@@memmarkcntra
          \if@mainmatter
            \@chapapp\ \thechapter
          \fi
        \fi
      }%
    }{%
      \memUChead{%
        ##1%
      }%
    }%
  }%
  \createplainmark{toc}     {both}{\contentsname}
  \createplainmark{lof}     {both}{\listfigurename}
  \createplainmark{lot}     {both}{\listtablename}
  \createplainmark{bib}     {both}{\bibname}
  \createplainmark{index}   {both}{\indexname}
  \createplainmark{glossary}{both}{\glossaryname}
}
\makeatother
\makeoddhead{myheadings}{\footnotesize\sffamily\rightmark}{}{\footnotesize\sffamily\thepage}
\makeevenhead{myheadings}{\footnotesize\sffamily\thepage}{}{\footnotesize\sffamily\leftmark}
\pagestyle{myheadings}

\begin{document}
\chapter{Chapter title}
\section{Introduction}
\lipsum[1-5]
\section{Section title}
\lipsum[6-10]
\end{document}
1

You must log in to answer this question.

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