1

I am preparing a book, which is to be divided into Parts, Chapters, and Sections. At the moment, my running headers give the Chapter title (on recto pages), and Section title (on verso). I would like to switch from "Chapter/Section" to "Part/Chapter." I'd be grateful for any suggestions.

2 Answers 2

2

Here's one possibility using the standard book (or report) class and fancyhdr; the etoolbox package was used to patch \@part so as to grab the part title:

\documentclass{book}
\usepackage[a6paper]{geometry}%just for the example
\usepackage{fancyhdr}
\usepackage{etoolbox}
\usepackage{lipsum}%just for the example

\makeatletter
\patchcmd{\@part}
  {\markboth{}{}}
  {\gdef\parttitle{#1}}
  {}
  {}
\makeatother

\pagestyle{fancy}

\fancyhf{}
\fancyhead[EL]{\partname~\thepart.\ \parttitle}
\fancyhead[OR]{\nouppercase\leftmark}
\fancyhead[ER,OL]{\thepage}

\begin{document}

\part{Test part one}
\chapter{Test chapter one}
\section{Test section one one}
\lipsum[1-4]
\part{Test part two}
\chapter{Test chapter two}
\section{Test section two one}
\lipsum[1-4]

\end{document}

enter image description here

1
  • Looking at book.cls for chapters, it seems there is an extra space between the dot and the forced space. \@chapapp\ \thechapter. \ %
    – Johannes_B
    Jun 17, 2015 at 16:37
1

Using scrlayer-scrpage from the KOMA-Script bundle and a bit of hackery...

\documentclass{book}
\usepackage{blindtext}
\usepackage{scrlayer-scrpage}
\automark[chapter]{part}
\usepackage{etoolbox}
\makeatletter
\apptocmd{\@part}{\partmark{#1}}{}{}% thanks to esdd and Markus
\makeatother
\begin{document}
\part{dance}
\chapter{walzing wombat}
\blindtext[10]
\chapter{samba squirrel}
\blindtext[10]
\part{property}
\chapter{busy bee}
\blindtext[10]
\chapter{lazy leguan}
\blindtext[10]
\end{document}

Using the KOMA equivalent, there is no need for hacks; everything works out of the box.

If the header should not be uppercase, use a markcase option1 to load scrlayer-scrpage

\usepackage[markcase=noupper]{scrlayer-scrpage}


1 - Chapter 5 of the KOMA-Script Manual (2016-06-14), Page 222

5
  • suggestion from Markus: \apptocmd{\@part}{\partmark{#1}}{}{}
    – esdd
    Jun 18, 2015 at 9:00
  • @esdd That works great, but where is it defined? Running grep, it is defined in the classes, scrlayer-scrpage defines partmarkformat. As soon as i know this, i can change the answer ;-)
    – Johannes_B
    Jun 18, 2015 at 11:12
  • \automark defines/redefines it for its arguments, see package scrlayer. If you have the book see page 469. Unfortunaly this is missing in the scrguide.
    – esdd
    Jun 18, 2015 at 11:29
  • Unfortunaly I can not upvote again ;-)
    – esdd
    Jun 18, 2015 at 11:43
  • @esdd You upvoted my answer, i upvoted Gonzalos answer. Where is Bill?
    – Johannes_B
    Jun 18, 2015 at 12:03

You must log in to answer this question.

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