2

I am required to output a specific number of authors which is dependent on whether the citation has appeared before. If a citation has not appeared, a citation

  • with up to five authors should list all authors
  • with more than five authors should only list the first author, followed by "et al.".

If a citation has already appeared, a citation

  • with up to two authors should list all authors
  • with more than two authors should only list the first author, followed by "et al.".

Using Audrey's answer, I was able to achieve most of it. However, I do not know how to query the number of authors in the patch commands. I assume that I could set maxnames based on whether the citation has been seen before, but Audrey mentions that this is probably not the best idea - is there another way?

Thank you very much!

Example:

\documentclass[]{scrbook}

\usepackage{filecontents}
\begin{filecontents}{lit.bib}
@article{Amabile.1993,
    author = {Amabile, Teresa M.},
    year = {1993},
    title = {Motivational Synergy: Toward new conceptualizations of intrinsic and extrinsic motivation in the workplace},
    pages = {185},
    volume = {3},
    number = {3},
    journal = {Human Resource Management Review}
}

@article{Stevenson.1990,
    author = {Stevenson, Howard H. and Jarillo, J. Carlos},
    year = {1990},
    title = {A Paradigm of Entrepreneurship: Entrepreneurial Management},
    pages = {17--27},
    volume = {11},
    journal = {Strategic Management Journal}
}

@article{Kivimaki.1997,
    author = {Kivim{\"a}ki, Mika and Kuk, George and Elovainio, Marko and Thomson, Louise and Kalliom{\"a}ki-Levanto, Tiina and Heikkil{\"a}, Armo},
    year = {1997},
    title = {The Team Climate Inventory (TCI)-four or five factors? Testing the structure of TCI in samples of low and high complexity jobs},
    pages = {375--389},
    volume = {70},
    number = {4},
    journal = {Journal of Occupational and Organizational Psychology}
}
\end{filecontents}


\usepackage[
natbib=true,
style=authoryear-comp,
backend=biber,
maxcitenames=2,
citetracker=true,]{biblatex}

\usepackage{xpatch}
\AtEveryCitekey{\ifciteseen{}{\clearfield{namehash}}}

\xpatchbibmacro{cite}
{\printnames{labelname}}
{\ifciteseen
    {\printnames{labelname}}
    {\printnames[][1-5]{labelname}}}
{}
{}

\xpatchbibmacro{textcite}
{\printnames{labelname}}
{\ifciteseen
    {\printnames{labelname}}
    {\printnames[][1-5]{labelname}}}
{}
{}

% some natbib backwards compatibility 
\let\citealp\cite
\let\cite\textcite

\addbibresource{lit.bib}

\begin{document}

    \citet{Amabile.1993} \\ % Amabile (1993) - correct
    \citet{Stevenson.1990} \\ % Stevenson and Jarillo (1990) - correct
    \citet{Kivimaki.1997} \\ % incorrect, should be Kivimäki et al. (1997)

    \citet{Amabile.1993} \\ % Amabile (1993) - correct
    \citet{Stevenson.1990} \\ % Stevenson and Jarillo (1990) - correct
    \citet{Kivimaki.1997} \\ % Kivimäki et al. (1997) - correct

    \printbibliography
\end{document}

The solution using \AtEveryCitekey would be the following; however, I'm a bit confused because of the "With biber as the backend, you might want to avoid messing around with the maxnames counter."

\AtEveryCitekey{\ifciteseen{\defcounter{maxnames}{2}}%
{\defcounter{maxnames}{5}}}
Max
  • 77
  • The comment about not messing up with maxnsmes might refer to the generation of alphabetic labels for citations – Guido Feb 19 '17 at 20:25
  • Biber does all kinds of name and list disambiguation. If uniquelist is set to anything other than false, Biber can - within reason - change the number of authors displayed. Biber also assigns the disambiguation letters ('Smith 2006a') and does that based on the name label it figured out. If we now change maxnames mid-document Biber won't know about it and labels might be a bit off. If this is only for the first cite, that is probably a risk you have to take anyway. – moewe Feb 20 '17 at 06:59

1 Answers1

1

biblatex stores the number of names in the <name> field in the <name> counter. So we can get the number of names in labelname with \value{labelname}.

\xpatchbibmacro{cite}
  {\printnames{labelname}}
  {\ifboolexpr{test {\ifciteseen} or 
               test {\ifnumgreater{\value{labelname}}{5}}}
     {\printnames{labelname}}
     {\printnames[][1-5]{labelname}}}
  {}
  {}

\xpatchbibmacro{textcite}
  {\printnames{labelname}}
  {\ifboolexpr{test {\ifciteseen} or 
               test {\ifnumgreater{\value{labelname}}{5}}}
     {\printnames{labelname}}
     {\printnames[][1-5]{labelname}}}
  {}
  {}

should work for you.

This prints up to five names only if the citation has not been seen before and there are no more than five names in labelname, this should give you exactly what you need. All of this assumes that maxcitenames is set to 2 in the preamble as it was in your MWE.

Your MWE with my modifications then gives

citations of the MWE

The reason that you should not mess with maxnames mid-document is that Biber does all kinds of name and list disambiguation. If uniquelist is set to anything other than false, Biber can - within reason - change the number of authors displayed in citations - that number is controlled by the maxnames counter. That means that Biber can locally override the globally set maxnames value. Biber also assigns the disambiguation letters ('Smith 2006a') and does that based on the name label it figured out. If we now change maxnames ourselves in the citation Biber won't know about it, and labels might be a bit off.

moewe
  • 175,683
  • I realized that it did not work properly in my real document and needed some time to figure out that it was due to the use of \citep (in this case, the second author was still printed); with \parentcite it works fine! – Max Feb 25 '17 at 20:15