# Fix a .bst file to display “Author et al. (year)” if a .bib entry contains more than 2 authors?

This question is very related to the question here:

Citation "et al." only for four and more authors with natbib and jf.bst

In the answer to that question Mico has shown how to replace the format.lab.names function in the jf.str so that a .bib entry is displayed as "Author et al. (year)" whenever more than 4 authors are present in the entry. However, this is done for the jf.str version found at nyu.edu's website. I want to be able to do achieve the same behavior with the .str file found here

http://pages.stern.nyu.edu/~dbackus/GE_asset_pricing/BGTZ/jf.bst

which although it has the same name has some modifications to fit Econometrica's bibliography requirements.

So the question is can anyone explain to me why when I replace the FUNCTION {format.lab.names} with

FUNCTION {format.lab.names}
{'s :=
"" 't :=
#1 'nameptr :=
s num.names$'numnames := numnames 'namesleft := { namesleft #0 > } { s nameptr "{vv~}{ll}" format.name$
't :=
nameptr #1 >
{
nameptr #2 =
numnames #2 > and
{ "others" 't :=
#1 'namesleft := }
'skip$if$
namesleft #1 >
{ ", " * t * }
{
s nameptr "{ll}" format.name$duplicate$ "others" =
{ 't := }
{ pop$} if$
t "others" =
{ " et~al." * }
{
numnames #2 >
{ "," * }
'skip$if$
bbl.and
space.word * t *
}
if$} if$
}
't
if$nameptr #1 + 'nameptr := namesleft #1 - 'namesleft := } while$
}


I don't get "Author et al. (year)" whenever a .bib entry has more than 2 authors. (I realize this might be something very simple and started reading Tame the Beast at http://www.lsv.ens-cachan.fr/~markey/BibTeX/doc/ttb_en.pdf). Thank you.

Here's a .tex file for testing purposes:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{abd:2007,
author      = "Torben G. Andersen and Tim Bollerslev and Francis X. Diebold",
title       = "Roughing it up: {Including} jump components in the
measurement, modeling and forecasting of return volatility",
journal     = "Review of Economics and Statistics",
year        = 2007,
volume      = 89,
number      = 4,
month       = "November",
pages       = "701--720",
}

@article{abde:2001,
author      = "Torben G. Andersen and Tim Bollerslev and Francis X. Diebold
and Heiko Ebens",
title       = "The distribution of realized stock return volatility",
journal     = "Journal of Financial Economics",
year        = 2001,
volume      = 61,
number      = 1,
month       = "July",
pages       = "43--76",
}

@unpublished{gavazzoni-santacreu-2015,
Author = {Gavazzoni, Federico and Ana Maria Santacreu},
Note = {manuscript, December},
Title = {International R\&D spillovers and Asset prices},
Year = {2015}
}

@article{segal-shaliastovich-yaron-2013,
Author = {Gill, Segal and Ivan Shaliastovich and Amir Yaron},
Journal = {Journal of Financial Economics},
Title = {Good and bad uncertainty: macroeconomic and financial market implications},
Volume={117},
Pages={369-397},
Year = {2015}
}

\end{filecontents*}
\usepackage[round,authoryear,comma]{natbib}
\bibliographystyle{jf_nyu}  % or: jf3
\begin{document}
Here's the output \\
\cite{abd:2007}\\
\cite{abde:2001}\\
\cite{gavazzoni-santacreu-2015}\\
\cite{segal-shaliastovich-yaron-2013}\\
\bibliography{\jobname}
\end{document}


Now that you pointed us at the correct bib style to modify here is a much shorter replacement for format.lab.names:

FUNCTION {format.lab.names}
{ 's :=
s num.names$'numnames := s #1 "{vv~}{ll}" format.name$
numnames #1 >
{ s #2 "{vv~}{ll}" format.name$'t := numnames #2 > t "others" = or { " et~al." * } { " and " * t * } if$
}
'skip$if$
}


On your sample file (slightly tidied, see below) it produces

The function works as follows. First store the list of authors in s. Store the number of authors in numnames. Format the first (#1) entry and output it. Then if there is more than one name, format the next name and assign it to t. If t was "others" or there actually are more than two authors output et al. others output the second (final) author preceeded by and.

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{abd:2007,
author      = "Torben G. Andersen and Tim Bollerslev and Francis X. Diebold",
title       = "Roughing it up: {Including} jump components in the
measurement, modeling and forecasting of return volatility",
journal     = "Review of Economics and Statistics",
year        = 2007,
volume      = 89,
number      = 4,
month       = "November",
pages       = "701--720",
}

@article{abde:2001,
author      = "Torben G. Andersen and Tim Bollerslev and Francis X. Diebold
and Heiko Ebens",
title       = "The distribution of realized stock return volatility",
journal     = "Journal of Financial Economics",
year        = 2001,
volume      = 61,
number      = 1,
month       = "July",
pages       = "43--76",
}

@unpublished{gavazzoni-santacreu-2015,
Author = {Gavazzoni, Federico and Ana Maria Santacreu},
Note = {manuscript, December},
Title = {International R\&D spillovers and Asset prices},
Year = {2015}
}

@article{segal-shaliastovich-yaron-2013,
Author = {Gill, Segal and Ivan Shaliastovich and Amir Yaron},
Journal = {Journal of Financial Economics},
Title = {Good and bad uncertainty: macroeconomic and financial market implications},
Volume={117},
Pages={369-397},
Year = {2015}
}

\end{filecontents*}
\usepackage[round,authoryear,comma]{natbib}

\bibliographystyle{jf1}  % or: jf3

\begin{document}
Here's the output

\cite{abd:2007}

\cite{abde:2001}

\cite{gavazzoni-santacreu-2015}

\cite{segal-shaliastovich-yaron-2013}

\bibliography{\jobname}

\end{document}

• Thank you @Andrew Swann. I actually need to write Author et al. (year) whenever I have strictly more than two authors (3 and up). I tried changing some of the ints in there (for num.names and so forth e.g. #2 and #1 as you said) but couldn't quite get it to work which is why I restored to Mico's function and started reading Tame the Beast. – y1code Jan 19 '17 at 19:45
• Isn't that the standard behaviour of the style you link to? – Andrew Swann Jan 19 '17 at 19:47
• If I just download the linked .bst file from berkeley, make no modifications, and compile the above document (with \bibliographystyle{jf} then citations with three or more authors are abbreviated (both with \citet and with \cite). If this isn't working for you then you need to post code showing how you make the citations. – Andrew Swann Jan 20 '17 at 15:57
• Hi Andrew. I apologize for the delay and for the confusion. I could post only one link in my original question and deleted the wrong one (I had originally included both links to the jf.str files for completeness). This is the .str I am trying to edit: pages.stern.nyu.edu/~dbackus/GE_asset_pricing/BGTZ/jf.bst It conforms to the idiosyncrasies of Econometrica's publication requirements. I edited the original question to reflect this. I can fix the .str from Berkeley to do what I want (i.e. truncate labels when more than 2 authors are present), but not this one from NYU. – y1code Jan 23 '17 at 15:09
• OK - I have replaced my previous answer with code relevant for this new bib style. – Andrew Swann Jan 23 '17 at 19:00