1

I have a lot of articles writed by Lionel Ho and co-workers. I use natbib package and plainnat style. When I compile, the bibliography is not sorted by the last name of the second author. How can I solve it?

\documentclass[10pt,a4paper]{article}
\usepackage[top=1cm,bottom=1cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[comma,authoryear,round,sort]{natbib}
\bibliographystyle{plainnat}
\setcitestyle{citesep={;},yysep={;}}
\begin{filecontents*}{\jobname.bib}
@Article{Ho2012,
  author   = {Ho, Lionel and Dreyfus, J. and Boyer, J. and Lowe, T. and Bustamante, H. and Duker, P. and Meli, T. and Newcombe, G.},
  title    = {Fate of...},
  year     = {2012},
}

@Article{Ho2007,
  author   = {Ho, Lionel and Hoefel, D. and Saint, C. P. and Newcombe, Gayle},
  title    = {Isolation...},
  year     = {2007},}

@Article{Ho2008,
  author  = {Ho, Lionel and Slyman, Najwa and Kaeding, Uwe and Newcombe, Gayle},
  title   = {Optimizing...},
  year    = {2008},}
\end{filecontents*}
\begin{document} 
\citep{Ho2012,Ho2007,Ho2008}
\bibliography{\jobname}
\end{document}

The result:

enter image description here

I tried erasing the sort option

\usepackage[comma,authoryear,round]{natbib}

but the result is the same

5
  • The scheme is author-year, so it first sorts by first author, then by year, so the sorting is correct. – Henri Menke Jul 4 '17 at 23:53
  • @HenriMenke Right, but it's impossible to sort by allthe authors first and then by year? – Daniel Valencia C. Jul 5 '17 at 0:01
  • It's not impossible but it doesn't make sense either. – Henri Menke Jul 5 '17 at 0:33
  • 1
    plainnat is "special" in that it sorts only on the first-placed author's surname, not on all authors' surnames. Other bibliography styles have other sorting criteria. You may want to look into running the makebst utility of the custom-bib package to create a bespoke bib style file that incorporates all of your formatting requirements. The utility is menu-driven; the output of a run is the bst file. – Mico Jul 5 '17 at 5:27
  • @HenriMenke - Various other authoryear-based bibtex style files do sort by all authors' surnames, not just the first author's surname. plainnat's sorting habits are certainly not universal. – Mico Jul 5 '17 at 5:44
2

A quick fix to your issue might go along the lines of the following code:

% start of bib file
@preamble{ " \providecommand{\noopsort[1]{}} " }
@Article{Ho2012,
  author   = {Ho, Lionel and Dreyfus, J. and Boyer, J. and Lowe, T. and Bustamante, H. and Duker, P. and Meli, T. and Newcombe, G.},
  title    = {Fate of...},
  year     = {\noopsort{c}2012},}
@Article{Ho2007,
  author   = {Ho, Lionel and Hoefel, D. and Saint, C. P. and Newcombe, Gayle},
  title    = {Isolation...},
  year     = {\noopsort{a}2007},}
@Article{Ho2008,
  author  = {Ho, Lionel and Slyman, Najwa and Kaeding, Uwe and Newcombe, Gayle},
  title   = {Optimizing...},
  year    = {\noopsort{b}2008},}
% bib file continues...

The \noopsort macro does nothing, as far as LaTeX is concerned, but it plays a role during BibTeX's operations. Basically, BibTeX "sees" 3 entries, with year fields given by "a2007", "b2008", and "c2012"; guess how they get sorted. The "a", "b", and "c" particles "disappear" during subsequent processing by LaTeX.


A more thorough fix, to ensure that sorting is performed automatically according to all authors' surnames, involves modifying (a copy of) the file plainnat.bst. I suggest you proceed as follows:

  • Find the files plainnat.bst and chicago.bst in your TeX distribution. (Why chicago.bst, you might ask? It's because it's a bib style that happens to perform sorting based on all authors' surnames.) Make a copy of plainnat.bst and call the copy, say plainnat-mod.bst. Do not edit an original file of the TeX distribution directly.

  • Open the files plainnat-mod.bst and chicago.bst in a text editor. The program you use to edit your tex files will do fine.

  • In the files plainnat-mod.bst and chicago.bst, locate the function called sort.format.names. (In my copies of these files, the function starts on line 1207 and line 1407, respectively.)

  • In the file plainnat-mod.bst, delete all 29 lines (1207 thru 1235) of the function sort.format.names. Copy and paste all 21 lines (1407 thru 1427) from the function sort.format.names in chicago.bst to the place in plainnat-mod.bst where you just deleted a bunch of lines.

  • Close the file chicago.bst, and save and close the file plainnat-mod.bst. Save the latter file either in the directory where your main tex file is located or in a directory that's searched by BibTeX. If you choose the latter option, be sure to update the filename database of your TeX distribution appropriately.

  • In your main tex file, change the instruction \bibliographystyle{plainnat-mod} to \bibliographystyle{plainnat}. Then, perform a full recompile cycle (latex, bibtex, and latex twice more) to fully propagate all changes.

Happy BibTeXing!

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.