29

With the KOMA-script scrreprt class the vertical spacing before and after chapter titles can be adjusted the following way:

\renewcommand*{\chapterheadstartvskip}{\vspace*{0cm}}
\renewcommand*{\chapterheadendvskip}{\vspace*{70.9pt}}

However, I can't find a way to do the same with section, subsection (and, possibly, subsubsection) titles. I know there is the titlesec package with the command

\titlespacing*{\section}{0pt}{28.35pt}{0pt}

but using KOMA-Script with titlesec gives me the warning "Usage of package `titlesec' together with a KOMA-Script class is not recommended". Is there some other way to adjust the vertical spacing around section headings that is compatible with the KOMA-Script classes?

1 Answer 1

46

Update

KOMA-Script version 3.26 introduces two new keys to \RedeclareSectionCommand and \RedeclareSectionCommands: runin and afterindent. Possible values for both keys are bysign, true and false.

runin:

This key is only defined for sectioning commands with style=section, eg section, subsection, subsubsection, paragraph, subparagraph.

By default runin=bysign is set. Then the sign of afterskip decides if the heading is a runin heading (negative sign) or not (positive value) and the absolute value of afterskip is used for the horizontal or vertical skip after the heading. This is the same behavior as explained in the original answer below.

With runin=true it is a runin heading and the sign of afterskip has no meaning anymore. Note that the absolute value of afterskip is used as the horizontal skip. So even a negative value of afterskip will result in positive horizontal skip.

With runin=false it is a freestanding heading and the value of afterskip is used as vertical skip. Note that with runin=false a negative value of afterskip results in a negative vertical skip.

afterindent:

By default

  • afterindent=bysign is set for style=section and style=chapter
  • afterindent=true is set for style=part and class scrartcl
  • afterindent=false is set for style=part and class scrbook

With afterindent=bysign the sign of beforeskip determines if the first line after the heading uses the paragraph indentation or not. With afterskip=bysign the absolute value of beforeskip is used as vertical skip above the heading. This is the same behavior as explained in the original answer below.

With afterindent=true the paragraph indentation is used for the first line following a freestanding heading. With afterindent=false this first line is not indented. With both afterindent=true or afterindent=false the value of beforeskip is used as the skip above the heading. So a negative value of beforeskip results in a negative skip, even for a runin heading.

Example:

\documentclass{scrreprt}

\RedeclareSectionCommand[
  %runin=false,
  afterindent=false,
  beforeskip=0pt,
  afterskip=2\baselineskip]{chapter}
\RedeclareSectionCommand[
  %runin=false,
  afterindent=false,
  beforeskip=\baselineskip,
  afterskip=.5\baselineskip]{section}
\RedeclareSectionCommand[
  %runin=false,
  afterindent=false,
  beforeskip=.75\baselineskip,
  afterskip=.5\baselineskip]{subsection}
\RedeclareSectionCommand[
  %runin=false,
  afterindent=false,
  beforeskip=.5\baselineskip,
  afterskip=.25\baselineskip]{subsubsection}
\RedeclareSectionCommand[
  runin=true,
  %afterindent=false,
  beforeskip=.5\baselineskip,
  afterskip=1em]{paragraph}
\RedeclareSectionCommand[
  runin=true,
  %afterindent=false,
  beforeskip=.5\baselineskip,
  afterskip=1em]{subparagraph}

\begin{document}
\chapter{Erde}
Der eigentliche Text.\par
Test
\section{Europa}
Der eigentliche Text.
\subsection{Italien}
Der eigentliche Text.
\subsubsection{Toskana}
Der eigentliche Text.
\paragraph{Florenz}
Der eigentliche Text.
\subparagraph{Dom}
Der eigentliche Text
\end{document}

Original answer

It is easy with the new macros \RedeclareSectionCommand and \RedeclareSectionCommands of the KOMA-Script version 3.15.

\documentclass{scrreprt}

\RedeclareSectionCommand[
  beforeskip=-1sp,
  afterskip=2\baselineskip]{chapter}
\RedeclareSectionCommand[
  beforeskip=-\baselineskip,
  afterskip=.5\baselineskip]{section}
\RedeclareSectionCommand[
  beforeskip=-.75\baselineskip,
  afterskip=.5\baselineskip]{subsection}
\RedeclareSectionCommand[
  beforeskip=-.5\baselineskip,
  afterskip=.25\baselineskip]{subsubsection}
\RedeclareSectionCommand[
  beforeskip=.5\baselineskip,
  afterskip=-1em]{paragraph}
\RedeclareSectionCommand[
  beforeskip=-.5\baselineskip,
  afterskip=-1em]{subparagraph}

\usepackage{blindtext}
\begin{document}
\chapter{Erde}
Der eigentliche Text.\par
Test
\section{Europa}
Der eigentliche Text.
\subsection{Italien}
Der eigentliche Text.
\subsubsection{Toskana}
Der eigentliche Text.
\paragraph{Florenz}
Der eigentliche Text.
\subparagraph{Dom}
Der eigentliche Text
\end{document}

enter image description here

beforeskip: The absolute value is the vertical space before the heading. If the value is negative the paragraph indent of the text following this heading is suppressed.

afterskip: A positive value is a vertical skip below the heading. A negative value activates a run-in heading. Then the absolute value is the horizontal skip.

There is also a command \RedeclareSectionCommands to change several section-like commands at once:

\documentclass{scrreprt}

