[Tex/LaTex] Page numbers vertically centered in the outer page margin

koma-scriptmarginspage-numberingpositioningscrbook

Even though it seems to be a non-standard position, I'd like to place my document's page numbers vertically centered in the outer page margin – i.e. where you usually have your thumb when you skim through a book.

How can I achieve that with scrbook? As far as I can see the only predefined positions for page numbers are in the header and footer.

Best Answer

Another solution with only KOMA-Script tools (and some low level trickery):

\usepackage{scrpage2}
\pagestyle{scrheadings}
\setlength{\footskip}{0pt}
\rofoot[\centerpageno{o}]{\centerpageno{o}}
\lefoot[\centerpageno{e}]{\centerpageno{e}}
\def\centerpageno#1{\leavevmode
  \vbox to 0pt{
    \vss
    \hbox to 0pt{\Huge\normalfont
      \if#1o\kern 2em\else\hss\fi\thepage
      \if#1o\hss\else\kern2em\fi}
    \vskip.5\textheight
    \vskip\baselineskip}}

I use the normal footer, putting into it a zero height box that contains a zero width box that is raised to the center of the text block; in it the page number is typeset shifted on the right or on the left depending if we are in an odd or even page.