# Section title with runin and KOMA-Script class?

I would like to have section titles with runin so that there is no newline after the section title. This can be done with

\documentclass{article}
\usepackage{titlesec}
\title{\section}[runin]{\large}{\thesection}{1em}{}[]
\begin{document}
\section{First section}
This text follows on the same line as "First section"
\end{document}


However, I am using the KOMA-Script scrartcl class and use of the titlesec package is discouraged (see Incompatibilities between KOMA-Script and titlesec).

I have searched through the KOMA-Script documentation, but cannot find anything like the runin option in titlesec. How can I achieve this functionality while using a KOMA-Script class?

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 scrartclis 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 chapterand 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.

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).

• It's unfortunate the KOMA classes don't support this directly. However, your answer seems to be the best option for now. – EP_Guy Sep 1 '14 at 17:49

The author of KOMA-Script added an easy to use interface to redeclare sectioning commands (chapters and parts as well). In my opinion, it is much simpler than using titlesec ;-)

Of course, you need a fairly recent KOMA-Script-bundle.

\documentclass{scrartcl}
\RedeclareSectionCommand[afterskip=-1em,%negative value -> runin
font=\large\normalfont%match the font of your example
]{section}
\begin{document}
\section{First section}
This text follows on the same line as "First section"
\end{document}

• Level 10 nonsense, a headline you can't distinguish from text. But however, +1 for Johannes_B for a good answer. – Keks Dose Feb 10 '15 at 15:27

As from v3.26, one may also use the switch runin.

\RedeclareSectionCommand[runin=on]{section}

• Short but almost perfectly good. You only should tell, that in this case the sign of afterskip becomes valid for the (horizontal) space after the heading and therefore should also be changed, because the default of runin is bysign. Compare: tex.stackexchange.com/a/418444/9057 (answer similar question but about how to avoid the run-in of the following paragraph). – Schweinebacke Mar 13 '19 at 6:33