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
titlesec
does not support KOMA-Script classes. So do not combine them. To change the layout of the chapter, section etc. titles you can use KOMA-Script options and\RedeclareSectionCommand
& Co and you can redefine\partlineswithprefixformat
,\chapterlineswithprefixformat
,\chapterlinesformat
,\sectionlinesformat
and\sectioncatchphraseformat
.Until version 3.26b KOMA-Script has provided a dirty internal hack to make
titlesec
work with these classes, when the bundle was released. But it has checked the version oftitlesec
and has disabled the workaround if it was newer. See also https://komascript.de/release3.26b - »Bekannte Probleme« - »scrartcl, scrbook, scrreprt:« (German).Since KOMA-Script version 3.27 the internal
titlesec
workaround is removed and there will be no such internal workaround in KOMA-Script version 3.27 or later versions. But 3.27 provides a new hack with the packagescrhack
that can be enabled using the package optionstandardsections
(not set by default). Then the commands for the sectioning levels are compatible with the standard classes but several KOMA-Script features regarding the sectioning commands are disabled (resulting in warnings).Example:
Hack with KOMA-Script version 3.26b or 3.27 (not recommended): If you really want to use
titlesec
in combination withscrbook
, then use\RedeclareSectionCommands
for all section levels lower thanchapter
used in the document but not redefined by\titleformat
: