使用 biblatex-apa 突出显示作者

使用 biblatex-apa 突出显示作者

我正在尝试实现此处提供的作者突出显示:

每次在参考书目中出现作者姓名时,将其设为粗体

在我激活 biblatex 的 apa 样式之前,该解决方案运行良好。这是我的代码:

\documentclass{article}
\usepackage[english,ngerman]{babel}
\usepackage[utf8]{inputenc}

\usepackage[
  babel,
  german=quotes
]{csquotes}

\usepackage[
  backend=biber,
  %style=apa, %<===========uncomment me!!
  sortcites=true,
  sorting=nyt,
  hyperref=true,
  backref=true,
  alldates=iso8601
]{biblatex}

\begin{filecontents}{\jobname.bib}
@article{zongker_chicken_2006,
    title = {Chicken chicken chicken: Chicken chicken},
    volume = {12},
    url = {http://www.superfrink.net/athenaeum/dougz.pdf},
    shorttitle = {Chicken chicken chicken},
    pages = {16--21},
    number = {5},
    journaltitle = {Annals of Improbable Research},
    author = {Zongker, Doug},
    urldate = {2013-04-05},
    date = {2006}
}

@article{zongker_chicken_2007,
    title = {Chicken chicken chicken: Chicken chicken},
    volume = {12},
    url = {http://www.superfrink.net/athenaeum/dougz.pdf},
    shorttitle = {Chicken chicken chicken},
    pages = {16--21},
    number = {5},
    journaltitle = {Annals of Improbable Research},
    author = {OhterZongker, Doug},
    urldate = {2013-04-05},
    date = {2007}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\DeclareLanguageMapping{ngerman}{ngerman-apa}

% https://tex.stackexchange.com/a/211821/48182
\newcommand{\makeauthorbold}[1]{%
\DeclareNameFormat{author}{%
  \edef\tempname{{#1}}%
  \ifnumequal{\value{listcount}}{1}
    {\ifnumequal{\value{liststop}}{1}
      {\expandafter\ifstrequal\tempname{##1}{\textbf{##1\addcomma\addspace ##4\addcomma\isdot}}{##1\addcomma\addspace ##4\addcomma\isdot}}
      {\expandafter\ifstrequal\tempname{##1}{\textbf{##1\addcomma\addspace ##4}}{##1\addcomma\addspace ##4}}}
    {\ifnumless{\value{listcount}}{\value{liststop}}
      {\expandafter\ifstrequal\tempname{##1}{\textbf{\addcomma\addspace ##1\addcomma\addspace ##4}}{\addcomma\addspace ##1\addcomma\addspace ##4}}
      {\expandafter\ifstrequal\tempname{##1}{\textbf{\addcomma\addspace ##1\addcomma\addspace ##4\addcomma\isdot}}{\addcomma\addspace ##1\addcomma\addspace ##4\addcomma\isdot}}%
    }%
}%
}
\makeauthorbold{Zongker}

\begin{document}
\fullcite{zongker_chicken_2006}


\fullcite{zongker_chicken_2007}
\end{document}

以下是没有 style=apa 的不同输出

大胆的

风格=apa

不大胆

为什么我的命令不能覆盖 APA 样式?

答案1

此帖子现已更新,适用于biblatex>= 3.3 和biblatex-apa>= 6.8。唯一需要更改的是,name:apa:last-first在 < 3.3 版本中调用的宏现在称为name:apa:family-given。修补必须适应该名称更改。旧版本可在此答案的历史记录中找到。

您使用的代码不起作用,因为biblatex-apa没有使用author格式,而是使用它自己的apaauthor

我建议你服用奥黛丽的方法使用 biblatex 将特定作者设为粗体使用哈希表,如使用 biblatex 突出显示参考书目中的作者,并允许使用参考书目样式对其进行格式化

这里我们唯一需要考虑的是您需要修补的宏现在被称为name:apa:family-given

MWE(当然,哈希值086a2ad072f9903168e35b73cd394263特定于 MWE,请阅读上面链接的答案以了解如何找出哈希值)

\documentclass{article}
\usepackage[english,ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{xpatch}
\usepackage[
  babel,
  german=quotes
]{csquotes}

\usepackage[
  backend=biber,
  style=apa,
  sorting=nyt,
  backref=true,
  alldates=iso
]{biblatex}

\newcommand*{\boldnames}{}

\newcommand*{\doboldhashes}[1]{%
  \iffieldequalstr{hash}{#1}
    {\bfseries\listbreak}
    {}}%

\newbibmacro*{name:bold}{%
  \forlistloop{\doboldhashes}{\boldnames}%
}

\xpretobibmacro{name:apa:family-given}{\begingroup\usebibmacro{name:bold}}{}{}
\xpretobibmacro{name:delim}{\begingroup\normalfont}{}{}

\xapptobibmacro{name:apa:family-given}{\endgroup}{}{}
\xapptobibmacro{name:delim}{\endgroup}{}{}

\renewcommand*{\boldnames}{}
\forcsvlist{\listadd\boldnames}
  {{086a2ad072f9903168e35b73cd394263}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{zongker_chicken_2006,
    title = {Chicken chicken chicken: Chicken chicken},
    volume = {12},
    url = {http://www.superfrink.net/athenaeum/dougz.pdf},
    shorttitle = {Chicken chicken chicken},
    pages = {16--21},
    number = {5},
    journaltitle = {Annals of Improbable Research},
    author = {Zongker, Doug},
    urldate = {2013-04-05},
    date = {2006}
}

@article{zongker_chicken_2007,
    title = {Chicken chicken chicken: Chicken chicken},
    volume = {12},
    url = {http://www.superfrink.net/athenaeum/dougz.pdf},
    shorttitle = {Chicken chicken chicken},
    pages = {16--21},
    number = {5},
    journaltitle = {Annals of Improbable Research},
    author = {OhterZongker, Doug},
    urldate = {2013-04-05},
    date = {2007}
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\fullcite{zongker_chicken_2006}

\fullcite{zongker_chicken_2007}
\end{document}

在此处输入图片描述

相关内容