[Tex/LaTex] komascript/scrpage2: odd page header in passages without a \section (two-sided docs)

double-sidedheader-footerkoma-scriptscrpage2

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!

Best Answer

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.