1

How can I move page number and headings to the margin using KOMA-Script?

I'm looking for this layout:

layout

where red circle means position of the page number after the section (or chapter) name.

So far i have following code:

\documentclass[12pt,parskip=half, DIV=calc]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern, libertine}

\usepackage[headsepline]{scrpage2}
\setheadwidth[0pt]{textwithmarginpar}

\usepackage{geometry}
\geometry{includemp,showframe}



\usepackage{blindtext}

\begin{document}
\section{test}
\blindtext[1]
\marginpar{\blindtext[1]}
\blindtext[3]
\end{document}
1

Swap the loading order.

Note that scrpage2 is outdated. Its successor is package scrlayer-scrpage. This package sets \pagestyle{scrheadings} automatically.

rerunnerScrbookHeaderInMargin

\documentclass[12pt,parskip=half]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern, libertine}

\usepackage{geometry}
\geometry{includemp,showframe}

\usepackage[
  headsepline,
  headwidth=textwithmarginpar,
  footwidth=head% if footer and header should have the same width
]{scrlayer-scrpage}% modern version


\usepackage{blindtext}

\begin{document}
\section{test}
\blindtext[1]
\marginpar{\raggedright No Wombat can be found here, please be aware of that}
\blindtext[3]
\end{document}

With outdated package scrpage2 you have to activate the page style scrheadings manually.

\documentclass[12pt,parskip=half]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern, libertine}

\usepackage{geometry}
\geometry{includemp,showframe}

\usepackage[headsepline]{scrpage2}
\setheadwidth[0pt]{textwithmarginpar}
\setfootwidth[0pt]{head}% if footer and header should have the same width
\pagestyle{scrheadings}% <- added

\begin{document}
\section{test}
\blindtext[1]
\marginpar{\raggedright No Wombat can be found here, please be aware of that}
\blindtext[3]
\end{document}
  • Maybe better \usepackage[headsepline, headwidth=textwithmarginpar, footwidth=textwithmarginpar]{scrlayer-scrpage}. Commands \setheadwidth and \setfootwidth are not mentioned in the documentation of scrlayer-scrpage. AFAIK \setheadwidth and \setfootwidth are defined for compatibility with scrpage2. Both commands are not mentioned in the documentation. They set only the related KOMA options. – esdd Nov 13 '16 at 10:25
  • @esdd I didn't check the manual. But the question is Community-wiki, feel free to improve it :-) – Johannes_B Nov 13 '16 at 10:31

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.