Could we create a titlesec
to KOMA-script
lexicon?
Or, in other words, how to emulate titlesec
commands with native KOMA
ones?
The point would be to define "\titleseccommand[<a>]{<b>}{<c>}
is emulated by \KOMAcommand1{<b>}\KOMAcommand2{<c>}{<a>}
" for each titlesec
commands.
Background
titlesec
is a great package to easily customize your titles.
KOMA-script
classes are great too.
However, there are incompatibilities between KOMA
classes and titlesec
.
Even if the clash is not crippling in most cases, you still get this nice warning:
Class scrartcl Warning: Usage of package `titlesec' together (scrartcl) with a KOMA-Script class is not recommended. (scrartcl) I'd suggest to use the package only (scrartcl) if you really need it, because it breaks several (scrartcl) KOMA-Script features, i.e., option `headings' and (scrartcl) the extended optional argument of the section (scrartcl) commands .
Indeed, KOMA
classes have their own commands to pimp your titles.
You thus find here several questions (1, 2, 3, etc.) asking to "translate" a personnalized title/heading using titlesec
macros into KOMA-script
native commands.
Since there are only case-specific answers, it is hard to generalize and adapt to your own problem.
Material
Here is a sum-up of titlesec
commands and options.
\titlelabel{<A:label-format>}
Defines what is printed as label (~number) for (sub)sections
. E.g. to add an em dash (---
) after the section number (\thesection
)): \titlelabel{\thesection---\quad}
\titleformat*{<B:sectionning-command>}{<C:format>}
(Light-version of \titleformat
) Changes the format (\itshape
, \bfseries
...) of a sectionning command (\title
, \section
...). E.g. to make paragraph titles bold : \titleformat*{\paragraph}{\bfseries}
\titleformat{D:command}[E:shape]{F:format}{G:label}{H:sep}{I:before-code}{J:after-code}
Redefines the "internal" format of a title (i.e. how it looks -- fontshape, label, etc.). Here are the arguments of options:- D:command : a sectionning command (
\part
,\section
, etc.) - E:shape :
hang
,block
,display
,runin
,leftmargin
,fightmargin
,drop
, orwrap
. See definition in titlesec documentation, p. 3. - F:format : text layout of the label and the title (e.g.
\bfseries
,\itshape
) - G:label : defines what is printed as label (~number). E.g. to add an em dash after the section number
{\thesection---\quad}
- H:sep : the horizontalspace between the label and the title. Must be a length (
2em
,1cm
,.1\linewidth
...) (Defined differently fordisplay
, andframe
shapes.) - I:before-code : code executed before the title body. (E.g. for a text shape different than the label's one)
- J:after-code : code executed after the title body.
- D:command : a sectionning command (
\titlespacing{K:command}{L:left}{M:before-sep}{N:after-sep}[O:right-sep]
Redefines the "external" format of a title (i.e. how it is regarding the rest of the text -- indentation, spacing, etc.). The starred version (\titlespacing*
) kills the indentation of the text following the paragraph. Here are the argument options- K:command : a sectionning command (
\part
,\section
, etc.) - L:left : increases the left margin
- M:before-sep : vertical space before the title (e.g.
2\parskip
) - N:after-sep : vertical (or horizontal regarding the shape used) space after the title (e.g.
5pc plus 2pt minus 3pt
). - O:right-sep : increases the right-sep margin in case of using
hang
,block
ofdiplay
shape.
- K:command : a sectionning command (