# Recreate Header from sample with scrlayer-scrpage

So on even pages, the chapter number is on the top left corner in a gray box. This is followed by the chapter name. In contrast to the example here, the headsepline should extend over the whole page, i.e. the line should extend into the inner margin.

On odd pages the section should be shown on the top right corner. Again, the headsepline should extend over the whole page.

My current attempt:

\documentclass[a4paper, twoside]{scrbook}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}

\usepackage{lmodern}

\usepackage{xcolor}

\automark[section]{chapter}
\automark*[subsection]{}

\renewcommand\chaptermarkformat{}

\makebox[0pt][r]{%
{\Graybox{\color{white}\textsf{\thechapter}}}\hspace*{1em}}%
\leftmark
}

\usepackage{blindtext}% dummy text

\begin{document}
\Blinddocument
\end{document}
• page 123 fillllll – Johannes_B Sep 3 '17 at 13:23
• scrlayer-scrpage is (almost) compatible with scrpage2. So you can use the scrpage2 code of the head from the book (page 134f) and do only the wanted changes like increasing the length of the headsepline. You will get warnings if you use obsolete commands. The warning messages should contain information about the corresponding new solution. – Schweinebacke Sep 3 '17 at 13:31
• Ah, thank you for the hint! I didn't think that the author would publish the layout directly in the book. – Merlin1896 Sep 3 '17 at 13:37

With the following MWE, a version based on the code of the author of the book, Herbert Voss, you can use scrlayer-scrpage instead of scrpage2 to get the layout you want.

There are some things you should look at:

With

\newlength\fullwidth
\setlength\fullwidth{\paperwidth}

\fullwidth the lebgth of the line in the header is calculated (right margin + textwidth), with

\KOMAoption is the headwidth set. Because we want the line reach the paper end we can not use textwithmarginpar, we have to use

and the headsepline is set with

With the following MWE

%
%%
%%  Ein Beispiel der DANTE-Edition
%%
%%  1. Auflage
%%
%%  Beispiel 05-02-13 auf Seite 134.
%%
%%  Copyright (C) 2012 Herbert Voss
%%
%%  It may be distributed and/or modified under the conditions
%%  of the LaTeX Project Public License, either version 1.3
%%
%%  See http://www.latex-project.org/lppl.txt for details.
%%
%%
%% ====
% Show page(s) 1,2,3
%%
%%
\documentclass[parskip=half,pagesize]{scrbook}
\pagestyle{empty}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{geometry,blindtext,xcolor}
\geometry{%
showframe, % <========================================================
paperheight=239mm,  %
paperwidth=169mm,   %
tmargin=5mm,        % top
textwidth=124mm,    %
textheight=195mm,   %
rmargin=22mm,       % right (outer)
heightrounded,
foot=18mm,          %
marginparsep=2mm,   %
marginparwidth=18mm %
}
\makeatletter
\newcommand\s@pt{\hspace{6pt}}
\newcommand\chaptertext{K\s@pt a\s@pt p\s@pt i\s@pt t\s@pt e\s@pt l}
\flushright
{\topskip\z@\null}
\fontsize{14.4}{5.5pc minus .5pc}\selectfont
\textbf{\chaptertext}
\fontsize{36}{\f@baselineskip}\selectfont\ \thechapter\kern-2pt
\par
\fontsize{28}{24pt}\selectfont
\begin{minipage}{\linewidth}\flushright
\end{minipage}%
\null
\par\endgroup
\rule{0pt}{7.5pc}\par}
\setcounter{chapter}{4}
\newlength\fullwidth
\setlength\fullwidth{\paperwidth}

%\setlength{\footheight}{51.3pt}
\usepackage[ilines]{scrlayer-scrpage}  % scrlayer-scrpage scrpage2 <====
\setlength\fboxsep{0pt}\raisebox{-2pt}{\colorbox{blue!80}{\makebox[22mm]{\hfill%
\ifnum\value{chapter}>0
\textcolor{white}{\fontsize{18}{19}\selectfont\thechapter}~\fi%
\hspace{1mm}}}
\hfill \rlap{\hspace{1mm}\rule[-13mm]{.6pt}{18mm}\ \thepage}}
\renewcommand\chaptermark[1]{\markboth{#1}{}}
\renewcommand\sectionmark[1]{%