如何在 biblatex 中用星号突出显示特定作者

如何在 biblatex 中用星号突出显示特定作者

我搜索了很多次以寻找问题的答案,似乎总是很接近但又没有完全找到。假设我有一位名叫“Tarcisio F. Maciel”的作者,我觉得他有点特别,我想在我的参考文献列表中用星号标记他。使用以下代码(可在本论坛中找到),我可以让他加粗,但添加星号对我来说不起作用(请注意,您需要一个相当新的 Miktex 或 Texlive 发行版才能正确编译)。你有什么想法吗?我希望尽可能少地更改示例,因为我非常喜欢通过哈希值识别作者的想法(我有多个参考文献,应该始终突出显示)。

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

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
  @incollection{Silva:2014a,
  title={Radio Resource Management for Device-to-Device Communications in Long Term Evolution Networks},
  author={Carlos F. M. Silva and Silva, Jr., Jos\'{e} Mairton B. and Tarcisio F. Maciel},
  booktitle={Resource Allocation and {MIMO} for {4G} and Beyond},
  publisher={Springer Science+Business Media},
  year=2014,
  address={New York, USA},
  editor={Francisco Rodrigo Porto Cavalcanti},
  pages={105-156},
  doi={10.1007/978-1-4614-8057-0_3},
  isbn={978-1-4614-8056-3},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\usepackage{xpatch}% or use https://tex.stackexchange.com/a/40705

\newbibmacro*{name:bold}[2]{%
  \def\do##1{\iffieldequalstr{hash}{##1}{\bfseries\listbreak}{}}%
  \dolistloop{\boldnames}%
}

\newcommand*{\boldnames}{}

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

\renewcommand*{\boldnames}{}
\forcsvlist{\listadd\boldnames}
  {{3288e5f9be7ec7c330203382f4e8d8ed}}

\begin{document}
\cite{Silva:2014a}

\printbibliography
\end{document}

电流输出:

电流输出

期望输出(使用 MS Word 复制):

期望输出

答案1

实际上,星号比粗体更容易。基本思路是一样的,但这次我们只需要挂接到宏的末尾(我们只附加代码),如果需要,我们可以在那里添加星号。不需要复杂的分组。

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

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
  @incollection{Silva:2014a,
  title={Radio Resource Management for Device-to-Device Communications in Long Term Evolution Networks},
  author={Carlos F. M. Silva and Tarcisio F. Maciel and Silva, Jr., Jos\'{e} Mairton B.},
  booktitle={Resource Allocation and {MIMO} for {4G} and Beyond},
  publisher={Springer Science+Business Media},
  year=2014,
  address={New York, USA},
  editor={Francisco Rodrigo Porto Cavalcanti},
  pages={105-156},
  doi={10.1007/978-1-4614-8057-0_3},
  isbn={978-1-4614-8056-3},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\usepackage{xpatch}% or use https://tex.stackexchange.com/a/40705

\newbibmacro*{name:ast}[2]{%
  \def\do##1{\iffieldequalstr{hash}{##1}{*\listbreak}{}}%
  \dolistloop{\astnames}}

\xapptobibmacro{name:family}{\usebibmacro{name:ast}}{}{}
\xapptobibmacro{name:given-family}{\usebibmacro{name:ast}}{}{}
\xapptobibmacro{name:family-given}{\usebibmacro{name:ast}}{}{}

\newcommand*{\astnames}{}
\forcsvlist{\listadd\astnames}
  {{3288e5f9be7ec7c330203382f4e8d8ed}}

\begin{document}
\cite{Silva:2014a}

\printbibliography
\end{document}

在此处输入图片描述

星号实际上并不像粗体那样突出。

答案2

您可以通过添加以下代码来更改 MWE

\newtoggle{addasterisk}

\newbibmacro*{name:bold}[2]{%
  \def\do##1{\iffieldequalstr{hash}{##1}{\toggletrue{addasterisk}}{}}%
  \dolistloop{\boldnames}%
}

\newcommand{\myast}{\iftoggle{addasterisk}{*\togglefalse{addasterisk}}{}}

这将使用您当前的代码来确定是否必须突出显示名称;如果是,则激活开关,然后根据开关打印星号(根据以下几行更改您附加到宏的内容)

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

在此处输入图片描述

相关内容