我正在实施提出的第一个解决方案这里将 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}
正是这样的问题,我才强烈推荐基于哈希的方法,如我的答案到使用 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}