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).
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}
Best Answer
This is not really a answer to the question. I think it is not possible to "translate" the
titlesec
commands in a general way to KOMA-Script commands. They are using different approaches. So here is only an overview of some possible ways.The relevant KOMA-Script commands and options are
\RedeclareSectionCommand
,\RedeclareSectionCommands
,\DeclareSectionCommand
etc.\partformat
,\chapterformat
,\sectionformat
etc.\raggedchapter
and\raggedsection
\addtokomafont
and\setkomatfont
chapterprefix
andappendixprefix
headings=<value>
with a<value>
likebig
,normal
,small
,onelineappendix
,twolineappendix
,onelinechapter
,twolinechapter
etc.\sectionlinesformat
,\sectioncatchphraseformat
,\chapterlinesformat
and\chapterlineswithprefixformat
See the KOMA-Script documentation for more informations.
\titlelabel
(from packagetitlesec
)You can redefine the KOMA-Script commands
\partformat
,\chapterformat
,\sectionformat
etc. Example:\titleformat*
(from packagetitlesec
)Use KOMA-Script commands
\addtokomafont
or\setkomafont
or\RedeclareSectionCommand
or\RedeclareSectionCommands
to change the font settings for section headings. Note that font elementdispostion
is used for all section levels before their own font element. The settings ofdisposition
can only be changed with\addtokomafont
or\setkomafont
. Examples:\titlespacing
(from packagetitlesec
)Use options
indent
(not available forpart
andchapter
styles),beforeskip
andafterskip
of commands\RedeclareSectionCommand
and\RedeclareSectionCommands
. Examples:Note there are more options for these commands like
font
,level
,style
,counterwithin
,prefixfont
,innerskip
etc. depending on optionstyle
that could besection
,chapter
orpart
.If you want to change the right margin (and/or the left margin of chapters and parts) you have to redefine
\sectionlinesformat
,\chapterlinesformat
or\chapterlineswithprefixformat
.\titleformat
(from packagetitlesec
)You have to use a combination of commands mentioned in the list above. This combination depends for a example from the desired shape. So I think this could not be answered in a short general way. Here are only some possibilities.
shape like hang: Default layout for chapter, section, subsection and subsubsection headings. To change paragraph and subparagraph headings to
hang
set a positive value to optionafterskip
by using\RedeclareSectionCommand
. Example:\RedeclareSectionCommand[afterskip=1sp]{paragraph}
. Then you can redefine\sectionlinesformat
or\chapterlinesformat
.shape like runin: Default layout for paragraph and subparagraph. To change other headings (with
style=section
) torunin
set a negative value to optionafterskip
using\RedeclareSectionCommand
. Example:\RedeclareSectionCommand[afterskip=-1em]{subsubsection}
. Then you can redefine\sectioncatchphraseformat
. If you want to change the shape of chapter heading to arunin
like you have to set itsstyle
tosection
.shape like display: Default layout for headings with
style=part
. To use a prefix line for chapters set optionchapterprefixline
orheadings=twolinechapter
. Note that you can switch the prefix line for appendix chapters separatly by optionappendixprefixline
orheadings=twolinechapter
etc. Then you can redefine\chapterlineswithprefixformat
. If you want to use a twoline heading for other section levels one possibility is redefining\sectionlinesformat
.Note that the
style
option of a section level can be changed using\RedeclareSectionCommand
. Example:\RedeclareSectionCommand[style=section,indent=0pt]{chapter}
Shapes block, frame, leftmargin and rightmargin should be also possible by redefining
\sectionlinesformat
,\sectioncatchphraseformat
,\chapterlinesformat
and/or\chapterlineswithprefixformat
.