2

If I use the option \usepackage[automark,headsepline]{scrlayer-scrpage} every even numbered page has the section title in the headings and every odd numbered page the subsection-title. If there is no subsection, there is no heading. I want that there is the section title on odd numbered pages if there is no subsection.

In the following example I want the heading '2 section 2' at page 5 in the output for example.

\documentclass[12pt,twoside,parskip=half-,numbers=noenddot,BCOR=8mm,headheight=29pt]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[automark,headsepline]{scrlayer-scrpage}
\begin{document}
Some text\dots
\clearpage
\section{section 1}
A section\dots
\clearpage
\subsection{subsection 1}
A subsection\dots
\cleardoublepage
\section{section 2}
Another section\dots
\end{document}

How can I do so?

2
  • So you want the section information to appear twice in the header in that case? (Once on the left and once on the right?)
    – cfr
    Sep 25, 2016 at 19:00
  • yes, exactly :)
    – user114179
    Sep 25, 2016 at 19:05

1 Answer 1

1

The method is explained on page 219 of the English version of the manual in chapter 5 section 5.5.

Basically, use \automark to set both the left and right marks when a new section is started, obliterating the existing configuration. Then use \automark* to set only the right mark when a new subsection is started, while leaving the existing marks in place. This allows \subsection to override the marks set by \section without erasing the latter when no \subsection is used.

[I'm assuming you intend to use the scrheadings/plain.scrheadings pair of page styles given your class and package choices. If not, you need to use \leftmark and \rightmark etc. directly, I think. But I can't imagine why you'd want to do that.]

\documentclass[12pt,twoside,parskip=half-,ngerman,numbers=noenddot,BCOR=8mm,headheight=29pt]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[automark,headsepline]{scrlayer-scrpage}
\pagestyle{scrheadings}
\automark[section]{section}
\automark*[subsection]{}
\begin{document}
Some text\dots
\clearpage
\section{section 1}
A section\dots
\clearpage
\subsection{subsection 1}
A subsection\dots
\cleardoublepage
\section{section 2}
Another section\dots
\end{document}

headers

You must log in to answer this question.