0

I am implementing the first solution presented here to make bold a selection of names in the biblatex bibliography.

The problem I have is with names containing an empty space " ". The solution does not apply then. Example Le Texier:

@article{schindlerHowFarPeople2022,
  title = {How Far Do People Travel to Use Urban Green Space? {{A}} Comparison of Three {{European}} Cities},
  author = {Schindler, Mirjam and Le Texier, Marion and Caruso, Geoffrey},
  date = {2022-04-01},
  journaltitle = {Applied Geography},
  volume = {141},
  pages = {102673},
  doi = {10.1016/j.apgeog.2022.102673},
}

I formed the filter based on the example given in the proposed solution:

    \forcsvlist{\listadd\boldnames} %this is the model of filter
      {{Herrmann, Wolfgang~A.}, {Herrmann, W.~A.}, {Herrmann, Wolfgang\bibnamedelima A.},
      {Herrmann, W\bibinitperiod\bibinitdelim A\bibinitperiod}}
   \forcsvlist{\listadd\boldnames} %this is my implementation of the filter
      {{Le Texier, Marion}, {Le~Texier, Marion}, {Le Texier, M.}, {Texier, M\bibinitperiod}}

The filters work for all the author names, but fails for this particular name containing an empty space.

1 Answers1

2

Names with spaces in them can be tricky in the string-based approach. If you check the .bbl file, you'll see that Biber produces

    {{hash=31cbf23407084cad2911631ec94eba70}{%
       family={Le\bibnamedelima Texier},
       familyi={L\bibinitperiod\bibinitdelim T\bibinitperiod},
       given={Marion},
       giveni={M\bibinitperiod}}}%

that's all biblatex sees, so you'll have to use Le\bibnamedelima Texier instead of Le Texier

\forcsvlist{\listadd\boldnames}
  {{Le\bibnamedelima Texier, Marion}, {Le\bibnamedelima Texier, M\bibinitperiod}}

This works as shown in the following MWE

\documentclass{article}
\usepackage{biblatex}
\usepackage{xpatch}

\makeatletter \newbibmacro{name:bold}[2]{% \edef\blx@tmp@name{\expandonce#1, \expandonce#2}% \def\do##1{\ifdefstring{\blx@tmp@name}{##1}{\bfseries\listbreak}{}}% \dolistloop{\boldnames}} \newcommand{\boldnames}{} \makeatother

\xpretobibmacro{name:family}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{} \xpretobibmacro{name:given-family}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{} \xpretobibmacro{name:family-given}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{} \xpretobibmacro{name:delim}{\begingroup\normalfont}{}{}

\xapptobibmacro{name:family}{\endgroup}{}{} \xapptobibmacro{name:given-family}{\endgroup}{}{} \xapptobibmacro{name:family-given}{\endgroup}{}{} \xapptobibmacro{name:delim}{\endgroup}{}{}

\forcsvlist{\listadd\boldnames} {{Le\bibnamedelima Texier, Marion}, {Le\bibnamedelima Texier, M\bibinitperiod}}

\begin{filecontents}{\jobname.bib} @article{schindlerHowFarPeople2022, title = {How Far Do People Travel to Use Urban Green Space? A Comparison of Three {European} Cities}, author = {Schindler, Mirjam and Le Texier, Marion and Caruso, Geoffrey}, date = {2022-04-01}, journaltitle = {Applied Geography}, volume = {141}, pages = {102673}, doi = {10.1016/j.apgeog.2022.102673}, } \end{filecontents} \addbibresource{\jobname.bib} \addbibresource{biblatex-examples.bib}

% just for demonstration \ExecuteBibliographyOptions{maxnames=99,giveninits} \DeclareNameAlias{default}{family-given/given-family}

\begin{document} \nocite{schindlerHowFarPeople2022} \printbibliography \end{document}

Schindler, M., M. Le Texier, and G. Caruso. “How Far Do People Travel to Use Urban Green Space? A Comparison of Three European Cities”. In: Applied Geography 141 (Apr. 1, 2022), p. 102673. doi: 10.1016/j.apgeog.2022.102673.


Issues like this are why I warmly recommend a hash-based approach as implemented in my answer to Make specific author bold using biblatex.

This would then look like the following, where you can pass the name to \addboldnames just as you would write it in the .bib file.

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

\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@writenametobib}[1]{% \stepcounter{nhblx@name}% \edef\nhblx@tmp@nocite{% \noexpand\AfterPreamble{% \noexpand\setbox0\noexpand\vbox{% \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{#1}}, % options = {dataonly=true},}% }% }

\AtEndDocument{% \closeout\nhblx@bibfile}

\addbibresource{\nhblx@bibfile@name}

\newcommand*{\nhblx@boldhashes}{} \DeclareNameFormat{nhblx@hashextract}{% \xifinlist{\thefield{hash}}{\nhblx@boldhashes} {} {\listxadd{\nhblx@boldhashes}{\thefield{hash}}}}

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

\newcommand{\addboldnames}{\forcsvlist\nhblx@writenametobib} \newcommand{\resetboldnames}{\def\nhblx@boldhashes{}}

\newcommand*{\ifhashinboldlist}{% \xifinlist{\thefield{hash}}{\nhblx@boldhashes}} \makeatother

\newcommand*{\mkboldifhashinlist}[1]{% \ifhashinboldlist {\mkbibbold{#1}} {#1}}

\DeclareNameWrapperFormat{boldifhashinlist}{% \renewcommand*{\mkbibcompletename}{\mkboldifhashinlist}% #1}

\DeclareNameWrapperAlias{sortname}{default} \DeclareNameWrapperAlias{default}{boldifhashinlist}

\addboldnames{{Le Texier, Marion}}

\begin{filecontents}{\jobname.bib} @article{schindlerHowFarPeople2022, title = {How Far Do People Travel to Use Urban Green Space? A Comparison of Three {European} Cities}, author = {Schindler, Mirjam and Le Texier, Marion and Caruso, Geoffrey}, date = {2022-04-01}, journaltitle = {Applied Geography}, volume = {141}, pages = {102673}, doi = {10.1016/j.apgeog.2022.102673}, } \end{filecontents} \addbibresource{\jobname.bib} \addbibresource{biblatex-examples.bib}

\begin{document} \nocite{schindlerHowFarPeople2022} \printbibliography \end{document}

Mirjam Schindler, Marion Le Texier, and Geoffrey Caruso. “How Far Do People Travel to Use Urban Green Space? A Comparison of Three European Cities”. In: Applied Geography 141 (Apr. 1, 2022), p. 102673. doi: 10.1016/j.apgeog.2022.102673.

moewe
  • 175,683