Biblatex:以粗体打印一些引文(\cite)

Biblatex:以粗体打印一些引文(\cite)

我想\cite{}在我的文档中以粗体打印指定作者的全部作品。目前,我shorthand = {\textbf{Foo23}}在我的.bib这样做,但这不太实用,而且,它不仅存在处理具有相同简写的错误重复条目的问题,更重要的是,字母顺序被破坏

在此处输入图片描述

\documentclass{article}

\usepackage[
  style=alphabetic,% also 
  minalphanames=3,maxalphanames=4, % [Foo+99] -> [FBB+99].
  maxnames=99, % Do not put "et al". Sets maxbibnames, maxcitenames and maxsortnames.
  sortcites=true,
  sortcites=false, % \cite{B,A,C}: [A,B,C] --> [B,A,C]
]{biblatex}

\usepackage{filecontents}

\begin{filecontents}[overwrite]{\jobname.bib}
@article{a1,
  author={John Smith and Mary Stuart and Peter Pan},
  year = 2020,
  shorthand = {\textbf{SSP20}},
  journal = {I should should have a Awesome Journal},
  volume = 3
}
@article{a2,
  author={John Smith and Mary Stuart and Peter Pan},
  year = 2020,
  journal = {Another Journal},
  volume = 3
}
@article{a3,
  author={Abc Abc and Def Ahi},
  year = 2020,
  journal = {I should appear first in the list as it is sorted alphabetically},
  volume = 3
}
\end{filecontents}


\addbibresource{\jobname.bib}

\begin{document}

\cite{a1,a2,a3}

\printbibliography

\end{document}

答案1

通常,最好尽可能避免在.bib输入中格式化命令。正如您所注意到的,命令将或多或少被视为普通文本,并且可能会弄乱排序和唯一性计算。

相反,最好在数据中设置一个语义标记,并在旁边采取行动biblatex。一种选择是设置一个关键字。

令人惊讶的是,没有简单的方法来突出biblatex显示整个引用标签,所以我们需要将其构建到citebibmacro 中。

\documentclass{article}

\usepackage[
  style=alphabetic,% also 
  minalphanames=3,maxalphanames=4, % [Foo+99] -> [FBB+99].
  maxnames=99, % Do not put "et al". Sets maxbibnames, maxcitenames and maxsortnames.
  sortcites=true,
  sortcites=false, % \cite{B,A,C}: [A,B,C] --> [B,A,C]
]{biblatex}

\DeclareFieldFormat{citelabel}{%
  \ifkeyword{importantauthor}
    {\mkbibbold{#1}}
    {#1}}

\DeclareFieldFormat{labelalphawidth}{%
  \mkbibbrackets{%
    \ifkeyword{importantauthor}
      {\mkbibbold{#1}}
      {#1}}}

\renewbibmacro*{cite}{%
  \printtext[bibhyperref]{%
    \printtext[citelabel]{%
      \printfield{labelprefix}%
      \printfield{labelalpha}%
      \printfield{extraalpha}%
      \ifbool{bbx:subentry}
        {\printfield{entrysetcount}}
        {}}}}

\begin{filecontents}{\jobname.bib}
@article{a1,
  author   = {John Smith and Mary Stuart and Peter Pan},
  year     = 2020,
  journal  = {I should should have a Awesome Journal},
  volume   = 3,
  keywords = {importantauthor},
}
@article{a2,
  author  = {John Smith and Mary Stuart and Peter Pan},
  year    = 2020,
  journal = {Another Journal},
  volume  = 3,
}
@article{a3,
  author  = {Abc Abc and Def Ahi},
  year    = 2020,
  journal = {I should appear first in the list as it is sorted alphabetically},
  volume  = 3,
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

\cite{a1,a2,a3}

\printbibliography

\end{document}

“[SSP20a; SSP20b; AA20]” 中的“SSP20a”以粗体显示

相关内容