[Tex/LaTex] natbib: how to display partial authors in reference

author-numbernatbib

I am using natbib to manage my references, now I have a problem: my reference list always displays all author names of an article:

Marcel H. Schulz, Daniel R. Zerbino, Martin Vingron, and Ewan Birney. Oases: robust
de novo RNA-seq assembly across the dynamic range of expression levels. Bioinformatics
(Oxford, England), 28(8):1086–1092, April 2012. 7, 9, 10, 40

I set the options to be:

\usepackage[round, sort, numbers]{natbib}

\bibliographystyle{Latex/Classes/PhDbiblio-url2} 
\renewcommand{\bibname}{References} 
\bibliography{9_backmatter/references} 

And use cite{} to cite the references. I tried to used biblatex, but seems it is not compatible with natbib:

\usepackage[maxnames=3]{biblatex}

I want to display at most 3 authors in full name, otherwise display as et al. How to set it?

================

Edit: The file PhDbiblio-url2.bst can be found here: https://bitbucket.org/dekz/thesis/src/3f8d8507cddc/Latex/Classes/PhDbiblio-url2.bst

It seems like the lines here define the display of authors:

INTEGERS { nameptr namesleft numnames }

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

But how to set the numnames from the tex file?

Best Answer

I believe that you need to set the number of authors before et al. in the .bst itself, rather than from the LaTeX.

I think the below does what you want, I have adapted it from a .bst I created using makebst. Just replace format.names in your .bst.

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

If you want to change the number of authors before the et al. is used, change #3 from three to the correct number. If you want to change the number of names that appear before et al. in the list, then change the #1 following nameptr on the line preceding #1 + = from one to the correct number.