
Estou destacando alguns autores no biblatex usando o recurso de anotação:
\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}
Quero adicionar outra anotação, por exemplo, highlightB
que destaque em negrito e na cor vermelha, que pode ser usada como alternativa à highlight
anotação já existente.
Eu brinquei com um adicional \ifitemannotation{highlightB}
em ambos \mkbibnamegiven
e \mkbibnamefamily
não consegui fazê-lo funcionar corretamente. Como faço para fazer isso?
Responder1
Você precisa aninhar os testes para as anotações. Observe que eu uso \mkbibcompletename
para formatar o nome completo de uma só vez em vez de redefinir as macros para todas as partes do nome.
\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}