I am tinkering with the Hansen chapter style for the memoir class, as reviewed and listed in texblog. The Hansen style is unfortunately not discussed in the memoir class documentation.
I changed it to be left-aligned and use \sfstyle chapter title font.
I would now like to control the color of the chapter title.
My current attempt:
\documentclass[12pt,english,american]{memoir}
\makeatletter
\usepackage{color}
\usepackage{kpfonts}
\usepackage{calc}
\definecolor{ChapNumColor}{gray}{0.90}
\definecolor{ChapTitleColor}{gray}{0.65}
% helper macros
\newcommand\numlifter[1]{\raisebox{-18mm}[0pt][0pt]{\smash{#1}}}
\newcommand\numindent{\kern08mm}
\newlength\chaptertitleboxheight
\makechapterstyle{hansen}{
\renewcommand\printchaptername{%
\color{ChapTitleColor}%
%\raggedleft
}
\renewcommand\printchapternum{%
\begingroup%
\leavevmode%
\chapnumfont%
\strut%
\numindent%
\numlifter{\thechapter}%
\endgroup%
}
\renewcommand*{\printchapternonum}{%
\vphantom{\begingroup%
\leavevmode%
\chapnumfont%
\numlifter{\vphantom{9}}%
\numindent%
\endgroup}
\afterchapternum}
\setlength\midchapskip{0pt}
\setlength\beforechapskip{0.5\baselineskip}
\setlength{\afterchapskip}{3\baselineskip}
\renewcommand\chapnumfont{%
\fontsize{40mm}{0mm}%
\bfseries%
\fontfamily{\sfdefault}\selectfont%
\color{ChapNumColor}%
}
\renewcommand\chaptitlefont{%
\huge%
\sffamily%
%\color{ChapTitleColor}%
%\raggedleft%
}%
\settototalheight\chaptertitleboxheight{%
\parbox{\textwidth}{\chaptitlefont \strut bg\\bg\strut}}
\renewcommand\printchaptertitle[1]{%
\parbox[t][\chaptertitleboxheight][t]{\textwidth}{%
%\microtypesetup{protrusion=false}% add this if you use microtype
\chaptitlefont\strut ##1\strut}%
}
}
\chapterstyle{hansen}
\makeatother
\usepackage{babel}
\begin{document}
\chapter*{Preface}
content
\chapter{Introduction}
content
\chapter{Conclusion}
content
\end{document}
This correctly colors numbered \chapters but not unnumbered \chapter*s, including the table of contents heading.

If I comment the statement \color{ChapTitleColor} in the macro \printchaptername and instead uncomment the color statement in the macro \chaptitlefont further below, I do get the right coloring but now the chapter title has been pushed down by a line or so.

Perhaps I have missed an end-of-line percent mark somewhere, as I am relatively unpractised at TeX's syntax.
(NB I do not know for sure if this applies to the \chapter* although I have indicated this in the image. Can I overlay a ruler grid on a latex page to check these things?)
How can I fix option 1 or option 2 without affecting the formatting?
What is the "correct" way to color this style, as intended by the developer?
\leavemodethread and advice on xcolor are very welcome. – Andreas Dec 11 '12 at 01:21