[Tex/LaTex] Author’s last name first using plainnat

bibliographiesbibtexnatbib

running the risk that this has been asked before, I'll ask it again as commonly suggested solutions didn't seem to work:

My bibliography stubbornly gives first names first, but I'd like it the other way round.

I followed the suggestions re. changing the .bst file and now have the following name format function:

FUNCTION {format.names}
{ 's :=
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }
    { s nameptr "{vv~}{ll}{, f.}{, jj}" format.name$ 't :=
      nameptr #1 >
        { namesleft #1 >
            { ", " * t * }
            { numnames #2 >
                { "," * }
                'skip$
              if$
              t "others" =
                { " et~al." * }
                { " and " * t * }
              if$
            }
          if$
        }
        't
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }

A sample bibliography entry is

@article{ghysels2007midas,
  title={MIDAS regressions: Further results and new directions},
  author={Ghysels, Eric and Sinko, Arthur and Valkanov, Rossen},
  journal={Econometric Reviews},
  volume={26},
  number={1},
  pages={53--90},
  year={2007},
  publisher={Taylor \& Francis}
}

printing this

Eric Ghysels, Arthur Sinko, and Rossen Valkanov. Midas regressions:
Further results and new directions. Econometric Reviews, 26(1):53–90,
2007.

As you can see, we've got first names first, which is a bit of a mystery to me. Any help on solving this would be greatly appreciated!

Best Answer

I copied plainnat.bst in the working directory as plainnat-swapnames.bst, making the suggested edit to the format.names function.

Then I composed the following minimal example:

\begin{filecontents*}{\jobname.bib}
@article{ghysels2007midas,
  title={MIDAS regressions: Further results and new directions},
  author={Ghysels, Eric and Sinko, Arthur and Valkanov, Rossen},
  journal={Econometric Reviews},
  volume={26},
  number={1},
  pages={53--90},
  year={2007},
  publisher={Taylor \& Francis}
}
\end{filecontents*}

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

\begin{document}

\cite{ghysels2007midas}

\bibliographystyle{plainnat-swapnames}
\bibliography{\jobname}

\end{document}

Usage of filecontents* is only for making the example self-contained, you can use whatever bib file you want.

Running LaTeX, BibTeX, LaTeX yielded the following result.

enter image description here