Consider this MWE:
\documentclass[twoside]{scrreprt}
\usepackage[automark]{scrlayer-scrpage}%
\clearscrheadfoot%clear default
\lehead{\llap{\pagemark\enskip\rule[-2ex]{1.5pt}{4.5ex}}\enskip\headmark}%
\rohead{\headmark\enskip\rlap{\rule[-2ex]{1.5pt}{4.5ex}\enskip\pagemark}}%
\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:
- it seems rather hacky. Especially defining the
\ruletwice manually (even positioning it manually) makes me think there is a smarter solution here. - 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.
- 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?

newcommandfor therule, 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. – Alex Povel Jan 17 '19 at 08:50\smashin the definition for the rule:\newcommand*\headvrule{\smash{\rule[-2ex]{1.5pt}{4.5ex}}}.\smashhides the height and the depth of its argument. – esdd Jan 17 '19 at 13:00