2

Inspired by this question about how to bold a set of names in a CV using biblatex.

moewe's answer implements name hashes for this. I'm wondering how to generalize this solution so that you can have an arbitrary number of sets of names, and do arbitrary things with them.

An actual use case might be in a CV where you want to:

  1. Bold your own name throughout, and
  2. Mark graduate student names with a trailing asterisk, like "Family, Given*" or "Given Family*", and
  3. Mark undergraduate student names with a trailing plus sign, like "Family, Given+" or "Given Family+".

So, from the user's pov, a document might look like this:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[backend=biber,style=numeric]{biblatex}

\addbibresource{biblatex-examples.bib}

\addboldnames{{Sigfridsson, Emma},{Vizedom, Monika B.}}

%%% New command? \addstarnames{Donald E. Knuth,Philipp Jaff{'e}} % <-- we could just build the * into the command \appendtonamelist{*}{Donald E. Knuth,Philipp Jaff{'e}} % <-- or maybe there's a general hook to append something to a name?

\begin{document} \fullcite{sigfridsson}

\fullcite{knuth:ct:a}

\fullcite{vizedom:related}

\resetboldnames\addboldnames{Donald E. Knuth} \fullcite{knuth:ct:a}

\resetboldnames\addboldnames{Philipp Jaff{'e}} \fullcite{jaffe} \end{document}

I'm looking for how to define something like \addstarnames or \appendtonamelist above.

1 Answers1

2

With a few changes to make things more flexible you can generate arbitrary lists of name hashes to check against.

Basically the only change against https://tex.stackexchange.com/a/416416/35864 was to introduce a parameter to allow for separate name lists for different things.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[backend=biber,style=numeric]{biblatex}

\addbibresource{biblatex-examples.bib}

\makeatletter \def\nhblx@bibfile@name{\jobname -nhblx.bib} \newwrite\nhblx@bibfile \immediate\openout\nhblx@bibfile=\nhblx@bibfile@name

\immediate\write\nhblx@bibfile{% @comment{Auto-generated file}\blx@nl}

\newcounter{nhblx@name} \setcounter{nhblx@name}{0}

\newcommand*{\nhblx@writenametobibfor}[2]{% \stepcounter{nhblx@name}% \edef\nhblx@tmp@nocite{% \noexpand\AfterPreamble{% \noexpand\setbox0\noexpand\vbox{% \noexpand\def\noexpand\nhblx@nametype{#1}% \noexpand\nhblx@getmethehash{nhblx@name@\the\value{nhblx@name}}}}% }% \nhblx@tmp@nocite \immediate\write\nhblx@bibfile{% @misc{nhblx@name@\the\value{nhblx@name}, author = {\unexpanded{#2}}, % options = {dataonly=true},}% }% }

\AtEndDocument{% \closeout\nhblx@bibfile}

\addbibresource{\nhblx@bibfile@name}

\newcommand*{\nhblx@boldhashes}{} \DeclareNameFormat{nhblx@hashextract}{% \xifinlistcs{\thefield{hash}}{nhblx@namelist@\nhblx@nametype} {} {\listcsxadd{nhblx@namelist@\nhblx@nametype}{\thefield{hash}}}}

\DeclareCiteCommand{\nhblx@getmethehash} {} {\printnames[nhblx@hashextract][1-999]{author}} {} {}

% add names to a certain highlight list % [<list name>]{<name_1>,...,<name_n>} \newcommand*{\addhlnames}[1][bold]{% \forcsvlist{\nhblx@writenametobibfor{#1}}}

% clear name list % [<list name>] \newcommand*{\resethlnames}[1][bold]{% \csdef{nhblx@namelist@#1}{}}

% check if current name (as identified by hash field) is in name list % [<list name>]{<true>}{<false>} \newcommand*{\ishlname}[1][bold]{% \xifinlistcs{\thefield{hash}}{nhblx@namelist@#1}} \makeatother

\newcommand{\mkhlname}[1]{% \ishlname[bold] {\mkbibbold{#1}} {#1}% \ishlname[star] {} {}% \ishlname[plus] {\textsuperscript{+}} {}}

\DeclareNameWrapperFormat{highlightname}{% \renewcommand*{\mkbibcompletename}{\mkhlname}% #1}

\DeclareNameWrapperAlias{sortname}{default} \DeclareNameWrapperAlias{default}{highlightname}

\addhlnames[bold]{{Sigfridsson, Emma},{Vizedom, Monika B.}}

\addhlnames[star]{Donald E. Knuth}

\addhlnames[plus]{Ulf Ryde}

\begin{document} \fullcite{sigfridsson}

\fullcite{knuth:ct:a}

\fullcite{vizedom:related}

\fullcite{knuth:ct:a}

\fullcite{jaffe} \end{document}

Emma Sigfridsson and Ulf Ryde+ . “Comparison of methods for deriving atomic charges from the electrostatic potential and moments”. In: Journal of Computational Chemistry 19.4 (1998), pp. 377–395. doi: 10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P ("Emma Sigfridsson" in bold, "Ulf Ryde" followed by a superscripted plus)

moewe
  • 175,683