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 from scrartcl
sometimes in the past. Be aware that this solution may break if scrartcl
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
and part
. Hopefully, we will see a similar command for \section
and her sisters.
Here, I have redefined both section and subsection to be runin-header.
\documentclass{scrartcl}
\makeatletter
\renewcommand\section{\@startsection{section}{1}{\z@}%
{-1.5ex}%
{-1em}%{2.3ex \@plus.2ex}% < - negative value here negative value here,
% the values behind % are the original.
% no use for rubber values, use a fix value to set the
% distance to between heading and the text
{\ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
\setlength{\parfillskip}{\z@ plus 1fil}\fi
\raggedsection\sectfont\nobreak\size@section}%
}
\renewcommand\subsection{\@startsection{subsection}{1}{\z@}%
{-1.5ex \@plus -1ex \@minus -.2ex}%
{-1em}%{2.3ex \@plus.2ex}% <- negative value here, the values behind % are the original
{\ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
\setlength{\parfillskip}{\z@ plus 1fil}\fi
\raggedsection\normalfont\sectfont\nobreak\size@section}%
}
\makeatother
\begin{document}
\section{First section}
This text follows on the same line as "First section"
\end{document}
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:
\DeclareSectionCommand[attributes]{name}
\DeclareNewSectionCommand[attributes]{name}
\RedeclareSectionCommand[attributes]{name}
\ProvideSectionCommand[attributes]{name}
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.
\RedeclareSectionCommand[%
afterskip=-10pt plus -1sp minus 1sp% using rubber is optional
]{section}
Just use a negative value as the first afterskip
value ( I have used -10pt here).
With the latest version of KOMA-script, you can declare
\RedeclareSectionCommand[afterskip=-.5em]{subsubsection}
MWE:
\documentclass{scrbook}
\usepackage{blindtext}
\RedeclareSectionCommand[afterskip=-.5em]{subsubsection}
\begin{document}
\chapter{A chapter heading}
\section{A section heading}
\subsection{A subsection heading}
\blindtext
\subsubsection{Inline subsubsection heading.}
\blindtext
\subsubsection{Another inline subsubsection heading.}
\blindtext
\end{document}
Output:
Best Answer
Update
KOMA-Script version 3.26 introduces two new keys to
\RedeclareSectionCommand
and\RedeclareSectionCommands
:runin
andafterindent
. Possible values for both keys arebysign
,true
andfalse
.runin
:This key is only defined for sectioning commands with
style=section
, egsection
,subsection
,subsubsection
,paragraph
,subparagraph
.By default
runin=bysign
is set. Then the sign ofafterskip
decides if the heading is a runin heading (negative sign) or not (positive value) and the absolute value ofafterskip
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 ofafterskip
has no meaning anymore. Note that the absolute value ofafterskip
is used as the horizontal skip. So even a negative value ofafterskip
will result in positive horizontal skip.With
runin=false
it is a freestanding heading and the value ofafterskip
is used as vertical skip. Note that withrunin=false
a negative value ofafterskip
results in a negative vertical skip.afterindent
:By default
afterindent=bysign
is set forstyle=section
andstyle=chapter
afterindent=true
is set forstyle=part
and classscrartcl
afterindent=false
is set forstyle=part
and classscrbook
With
afterindent=bysign
the sign ofbeforeskip
determines if the first line after the heading uses the paragraph indentation or not. Withafterskip=bysign
the absolute value ofbeforeskip
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. Withafterindent=false
this first line is not indented. With bothafterindent=true
orafterindent=false
the value ofbeforeskip
is used as the skip above the heading. So a negative value ofbeforeskip
results in a negative skip, even for a runin heading.Example:
Original answer
It is easy with the new macros
\RedeclareSectionCommand
and\RedeclareSectionCommands
of the KOMA-Script version 3.15.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: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.