Skip to content

Instantly share code, notes, and snippets.

@Wacken88
Created January 12, 2019 03:04
Show Gist options
  • Save Wacken88/ba12203094e0ec026f5ffec3cc944a2e to your computer and use it in GitHub Desktop.
Save Wacken88/ba12203094e0ec026f5ffec3cc944a2e to your computer and use it in GitHub Desktop.
FUNCTION { format.names }
{
#3 'maxauthors := % print at most <maxauthors> authors
#2 'cutafter := % only print <cutafter> authors
% if number of authors exceeds <maxauthors>
% Format bibliographical entries with the first author last name first,
% and subsequent authors with initials followed by last name.
% All names are formatted in this routine.
's :=
#1 'nameptr := % nameptr = 1;
s num.names$ 'numnames := % numnames = num.name$(s);
numnames 'namesleft :=
{ namesleft #0 > }
{ nameptr #1 =
%NO: BAD ORDER: {"{" s nameptr "{ff~}{ll}{, jj}{, vv}" format.name$ * "}" * 't := }
%NO: BAD ORDER: {"{" s nameptr "{ff~}{ll}{, jj}{, vv}" format.name$ * "}" * 't := }
{"\bibinfo{person}{" s nameptr "{ff }{vv }{ll}{, jj}" format.name$ * "}" * 't := }
{"\bibinfo{person}{" s nameptr "{ff }{vv }{ll}{, jj}" format.name$ * "}" * 't := }
if$
nameptr #1 >
{
numnames maxauthors >
{
nameptr cutafter >
{
"\bibinfo{person}{others}" 't :=
#0 'namesleft :=
#0 'numnames :=
}
'skip$
if$
}
'skip$
if$
namesleft #1 >
{ ", " * t * }
{
numnames #2 >
{ "," * }
'skip$
if$
t "\bibinfo{person}{others}" =
{ " {et~al\mbox{.}}" * } % jrh: avoid spacing problems
{ " {and} " * t * } % from Chicago Manual of Style
if$
}
if$
}
't
if$
nameptr #1 + 'nameptr := % nameptr += 1;
namesleft #1 - 'namesleft := % namesleft =- 1;
}
while$
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment