Выделите жирным шрифтом имя, содержащее пустое место в библиографии biblatex

Выделите жирным шрифтом имя, содержащее пустое место в библиографии biblatex

Я реализую первое представленное решение.здесьвыделить жирным шрифтом некоторые имена в библиографии biblatex.

Проблема у меня с именами, содержащими пустой пробел " ". Тогда решение не применимо. Пример 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},
}

Фильтр я сформировал на основе примера, приведенного в предлагаемом решении:

    \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}}

Фильтры работают для всех имен авторов, но не работают для этого конкретного имени, содержащего пробел.

решение1

Имена с пробелами в них могут быть сложными в подходе на основе строк. Если вы проверите файл .bbl, вы увидите, что Biber производит

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

это все biblatexвидит, так что вам придется использовать Le\bibnamedelima TexierвместоLe Texier

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

Это работает, как показано в следующем 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}

Шиндлер, М., М. Ле Тексье и Г. Карузо. «Как далеко люди путешествуют, чтобы воспользоваться городским зеленым пространством? Сравнение трех европейских городов». В: Прикладная география 141 (1 апреля 2022 г.), стр. 102673. doi: 10.1016/j.apgeog.2022.102673.


Вот почему я настоятельно рекомендую подход на основе хэширования, реализованный вмой ответкВыделите конкретного автора жирным шрифтом с помощью biblatex.

Это будет выглядеть следующим образом, где вы можете передать имя \addboldnamesтак же, как вы бы записали его в .bibфайле.

\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}

Мирьям Шиндлер, Марион Ле Тексье и Джеффри Карузо. «Как далеко люди путешествуют, чтобы воспользоваться городским зеленым пространством? Сравнение трех европейских городов». В: Applied Geography 141 (1 апреля 2022 г.), стр. 102673. doi: 10.1016/j.apgeog.2022.102673.

Связанный контент