Annotations de plusieurs auteurs Biblatex
Sep 02 2020
Je mets en évidence certains auteurs dans biblatex en utilisant la fonction d'annotation:
\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}
Je veux ajouter une autre annotation, par exemple, highlightBqui met en évidence par exemple en gras et de couleur rouge qui peut être utilisée comme une alternative à l' highlightannotation déjà existante .
Je me suis agité avec un supplément \ifitemannotation{highlightB}dans les deux \mkbibnamegivenet \mkbibnamefamilymais je n'ai pas pu le faire fonctionner correctement. Comment dois-je procéder?
Réponses
2 moewe Sep 02 2020 at 12:02
Vous devez imbriquer les tests pour les annotations. Notez que j'utilise \mkbibcompletenamepour formater le nom complet à la fois au lieu de redéfinir les macros pour toutes les parties du nom.
\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}