I'd like to reproduce the results of this post using the numeric-comp citestyle. Using the solution as-is, I get an error saying "Macro 'cite' undefined", and nothing comes out boldfaced.
I tried changing cite to cite:comp in the relevant lines (see below), and got some boldface out of that, but not consistently. It looks like the last number in a compressed range does not get boldface unless it is followed by another boldface number, but I don't know why. Any help would be much appreciated. Thanks!
MWE:
\documentclass{article}
\usepackage{filecontents}
\usepackage[backend=biber,style = numeric-comp, sortcites]{biblatex}
\usepackage[colorlinks=true, breaklinks, allcolors = blue]{hyperref}
\DeclareSourcemap{%
\maps[datatype=bibtex]{%
\map{%
\step[fieldsource=author, match=Doe, final]%
\step[fieldset=keywords, fieldvalue=doe]%
}%
}%
}
\begin{filecontents}{\jobname.bib}
@Book{p1,
author = "Joe Bar",
title = "A Scientific Article 1",
year = "1995"
}
@Book{p2,
author = "John Doe",
title = "A Scientific Article 2",
year = "1985"
}
@Book{p3,
author = "A. U. Thor and John Doe",
title = "A Scientific Article 3",
year = "1975"
}
@Book{p4,
author = "A. U. Thor and John Doe",
title = "A Scientific Article 4",
year = "2010"
}
@Book{p5,
author = "Jane Zaz",
title = "A Scientific Article 5",
year = "2005"
}
@Book{p6,
author = "Jane Zaz",
title = "A Scientific Article 6",
year = "2015"
}
@Book{p7,
author = "Jane Zaz and John Doe",
title = "A Scientific Article 7",
year = "2020"
}
\end{filecontents}
\addbibresource{\jobname.bib}
\DeclareFieldFormat{keywordcite}{\ifkeyword{doe}{\mkbibbold{#1}}{#1}}
\csletcs{old:cite:comp}{abx@macro@cite:comp}
\renewbibmacro{cite:comp}{\printtext[keywordcite]{\csuse{old:cite:comp}}}
\nocite{*}
\begin{document}
In \cite{p2, p3, p4, p6}, 2 and 4 should be \textbf{bold}.
In \cite{p2, p3, p4, p7}, 2, 4, and 7 should be \textbf{bold}.
In \cite{p1, p3, p4, p5, p6, p7}, 3 and 7 should be \textbf{bold}.
In \cite{p1, p2, p3}, 3 should be \textbf{bold}.
In \cite{p1, p2, p3, p7}, 3 and 7 should be \textbf{bold}.
\printbibliography
\end{document}
UPDATE:
I was able to make things a little better by adding the lines
\csletcs{old:cite:dump}{abx@macro@cite:dump}
\renewbibmacro{cite:dump}{\printtext[keywordcite]{\csuse{old:cite:dump}}}
Still not a complete solution, though.


![Output is
"In [2–4, 6], 2 and 4 should be bold.
In [2–4, 7], 2, 4, and 7 should be bold.
In [1, 3–7], 3 and 7 should be bold.
In [1–3], 3 should be bold.
In [1–3, 7], 3 and 7 should be bold."
with the expected numbers in bold.](../../images/f7f5daadfc8454184bc62a3bbebfa0fb.webp)
numeric-compcan only decide if/how to print an entry if it has examined the citations that come after it. So some citations are printed "after" they were processed. ... – moewe Nov 05 '21 at 16:43biblatexremembers the relevant bits for the citation label, but not all entry data.) In particular the\ifkeywordat that point does not correspond to the entry 4 but to a different entry. – moewe Nov 05 '21 at 16:43