I would like the headsepline of each page to extend across the page. The problem I am encountering is when the geometry is changed via \newgeometry
:
\documentclass{scrreprt}
\usepackage{geometry}
\usepackage[headsepline, headwidth=paper:\the\textwidth/2-\the\paperwidth/2:\the\textwidth/2-\the\paperwidth/2]{scrlayer-scrpage}
\usepackage{lipsum}
\begin{document}
\lipsum
\newgeometry{textwidth=5cm}
\lipsum
\end{document}
On the pages with new geometry, the header does not extend across the page. How can I make scrlayer-scrpage
extend the headsepline with an arbitrary page geometry?
Best Answer
With your code the header offset is calculated once depending on the current
\textwidth
. It is not recalculated if the\textwidth
is changed.If the
headoffset
should depend on flexible\textwidth
you have to ensure that theheadwidth
including the offsets is recalculated on every page.Note, that
headwidth=paper
in oneside mode uses the offsets\the\textwidth/2-\the\paperwidth/2
as default.But there are possibilities without recalculating the offsets on every page too.
If the header should have the same width as the paper set the horizontal offset of all header layers to 0pt:
Maybe you have to do the same for
plain.scrheadings
. Note that page styleplain
is only an alias forplain.scrheadings
ifscrlayer-scrpage
is loaded.Code:
If only the line below of the header should be extended but not the header itself you have to modify only the
scrheadings.head.below.line
layer.Result: