How to edit the .bst file to order reference by only lead author then publishing year. Most of refercence style order all the authors first. I try to edit the FUNCTION {sort.format.names} in .bst file, but not familiar with the syntax.

1 Answer 1


I can't remember the logic with complete certainty, but I think you've found the right function to edit. The .bst syntax is slightly ... odd, but the key couple of lines in plain.bst are:

  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }

(this is from plain.bst – many other .bst files are derived from this). I suspect that, as a quick hack, if you were to replace that first line with

#1 'numnames :=

then the function would go round the loop only once, and so would add only a single name to the sort key, which would get the effect you're looking for.

To give you an idea of what's going on, the way that BibTeX works here is that:

  1. The ITERATE {presort} call iterates through all of the entries that are to be processed, calling the presort function on each. The presort function, you'll see, defines the magic value sort.key$ for each entry.

  2. The SORT call sorts all the entries in alphabetical order of their sort.key$.

  3. The ITERATE function (which is called twice after SORT, in plain.bst) then runs through each of the entries again, this time in their sorted order. The ITERATE{call.type$} call is what actually writes out the .bbl file, since it calls the function article, or inproceedings, or whatever, as appropriate.

The authoritative documentation for this is in the file btxhak.pdf, which might be on your system already, or which you can find at CTAN.

  • Thank you very much. Your answer is so clear and it does works perfectly.
    – Faye
    Jul 15, 2014 at 3:03
  • (just by the way, if you do make such a change to your .bst file, be sure to rename the file, or things could get terribly confusing...) Jul 15, 2014 at 9:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .