参考文献内の空白を含む名前を太字にする 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}

Schindler, M.、M. Le Texier、G. Caruso。「都市の緑地を利用するために人々はどのくらい遠くまで移動するのか?ヨーロッパ3都市の比較」。応用地理学141(2022年4月1日)、p. 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}

ミリアム・シンドラー、マリオン・ル・テキシエ、ジェフリー・カルーソ。「都市の緑地を利用するために人々はどのくらい遠くまで移動するのか?ヨーロッパ3都市の比較」。応用地理学141(2022年4月1日)、p.102673。doi: 10.1016/j.apgeog.2022.102673。

関連情報