# KOMA-Script: How to colour just the section numbers

I have added a splash of colour to my thesis and found it looked quite nice. The theme is: Chapter and Section headings are a dark blue, and the numbering is a brighter blue.

I managed to do this for the \part and \chapter sections in this scrreprt class, however I cannot seem to find a way to use the only apparently available control for other sections being the following: \othersectionlevelsformat{sectioning name}{}{counter output}.

How do I change just the colour of the numbering for \section \subsection, \subsubsection and \paragraph? Would I have to start using the titlesec package?

Please find below my MWE. Thank you

\documentclass[
DIV=11,
%fontsize=12,
twoside,
headinclude=false,
titlepage=firstiscover,
abstract=true,
headsepline=true,
footsepline=true,
chapterprefix=true, %this allows for editing of the chapter titles
headings=big,
bibliography=totoc,%adds unnumbered Bibliography chapter to toc
captions=tableheading
]{scrreprt}

%%% Packages
\usepackage[left=2cm,right=2cm,top=2.5cm,bottom=3cm]{geometry}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage[svgnames,x11names]{xcolor}
\usepackage{minitoc}
\usepackage{notoccite}
\usepackage{kpfonts}
\usepackage[T1]{fontenc}
%\usepackage{biblatex}
%\usepackage{mathchars}
%\usepackage{acro}
%\usepackage[hidelinks
%,bookmarksopen=true,bookmarksopenlevel=4 %This is for the appendix command formulated
%]{hyperref}
\usepackage{tensor}
\usepackage{siunitx}
\usepackage{wasysym}

\linespread{1.5} %imperial uses 1.5
\flushbottom

%%%%%%%%%%% ToC DEPTH LEVEL
\setcounter{secnumdepth}{4} % number subsubsection
\setcounter{tocdepth}{4} % list subsubsection
\setcounter{minitocdepth}{4}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Entry of TOC LOF LOT
\def\body{
\pagenumbering{roman}
\cleardoublepage
\linespread{1.25}
%%% MINITOC
\dominitoc
% MINITOC styling
\renewcommand{\mtcfont}{\normalsize\fontfamily{jkpss}\selectfont}
\renewcommand{\mtcSfont}{\normalsize\bf\fontfamily{jkpss}\selectfont}

\mtcsettitlefont{minitoc}{\bf\fontfamily{jkpss}\selectfont}
\mtcsettitle{minitoc}{Contents \textcolor{white}{mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmn} Page}

%%% TOC
\tableofcontents
\addtocontents{toc}{~\hfill\textbf{Page}\par} %Adds the word Page
\cleardoublepage

%%% LOF
\listoffigures \addcontentsline{toc}{section}{List of Figures}
\addtocontents{lof}{~\hfill\textbf{Page}\par} %Adds the word Page
\cleardoublepage

%%% LOT
\listoftables \addcontentsline{toc}{section}{List of Tables}
\addtocontents{lot}{~\hfill\textbf{Page}\par} %Adds the word Page
\cleardoublepage

\pagestyle{headings}
\pagenumbering{arabic}

%%% CHAPTER STYLING
\addtokomafont{chapterprefix}{\raggedleft \linespread{1}}
\setkomafont{chapter}{\color{DodgerBlue4}\fontsize{40}{30}\selectfont}

\addtokomafont{section}{\color{DodgerBlue4}\fontsize{20}{24}\selectfont}
\addtokomafont{subsection}{\color{DodgerBlue4}\fontsize{18}{22}\selectfont}
\addtokomafont{subsubsection}{\color{DodgerBlue4}\fontsize{16}{19}\selectfont}
\addtokomafont{paragraph}{\color{DodgerBlue4}\fontsize{15}{19}\selectfont}

\renewcommand*{\chapterformat}{%
\mbox{\scalebox{0.80}{\chapappifchapterprefix{\nobreakspace}}%
\scalebox{3.5}{\color{DeepSkyBlue2}\thechapter}\enskip}}

}

\begin{document}

\body

\chapter{First Chapter}
\linespread{1}
\dictum[Neil deGrasse Tyson]{The good thing about science is that it's true whether or not you believe in it.}

\minitoc

Here is some introduction

\section{Here is a section for the minitoc}
Bla bla.

\subsection{And why not a subsection too}
Just to spice things up a bit.

\end{document}


## 1 Answer

\renewcommand*{\othersectionlevelsformat}[3]{\textcolor{DeepSkyBlue2}{#3}\autodot\enskip}


A little explanation:

As you said in your question, \othersectionlevelsformat is given 3 arguments, so, when you (re)define it, it needs to have 3 arguments, hence the [3]. And the definition only uses the third argument (where the counter is given) so you only need to use #3.

By the way, the examples in pages 97 an 98 of scrguien.pdf are self explaining.

• Thank you, if it's not too much trouble could you explain a little bit how the command works please? I don't intuitively understand the [3] and {#3} parts. – Fiztban Jul 25 '14 at 11:59
• Done, but I really just looked into the documentation. – Manuel Jul 25 '14 at 12:04
• Ah ok that makes more sense now, well I had read them but I am still rather new to LaTeX and command jargon I didn't realise that that was what inserting those parts meant, I read them but I didn't know how to use them I was writing \othersectionlevelsformat}{section} etc... as it said that \othersectionlevelsformat{sectioning name} in the manual. – Fiztban Jul 25 '14 at 12:14
• Aha :) The thing is that KOMA-Script uses that command inside of the sectioning commands, and it uses it in that way: \othersectionlevelsformat{…}{…}{…}. So you needed to redefine it (with three arguments), and make use of them as you wish; in this case only the third one was relevant since it's the one where the counter is given. – Manuel Jul 25 '14 at 12:17