I would like to colorize some of the references in the bibliography similarly to this question, this one, and this one.
However, these techniques use an additional category. This other one uses keywords. Rather, I would like to use annotations on authors, which I already use for highlighting author names.
Here is an example in which the author highlighting works, but not reference and citation. The objective is to have the names of annotated authors in bold, and all the references for which at least one author annotated in red (both the reference and the citations).
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[usenames,dvipsnames]{xcolor}
\begin{filecontents}{test-example.bib}
@article{a,
author = {Name, A and Name, B},
author+an = {1=highlight},
title = {Title A},
journal = {Journal A}
}
@inproceedings{b,
author = {Name, E and Name, F},
title = {Title B},
booktitle = {Conference B}
}
@article{c,
author = {Name, C and Name, D},
title = {Title C},
journal = {Journal C}
}
@inproceedings{d,
author = {Name, E and Name, F},
author+an = {2=highlight},
title = {Title D},
booktitle = {Conference D}
}
\end{filecontents}
\usepackage[style=numeric]{biblatex}
\addbibresource{test-example.bib}
% Highlighting annotated authors
\renewcommand{\mkbibnamegiven}[1]{%
\ifitemannotation[author]{highlight}
{\textbf{#1}}
{#1}}
\renewcommand{\mkbibnamefamily}[1]{%
\ifitemannotation[author]{highlight}
{\textbf{#1}}
{#1}}
% Expected result: citations and references with at least
% one annotated author should be red
\DeclareFieldFormat{labelprefix}{%
\iffieldannotation[author]{highlight}
{\textcolor{red}{#1}}
{#1}}
\DeclareFieldFormat{labelnumber}{%
\iffieldannotation[author]{highlight}
{\textcolor{red}{#1}}
{#1}}
\DeclareFieldFormat{labelnumberwidth}{%
\iffieldannotation[author]{highlight}
{\textcolor{red}{\mkbibbrackets{#1}}}
{\mkbibbrackets{#1}}}
\AtEveryBibitem{%
\iffieldannotation[author]{highlight}
{\color{red}}
{}}
\begin{document}
\cite{a,b,c,d}
\cite{a}\cite{b}\cite{c}\cite{d}
\printbibliography
\end{document}
![[1, 3, 2, 4]
[1][3][2][4]
[1] A Name and B Name. “Title A”. In: Journal A ().
[2] C Name and D Name. “Title C”. In: Journal C ().
[3] E Name and F Name. “Title B”. In: Conference B.
[4] E Name and F Name. “Title D”. In: Conference D.
The entries "1" and "4" are always highlighted in red](../../images/d23ea77080eee31a27e5ab32ac6e65dc.webp)