1

I want to recreate the header from this book: https://books.google.de/books?id=ybEmCgAAQBAJ&pg=PA36&hl=de&source=gbs_selected_pages&cad=3#v=onepage&q&f=false Example images: Header even pages header odd pages

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}

\usepackage[markcase=noupper,headsepline]{scrlayer-scrpage}

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

\renewcommand\chaptermarkformat{}

\usepackage{adjustbox}

\newcommand{\Graybox}{\noindent\adjustbox{minipage=[c]{\marginparwidth}\centering,height=8pt, bgcolor=gray}}

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

\rohead{\rightmark}

\setkomafont{pagehead}{\normalfont\sffamily}

\usepackage{blindtext}% dummy text

\begin{document}
\Blinddocument
\end{document}
  • page 123 fillllll – Johannes_B Sep 3 '17 at 13:23
  • 1
    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
1

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}
\addtolength\fullwidth{-1in}
\addtolength\fullwidth{-\oddsidemargin}% für die Kopflinie

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

%\setheadwidth[\marginparsep]{textwithmarginpar} % <====================
%\KOMAoption{headwidth}{textwithmarginpar} % <==========================

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

\KOMAoption{headwidth}{\fullwidth:0mm} % <=========================== 

and the headsepline is set with

%\setheadsepline[\fullwidth]{0.8pt}  % <================================
\KOMAoption{headsepline}{0.8pt} % <=====================================

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
%%  of this license or (at your option) any later version.
%% 
%%  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,
  includeheadfoot,
  headheight=5mm,     % 
  headsep=8mm,        % 
  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}
\DeclareRobustCommand\headingfont{\sffamily\bfseries}
\renewcommand\@makechapterhead[1]{\begingroup
      \flushright
      {\topskip\z@\null}
      \headingfont\mdseries
      \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
      \rule{0pt}{5pc}\normalfont\headingfont #1
      \end{minipage}%
      \null
      \par\endgroup
      \rule{0pt}{7.5pc}\par}
\setcounter{chapter}{4}
\newlength\fullwidth
\setlength\fullwidth{\paperwidth}
\addtolength\fullwidth{-1in}
\addtolength\fullwidth{-\oddsidemargin}% für die Kopflinie

%\setlength{\footheight}{51.3pt}  
\usepackage[ilines]{scrlayer-scrpage}  % scrlayer-scrpage scrpage2 <====
\pagestyle{scrheadings} 
\clearscrheadfoot{}
%\setheadwidth[\marginparsep]{textwithmarginpar} % <====================
%\KOMAoption{headwidth}{textwithmarginpar} % <==========================
\KOMAoption{headwidth}{\fullwidth:0mm} % <===========================
\lehead[\clearscrheadfoot]{\mbox{\headingfont\smash{%
  \setlength\fboxsep{0pt}\raisebox{-2pt}{\colorbox{blue!80}{\makebox[22mm]{\hfill%
   \ifnum\value{chapter}>0
      \textcolor{white}{\fontsize{18}{19}\selectfont\thechapter}~\fi%
      \rule[-2.85pt]{2mm}{12mm}}}}}\quad\small\leftmark}}
\rohead[\clearscrheadfoot]{\small\headingfont\rightmark\quad\makebox[22mm]{}}
\lefoot[\clearscrheadfoot]{\small\headingfont\llap{\thepage~\rule[-13mm]{.6pt}{18mm}
  \hspace{1mm}}} 
\rofoot[\clearscrheadfoot]{\small\headingfont~
  \hfill \rlap{\hspace{1mm}\rule[-13mm]{.6pt}{18mm}\ \thepage}}
%\setheadsepline[\fullwidth]{0.8pt}  % <================================
\KOMAoption{headsepline}{0.8pt} % <=====================================
\renewcommand\chaptermark[1]{\markboth{#1}{}}
\renewcommand\sectionmark[1]{%
   \markright{\ifnum\c@secnumdepth>\@ne \thesection\quad #1\fi}}
\makeatother

\begin{document}
\chapter{Textformatierungen}
\section{Seitenstil}\blindtext\par\blindtext\newpage
\section{baz}   \blindtext[2]\par\blindtext\newpage
\section{foobar}\blindtext[2]\par\blindtext\newpage  \blindtext[2]
\end{document}

you get the wished result:

enter image description here

| improve this answer | |
  • Please don't use \setlength{\parindent}{0pt}. If you don't like pararagraph indention you should use paragraph separation. With KOMA-Script you should use option parskip to do so. And redefinition if \@makechapterhead is also not needed for the example and is not recommended if you use a newer KOMA-Script release. And if the line should be extended into the inner margin headwidth=paper should be enough. – Schweinebacke Sep 4 '17 at 8:41

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.