# How to change part and chapter pages on KOMA-Script?

In KOMA-Script classes, how can I change the appeareance (font size, color, arrangment, content, etc.) of the page created by \part an \chapter?

The pagestyle can be changed easily with KOMA-Script commands, but this only allows changes to the header and footer but not to the actual content, as far as I understood the scrguide.

I tried with titlesec, but this has some drawbacks, because it does not support KOMA's \setpartpreamble and \setchapterpreamble, which I'd really like to use.

-
If you specify the layout I can update my answer. –  Marco Daniel Apr 22 at 19:48
@MarcoDaniel I'm not yet sure about the layout. I hoped to learn how/where to change the layout at all to try some designs out. I have no problems with "low-level stuff" myself (redefining commands), if I just knew which ones are important. ;) –  Foo Bar Apr 22 at 20:10
@FooBar you can do many things using (nearly) only the official interfaces: tex.stackexchange.com/a/94703/5049 –  cgnieder Apr 22 at 21:56

The code for \part and \chapter are different from the other sectional units, and like the default document classes, are contained in the class in question. So, if you're using scrreprt.cls, the following is the code that produces the layout (including font size, colour, arrangement and content):

### Parts:

\def\@part[#1]#2{%
\ifnum \c@secnumdepth >-2\relax
\refstepcounter{part}\@maybeasf%
\else
\fi
\chaptermark{}
{\centering
\interlinepenalty \@M
\normalfont
\ifnum \c@secnumdepth >-2\relax
\size@partnumber\sectfont\partformat
\par
\vskip 20\p@
\fi
\size@part\sectfont #2\par}%
\@endpart}


### Chapters:

\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
{\protect\numberline{\thechapter}#1}%
\else
\fi
\chaptermark{#1}%
\if@twocolumn
\else
\fi}
{\size@chapter{\sectfont
\@hangfrom{\ifnum \c@secnumdepth >\m@ne%
\chapterformat\fi}%
{\raggedsection \interlinepenalty \@M #1\par}}
}}


There is a minor difference in terms of the layout for numbered and unnumbered elements like above (for example, for \part* and \chapter*), but you can find those definitions in the source classes as well.

How would you go about changing them? Either by means of the supplied hooks provided in the KOMA-script documentation, or by updating the above definitions to your liking. For example,

• Updating the font and colour for \part:

Update the macro \partformat to include colour. It's currently defined as

\newcommand*\partformat    {\partname~\thepart\if@altsecnumformat.\fi}


so using

\usepackage{xcolor}% http://ctan.org/pkg/xcolor
%...
\newcommand*\partcolor{\color{blue!50}}% Part is coloured blue
\newcommand*\partformat    {\partcolor\partname~\thepart\if@altsecnumformat.\fi}


The above allows you to change only \partcolor rather than reformat the entire \partformat if you want to update the colour (from one \part to another, say).

• Modify the space after the chapter title:

Update the definition of \chapterheadendvskip (either via the document class option, or directly). For example,

\def\chapterheadendvskip{\vspace{50pt}}


would leave a 50pt gap between the chapter title and the start of the chapter text. This is specifically covered in the KOMA-script documentation (section 16.3. Expert Commands, p 285).

The question is very general, as such I've only given some general guidelines as to the modification of these structural units. If the class does not provide adequate control over specific elements of the layout, you'd have to modify the structural parts manually. To that end, a document class is typically considered restrictive, while (compatible) packages provide an extension or flexibility to modify things to your liking, rather than tinkering with the actual code.

-
Sorry but your answer doesn't use the advantages of KOMA. –  Marco Daniel Apr 22 at 19:28
@MarcoDaniel: Not entirely, sure. Some of the entries in terms of the construction are hooks themselves, and have to be redefined in the traditional way (like \chapterheadendvskip, say). That is, there's not clear KOMA-script hook into setting these values other than using \renewcommand or \def. –  Werner Apr 22 at 19:35
Unfortunately true, this can't be done by any hooks. :-( I am sure Markus will change this. –  Marco Daniel Apr 22 at 19:38

KOMA provides the commands \addtokomafont, \setkomafont and \usekomafont. The first and the second command have two mandatory argument. The first one is the name of the element which font should be changed. The second argument is the font definition:

\setkomafont{part}{\Huge\bfseries}


set the part as huge and bold. The command \addkomafont adds the elements of the second mandatory argument to the default definition. With the command \usekomafont you can use a predefined setting.

Related to part and chapter there are the following commands possible:

• part: set the font of \part
• partentry: set the font of \part in toc
• chapter: set the font of \chapter
• chapterentry: set the font of \chapter in toc

The documentation shows more examples and options. To add a color definition you can use:

\setkomafont{part}{\Huge\bfseries\color{red}}


The arrangement of part is done by \raggedpart with the default definition

\newcommand*{\raggedpart}{}
\let\raggedpart\centering

-
There are also chapterentrypagenumber, chapterprefix, partentrypagenumber and partnumber for other related properties. –  cgnieder Apr 22 at 19:36
@cgnieder: Indeed. But I didn't want to copy the complete table ;-) –  Marco Daniel Apr 22 at 19:39