\renewcommand*{\chapterheadstartvskip}{\vspace*{0cm}}
\renewcommand*{\chapterheadendvskip}{\vspace*{2\baselineskip}}

\RedeclareSectionCommands[
  beforeskip=-.5\baselineskip,
  afterskip=.25\baselineskip
]{section,subsection,subsubsection}
\RedeclareSectionCommands[
  beforeskip=.5\baselineskip,
  afterskip=-1em]{paragraph,subparagraph}

\begin{document}
\chapter{Erde}
Der eigentliche Text.\par
Test
\section{Europa}
Der eigentliche Text.
\subsection{Italien}
Der eigentliche Text.
\subsubsection{Toskana}
Der eigentliche Text.
\paragraph{Florenz}
Der eigentliche Text.
\subparagraph{Dom}
Der eigentliche Text
\end{document}

enter image description here

The result is the same as in the original answer.

With KOMA-Script version 3.14 you have to redefine the original commands (based on a suggestion by Markus Kohm). Note that the original definitions of this commands differ from KOMA-Script version to KOMA-Script version.

\documentclass[headings=small]{scrreprt}

\renewcommand*{\chapterheadstartvskip}{\vspace*{0cm}}
\renewcommand*{\chapterheadendvskip}{\vspace*{2\baselineskip}}

\makeatletter
 %% check if this are the original definitions
\CheckCommand\section{%
  \scr@startsection{section}{\sectionnumdepth}{\z@}%
  {-3.5ex \@plus -1ex \@minus -.2ex}%
  {2.3ex \@plus.2ex}%
  {\ifnum \scr@compatibility>\@nameuse{scr@[email protected]}\relax
    \setlength{\parfillskip}{\z@ plus 1fil}\fi
    \raggedsection\normalfont\sectfont\nobreak\size@section}%
}
\CheckCommand\subsection{%
  \scr@startsection{subsection}{\subsectionnumdepth}{\z@}%
  {-3.25ex\@plus -1ex \@minus -.2ex}%
  {1.5ex \@plus .2ex}%
  {\ifnum \scr@compatibility>\@nameuse{scr@[email protected]}\relax
    \setlength{\parfillskip}{\z@ plus 1fil}\fi
    \raggedsection\normalfont\sectfont\nobreak\size@subsection
  }%
}
\CheckCommand\subsubsection{%
  \scr@startsection{subsubsection}{\subsubsectionnumdepth}{\z@}%
  {-3.25ex\@plus -1ex \@minus -.2ex}%
  {1.5ex \@plus .2ex}%
  {\ifnum \scr@compatibility>\@nameuse{scr@[email protected]}\relax
    \setlength{\parfillskip}{\z@ plus 1fil}\fi
    \raggedsection\normalfont\sectfont\nobreak\size@subsubsection
  }%
}
 %% redefine
\renewcommand\section{%
  \scr@startsection{section}{\sectionnumdepth}{\z@}%
  {-.5\baselineskip}%
  {.25\baselineskip}%
  {\ifnum \scr@compatibility>\@nameuse{scr@[email protected]}\relax
    \setlength{\parfillskip}{\z@ plus 1fil}\fi
    \raggedsection\normalfont\sectfont\nobreak\size@section}%
}
\renewcommand\subsection{%
  \scr@startsection{subsection}{\subsectionnumdepth}{\z@}%
  {-.5\baselineskip}%
  {.25\baselineskip}%
  {\ifnum \scr@compatibility>\@nameuse{scr@[email protected]}\relax
    \setlength{\parfillskip}{\z@ plus 1fil}\fi
    \raggedsection\normalfont\sectfont\nobreak\size@subsection
  }%
}
\renewcommand\subsubsection{%
  \scr@startsection{subsubsection}{\subsubsectionnumdepth}{\z@}%
  {-.5\baselineskip}%
  {.25\baselineskip}%
  {\ifnum \scr@compatibility>\@nameuse{scr@[email protected]}\relax
    \setlength{\parfillskip}{\z@ plus 1fil}\fi
    \raggedsection\normalfont\sectfont\nobreak\size@subsubsection
  }%
}
\makeatother

\begin{document}
\chapter{Erde}
Der eigentliche Text.\par
Test
\section{Europa}
Der eigentliche Text.
\subsection{Italien}
Der eigentliche Text.
\subsubsection{Toskana}
Der eigentliche Text.
\paragraph{Florenz}
Der eigentliche Text.
\subparagraph{Dom}
Der eigentliche Text

\end{document}
8
  • Notice: The \RedeclareSectionCommand thing works even as it is not documented in the koma script guide. Jan 10, 2017 at 18:02
  • \RedeclareSectionCommand is documented in the current documentation on CTAN. See mirrors.ctan.org/macros/latex/contrib/koma-script/doc/…, section "21.3 Expert commands", page 390
    – esdd
    Jan 10, 2017 at 19:51
  • OK sorry, so I had an old version offline ... :) Jan 10, 2017 at 22:52
  • 1
    AFAIK there must be a number before \baselineskip. So you have to write beforeskip=-1\baselineskip. But with the minus the skip is a horizontal one. So the text starts no the same line. There is no possibility to use a smaller sep between the a section title and the following text as between two normal paragraphs in the text.
    – esdd
    Feb 27, 2017 at 23:19
  • 1
    The sep between the section title and the following text is afterskip not beforeskip and since KOMA-Script 3.26 you can use negative values for afterskip. See option runin in the answer. So @esdd's comment from 27 '17 at 23:19 is not longer valid. Mar 9, 2019 at 16:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .