1

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] or \fullcite{LabelB}[3] or some command for that?

Thanks for any help you could provide.

3
  • You have tagged your question with BibTeX and you also explicitly mention it in your question, but the \fullcite makes me think you are really using biblatex. Can you check that? In any way, a solution will not only depend on the package you use, but also on the bibliography/citation style. The easiest way to make sure that we have all the info we need is by providing a complete, compilable example document, an MWE/MWEB. Please add one to your question, so we can be sure we talk about the same thing.
    – moewe
    Aug 7, 2018 at 20:15
  • Also: Welcome to TeX.SX!
    – moewe
    Aug 7, 2018 at 20:15
  • Thanks a lot moewe. I use the clean thesis template (cleanthesis.der-ric.de ) . Both bibsystems are mentioned in the style file but not sure which one is the right one here. I included the following line to order the refs by appearance: PassOptionsToPackage{sorting=none}{biblatex}
    – Jr.
    Aug 7, 2018 at 20:37

1 Answer 1

4

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 \fullcites 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}{\let\nhcbx@highlightlist\@empty}
\resetnamehighlights

\newcommand*{\highlightnames}{%
  \@ifstar{\resetnamehighlights\highlightnames@add}{\highlightnames@add}}

\newcommand*{\highlightnames@add@inner}[2]{%
  \listeadd{#1}{\the\numexpr#2\relax}}

\newcommand*{\highlightnames@add}{%
  \forcsvlist{\highlightnames@add@inner\nhcbx@highlightlist}}

\newcommand*{\mkbibhighlightnthname}[1]{%
  \xifinlist{\the\value{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}
{\frenchspacing\fullcite{sigfridsson}}

\highlightnames*{2}
{\frenchspacing\fullcite{sigfridsson}}

\resetnamehighlights
{\frenchspacing\fullcite{sigfridsson}}

\printbibliography
\end{document}

"Sigfridsson and Ryde" in various combination of bold-ness. The first citation has "Sigfridsson" highlighted, the second "Ryde", the third none of the two. The bibliography has no names highlighted either.

edit Modified to work with biblatex v3.13 and above. For older versions see the edit history.

1
  • Awesome Moewe! Thanks a lot. It even works if you want to highlight more than one author.
    – Jr.
    Aug 8, 2018 at 9:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .