
Estoy destacando ciertos autores en biblatex usando la función de anotación:
\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}
Quiero agregar otra anotación, por ejemplo, highlightB
que se resalte en negrita y en color rojo, que se puede utilizar como alternativa a la highlight
anotación ya existente.
Jugué con un adicional \ifitemannotation{highlightB}
en ambos \mkbibnamegiven
y \mkbibnamefamily
no pude hacerlo funcionar correctamente. ¿Cómo hago esto?
Respuesta1
Tienes que anidar las pruebas para las anotaciones. Tenga en cuenta que suelo \mkbibcompletename
formatear el nombre completo de una vez en lugar de redefinir las macros para todas las partes del nombre.
\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}