2

Thanks, Werner, your suggestion worked nicely. I here provide a minimalist example that works

In book class, I define headers and have a Preface:

\documentclass[12pt,twoside,openright]{book}
\usepackage[utf8]{inputenc} % 
\usepackage[T1]{fontenc} % 
\usepackage{lipsum,layout,fancyhdr}
\let\oldchaptermark\chaptermark% Store \chaptermark % added to cut
\pagestyle{fancy} % read package doc. 
\let\chaptermark\oldchaptermark% Restore \chaptermark % added to restore
\fancyfoot{}
\fancyhead[LO]{\slshape\nouppercase{\leftmark}}
\fancyhead[RE]{\textit{<Historical Materialism>}} %
\fancyhead[RO]{\thepage} %
\fancyhead[LE]{\thepage} %
\begin{document} %
\frontmatter \chapter{Preface}
\lipsum
\mainmatter 
\chapter*{Chapter}
\backmatter 
\end{document}      

Now the Preface header is just "Preface"

2
  • Could you post a minimal compilable code?
    – Bernard
    Nov 25, 2016 at 19:43
  • 1
    I don't understand what the problem here is. Can you clarify?
    – Johannes_B
    Dec 4, 2016 at 14:30

1 Answer 1

2

fancyhdr's fancy page style redefines \chaptermark - the macro responsible for storing content in the page marks.

Here's the original definition of \chaptermark when you just load the book class *without fancyhdr:

\def\chaptermark#1{%
  \markboth {\MakeUppercase{%
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \@chapapp\ \thechapter. \ %
      \fi
    \fi
    #1}}{}}%

Note how it conditions on whether you're in the \mainmatter or not - \ifmainmatter ... \fi. Here's the definition when you load fancyhdr and execute \pagestyle{fancy}:

\def\chaptermark#1{%
  \markboth {\MakeUppercase{%
    \ifnum \c@secnumdepth > \m@ne
      \@chapapp\ \thechapter. \ %
    \fi
    #1}}{}}%

There's no conditioning on the existence of \mainmatter.

A solution is to store \chaptermark before \pagestyle{fancy} and restore it afterwards:

\let\oldchaptermark\chaptermark% Store \chaptermark
\pagestyle{fancy}
\let\chaptermark\oldchaptermark% Restore \chaptermark

You must log in to answer this question.

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