2

I changed the chapterpagestyle to scrheadings to have the page numbers on the first page of a new chapter, but for the table of contents I do not want to have the headmark (in this case the chapter title ("contents") on the first page of the table of contents (same is true for list of figures and list of tables).

How can I omit the headmark for this specific pages?

MWE:

\documentclass[twoside,open=right,headinclude,footinclude]{scrreprt}

\usepackage[headsepline]{scrlayer-scrpage}
    \pagestyle{scrheadings}
    \clearpairofpagestyles
    \renewcommand*{\chapterpagestyle}{scrheadings}
\ihead{\headmark}
\automark*{chapter}
\automark*[section]{}
\ohead{\pagemark}

\usepackage{lipsum}
\begin{document}
    \tableofcontents
    \chapter{Test}
    \section{Test}
    \lipsum[1]
    \chapter{Test 2}
    \section{Test 2}
    \lipsum[1-10]
\end{document}
1
  • In your MWE \headmark is empty on chapters first page, too. So maybe you should use the default setting of \chapterpagestyle, ie. page style plain. Add option plainheadsepline to get the rule below the header on plain pages, too.
    – esdd
    Jun 24, 2021 at 10:32

1 Answer 1

2

\headmark is empty on the first page of each normal chapter in your MWE (using open=right), because \chapter sets the left mark and cleans up the right mark. Therefore the first right mark on an odd chapter page is empty.

Note that \automark*{chapter}\automark*[section]{} or \automark{chapter}\automark*[section]{} does the same as \automark[section]{chapter}.

Table of contents puts \contentsname in both marks \leftmark and \rightmark at the same time. Therefore \headmark is not empty on the first page of ToC.

So I suggest to remove the redefinition of \chapterpagestyle and to adjust the content of page style plain to your needs. Then page style plain is used on all first pages of chapters including ToC, LoF and LoT.

Maybe you want:

\documentclass[twoside,open=right,headinclude,footinclude]{scrreprt}

\usepackage[headsepline,
  plainheadsepline,% <- added
  automark% <- added
  ]{scrlayer-scrpage}% sets page style scrheadings automatically
\clearpairofpagestyles
\ihead{\headmark}
\ohead*{\pagemark}% <- changed

\usepackage{lipsum}
\begin{document}
\tableofcontents
\chapter{Test}
\section{Test}
\lipsum[1]
\chapter{Test 2}
\section{Test 2}
\lipsum[1-10]
\end{document}

Explanations:

  1. The first page of each chapter uses the page style which is saved in \chapterpagestyle. This is page style plain by default. So removing the redefinition of \chapterpagestyle the example uses plain on the first page of a new chapter.
  2. Option plainheadsepline adds the rule below the header on pages with style plain, but only if option headsepline is set, too.
  3. Option automark activates running header entries. It uses the section level as right mark and the chapter level als left mark. So it does the same as \automark[section]{chapter}.
  4. \clearpairofpagestyles removes the default content of page header and footer for both page style scrheadings and page style plain (alias of plain.scrheadings)
  5. \ihead{\headmark} adds \headmark to the inner header of page style scrheadings. In twosided documents \headmark will be \rightmark on odd pages and \leftmark on even pages.
  6. \ohead*{\pagemark} is a short version of \ohead[\pagemark]{\pagemark} and adds the formatted page number to the outer header of both page styles plain (alias of plain.scrheadings) and scrheadings.
2
  • This did the trick, thank you very much. Just for my understanding: with your MWE 1) The first page of each chapter still uses the plain pagestyle. 2) With plainheadsepline these pages get the headsepline. 3) The starred ohead adds the pagemark to these pages. But what does the automark in the package options do and why don't I need to declare where to put the chapter and sections in the header? Is this so because it is the KOMA standard for Automark?
    – Lukas
    Jun 24, 2021 at 10:57
  • See my updated answer.
    – esdd
    Jun 24, 2021 at 13:26

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.