# How to add page numbers and rotated chapter title to the outer margin?

I'd like to have page numbers on the outer page border slightly bellow the center, and the current chapter title at the bottom but rotated 90 degrees counter-clockwise (i.e. to the left) such that it also sticks to the page outer border, i.e.

+--------------+--------------+
|              |              |
|              |              |
|              |              |
|              |              |
|              |              |
|p             |             p|   p = page number
|              |              |
|C             |             C|   CT = chapter title, rotated
|T             |             T|        90 degrees counter-clockwise
+--------------+--------------+


Sure enough I could use in a similar way as mentioned here (and I'm already using tikz due to that very scenario), via

\node [anchor=west] at ([yshift=-0.5cm] current page.west){\pagemark}


and similarly use it to rotate the chapter title, but isn't there a better way that maybe also respects pagestyle, e.g. by defining a pagemargin similar to pageheader?

• If it's relevant, I am currently also using \usepackage[top=30mm,bottom=30mm,inner=25mm,outer=35mm]{geometry} and wouldn't mind putting that into a pagestyle as well... – Tobias Kienzler Nov 27 '15 at 15:02
• If I understand well, you'd like to have the header (or the footer) in the outer margin? Do you already use a package like fancyhdr or titleps (the latter from titlesec)? – Bernard Nov 27 '15 at 15:12
• @Bernard Correct, and no, none of these so far – Tobias Kienzler Nov 27 '15 at 15:13
• @Johannes_B Ok, it's nice to know that's basically solved via chapterthumbs.sty... Then I guess I should read through this question... – Tobias Kienzler Nov 27 '15 at 15:17

Here is a suggestion using package scrlayer-scrpage to define a new page style:

\documentclass[
%oneside
]{scrbook}
\usepackage[top=30mm,bottom=30mm,inner=25mm,outer=35mm]{geometry}
\usepackage{blindtext}
\usepackage{rotating}
\usepackage{scrlayer-scrpage}
\automark[chapter]{chapter}

% new font element for the text in outermargin
\newkomafont{outermargin}{\scshape\Large}

% declare new layers for the outermargin
\DeclareNewLayer[
foreground,
outermargin,
oddpage,
contents={\rotatebox{90}{\parbox[b][\layerwidth][b]{\layerheight}{%
\vspace*{.5cm}}}}
]{ChapterInOutermargin.odd}
\DeclareNewLayer[
clone=ChapterInOutermargin.odd,
evenpage,
contents={\rotatebox{90}{\parbox[t][\layerwidth][t]{\layerheight}{%
\vspace*{.5cm}%
]{ChapterInOutermargin.even}
\DeclareNewLayer[
clone=ChapterInOutermargin.odd,
contents={\parbox{\layerwidth}{\vspace*{.55\layerheight}%
\hfill\usekomafont{outermargin}\pagemark\hspace*{.5cm}}}
]{PagenumberInOutermargin.odd}
\DeclareNewLayer[
clone=ChapterInOutermargin.even,
contents={\parbox{\layerwidth}{\vspace*{.55\layerheight}%
\hspace*{.5cm}\usekomafont{outermargin}\pagemark\hfill}}
]{PagenumberInOutermargin.even}

% declare new page styles using the new layers
\DeclarePageStyleByLayers{outermargin}{%
ChapterInOutermargin.odd,ChapterInOutermargin.even,%
PagenumberInOutermargin.odd,PagenumberInOutermargin.even}
\DeclarePageStyleByLayers{plain.outermargin}{%
PagenumberInOutermargin.odd,PagenumberInOutermargin.even}

% if page style plain should be an alias for plain.outermargin
\RedeclarePageStyleAlias{plain}{plain.outermargin}

% use the new page style
\pagestyle{outermargin}
% if chapter pages should use page style outermargin instead plain
\renewcommand*{\chapterpagestyle}{outermargin}

\begin{document}
\tableofcontents
\blinddocument
\end{document}


• Perfect, thanks. In case anyone's interested, one can of course use \usekomafont{pagenumber} in the respective layers to have a different font for pagenumbers, and \renewcommand*{\chaptermarkformat}{} to hide chapter numbers. edit Never mind \usekomafont{pagenumber}, that should be implicitly included in \pagemark - @esdd, shouldn't that be a \thepage instead to avoid using the pagenumber font? – Tobias Kienzler Nov 30 '15 at 7:13
• I suggest to use \pagemark. Then you have to use \setkomafont or \addtokomafont only once to change the font of all page numbers. If you do not want to use a special pagenumber font insert \setkomafont{pagenumber}{} in your preamble. – esdd Nov 30 '15 at 12:58