首次使用 \citeauthor 时打印“作者作者作者(简称:author1 et al)”

首次使用 \citeauthor 时打印“作者作者作者(简称:author1 et al)”

可以改变吗解决方案(用于打印所有作者, \citeauthor第一次使用时)打印

Author1, Author2, Author3 (short Author1 et. al)

将源更改为

\newbibmacro*{labelname}{%
  \ifcategory{nameseen}
    {\printnames{labelname}}
    {\addtocategory{nameseen}{\thefield{entrykey}}%
     \printnames[][1-99]  {labelname}\addspace\printtext{(kurz\addspace\printnames{labelname})}}}

不起作用,因为它对单个作者执行相同的操作:

Author1 (short Author1)

完整示例如下:

\documentclass[a4paper]{book}

\usepackage[american]{babel}
\usepackage[utf8]{inputenc}

\usepackage[style=authoryear, maxcitenames=2,maxbibnames=99, backend=biber,citetracker=true]{biblatex}


\DeclareBibliographyCategory{nameseen}

% old, but with no "short" in the parents:
%\newbibmacro*{labelname}{%
%  \ifcategory{nameseen}
%    {\printnames{labelname}}
%    {\addtocategory{nameseen}{\thefield{entrykey}}%
%     \printnames[][1-99]{labelname}}}

% new, but with the problem:
\newbibmacro*{labelname}{%
  \ifcategory{nameseen}
    {\printnames{labelname}}
     {\addtocategory{nameseen}{\thefield{entrykey}}%
     \printnames[][1-99]{labelname}\addspace\printtext{(short\addspace\printnames{labelname})}}}


% Based on generic definition from biblatex.def
\DeclareCiteCommand{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \usebibmacro{labelname}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\makeatletter
% Based on definition from alphabetic.cbx
\renewbibmacro*{textcite}{%
  \ifcategory{nameseen}
    {}
    {\clearfield{namehash}}%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\multicitedelim}
    {\cbx@tempa
     \ifnameundef{labelname}
       {}
       {\usebibmacro{labelname}\space}%
     \bibopenbracket}%
  \ifnumequal{\value{citecount}}{1}
    {\usebibmacro{prenote}}
    {}%
  \usebibmacro{cite}%
  \savefield{namehash}{\cbx@lasthash}%
  \gdef\cbx@tempa{\bibclosebracket\multicitedelim}}
\makeatother

\begin{filecontents}{test.bib}
@article{foobar,
  Author = {Author1, A. and Author2, B. and Author3, C.},
  Journal = {Journal of Foo},
  Pages = {1--2},
  Title = {Foo is bar},
  Volume = {1},
  Year = {1999}
}

@article{foobar2,
  Author = {SingleAuthor, A.},
  Journal = {Journal of Foo},
  Pages = {1--2},
  Title = {Foo is bar},
  Volume = {1},
  Year = {1999}
}
\end{filecontents}

\addbibresource{test.bib}


\begin{document}

1. \citeauthor{foobar}\\
2. \citeauthor{foobar}
3. \citeauthor{foobar}
1. \citeauthor{foobar2}\\
2. \citeauthor{foobar2}
3. \citeauthor{foobar2}


\end{document}

答案1

该答案仅针对样式alphabetic,其中名称标签仅出现在及其相关命令中。对于样式,\citeauthor您可能应该调整此帖子中的解决方案:\textciteauthoryearbiblatex – et. al 从第二次引用开始?

无论如何,要测试名称标签是否被截断,您可以比较计数器值labelnamemaxnamesuniquelistlabelname计数器给出当前条目的列表长度labelname。通常,这与计数器相同author。在引用中maxnames对应于。当启用maxcitenamesbiber-only功能时,计数器对应于消除列表与其他条目歧义所需的名称标签长度。uniquelistuniquelistlabelname

\newcommand*{\iftruncated}{%
  \ifboolexpr {
    test {\ifnumgreater{\value{labelname}}{1}}
    and
    ( ( test {\ifnumgreater{\value{uniquelist}}{0}}
        and
        test {\ifnumgreater{\value{labelname}}{\value{uniquelist}}} )
      or
      ( test {\ifnumequal{\value{uniquelist}}{0}}
        and
        test {\ifnumgreater{\value{labelname}}{\value{maxnames}}} ) ) }}

当标准样式中的名称标签被截断时,此新测试\iftruncated{<true>}{<false>}将扩展,否则将扩展。要将此测试与现有测试结合使用,请使用:<true><false>

\ifboolexpr{ test {\ifcategory{nameseen}} or not test {\iftruncated} }

相关内容