I'm writing a paper in LaTeX. I'm working with the natbib package and the plainnat style for the citations and references. The problem is how the citations and the references is being sorted.

I want the citations sorted by year (for the same year alphabeticaly) and the references sorted alphabeticaly by the author's last name. How can I do it?

My code:

    \usepackage[left=2.00cm, right=2.00cm, top=2.00cm, bottom=2.00cm]{geometry}

     author = {Ho, L. and Auntz, K. and Zwitter, B. F. and Valencia, D.},
     year = {2010},
     title = {Title Example 1},
     author = {Ho, L. and Yelp, A. and Richter, G. and Gregory, K. T.},
     year = {2005},
     title = {Title Example 2},
     author = {Ho, L. Abrook, H. and Dolman, R. G. and Fjing, H. and Ho, S. and Xerem, R.},
     year = {2013},
     title = {Title Example 3},
     author = {Di Bernardo, L. and Mc Daug, C. and Coelho, L},
     year = {2000},
     title = {Title Example 4},
     author = {Gomes, L. N. L. and Ginoris, Y. P and Brand\~{a}o, C. C. S.},
     year = {2010},
     title = {Title Example 5},

    Hi, this is an example. First a citation \citep{A,B},
then an inline citation \citet{B}.
Another citation \citep{C,D} and
the last one \citep{A,E}

And the result with the observations:

enter image description here


1 Answer 1


If you add the sort option to natbib


then it sorts first by author name and then by year. You seem to want to sort by year first and then author name. I don't believe natbib has support for that.

Edit: It's pretty easy to modify a copy of plainnat.bst to sort first by year than by name. This doesn't seem to be what you're showing in your example, but maybe it's what you want.

First, make a copy of plainnat.bst in your current directory and call it yearnat.bst. On my machine I can do that via

$ cp `kpsewhich plainnat.bst` yearnat.bst

Edit yearnat.bst and change the presort function to the following.

FUNCTION {presort}
{ calc.label
  label sortify
  "    "
  year field.or.null sortify
  "    "
  type$ "book" =
  type$ "inbook" =
    { type$ "proceedings" =
        { type$ "manual" =
  "    "
  #1 entry.max$ substring$
  'sort.label :=
  sort.label *
  #1 entry.max$ substring$
  'sort.key$ :=

All this does is move the year field to the beginning of the sort key.

Now compile your example with the addition of the sort option as above and the \bibliographystyle{yearnat}. Here's the result.

enter image description here

You can see that everything is sorted first by year, and then by author. If you want to know how that works, you should read btxhak (or by running texdoc btxhak).

  • the sort option sort the citations by year first as I want. But the references still are unsorted as I want Commented Jun 29, 2017 at 21:17
  • 1
    @DanielValencia No, that's not correct. sort puts them in the same order as the references. BibTeX (and the .bst used) sort the references. I don't know off-hand how the sorting is controlled, but given that different .bsts do it differently, you may be able to make a copy of, and edit, plainnat.bst to get the sorting behavior you want.
    – TH.
    Commented Jun 29, 2017 at 22:35
  • How would you modify the yearnat.bst file to sort in reverse chronological order?
    – user257566
    Commented May 7, 2020 at 17:47
  • @user257566, Although it would be a bit of work, this answer may answer your question about modifying a .bst file to customize the sorting.
    – possum
    Commented May 9, 2023 at 21:21

You must log in to answer this question.

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