The memoir
class provides plenty of hooks for doing this sort of thing, but chapters and sections are treated differently. The \printchaptername
macro prints the chapter name. Since we don't want to redefine it, I have used the \addtodef
macro to prepend the \color
macro to its definition, leaving the rest unchanged.
Depending on how you want the Table of Contents to look like, there are two different macros that can be changed. If you only want the TOC title changed, a different patching macro \addtoiargdef
is used, since that macro takes an argument and cannot be patched with addtodef
.
For the section formatting, there is an empty hook for each sectioning level which is initially set to {}
. There is a macro \setSstyle
(where S
stands for the sectioning level (sec
, subsec
, subsubsec
).
\documentclass{memoir}
\usepackage{xcolor}
\addtodef{\printchaptername}{\color{blue!50!black}}{}
\addtodef{\tocheadstart}{\color{blue!50!black}}{} % If you want the whole TOC to be blue also
%\addtoiargdef{\printtoctitle}{\color{blue!50!black}}{} % If you just want the TOC title blue
\setsecheadstyle{\color{blue!50!black}}
\setsubsecheadstyle{\color{blue!50!black}}
\begin{document}
\frontmatter
\tableofcontents*
\mainmatter
\chapter{A chapter}
\section{A section}
\subsection{A subsection}
\appendix
\chapter{An appendix}
\section{A section}
\subsection{A subsection}
\end{document}
