1

Problem

I would like to increase the headsep on pages that start with a section\subsection or paragraph title.

I redefined the chapter spacing settings (before and afterskip) according to my wishes and it looks brilliant in text. Just if the title is on top of the page the beforeskip doesnt seem to influence the spacing to the headerline. An example picture below:

enter image description here

Question

Is there a way to redifine the headsep for pages that start with some kind of section title or is it possible to define it somehow in the settings of the \sections ? I am using koma-script-report-class:

This is the fullcode:

Code

\documentclass[11pt,twoside,english,openright, bibliography=totoc]  {scrreprt}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.75cm,rmargin=2.5cm,headheight=18pt,headsep=8pt,footskip=26pt}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{\smallskipamount}
\setlength{\parindent}{0pt}
\usepackage{verbatim}
\usepackage{setspace}
\usepackage[authoryear]{natbib}
\onehalfspacing

\makeatletter
\usepackage{lscape} 
\usepackage[automark, headsepline, footsepline, plainfootsepline]{scrlayer-scrpage}
\pagestyle{scrheadings}
\clearscrheadfoot
\ohead{\headmark}
\ifoot[Test]{Test}
\cfoot[]{}
\ofoot[\pagemark]{\pagemark}
\ihead[]{}
\chead[]{}
\automark[chapter]{chapter} 
\usepackage{pdfpages}
\RedeclareSectionCommand[beforeskip=12pt,afterskip=12pt]{chapter}
\setkomafont{chapter}{\sffamily\LARGE}
\RedeclareSectionCommand[beforeskip=12pt,afterskip=10pt]{section}
\RedeclareSectionCommand[beforeskip=12pt,afterskip=8pt]{subsection}
\RedeclareSectionCommand[beforeskip=-12pt,afterskip=8pt]{paragraph}
\setkomafont{paragraph}{\sffamily\normalsize}
\usepackage {blindtext} 

\setkeys{Gin}{width=\textwidth} 
\raggedbottom
\usepackage[hyphens]{url}
\usepackage[colorlinks=true, urlcolor=blue, linkcolor=black,  citecolor=black]{hyperref} 
\makeatother
\usepackage{babel}
\begin{document}

\renewcommand{\thepage}{\roman{page}}
\chapter{Introduction}
\setcounter{page}{1}
\renewcommand{\thepage}{\arabic{page}}
\section{This is a Section}
\blindtext
\blindtext
\blindtext
\blindtext
\subsection{This is a Sub-section}
\blindtext
\end{document}
4

Note that this is unusual. It would be better to not use such a small headsep.

But if you really want to do this, you can use

\usepackage{xpatch}
\xpretocmd\sectionlinesformat{\vspace*{0pt}}{}{\PatchFailed}

Then the beforeskip is also inserted if the section titles (section, subsection etc.) are on top of a new page.

enter image description here

Additional remarks:

Do not set \parskip manually. Use the KOMA-Script option parskip=half- instead.

Replace \clearscrheadfoot by \clearpairofpagestyles. With both commands \cfoot[]{} is not needed. And if both the optional and the mandatory argument of \ifoot etc. are equal you can use the starred version.

To restart the page numbering use \pagenumbering and insert a \cleardoublepage or \cleardoubleoddpage before this command to ensure that it is excecuted on a righthand page.

Code:

\documentclass[11pt,twoside,english,openright, bibliography=totoc,
  parskip=half-
]{scrreprt}

\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,margin=2.5cm,lmargin=2.75cm,headheight=18pt,headsep=8pt,footskip=26pt}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{verbatim}
\usepackage{setspace}
\usepackage[authoryear]{natbib}
\onehalfspacing

\makeatletter
\usepackage{lscape} 
\usepackage[automark, headsepline, footsepline, plainfootsepline]{scrlayer-scrpage}
\pagestyle{scrheadings}
\automark[chapter]{chapter} 
\clearpairofpagestyles
\ohead{\headmark}
\ifoot*{Test}
\ofoot*{\pagemark}

\usepackage{pdfpages}
\RedeclareSectionCommand[beforeskip=12pt,afterskip=12pt]{chapter}
\setkomafont{chapter}{\sffamily\LARGE}
\RedeclareSectionCommand[beforeskip=-12pt,afterskip=10pt]{section}
\RedeclareSectionCommands[beforeskip=-12pt,afterskip=8pt]{subsection,subsubsection,paragraph}
\setkomafont{paragraph}{\sffamily\normalsize}

