# Page numbers vertically centered in the outer page margin

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.

• Thanks Gonzalo and egreg, both of your solutions work. I prefer egreg's one because it goes without an additional package and because it's way beyond my LaTeX skills :) p.s. I'm sorry to post this as an answer to my own question, but SX doesn't recognize me. I guess it's because I posted the question as unregistered user and now I'm registered (even though I used the same email address - anyways). Also I'm sorry for not being able to mark the question answered and give credits :( – Matthias Jul 29 '11 at 20:38
• I merged your two accounts together now (the questions was asked with an unregistered account). I also converted your post to a comment. Don't worry about it. You can now place comments here and also accept your favored answer to conclude the question. Welcome to TeX.sx! – Martin Scharrer Jul 29 '11 at 20:58
• @Martin: Wow, that was quicker than quick! I was in the means of writing a mail about this, but it seems I don't need to send it anymore :) Great site, great people! – Matthias Jul 29 '11 at 21:04
• Note that you can flag posts for moderator attention which will be noticed very quickly. Use the 'flag' link below each post to do so. There is also the chat and our TeX - LaTeX Meta site. – Martin Scharrer Jul 29 '11 at 21:26

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

\usepackage{scrpage2}
\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.

You can use the background package; a little exampe:

\documentclass[twoside]{scrbook}
\usepackage{background}
\usepackage{ifthen}
\usepackage{lipsum}

\SetBgContents{}
\SetBgAngle{0}
\SetBgColor{black}
\SetBgScale{3}

\makeatletter
\ifthenelse{\isodd{\value{page}}}%
{\SetBgPosition{1.05\textwidth,-.5\textheight}}
{\SetBgPosition{0.3,-.5\textheight}}
\SetBgContents{-\thepage-}
\bg@material%
}
\makeatother

\pagestyle{empty}

\begin{document}
\lipsum[1-30]
\end{document}


You could also use KOMA-Script package scrlayer-scrpage. It is the successor of the deprecated package scrpage2.

scrlayer-scrpage uses layer to declare pagestyles. So you can declare a new layer for the pagenumber in the outer margin and add this layer to pagestyle scrheadings and plain.scrheadings. Note that after loading scrlayer-scrpage pagestyle scrheadings is set and pagestyle plain is redefined as an aliaspagestyle for plain.scrheadings.

\documentclass{scrbook}
\usepackage[automark]{scrlayer-scrpage}
\clearpairofpagestyles

\DeclareNewLayer[
background,
outermargin,
height=\textheight,
contents={%
\vfill
\ifodd\value{page}\hspace*{.4\layerwidth}\else\hfill\fi
\pagemark
\ifodd\value{page}\else\hspace*{.4\layerwidth}\fi
\vfill
}
]{outermargin.pagenumber}