# Align Header with Text/Type Area in KOMA but let Page Number bleed into Margin [closed]

Consider this MWE:

\documentclass[twoside]{scrreprt}

\usepackage[automark]{scrlayer-scrpage}%
\usepackage{lipsum}
\begin{document}
\chapter{First Chapter}
\lipsum
\section{The first Section}
\lipsum
\newpage
\noindent\rule{\textwidth}{\textheight}
\newpage
\noindent\rule{\textwidth}{\textheight}
\end{document}


What I am trying to do is this:

And surprisingly, it works, taking \rlap from here. There have been others questions like this, but not often with KOMA, like this one.

This question comes quite close, but they use the entire headwidth=textwithmarginpar, an area/width much too large for me.

I simply want the vertical \rule to be aligned along the text, and the page number -- be it one, two, three or even four digit -- to bleed into the margin freely.

While that is achieved, my questions are:

1. it seems rather hacky. Especially defining the \rule twice manually (even positioning it manually) makes me think there is a smarter solution here.
2. are there caveats to using the rule? I guess it takes away vertical space in an unplanned manner; is that okay typographically? I don't want to mess with the carefully crafted defaults. For example, the text now seems to sit quite 'high up'; I thought about pushing it down.
3. simply forcing the page number into the margin seems hacky, too. I guess KOMA is not aware this is happening, which might cause incompatibilities or crashes I am not aware of yet?

## closed as primarily opinion-based by schtandard, Phelype Oleinik, Stefan Pinnow, Raaja, MarijnJul 24 at 8:10

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

• It seems perfectly acceptable to me: it's highly predictable where this will go, and the page geometry is fixed. I wouldn't be too precious about it if the effect seems desirable to you. Personally, I think it's a fussy bit of typographical decoration: but that's just a personal aesthetic choice. – Paul Stanley Jan 16 at 23:21
• Thank you for your feedback. I now used a newcommand for the rule, so it looks quite cleaned up now. You're definitely right that it looks quite fuzzy, fidgety and maybe too alternative. But I like it once the fully-fledged, two-sided output is in front of you. – Hans Lollo Jan 17 at 8:50
• You could use \smash in the definition for the rule: \newcommand*\headvrule{\smash{\rule[-2ex]{1.5pt}{4.5ex}}}. \smash hides the height and the depth of its argument. – esdd Jan 17 at 13:00