4

I'm writing a thesis using memoir as my class. I would like a header similar to fancyhdr, but this is not emulated in memoir. I know how to make my own pagestyle, however when I try to refer to the chapter name it only prints the chapter number. On verso pages, I want the chapter name to be left ragged and the section name to be right ragged, and vice versa on recto pages. My code looks like this:

    \makepagestyle{dtu}
    \makeevenhead{dtu}{\sffamily \thechapter}{}{\sffamily \thesection}
    \makeoddhead{dtu}{\sffamily \thesection}{}{\sffamily \thechapter}
    \makeevenfoot{dtu}{\sffamily \thepage}{}{}
    \makeoddfoot{dtu}{}{}{\sffamily\thepage}
    \makeheadrule{dtu}{\textwidth}{1pt}
    \pagestyle{dtu}

But it only prints the numbers, not the number + name of the chapter/section! How can I include the number+name of each chapter and section in the header?

1

1 Answer 1

4

Use \leftmark/\rightmark instead of \thechapter/\thesection. See p. 120 of the memoir manual for details.

\documentclass{memoir}

\makepagestyle{dtu}
\makeevenhead{dtu}{\sffamily\leftmark}{}{\sffamily\rightmark}
\makeoddhead{dtu}{\sffamily\rightmark}{}{\sffamily\leftmark}
\makeevenfoot{dtu}{\sffamily\thepage}{}{}
\makeoddfoot{dtu}{}{}{\sffamily\thepage}
\makeheadrule{dtu}{\textwidth}{1pt}
\pagestyle{dtu}

\usepackage{lipsum}

\begin{document}

\chapter{foo}

\section{foobar}

\lipsum[1-12]

\end{document}
2
  • 1
    ha may need to set the chapter and section marks as well if they are much different than the default, hence the reference to my article.
    – daleif
    Commented Oct 18, 2012 at 11:31
  • Tak for din artikel, Lars. Jeg har også hentet din bog. Dit arbejde er meget værdsat :-) Commented Oct 22, 2012 at 8:46

You must log in to answer this question.

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