1

By default, in the reference list generated by using the plainnat, the references are ordered by their last names.

How to order them by their first names?

Here I attach an MWE

article.tex

\documentclass[]{article}
\usepackage{natbib}

\begin{document}

Test \citep{a1,a2,a3}

\bibliographystyle{plainnat}
\bibliography{refs}

\end{document}

refs.bib

@article{a1,
    title={Test paper 1},
    author={Albert Zwick},
    journal={Nature},
    year={2000}
}
@article{a2,
    title={Test paper 2},
    author={Christ Johnson},
    journal={Nature},
    year={2000}
}
@article{a3,
    title={Test paper 3},
    author={John Doe},
    journal={Nature},
    year={2000}
}

By default we will get

enter image description here

which are ordered by the last name. How to order by first name while sticking with plainatstyle?

4
  • apalike does not sort by given names either. It also sorts by the author's family (last) name, what's more it even inverts the name order in the bibliography so the family name comes first.
    – moewe
    Apr 23 '21 at 12:49
  • @moewe ah yes, I didn't even notice that. I corrected my questio now. Apr 23 '21 at 12:50
  • So you really want to sort by first names? I'm asking again, because that is extremely unusual (at least with Western names) and unexpected for your readers.
    – moewe
    Apr 23 '21 at 12:54
  • I understand the style might look weird, but I think at least it could be a good tex practice ^ Apr 23 '21 at 12:56
1

Sorting by given (first) name is extremely unusual with Western names. With natbib's authoryear style it also makes references much harder to find in the bibliography since your readers only know the family (last) names.

Anyway, to achieve the desired sorting you need to modify the .bst file

  1. Locate plainnat.bst on your machine. You can do this by typing kpsewhich plainnat.bst into the command line/terminal. Alternatively, obtain a copy of the file from CTAN http://mirrors.ctan.org/macros/latex/contrib/natbib/plainnat.bst

  2. Copy the file to a location where TeX can find it. The document directory will do fine.

  3. Rename the file to plainnat-sortby-first.bst

  4. Open the file and replace the block starting with FUNCTION {sort.format.names} (ll. 1207-1235 in my version) by

    FUNCTION {sort.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 "others" = and
                { "zzzzz" * }
                { numnames #2 > nameptr #2 = and
                    { "zz" * year field.or.null * "   " * }
                    'skip$
                  if$
                  t sortify *
                }
              if$
            }
            { t sortify * }
          if$
          nameptr #1 + 'nameptr :=
          namesleft #1 - 'namesleft :=
        }
      while$
    }
    

The only change here is from s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't := to s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=.

  1. Add your name and date and explain the modification in the comments at the top of the file.

  2. Use \bibliographystyle{plainnat-sortby-first.bst} instead of \bibliographystyle{plainnat} in your document.

As alternative to steps 1 to 5 above, you can get plainnat-sortby-first.bst from https://gist.github.com/moewew/203188e9933fdac3873601770b932357.

\documentclass[]{article}
\usepackage{natbib}

\begin{filecontents}{\jobname.bib}
@article{a1,
  title   = {Test paper 1},
  author  = {Albert Zwick},
  journal = {Nature},
  year    = {2000},
}
@article{a2,
  title   = {Test paper 2},
  author  = {Christ Johnson},
  journal = {Nature},
  year    = {2000},
}
@article{a3,
  title   = {Test paper 3},
  author  = {John Doe},
  journal = {Nature},
  year    = {2000},
}
\end{filecontents}

\begin{document}
Test \citep{a1,a2,a3}

\bibliographystyle{plainnat-sortby-first}
\bibliography{\jobname}
\end{document}

Albert Zwick. Test paper 1. Nature, 2000.//Christ Johnson. Test paper 2. Nature, 2000.//John Doe. Test paper 3. Nature, 2000.


If you want given-family order everywhere (not just for sorting, but also in citations), get plainnat-firstlast.bst from https://gist.github.com/moewew/008625af47bc58c76e2e89ef2789fa1a.

1

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.