如何使用 biblatex-apa 样式调整 3-5 位作者的引用?

如何使用 biblatex-apa 样式调整 3-5 位作者的引用?

biblatex-apa关于这种风格,我无法习惯的一件事是 3-5 位作者的引用:如果作者数量在 3-5 位之间,则所有作者都会打印在引用中。

例如 Biblatex-apa 风格:

  • [引文] Goossens、Mittelbach、Samarin 和 Peter (2020)
  • [参考书目] Goossens, M., Mittelbach, F., Samarin, A. 和 Peter, T. (2020)。如何在家自制核弹(第 1 版)。马萨诸塞州雷丁:Addison-Wesley。

有时作者列表在文本中很长,我认为这确实没有必要。那么如何将数字设置maxcitenames2,就像内置的 biblatex 样式一样。

提供 MWE:

\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage{libertine}
\usepackage[UKenglish]{babel}
\usepackage{csquotes}
\usepackage[
    style=apa,
    backend=biber,
    maxcitenames=2,  % no effect!      
    natbib=true] {biblatex} 
\DeclareLanguageMapping{british}{british-apa}
\LetLtxMacro{\cite}{\citet} %

\addbibresource{biblatex-examples.bib}
\begin{document}

\section*{Apa citation}

Article - 2 authors: \cite{sarfraz}\\
Article - 3 authors: \cite{companion}\\
In proceeding: \cite{salam}\\
Ph.D thesis:  \cite[see e.g.][]{geer} \\
Master thesis: \cite{loh}\\
Report: \cite{padhye}\\
Repeat citation:  \cite{companion}, \citet{companion}, \citep{companion} \\
Multi-citation:  \cite{bertram,knuth:ct:a,knuth:ct:b,knuth:ct:c} \\
\printbibliography

\end{document}

答案1

是的,maxcitenames显然对没有影响biblatex-apa。我遇到过这个问题,其中biblatex-apa非常接近我所需的样式,但我并不需要 3-5 位作者的所有作者姓名,我也不希望实现首次引用如 APA 格式所述。

解决方案是修改导致这种情况的代码,您可以在文件中找到它apa.cbx,它通常位于...../tex/latex/biblatex-apa

对应的一段代码如下:

\DeclareNameFormat{labelname}{%
  \ifthenelse{\value{uniquelist}>1}
    {\numdef\cbx@min{\value{uniquelist}}}
    {\numdef\cbx@min{\value{minnames}}}%
  \ifboolexpr{test {\ifnumcomp{\value{listcount}}{=}{1}}
              or test {\ifnumcomp{\value{listtotal}}{=}{2}}}
    {\usebibmacro{labelname:doname}{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}}
    {\ifboolexpr{test {\ifnumcomp{\value{listtotal}}{>}{5}}
                 or test {\ifciteseen}}
     {\ifnumcomp{\value{listcount}}{<}{\cbx@min + 1}% normal name
       {\usebibmacro{labelname:doname}{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}}%
       {}%
      \ifnumcomp{\value{listcount}}{=}{\cbx@min + 1}% first past ul is et al
      % but enforce plurality of et al - only truncate here if there is at
      % least one more element after the current potential truncation point
      % so that "et al" covers at least two elements.
       {\ifnumcomp{\value{listcount}}{<}{\value{listtotal}}
         {\andothersdelim\bibstring{andothers}}
         {\usebibmacro{labelname:doname}{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}}}%
       {}%
      \ifnumcomp{\value{listcount}}{>}{\cbx@min + 1}% nothing thereafter
       {\relax}%
       {}}%
     {\usebibmacro{labelname:doname}{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}}}}

此代码执行的操作之一是检查作者数量是否大于 5,或者条目是否已被引用,如果是,则et al在第一位作者之后分配。通过修改代码,将 改为52删除or test {\ifciteseen}(注意右括号),那么任何超过 2 位作者的引用都将具有,et al无论是否已被使用。以下是编辑后的部分,除了 和 之外,\makeatletter\makeatother其放入文档序言时需要这些

\makeatletter

\DeclareNameFormat{labelname}{%
  \ifthenelse{\value{uniquelist}>1}
    {\numdef\cbx@min{\value{uniquelist}}}
    {\numdef\cbx@min{\value{minnames}}}%
  \ifboolexpr{test {\ifnumcomp{\value{listcount}}{=}{1}}
              or test {\ifnumcomp{\value{listtotal}}{=}{2}}}
    {\usebibmacro{labelname:doname}{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}}
    {\ifboolexpr{test {\ifnumcomp{\value{listtotal}}{>}{\value{maxnames}}}}% <- EDIT
     {\ifnumcomp{\value{listcount}}{<}{\cbx@min + 1}% normal name
       {\usebibmacro{labelname:doname}{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}}%
       {}%
      \ifnumcomp{\value{listcount}}{=}{\cbx@min + 1}% first past ul is et al
      % but enforce plurality of et al - only truncate here if there is at
      % least one more element after the current potential truncation point
      % so that "et al" covers at least two elements.
       {\ifnumcomp{\value{listcount}}{<}{\value{listtotal}}
         {\andothersdelim\bibstring{andothers}}
         {\usebibmacro{labelname:doname}{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}}}%
       {}%
      \ifnumcomp{\value{listcount}}{>}{\cbx@min + 1}% nothing thereafter
       {\relax}%
       {}}%
     {\usebibmacro{labelname:doname}{#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}}}}

\makeatother

xpatch包提供了一种将相同的更改应用于labelname格式指令的简单方法。

\usepackage[style=apa,backend=biber,natbib=true,
            maxcitenames=2,uniquelist=false]{biblatex} 
\DeclareLanguageMapping{british}{british-apa}
\usepackage{xpatch}

\xpatchnameformat{labelname}
  {\ifciteseen}{\ifnumcomp{\value{listtotal}}{>}{\value{maxnames}}}{}{}

相关内容