biblatex:“et al.”当 uniquename = false 时也是如此

biblatex:“et al.”当 uniquename = false 时也是如此

使用biblatex选项uniquename = true(和citetracker = true, maxcitenames = 1),我可以通过添加代码\AtEveryCitekey{\ifciteseen{}{\defcounter{maxnames}{99}}}将任何多作者作品在Author et al.其第一次完整引用后缩写为,参见下面的 MWE:

\documentclass{article}
\usepackage[style = authoryear-comp, citetracker = true, maxcitenames = 1, uniquename = true]{biblatex}
\AtEveryCitekey{\ifciteseen{}{\defcounter{maxnames}{99}}} % cite all authors of multi-authored works only once
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{lennon1963,
    AUTHOR = "John Lennon and Paul McCartney",
    TITLE = "She loves you",
    YEAR = "1963"}
@BOOK{lennon2004,
    AUTHOR = "Sean Lennon",
    TITLE = "My father was John Lennon",
    YEAR = "2004"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\noindent\cite{lennon1963}\\
\cite{lennon1963}\\
\cite{lennon2004}
\end{document}

在此处输入图片描述

但是当更改uniquename = true为时uniquename = false,这不起作用:

在此处输入图片描述

\AtEveryCitekey{\ifciteseen{}{\defcounter{maxnames}{99}}}问题: 我怎样才能保留该biblatex选项的功能uniquename = false


编辑 卡洛的回答如下可以,但现在我很好奇如何限制这一点,以便只有当作品有三位或更多作者时,Author 1, Author 2, and Author 3缩写为才会生效。在下面的 MWE 中,在第二次引用中应保持原样,而应在第二次引用中缩写为。Author 1 et al.Lennon and McCartney 1963Lennon, McCartney, Harrison, and Starkey 1970Lennon et al. 1970

\documentclass{article}
\usepackage[style = authoryear-comp, citetracker = true, maxcitenames = 99, mincitenames = 2, uniquename = false]{biblatex}
\AtEveryCitekey{\ifciteseen{\defcounter{maxnames}{1}}{}} % cite all authors of multi-authored works only once
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{lennon1963,
    AUTHOR = "John Lennon and Paul McCartney",
    TITLE = "She loves you",
    YEAR = "1963"}
@BOOK{lennon1970,
    AUTHOR = "John Lennon and Paul McCartney and George Harrison and Richard Starkey",
    TITLE = "We're breaking up now",
    YEAR = "1970"}
@BOOK{lennon2004,
    AUTHOR = "Sean Lennon",
    TITLE = "My father was John Lennon",
    YEAR = "2004"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\noindent\cite{lennon1963}\\
\cite{lennon1963}\\
\cite{lennon1970}\\
\cite{lennon1970}\\
\cite{lennon2004}
\end{document}

在此处输入图片描述


编辑至编辑

Carlo 的以下回答非常完美。不过,我稍微简化了代码,并对其进行了一些调整,以便至少以后查看时能够理解它:)

\AtEveryCitekey% for every citation
    {%
        \ifnumgreater{\value{labelname}}{2}% if there are >2 authors
            {%
                \ifciteseen% and if citation has been seen before
                    {\setcounter{maxnames}{1}}% then cite only one author
                    {\setcounter{maxnames}{\value{labelname}}}% otherwise cite all authors
            }
            {\setcounter{maxnames}{\value{labelname}}}% otherwise cite ≤2 authors
    }

答案1

“更改逻辑”。maxcitenames = 99biblatex选项中,并\defcounter{maxnames}{1}True的中ifciteseen

平均能量损失

\documentclass{article}
\usepackage[style = authoryear-comp, citetracker = true, maxcitenames = 99, uniquename = false]{biblatex}
\AtEveryCitekey{%
    \ifciteseen
    {\defcounter{maxnames}{1}}
    {}} % cite all authors of multi-authored works only once
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{lennon1963,
    AUTHOR = "John Lennon and Paul McCartney",
    TITLE = "She loves you",
    YEAR = "1963"}
@BOOK{lennon2004,
    AUTHOR = "Sean Lennon",
    TITLE = "My father was John Lennon",
    YEAR = "2004"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\noindent\cite{lennon1963}\\
\cite{lennon1963}\\
\cite{lennon2004}
\end{document}

在此处输入图片描述

编辑回答编辑问题。##

我找到了两种方法并且打算将其发布出来。

首先

这不是最好的形式,最初我没有找到其他形式。这种方式不使用\AtEveryCitekey。它使用listtotal是列表中总数的计数器(authoreditors...或labelname)。计数器listtotal仅允许在列出格式指令,在其他地方使用时不具有任何有意义的值

\patchlabelnameformat如果 的值listtotal大于 2 并且它是第一个引用,则liststop在 中设置 (要打印的项目列表的最大数量) \value{listtotal}。如果不是第一个引用,则listtop设置为 1。另一方面,如果 的值listtotal小于 2,则listtop设置为\value{listtotal}

梅威瑟:

\documentclass{article}
\usepackage[style = authoryear-comp, citetracker = true,maxnames=2, minnames=2,uniquename=false]{biblatex}

\def\fgt{\setcounter{liststop}{\value{listtotal}}} %first and greater than two
\def\nfgt{\setcounter{liststop}{1}} %non first and greater than two

\def\flt{\setcounter{liststop}{\value{listtotal}}} %first and lower than two

\def\patchlabelnameformat{%
 \ifnumgreater{\value{listtotal}}{2}
    {\ifciteseen
       {\nfgt}
       {\fgt}}
    {\flt}}

\DeclareNameFormat{labelname}{%
 \patchlabelnameformat
 \ifcase\value{uniquename}%
    \usebibmacro{name:last}{#1}{#3}{#5}{#7}%
  \or
    \ifuseprefix
      {\usebibmacro{name:first-last}{#1}{#4}{#5}{#8}}
      {\usebibmacro{name:first-last}{#1}{#4}{#6}{#8}}%
  \or
    \usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
  \fi
  \usebibmacro{name:andothers}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{lennon1963,
    AUTHOR = "John Lennon and Paul McCartney",
    TITLE = "She loves you",
    YEAR = "1963"}
@BOOK{lennon1970,
    AUTHOR = "John Lennon and Paul McCartney and George Harrison and Richard Starkey",
    TITLE = "We're breaking up now",
    YEAR = "1970"}
@BOOK{lennon2004,
    AUTHOR = "Sean Lennon",
    TITLE = "My father was John Lennon",
    YEAR = "2004"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\noindent\cite{lennon1963}\\
\cite{lennon1963}\\
\cite{lennon1970}\\
\cite{lennon1970}\\
\cite{lennon2004}
\end{document}

第二

最佳形式。使用\AtEveryCitekey。逻辑与第一种方式相同,但无法使用listtotallisttop因为\AtEveryCitekey不是列表格式化指令。然后,以这种方式使用计数器labelname并设置maxnames。必须在选项uniquelist=false中使用biblatex

梅威瑟:

\documentclass{article}
\usepackage[style = authoryear-comp, citetracker = true,uniquename=false,uniquelist=false]{biblatex}

\AtEveryCitekey{\maxminformat} % cite all authors of

\def\fgt{\setcounter{maxnames}{\value{labelname}}} %first and greater than two
\def\nfgt{\setcounter{minnames}{1}\setcounter{maxnames}{1}} %non first and greater than two

\def\flt{\setcounter{maxnames}{\value{labelname}}} %first and lower than two

\def\maxminformat{%
 \ifnumgreater{\value{labelname}}{2}
    {\ifciteseen
       {\nfgt}
       {\fgt}}
    {\flt}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{lennon1963,
    AUTHOR = "John Lennon and Paul McCartney",
    TITLE = "She loves you",
    YEAR = "1963"}
@BOOK{lennon1970,
    AUTHOR = "John Lennon and Paul McCartney and George Harrison and Richard Starkey",
    TITLE = "We're breaking up now",
    YEAR = "1970"}
@BOOK{lennon2004,
    AUTHOR = "Sean Lennon",
    TITLE = "My father was John Lennon",
    YEAR = "2004"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\noindent\cite{lennon1963}\\
\cite{lennon1963}\\
\cite{lennon1970}\\
\cite{lennon1970}\\
\cite{lennon2004}
\end{document}

在此处输入图片描述

相关内容