Skip to content

Instantly share code, notes, and snippets.

@rwirth
Created September 14, 2015 08:56
Show Gist options
  • Save rwirth/b3d68e5786b08d019691 to your computer and use it in GitHub Desktop.
Save rwirth/b3d68e5786b08d019691 to your computer and use it in GitHub Desktop.
Limit LaTeX natbib author lists
\newcounter{@maxauthors}
\setcounter{@maxauthors}{3}
\newcounter{@authors}
\def\BibitemOpen{
\setcounter{@authors}{0}
\bibitemOpen
}
%\NewDocumentCommand{\@gobbletoend}{u{,\ }}{\fi\fi\showtokens{#1}}
\NewDocumentCommand{\@gobbletoend}{u{,\ }}{\fi\fi}
\newcommand{\bibinfo@X@author}[1]{%
% \showtokens{#1}
\ifnum \value{@authors} < \value{@maxauthors}%
\stepcounter{@authors}%
#1,%
\else\ifnum \value{@authors} = \value{@maxauthors}%
\stepcounter{@authors}%
\emph{et~al.},\ \@gobbletoend%
\fi\fi%
\@ifnextchar,\@gobble\relax
}
@rwirth
Copy link
Author

rwirth commented Sep 14, 2015

First try, doesn't work in all cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment