5

I'm using scrbook for a collection of papers. Every chapter has a different author, and is typeset with a custom command. I want the headers alternate between chapter and author (rather than whatever is section) -- so I redefine \markright and afterwards use \rightmark in scrlayer-scrpage's \cohead.

Here's an MWE:

\documentclass[a4paper,10pt,headings=optiontohead,version=last,openany]{scrbook}
\author{Immanuel Kant}
\title{Doubling section titles}
\usepackage{kantlipsum}\date{}
%% make individual papers chapters
\usepackage{suffix}
\renewcommand{\sectionmark}{}%prevent rewriting \markright 
\renewcommand{\subsectionmark}{}%prevent rewriting \markright 
\newcommand{\chapterauthor}[1]{\authortoc{#1}\printchapterauthor{#1}\markright{#1}}% setting \markright to author

\makeatletter
\newcommand{\printchapterauthor}[1]{%
 {\parindent0pt\vspace*{-10pt}%
 \linespread{1.1}\large\scshape#1%
 \par\nobreak\vspace*{30pt}}
 \@afterheading%
}
\newcommand{\authortoc}[1]{%
 \addtocontents{toc}{\vskip-10pt}%
 \addtocontents{toc}{%
 \protect\contentsline{chapter}%
 {\hskip1.3em\mdseries\scshape\protect\scriptsize#1}{}{}}
 \addtocontents{toc}{\vskip5pt}%
}
\makeatother
%% put authors in headers
%% http://tex.stackexchange.com/a/228219/12934
\usepackage{scrlayer-scrpage}
\clearpairofpagestyles
\renewcommand{\chaptermarkformat}{}
 \cohead{\small{\rightmark}}
 \cehead{\small{\leftmark}}
 \cfoot*{\pagemark}

\begin{document}
\maketitle
\chapter{Erst}
\chapterauthor{Auguste Comte}
\kant[2]
\section{Quite positive}
\kant[3]
\end{document}

Something happens because of fiddling with \sectionmark, and section titles print twice. My question is: What causes doubling of the titles and how to avoid it? Thank you for suggestions!

2 Answers2

5

Both \sectionmark and \subsectionmark should take an argument:

\renewcommand{\sectionmark}[1]{}%prevent rewriting \markright 
\renewcommand{\subsectionmark}[1]{}%prevent rewriting \markright 

The \section command produces

\sectionmark{<title>}

and if you redefine \sectionmark to have no argument, the tokens {<title>} are not removed.

egreg
  • 1,121,712
3

Because you are loading scrlayer-scrpage: Remove the (unnecessary) redefinitions of \sectionmark and \subsectionmark and use the possibilities of scrlayer-scrpage.

\usepackage{scrlayer-scrpage}
\automark{chapter}% -> section does not rewrite \markright
\clearpairofpagestyles
\renewcommand{\chaptermarkformat}{}
\addtokomafont{pagehead}{\small}
\chead{\headmark}% -> \rightmark on odd pages, \leftmark on even pages
\cfoot*{\pagemark}

Then the chapter is in the header of even pages and whatever you set as argument of \markright is in the header of odd pages.

Here is a short MWE:

\documentclass[openany]{scrbook}
%\documentclass[openany]{book}
\usepackage{kantlipsum}
\newcommand{\chapterauthor}[1]{\markright{#1}}
%
\usepackage{scrlayer-scrpage}
\automark{chapter}
\clearpairofpagestyles
\renewcommand{\chaptermarkformat}{}
\addtokomafont{pagehead}{\small}
\chead{\headmark}
\cfoot*{\pagemark}
%
\begin{document}
\tableofcontents
\chapter{Erst}
\chapterauthor{Auguste Comte}
\kant[2]
\section{Quite positive}
\kant[1-10]
\chapter{Next}
\chapterauthor{Other author}
\section{Quite positive}
\subsection{Test}
\kant[1-10]
\end{document}

enter image description here

enter image description here

esdd
  • 85,675