\usepackage{xpatch}
\xpretocmd\sectionlinesformat{\vspace*{0pt}}{}{\PatchFailed}

\usepackage{blindtext}% only for dummy text
\setkeys{Gin}{width=\textwidth}% default width for \includegraphics
\raggedbottom
\usepackage{babel}
\usepackage[hyphens]{url}
\usepackage[colorlinks=true, urlcolor=blue, linkcolor=black,citecolor=black]{hyperref} 

\begin{document}

\pagenumbering{roman}
\chapter{Introduction}
\Blindtext
\cleardoubleoddpage
\pagenumbering{arabic}
\chapter{A Chapter}
\section{This is a Section}
\blindtext
\blindtext
\blindtext
\blindtext
\section{A Second Section}
\subsection{This is a Sub-section}
\blindtext
\section{A Second Section}
\subsection{This is a Sub-section}
\Blindtext
\end{document}

If you want to use a smaller skip before section titles on a new page than the normal beforeskip, you can use something like

\usepackage{xpatch}
\makeatletter
\xpatchcmd\sectionlinesformat
  {\@hangfrom{\hskip #2#3}{#4}}
  {\parbox[b]{\textwidth}{\vspace*{7pt}\raggedsection\@hangfrom{\hskip #2#3}{#4}}}
  {}{\PatchFailed}
\makeatother

But then you have to decrease the beforeskip by the same length. In the example beforeskip would be 12pt-7pt=5pt.

\RedeclareSectionCommand[beforeskip=-5pt,afterskip=10pt]{section}
\RedeclareSectionCommands[beforeskip=-5pt,afterskip=8pt]{subsection,subsubsection,paragraph}

enter image description here

Code:

\documentclass[11pt,twoside,english,openright, bibliography=totoc,
  parskip=half-
]{scrreprt}

\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,margin=2.5cm,lmargin=2.75cm,headheight=18pt,headsep=8pt,footskip=26pt}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{verbatim}
\usepackage{setspace}
\usepackage[authoryear]{natbib}
\onehalfspacing

\makeatletter
\usepackage{lscape} 
\usepackage[automark, headsepline, footsepline, plainfootsepline]{scrlayer-scrpage}
\pagestyle{scrheadings}
\automark[chapter]{chapter} 
\clearpairofpagestyles
\ohead{\headmark}
\ifoot*{Test}
\ofoot*{\pagemark}

\usepackage{pdfpages}

\RedeclareSectionCommand[beforeskip=12pt,afterskip=12pt]{chapter}
\setkomafont{chapter}{\sffamily\LARGE}
\RedeclareSectionCommand[beforeskip=-5pt,afterskip=10pt]{section}
\RedeclareSectionCommands[beforeskip=-5pt,afterskip=8pt]{subsection,subsubsection,paragraph}
\setkomafont{paragraph}{\sffamily\normalsize}

\usepackage{xpatch}
\makeatletter
\xpatchcmd\sectionlinesformat
  {\@hangfrom{\hskip #2#3}{#4}}
  {\parbox[b]{\textwidth}{\vspace*{7pt}\raggedsection\@hangfrom{\hskip #2#3}{#4}}}
  {}{\PatchFailed}
\makeatother

\usepackage{blindtext}% only for dummy text
\setkeys{Gin}{width=\textwidth}% default width for \includegraphics
\raggedbottom
\usepackage{babel}
\usepackage[hyphens]{url}
\usepackage[colorlinks=true, urlcolor=blue, linkcolor=black,citecolor=black]{hyperref} 

\begin{document}

\pagenumbering{roman}
\chapter{Introduction}
\Blindtext
\cleardoubleoddpage
\pagenumbering{arabic}
\chapter{A Chapter}
\section{This is a Section}
\blindtext
\blindtext
\blindtext
\blindtext
\section{A Second Section}
\subsection{This is a Sub-section}
\blindtext
\section{A Second Section}
\subsection{This is a Sub-section}
\Blindtext
\end{document}
  • Thanks for your answer! Could you maybe explain how the command you use works, so that I could adapt it that it fits my format ? I googled a bit but I dont really get it oO. Thanks in advance – KiW Jul 22 '16 at 8:41
  • @KiW I haved added another version. But it would be much better if you simple enlarge headsep for all pages instead of patching \sectionlinesformat. A different skip above sections on top of a page and above normal text is unusual. – esdd Jul 22 '16 at 9:20
  • Thanks a lot! Well unusual is not neccessarily bad is it ? But I will consider your advice! – KiW Jul 22 '16 at 10:25

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.