TeX - LaTeX Asked by Jr. on April 9, 2021
I have found different answers about highlighting authors in biblatex in the bibliography but not so much in specific citations.
I have different fullcite{Label}
commands along a text where I show the full reference of some papers from different authors. I use the clean thesis template
I would like to highlight a different author in each fullcite
(bold, underline, colorized, whatever). For instance, lets say to make
bold the 1st author in the first fullcite but the 3rd author in
another fullcite and so on.
However, the bibliography has to remain the same. No highlights there.
Is there any way to highlight the n-th author in a fullcite as
fullcite{LabelA}[1]
orfullcite{LabelB}[3]
or some command for that?
Thanks for any help you could provide.
As explained in Biblatex style authoring. How do we refactor DeclareCiteCommand to taken an additional parameter? there is no official way to add another argument to cite
commands and I feel that abusing the pre- or postnote argument is not good style here. So I used the naive approach where you call a macro highlightnames
and give the names to be highlighted there. The list of highlighted names is stored between fullcite
s and can be emptied with resetnamehighlights
, the starred version highlightnames*
resets the list before adding new numbers.
documentclass[british]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{babel}
usepackage{csquotes}
usepackage[style=numeric, backend=biber]{biblatex}
addbibresource{biblatex-examples.bib}
makeatletter
newcommand*{resetnamehighlights}{letnhcbx@highlightlist@empty}
resetnamehighlights
newcommand*{highlightnames}{%
@ifstar{resetnamehighlightshighlightnames@add}{highlightnames@add}}
newcommand*{highlightnames@add@inner}[2]{%
listeadd{#1}{thenumexpr#2relax}}
newcommand*{highlightnames@add}{%
forcsvlist{highlightnames@add@innernhcbx@highlightlist}}
newcommand*{mkbibhighlightnthname}[1]{%
xifinlist{thevalue{listcount}}{nhcbx@highlightlist}
{mkbibbold{#1}}
{#1}}
makeatother
DeclareNameWrapperFormat{highlightnthname}{%
renewcommand*{mkbibcompletename}{mkbibhighlightnthname}%
#1}
DeclareCiteCommand{fullcite}
{usebibmacro{prenote}}
{usedriver
{DeclareNameWrapperAlias{author}{highlightnthname}%
DeclareNameWrapperAlias{editor}{highlightnthname}%
DeclareNameWrapperAlias{translator}{highlightnthname}%
DeclareNameWrapperAlias{sortname}{highlightnthname}}
{thefield{entrytype}}}
{multicitedelim}
{usebibmacro{postnote}}
begin{document}
highlightnames{1}
{frenchspacingfullcite{sigfridsson}}
highlightnames*{2}
{frenchspacingfullcite{sigfridsson}}
resetnamehighlights
{frenchspacingfullcite{sigfridsson}}
printbibliography
end{document}
edit Modified to work with biblatex
v3.13 and above. For older versions see the edit history.
Correct answer by moewe on April 9, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP