# Define color for chapter in scrbook

I try to change the color of my chapter heading:

\documentclass{scrbook}
\usepackage{xcolor}
\definecolor{myColor_MainA}{RGB}{0,64,119}

\begin{document}
\chapter{first}
\section{here}
\end{document}


and get following error:

! Missing $inserted. <inserted text>$
l.8  \chapter{first}

! Extra }, or forgotten $. \size@chapter ->\huge \color {myColor_MainA} l.8 \chapter{first} ! Missing$ inserted.
<inserted text>
\$
l.8  \chapter{first}

! Missing } inserted.
<inserted text>
}
l.8  \chapter{first}

• Remove the underscore _ from the color name. – sodd Aug 20 '15 at 14:57

It's a bug in KOMA-Script (2015/07/02 v3.18). The chapter uses the command \usefontofcomafont{chapter} which disables the color commands by assigning \color to \relax. This way, the argument of \color remains and the underscore in the name is typeset as text, causing trouble, because _ is not in math mode.
• \string before the underscore also fixes the issue. The color name remains valid (the name is used inside \csname and \endcsname), and the name can be processed in text typesetting mode.
\addtokomafont{chapter}{\color{myColor\string_MainA}}