3

Suppose you have a two-sided document. The even page's header contains the title of the current chapter; the odd page's header contains the title of the current section. Nothing too fancy, and pretty easily done using the scr* classes and scrpage2.

\documentclass[paper=a5,headinclude=true,pagesize,twoside=true]{scrreprt}
\usepackage[automark]{scrpage2}
\usepackage{blindtext}

\pagestyle{scrheadings}

\begin{document}
\chapter{Chapter one}
%\renewcommand*{\sectionmarkformat}{} %removes section number
%\sectionmark{\thechapter\enskip Chapter one} %sets odd header
\Blindtext\Blindtext\Blindtext\Blindtext
\section{Section one}
\Blindtext\Blindtext\Blindtext\Blindtext
\end{document}

everything in its right place

Things get difficult in the introductory passages of chapters. Say you have three or more pages of text at the beginning of a chapter before the first \section starts, which is something I do quite often to provide readers with some signposting. Now, in the above setup, the odd page headers will remain empty, which is what you'd expect, but I'd like to change it -- so the odd page header will have the chapter's title until a section is available.

I do know how to manually modify \sectionmark, which I can use to insert anything I want. See the two comment lines in the MWE. But of course you'd usually want a more automated solution. For example, is there a way to ›grab‹ the current chapter title and pass it on to \sectionmark? I tried

\sectionmark{\leftmark},

too, but to no avail. Thanks in advance!

  • @cgnieder works great! Feel free to turn this into an official answer. – Nils L Mar 12 '13 at 8:19
2

Short idea: set \chaptermark to write both headers. The next call of \section will set its headers again. So something like

\renewcommand*\chaptermark[1]{%
  \markboth
    {\MakeMarkcase{\chaptermarkformat#1}}
    {\MakeMarkcase{\chaptermarkformat#1}}}

should do.

2

Replace scrpage2 by its successor scrlayer-scrpage and use the new starred version of \automark:

\documentclass[paper=a5,headinclude=true,pagesize,twoside=true]{scrreprt}

\usepackage{scrlayer-scrpage}% sets pagestyle scrheadings automatically
\automark[chapter]{chapter}
\automark*[section]{}

\usepackage{blindtext}
\begin{document}
\chapter{Chapter one}
\Blindtext[20]
\section{Section one}
\Blindtext[20]
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.