选择性地修改一些引文的外观

选择性地修改一些引文的外观

我正在使用 biblatex,设置如下:

\usepackage[style=nejm,hyperref,natbib,backend=biber,maxnames=2,minnames=1]{biblatex}

让我们以这个引文为例。(

@article{RefWorks:41,
    author={K. J. Koval and J. J. Harrast and J. O. Anglen and J. N. Weinstein},
    year={2008},
    month={Sep},
    title={Fractures of the distal part of the radius. The evolution of practice over time. Where's the evidence?},
    journal={The Journal of bone and joint surgery.American volume},
    volume={90},
    number={9},
    pages={1855-1861},
}

当我使用 \textcite{RefWorks:41} 进行引用时,我希望使名称部分Koval et al.显示为\textbf{\textsf{\textsc{Koval et al.}}}。与此同时,bibstyle 应保持不变。此外,它应应用于选定的引用(不是全部,而是根据上下文应用于某些特定的引用)。有什么想法或建议吗?

编辑:进一步解释:鉴于 bib 文件中的作者密钥 author={KJ Koval and JJ Harrast and JO Anglen and JN Weinstein},我想将 \textcite 输出中的“作者”部分加粗,无论它是什么。我的意思是,如果 maxnames=2,minnames=1,则输出应该是Koval 等人[25],maxnames=6,minnames=3 应该是科瓦尔、哈拉斯特、安格伦和温斯坦[25]后半部分(25)保持不变。

此外,如果一个参考文献被引用多次,我想选择哪些引用应该加粗(而不是全部)。

答案1

通常,这不会花费超过几行代码,但nejm风格基于numeric-comp,并且numeric-comp具有非常特殊的处理textcite以确保一切看起来都很好。因此,我们将不得不复制相当多的代码来进行非常小的修改。

我们的新 bibmcaro是bibmacroboldtextcite的逐字复制,并在周围添加了包装器。 是一个在 中定义的助手。textcite\mkbibbold\printnames{labelnames}\cbx@boldtextcite\boldtextcite\DeclareCiteCommand{\boldtextcite}

\makeatletter
\newbibmacro*{boldtextcite}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\usebibmacro{cite:comp}}
    {\usebibmacro{cite:dump}%
     \ifbool{cbx:parens}
       {\bibclosebracket\global\boolfalse{cbx:parens}}
       {}%
     \iffirstcitekey
       {}
       {\textcitedelim}%
     \usebibmacro{cite:init}%
     \ifnameundef{labelname}
       {\printfield[citetitle]{labeltitle}}
       {\mkbibbold{\printnames{labelname}}}%
     \global\booltrue{cbx:parens}%
     \addspace\bibopenbracket%
     \ifnumequal{\value{citecount}}{1}
       {\usebibmacro{prenote}}
       {}%
     \usebibmacro{cite:comp}%
     \stepcounter{textcitecount}%
     \savefield{namehash}{\cbx@lasthash}}}

\DeclareCiteCommand{\cbx@boldtextcite}
  {\usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{boldtextcite}}
  {}
  {\usebibmacro{cite:dump}%
   \usebibmacro{postnote}%
   \ifbool{cbx:parens}
     {\bibclosebracket\global\boolfalse{cbx:parens}}
     {}}

\DeclareCiteCommand{\boldtextcite}[\cbx@textcite@init\cbx@boldtextcite]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{cite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\makeatother

我们现在必须引用命令、标准\textcite并将\boldtextcite名称加粗。

平均能量损失

\documentclass{article}
\usepackage{filecontents}
\usepackage[style=nejm,hyperref,natbib,backend=biber,maxnames=2,minnames=1]{biblatex}


\makeatletter
\newbibmacro*{boldtextcite}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\usebibmacro{cite:comp}}
    {\usebibmacro{cite:dump}%
     \ifbool{cbx:parens}
       {\bibclosebracket\global\boolfalse{cbx:parens}}
       {}%
     \iffirstcitekey
       {}
       {\textcitedelim}%
     \usebibmacro{cite:init}%
     \ifnameundef{labelname}
       {\printfield[citetitle]{labeltitle}}
       {\mkbibbold{\printnames{labelname}}}%
     \global\booltrue{cbx:parens}%
     \addspace\bibopenbracket%
     \ifnumequal{\value{citecount}}{1}
       {\usebibmacro{prenote}}
       {}%
     \usebibmacro{cite:comp}%
     \stepcounter{textcitecount}%
     \savefield{namehash}{\cbx@lasthash}}}

\DeclareCiteCommand{\cbx@boldtextcite}
  {\usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{boldtextcite}}
  {}
  {\usebibmacro{cite:dump}%
   \usebibmacro{postnote}%
   \ifbool{cbx:parens}
     {\bibclosebracket\global\boolfalse{cbx:parens}}
     {}}

\DeclareCiteCommand{\boldtextcite}[\cbx@textcite@init\cbx@boldtextcite]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{cite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\makeatother

\addbibresource{biblatex-examples.bib}
\begin{document}
\textcite{wilde,companion}

\boldtextcite{wilde,companion}

\printbibliography
\end{document}

在此处输入图片描述

相关内容