How can I change the color of bibliography headers when I use biblatex with the reading style?

Based on the answer https://tex.stackexchange.com/a/149753/4172 to the question Highlighting particular bibliography entries, I am trying to obtain a reference listing using the reading style of biblatex, where some items are highlighted.

The code I've got is the following (which is the same as in the above-mentioned answer, with the exception that I am using the reading style for biblatex):

\documentclass[12pt]{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{cite1,
author = {Knuth, Donald},
title = {{Title One}},
journal = {Some Journal},
year = {2005},
volume = {1},
pages = {1--42},
}

@book{cite2,
author = {Knuth, Donald},
title = {{A Way More Important Title}},
publisher = {Oxford},
year = {2009},
}
\end{filecontents}

\usepackage[T1]{fontenc}

%% Highlight entries
\usepackage[svgnames]{xcolor}
\DeclareBibliographyCategory{important}
% the colour definition
\colorlet{impentry}{Maroon}% let 'impentry' = Maroon

% Inform biblatex that all books in the 'important' category deserve
% special treatment, while all others do not
\AtEveryBibitem{%
\ifcategory{important}%
{\bfseries\color{impentry}}%
{}%
}

% Add books to 'important' category in preamble
cite2,
}

\begin{document}

\nocite{*}
\printbibliography

\end{document}


The result I am getting looks like the following:

How can I also change the color of the header of the first entry? That is, how can I highlight the text Knuth: A Way More Important Title cite2and the corresponding underline below it?

The "headers" are created using the bibmacro entryhead:full (or entryhead:name, depending on the value passed to entryhead).

In order to also colour in the entry head we just apply the code in \AtEveryBibitem to entryhead:full:

\renewbibmacro*{entryhead:full}{%
\ifcategory{important}
{\bfseries\color{impentry}}
{}
\printnames[labelname][-1]{labelname}%
\printfield{labeltitle}}


This is analogous for entryhead:name:

\makeatletter
\ifcategory{important}
{\bfseries\color{impentry}}
{}
\ifnameundef{labelname}
{\printfield{labeltitle}}
{\printnames[labelname]{labelname}}%
\savefield{fullhash}{\bbx@lasthash}}
\makeatother


If you want to keep the colouring more local (don't colour the entry key) we can do that with a bit of group action:

\renewbibmacro*{entryhead:full}{%
\begingroup
\ifcategory{important}
{\bfseries\color{impentry}}
{}
\printnames[labelname][-1]{labelname}%
\printfield{labeltitle}
\endgroup}


MWE

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}

%% Highlight entries
\usepackage[svgnames]{xcolor}
\DeclareBibliographyCategory{important}
% the colour definition
\colorlet{impentry}{Maroon}% let 'impentry' = Maroon

% Inform biblatex that all books in the 'important' category deserve
% special treatment, while all others do not
\AtEveryBibitem{%
\ifcategory{important}%
{\bfseries\color{impentry}}%
{}%
}

% Add books to 'important' category in preamble
cicero,
}

\ifcategory{important}
{\bfseries\color{impentry}}
{}
\printnames[labelname][-1]{labelname}%
\printfield{labeltitle}}

\begin{document}
\nocite{wilde,cicero}
\printbibliography
\end{document}


If you also want to colour in the horizontal rule, it is probably better to modify another macro (that is, you do not have to apply the customisations to entryhead:full above)

\makeatletter
\def\bbx@item@full{%
\begingroup
\ifcategory{important}
{\color{impentry}}
{}
\itemsep2\bibitemsep
\@itempenalty\z@
\item\relax
\begingroup
\samepage\bfseries
\def\finentrypunct{\strut}%
\ifbool{bbx:entrykey}
{\def\newblockpunct{%
\nobreak\hskip\z@skip\strut
\hfill\penalty100\hskip1em\relax
\hbox{}\nobreak\hfill\strut}%
\def\finentrypunct{%
\parfillskip\z@\finalhyphendemerits\z@
\par\nobreak}%
\newblock
\printfield{entrykey}}
{}%
\finentry
\endgroup
\hrule height 1.25pt\relax
\itemsep\bibitemsep
\@itempenalty\@M
\item\strut
\@itempenalty\z@
\endgroup}
\makeatother


MWE

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}

%% Highlight entries
\usepackage[svgnames]{xcolor}
\DeclareBibliographyCategory{important}
% the colour definition
\colorlet{impentry}{Maroon}% let 'impentry' = Maroon

% Inform biblatex that all books in the 'important' category deserve
% special treatment, while all others do not
%\AtEveryBibitem{%
%  \ifcategory{important}%
%    {\bfseries\color{impentry}}%
%    {}%
%  }

% Add books to 'important' category in preamble
cicero,
}

\AtEveryBibitem{%
\ifcategory{important}%
{\bfseries\color{impentry}}%
{}%
}

\makeatletter
\def\bbx@item@full{%
\begingroup
\ifcategory{important}
{\color{impentry}}
{}
\itemsep2\bibitemsep
\@itempenalty\z@
\item\relax
\begingroup
\samepage\bfseries
\def\finentrypunct{\strut}%
\ifbool{bbx:entrykey}
{\def\newblockpunct{%
\nobreak\hskip\z@skip\strut
\hfill\penalty100\hskip1em\relax
\hbox{}\nobreak\hfill\strut}%
\def\finentrypunct{%
\parfillskip\z@\finalhyphendemerits\z@
\par\nobreak}%
\newblock
\printfield{entrykey}}
{}%
\finentry
\endgroup
\hrule height 1.25pt\relax
\itemsep\bibitemsep
\@itempenalty\@M
\item\strut
\@itempenalty\z@
\endgroup}
\makeatother
\begin{document}
\nocite{wilde,cicero}
\printbibliography
\end{document}

• Thanks. What about the underline? Do you know how to change its color? – davitenio Oct 28 '14 at 8:04
• @davitenio There seems to be a way to do that, yes. Have a look at the edited answer. – moewe Oct 28 '14 at 8:32