1

is it possible to change this solution (for printing all authors, when \citeauthor is used the first time) that it prints

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

?

changing the source to

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

doesn't work, because it does the same for single authors:

Author1 (short Author1)

Here the full example:

\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}
Moriambar
  • 11,466
Christian
  • 135
  • 1
  • 6
  • Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Marco Daniel Jun 10 '13 at 15:40
  • the problem is, that i don't know how to check , if \printnames{labelname} is different from \printnames[][1-99]{labelname} i'm sure there must be an easy way to check if an "et. al"-truncation needs to be made or not. – Christian Jun 10 '13 at 16:23
  • It seems you need the test \ifciteseen – Marco Daniel Jun 10 '13 at 16:24
  • thank you :)

    but that will not indicate, if there are more than 2 authors. the identification for first time vs. any other time works well. i need to avoid situations like "Author1 (short Author1)".

    – Christian Jun 10 '13 at 16:27
  • You need to look at the liststop counter and compare this with listtotal for the name list (see page 218 of biblatex manual). If there is any name list truncation to "et al" it means that liststop < listtotal. – PLK Jun 12 '13 at 06:52

1 Answers1

1

That answer was intended only for the alphabetic style, where name labels appear only in \citeauthor, \textcite and their related commands. For the authoryear style you should probably adapt the solution in this post: biblatex – et. al beginning from second citation?

In any case to test whether or not the name label is truncated you can compare the counter values labelname, maxnames and uniquelist. The labelname counter gives the length of the labelname list for the current entry. Typically this is the same as the author counter. Inside a citation maxnames corresponds to maxcitenames. When the biber-only uniquelist feature is enabled, the uniquelist counter corresponds to the length of the name label needed to disambiguate the labelname list from other entries.

\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}}} ) ) }}

This new test \iftruncated{<true>}{<false>} will expand <true> whenever the name label in the standard styles is truncated and expands <false> otherwise. To combine this test with your existing one, use:

\ifboolexpr{ test {\ifcategory{nameseen}} or not test {\iftruncated} }
Audrey
  • 28,881