[Tex/LaTex] scrpage2: Three “marks” for headings

header-footerkoma-scriptscrpage2

As far as I know of the \automark command (scrpage2 package), it is only possible to mark two different "header-types" (e.g. sections and chapters). I'm searching for a way to mark an additional "header" (e.g. part) to use it in headings.

Example usage of this would be:

\documentclass{scrbook}

\usepackage{scrpage2}
\pagestyle{scrheadings}
\clearscrheadfoot
\automark[section]{chapter}
\ihead{\leftmark}
\ohead{\rightmark}
\ifoot{Display part title here}

\begin{document}
    \part{Test}
    \chapter{Test 2}
    \section{Test 3}
\end{document}

Does anybody know of an automatic way to do this? Thanks in advance for any help!

Best Answer

Here's a simple patch: we add to \@part the code that stores in \theparttitle the current part title. You can also give anywhere \parttitle{whatever} (perhaps with an empty argument) to change the footer.

\documentclass{scrbook}
\usepackage{scrpage2}

\usepackage{etoolbox}
\makeatletter
\apptocmd{\@part}{\parttitle{#2}}{}{}
\def\parttitle#1{\gdef\theparttitle{#1}}
\def\theparttitle{} % initialization
\makeatother

\pagestyle{scrheadings}
\clearscrheadfoot
\automark[section]{chapter}
\ihead{\leftmark}
\ohead{\rightmark}
\ifoot[\theparttitle]{\theparttitle} % on both sides of a spread, just for the example

\begin{document}
\part{Test}
\chapter{Test 2}
\section{Test 3}
\end{document}

enter image description here