# scrlayer-scrpage puts my header to offset with geometry and margin

I'm trying to copy the header from koma-script-manual. So far everything worked out fine, although I needed to use geometry to set my specific typearea. If I use scrlayer-scrpage to set my header the header magically gets an offset. Even more odd - the offset depends on the loading order of geometry - loaded before scrlayer-scrpage the offset is positive - loaded after it's negative. Any ideas why this happens and how to fix it?

%%%%%%%%%%%%%%% DOCUMENTCLASS
\documentclass[%
paper=a4,%
parskip=never,%
fontsize=10pt%
]{scrartcl}%
%%%%%%%%%%%%%%% TYPEAREA
\usepackage{geometry}%
\geometry{
left=2mm,%
right=2mm,%
top=0mm,%
bottom=2mm,%
includemp,%
nofoot,%
marginparwidth=20mm,%
marginparsep=2mm,%
reversemp%
}%
%%%%%%%%%%%%%%% COLORS
\usepackage{xcolor}%
\usepackage[%
automark,%
]{scrlayer-scrpage}%
\clearpairofpagestyles%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% from scrguide to color header
contents={%
\rule[-\dp\strutbox]%
{\layerwidth}{\layerheight}%
}%
contents={%
\rule[-\dp\strutbox]%
{\layerwidth}{\layerheight}%
}%
contents={%
\rule[-\dp\strutbox]%
{\layerwidth}{\layerheight}%
}%
}
%%%%%%%%%%%%%%% DEBUG
\usepackage{layout}% shows layout on page
\makeatletter% layout in mm
\renewcommand*{\lay@value}[2]{%
\strip@pt\dimexpr0.351459\dimexpr\csname#2\endcsname\relax\relax mm%
}%
\makeatother%
\KOMAoptions{%
%   draft=true% small black boxes in overfull lines
overfullrule=true% like draft - sometimes works better
}%
%   \geometry{showframe}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\lipsum
\newpage
\layout
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


Load package scrlayer-scrpage after the layout settings by geometry. But you have to set the offset for the header. See the documentation to get information what happens if the offset part is missing for the headwidth key.

\usepackage[%
automark,%
]{scrlayer-scrpage}


or

\usepackage[%
automark,%
]{scrlayer-scrpage}


Code:

\documentclass[%
parskip=never,%
fontsize=10pt%
]{scrartcl}%

\usepackage{geometry}%
\geometry{
margin=2mm,% all margins 2mm
top=0mm,% but top 0mm
includemp,%
nofoot,%
marginparwidth=20mm,%
marginparsep=2mm,%
reversemp%
}%

\usepackage{xcolor}%

\usepackage[%
automark,%
]{scrlayer-scrpage}% sets page style scrheadings automatically

\clearpairofpagestyles

\DeclareLayer[
everyside,% removes restrication to oneside
oddorevenpage,% removes restrication to oddside
contents={%
\rule[-\dp\strutbox]{\layerwidth}{\layerheight}%
}
}

\usepackage{lipsum}% only for dummy text
\begin{document}%
\lipsum[1-50]
\end{document}


• \the\oddsidemargin was exactly the "unit" I was searching for @esdd – Jabaal Jul 10 '18 at 10:15