2

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:

enter image description here

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?
  • 1
    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
  • 1
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.