3

I am using natbib and the bibliography style apalike. This looks fine to me but my supervisor wants the bibliography to be sorted according to 1.) first author's surname, 2.) year. So, if I have several papers from the same first author, they should not be sorted by the name of the second author but rather by the publishing year.

What apalike does

  1. Apple, Banana, Pear (2011)
  2. Apple, Pear, Banana (2009)

What I want

  1. Apple, Pear, Banana (2009)
  2. Apple, Banana, Pear (2011)

How can I do this?

1

I will assume your bibliography contains only a handful of entries whose final sorting order depends on whether (a) standard sorting (i.e., based on all authors' surnames) or (b) your supervisor's "special" sorting (i.e, based only on the first author's surname) is in effect. If that's the case, it's almost certainly not worth anyone's time to modify the file apalike.bst. Instead, I suggest you proceed as follows:

  • Make a copy of your bib file. E.g., if the bib file is named mybib.bib, make a copy of this file and call it, say, mybib-harebrained-sorting-order.bib. (Can you guess what I think of your supervisor's requirement?)

  • Add the following line to the top of the new bib file:

    @preamble{ "\providecommand{\noopsort}[1]{} " }
    

    The macro does nothing, as far as LaTeX is concerned; however, as we will see next, it does matter for sorting purposes. (Hence also the name "noopsort"...)

  • Suppose there are the following two entries involving the same three authors (Apple, Banana, and Pear):

    @misc{abp:2011,
      author = "Anna Apple and Bertha Banana and Petunia Pear",
      title  = "Further Thoughts",
      year   = 2011,
    }
    @misc{apb:2009,
      author = "Anna Apple and Petunia Pear and Bertha Banana",
      title  = "Thoughts",
      year   = 2009,
    }
    

    Obviously, if "normal" sorting (i.e., based on all authors' surnames, followed by the publication year) were in effect, the abp:2011 entry would come before the apb:2009 entry.

  • Change the author fields of the two entries by providing targeted \noopsort directives as follows:

    @misc{abp:2011,
      author = "Anna Apple\noopsort{b} and Bertha Banana and Petunia Pear",
      title  = "Further Thoughts",
      year   = 2011,
    }
    @misc{apb:2009,
      author = "Anna Apple\noopsort{a} and Petunia Pear and Bertha Banana",
      title  = "Thoughts",
      year   = 2009,
    }
    

    Observe the two \noopsort directives appended to the first author's surname. During BibTeX's sorting phase (but not, fortunately, during the later LaTeX processing phase...), the first author's surnames of the two entries will be seen as "Applea" and "Appleb", respectively. BibTeX will therefore believe that it's dealing with two distinct surnames. And, since "Applea" precedes "Appleb", alphabetically speaking, apb:2009 will be sorted before abp:2011.

  • Save the new bib file, and change the argument of bibliography from mybib to mybib-harebrained-sorting-order. Finally, be sure to re-run LaTeX, BibTeX, and LaTeX twice more to fully propagate all changes made to the bib file.


The output of a full MWE:

enter image description here

\RequirePackage{filecontents}
\begin{filecontents}{mybib-harebrained-sorting-order.bib}
@preamble{ "\providecommand{\noopsort}[1]{} " }

@misc{abp:2011,
  author = "Anna Apple\noopsort{b} and Bertha Banana and Petunia Pear",
  title  = "Further Thoughts",
  year   = 2011,
}
@misc{apb:2009,
  author = "Anna Apple\noopsort{a} and Petunia Pear and Bertha Banana",
  title  = "Thoughts",
  year   = 2009,
}
\end{filecontents}

\documentclass{article}
\usepackage[authoryear]{natbib}
\bibliographystyle{apalike}
\begin{document}
\nocite{*}
\bibliography{mybib-harebrained-sorting-order}
\end{document}
| improve this answer | |
  • 1
    A closing remark: This type of work should be performed only very late in the authoring process, i.e., only after all bib entries have been decided on. – Mico Oct 23 '16 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.