# customizing section formatting using memoir class (color and numbering)

I see in memoir that \section is implemented like so:

\newcommand{\section}{%
\sechook%
\@startsection{section}{1}%  level 1
\newcommand{\sechook}{}
\newlength{\secindent}
\newcommand{\setsecindent}[1]{\setlength{\secindent}{#1}}
\setsecindent{\z@}
\newskip\beforesecskip
\newcommand{\setbeforesecskip}[1]{\setlength{\beforesecskip}{#1}}
\setbeforesecskip{-3.5ex \@plus -1ex \@minus -.2ex}
\newskip\aftersecskip
\newcommand{\setaftersecskip}[1]{\setlength{\aftersecskip}{#1}}
\setaftersecskip{2.3ex \@plus .2ex}


I thought I'd try color'izing my section numbers, and first tried:

\renewcommand{\sechook}{\color{blue}}


This didn't work, since the scope of the blue was everything after and including the section. Next I tried:

\setsecheadstyle{\color{blue}\Large\bfseries\memRTLraggedright}


This is better, but color'izes the section number and the section title. I can't see in the \section implementation above where the counter is, so I think I'm looking in the wrong place.

Here's a MWE for my busted attempt:

\documentclass[openany]{memoir}
\usepackage{color}

\begin{document}

\chapter{Foo}
\section{blah}
\section{stuff}
\subsection{more stuff}
\subsubsection{even more stuff}

\end{document}


This produces

I also see that I've lost subsection and subsubsection numbers (which I had with the book class). So two questions:

• How can I get back my sub and subsub section numbers?
• How would one color just the section numbers (and subsection numbers once I get them back)?
-

To control the level up to which sectional units will be numbered, you can use \setsecnumdepth{<sectional unit>}; to color the sectional unit numbers, you can use \setsecnumformat:

\documentclass[openany]{memoir}
\usepackage{xcolor}

\setsecnumdepth{subsubsection}

\begin{document}

\chapter{Foo}
\section{blah}
\section{stuff}
\subsection{more stuff}
\subsubsection{even more stuff}

\end{document}


-