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}
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}
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@v@2.96}\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@v@2.96}\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@v@2.96}\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@v@2.96}\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@v@2.96}\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@v@2.96}\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}
The parskip=half
option results in additional space after a section heading. So you have to use afterskip=1sp
together with parskip=half
.
\documentclass[
parskip=half% inserts additional space after \section
]{scrartcl}
\usepackage{lipsum}
\usepackage{multicol}
\RedeclareSectionCommand[
afterskip=1sp]{section}
\begin{document}
\rule{\textwidth}{15cm}
\begin{multicols}{2}
\section*{Section 1}
\lipsum[1-2]
\end{multicols}
\end{document}
In addition the \flushcolumns
command (used by the multicolumns
environment) may also insert additional white space. Thats why there is still a distance when I remove the parskip=half
option:
To avoid this you can use \raggedcolumns
.
Code:
\documentclass[
%parskip=half% inserts additional space after \section
]{scrartcl}
\usepackage{lipsum}
\usepackage{multicol}
\RedeclareSectionCommand[
afterskip=1sp]{section}
\begin{document}
\noindent%< added
\rule{\textwidth}{15cm}
\begin{multicols}{2}
\raggedcolumns% <- added
\section*{Section 1}
\lipsum[1-2]
\end{multicols}
\end{document}
Update: You can change the afterskip
for sections only inside the multicols
Environment. And maybe you can use there a parindent instead the parskip.
\documentclass[parskip=half]{scrartcl}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{bera}
\usepackage[charter]{mathdesign}
%\RedeclareSectionCommand[afterskip=1ex]{section}
\usepackage{etoolbox}
\AtBeginEnvironment{multicols}{%
\raggedcolumns%
\RedeclareSectionCommand[afterskip=1sp]{section}%
\KOMAoptions{parskip=false}%
}
\begin{document}
\rule{\textwidth}{15cm}
\begin{multicols}{2}
\section*{Section 1}
\lipsum[1-2]
\end{multicols}
\section*{Section 2}
\lipsum
\end{document}
Or you can use parskip=full
inside multicols
\AtBeginEnvironment{multicols}{%
\raggedcolumns%
\RedeclareSectionCommand[afterskip=1sp]{section}%
\KOMAoptions{parskip=full}%
}
Best Answer
1. Older versions of KOMA-Script
You have to redefine the definition of
\section
,subsection
etc. You use a negativ value to set runin heading, similar to the standard article-class. I have copied the definition of headings fromscrartcl
sometimes in the past. Be aware that this solution may break ifscrartcl
is changed.If you take a look at page 351 in the English manual for KOMA-Script, you will see that there are several commands for changing the space above and below
chapter
andpart
. Hopefully, we will see a similar command for\section
and her sisters.Here, I have redefined both section and subsection to be runin-header.
You use the ordinary
\addtokomafont
etc. to change the font, colour etc. And of course, you have to fiddle around with the figures to get the space above you prefer.2. Newer versions of KOMA-Script
I refer to Johannes_B’s answer below.
For the sake of completeness, I will bring your attention to page 363 ff. in the English KOMA-Script manual as of 2015-10-03. The author has (from version 3.16?) added the possibility to interface to
\section{}
and her sisters by the four commands:You may use this commands to define totally new sectioning commands, but also to redefine the existing ones, including the possibility to easily define the
\section{}
-command to be a run-in heading.Just use a negative value as the first
afterskip
value ( I have used -10pt here).