1

I am using the following to define my default pagestyle and adjust it for the first page of chapters to also include the footer:

\usepackage[headsepline,footsepline]{scrlayer-scrpage}

%% set DEFAULT pagestyle
\pagestyle{scrheadings}
\clearpairofpagestyles
\ihead{\workAuthor}
\ohead{\headmark}
\automark[section]{chapter}
\ofoot{\pagemark}

%% Chapter begin
\newpairofpagestyles[scrheadings]{chap-begin}{%
\KOMAoptions{headsepline=false}
\ihead*{}
}
\renewcommand*{\chapterpagestyle}{chap-begin}

This works exactly as expected, so far so good. Now I want all the TOC pages (including list-of-figures, list-of-listings, ...) to look just like regular pages with the full header and footer, because IMHO they are not chapter and since there are lot of pages altogether it's nice to have footers and headers to not get confused.

I have tried this:

\BeforeTOCHead[toc]{%
\clearpairofpagestyles
\KOMAoptions{headsepline=true}
\ihead{\workAuthor}
\ohead{\headmark}
\automark[section]{chapter}
\ofoot{\pagemark}
}

And this:

\newpairofpagestyles{sameasdefault}{%
\KOMAoptions{headsepline=true}
\ihead{\workAuthor}
\ohead{\headmark}
\automark[section]{chapter}
\ofoot{\pagemark}
}

%% overwrite style for first page of list-of-*
\BeforeTOCHead[toc]{%
\clearpairofpagestyles
\pagestyle{sameasdefault}
}

But neither has any effect. The TOC, LOF... have regular plain-style.

For some reason the first page of the list-of-listings appears differently from the rest of TOCs: it doesn't have plainstyle, it has the regular footer (I assume it's treated like a generic chapter*) but curiously it also has the ohead entry but no headsepline 🤷‍♂️

Thank you for your help!

P.S: Note that I do not want to manipulate the plain-style in general, because I have many other pages (e.g. part) that should remain plain.

1 Answer 1

2

ToC, LoF, LoT etc. are chapters by default. But the desired result is possible, using

\AfterTOCHead{\thispagestyle{scrheadings}}

Load package scrhack to control the LoL by package tocbasic too.

Example (unfortunaly there was no MWE in the question):

\documentclass{scrbook}
\usepackage{blindtext}% only for dummy text
\usepackage{listings}
\usepackage{scrhack}% <- added!
\newcommand*\workAuthor{workAuthor}

\usepackage[headsepline,footsepline]{scrlayer-scrpage}% sets page style scrheadings automatically

\clearpairofpagestyles
\ihead{\workAuthor}
\ohead{\headmark}
\automark[section]{chapter}
\ofoot{\pagemark}

%% Chapter begin
\newpairofpagestyles[scrheadings]{chap-begin}{
  \KOMAoptions{headsepline=false}
  \ihead*{}
}
\AddToLayerPageStyleOptions{scrheadings}{onselect=\KOMAoptions{headsepline=true}}% <- added
\renewcommand*{\chapterpagestyle}{chap-begin}

\AfterTOCHead{\thispagestyle{scrheadings}}% <- changed
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\lstlistoflistings

\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\begin{lstlisting}[caption={Listing}]
  code
\end{lstlisting}
\end{document}
5
  • Thank you for the quick answer and for reminding me to create a MWE. Working with that revealed that another package is breaking the behaviour, because your solutions does in fact not fix it inside my project. The offending package is \usepackage{tocloft} \setlength{\cftfignumwidth}{3em} Which breaks it. But I need to to fix the width of the space allocated for toc-entry numbering. Any ideas?
    – user188968
    Feb 7, 2020 at 14:57
  • Found it! tocleft actually provides an option for this: \tocloftpagestyle{scrheadings}. Now everything looks right!
    – user188968
    Feb 7, 2020 at 15:21
  • Do not use package tocloft together with a KOMA-Script class. It breaks KOMA-Script features. Without tocloft you can use \DeclareTOCStyleEntry[numwidth=3em]{tocline}{figure} or \DeclareTOCStyleEntries[numwidth=3em]{tocline}{figure,table}. And if you replace numwidth=3em by dynnumwidth the needed width will be calculated (needs an additional run).
    – esdd
    Feb 7, 2020 at 19:51
  • Thank you for pointing this out, however, my distribution ships texlive-2015 and that does not seem to offer the command. Any advice?
    – user188968
    Feb 10, 2020 at 13:59
  • 1
    This is a really outdated version. But with TL2015 you can redefine the internal command \l@figure: \makeatletter\renewcommand*\l@figure{\@dottedtocline{1}{1.5em}{3em}}\makeatother.
    – esdd
    Feb 12, 2020 at 12:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .