Search code examples
r-markdownbibtex

Bibtex in Rmarkdown - First and and last names of second author get swapped in citation


As the title says, I use Rmarkdown to write a document.

I use the following text at the top of the .Rmd document:

    ---
title: "Title"
author: "Me"
date: "September 10, 2018"
output:
  pdf_document: default
  html_document: default
bibliography: bibliography.bib
---

And then I use the following code in my bibliography.bib document, which, according to the document properties is a bibtex file:

@article{Brooks98,
    author={ Brooks, S. P. and Gelman, A.},
    title={Interface foundation of america general methods for monitoring convergence of iterative simulations general methods for monitoring convergence of iterative simulations},
    year={1998},
    journal={Journal of Computational and Graphical Statistics},    
    volume=7,
    issue=4,
    pages=434-455 
}

I expect to get

Brooks, S. P. and Gelman, A. 1998

but instead I get

Brooks, S. P., and A. Gelman. 1998

My question is, what causes this and how do I solve the problem?


Solution

  • You have to change your citation style. One simple solution would be to use bibtex together with natbib and apalike:

    ---
    title: "Title"
    author: "Me"
    date: "September 10, 2018"
    output:
      pdf_document:
        citation_package: natbib
      html_document: default
    bibliography: bibliography.bib
    biblio-style: apalike
    ---
    

    (Note that you will have to use pages={434-455} for this to work.)

    If there are other aspects of the citation style that do not fit, you can have a look at this answer for ways of finding other styles. Another alternative would be biblatex.

    The default, which I am less familiar with, is to use pandoc-citeproc, which uses CSL files to define the style. See here for resources about additional CSL styles: https://citationstyles.org/