4

I'm highlighting certain authors in biblatex using the annotation feature:

\documentclass{article}
\usepackage{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@MISC{test,
  AUTHOR    = {Last1, First1 and Last2, First2 and Last3, First3},
  AUTHOR+an = {2=highlight},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\renewcommand*{\mkbibnamegiven}[1]{% \ifitemannotation{highlight} {\textbf{#1}} {#1}}

\renewcommand*{\mkbibnamefamily}[1]{% \ifitemannotation{highlight} {\textbf{#1}} {#1}}

\begin{document} \nocite{*} \printbibliography

\end{document}

I want to add another annotation e.g. highlightB which highlights in e.g. bold and color red which can be used as an alternative to the already existing highlight annotation.

I fideled around with an additional \ifitemannotation{highlightB} in both \mkbibnamegiven and \mkbibnamefamily but couldn't get it to work properly. How do I go about this?

1 Answers1

4

You have to nest the tests for the annotations. Note that I use \mkbibcompletename to format the complete name at once instead of redefining the macros for all name parts.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{xcolor}

\usepackage[style=authoryear, backend=biber]{biblatex}

\renewcommand*{\mkbibcompletename}[1]{% \ifitemannotation{highlight} {\textbf{#1}} {\ifitemannotation{highlightB} {\textcolor{red}{#1}} {#1}}}

\begin{filecontents}{\jobname.bib} @misc{example1, title = {Mock Title}, author = {Albert Einstein}, author+an = {1=highlight}, year = {2019}, } @misc{example2, title = {Mock Turtle}, author = {Anne Elk}, author+an = {1=highlightB}, year = {2020}, } \end{filecontents} \addbibresource{\jobname.bib} \addbibresource{biblatex-examples.bib}

\begin{document} \cite{sigfridsson,example1,example2} \printbibliography \end{document}

Einstein in bold, Elk in red

moewe
  • 175,683