What is the syntax for using pandoc with RStudio Markdown for conversion to MS Word? How can it be used to include bibliography and inline citations?

knitr, r, r-markdown, rstudio

Solution

You need to enclose your arguments in quotation marks, (`""`) and be separated by commas

If I have a bibliography file called `biblio.bib` and the `csl` file is `chicago-author-date.csl`,

the following will front matter will work

---
title: "Example Doc"
output:
  word_document:
    pandoc_args: [
      "--csl", "chicago-author-date.csl",
      "--bibliography", "biblio.bib"
    ]
---

Problem

RStudio now supports directly knitting .Rmd files into docx format --pure gold for someone who is the technical side of most collaborations where the final revisions of the article are going to be done in Word. However, I had just barely figured out how to get R, knitr, and pandoc to play with each other and so I am looking for some help in making the transition while the documentation is still in its infancy. My file converts with no problem using the yaml code block as follows: ``` --- title: "Testing" output: word_document: fig_width: 5 fig_height: 5 fig_caption: true --- ``` and the documentation says that, assuming I have a file 'myLibrary.bib' in the same directory as my .Rmd file, I should be able to add something like this: ``` pandoc_args: [ bibliography: "myLibrary.bib" ] ``` or ``` pandoc_args: [ --bibliography "myLibrary.bib" ] ``` but I can't seem to find any examples of how to format this in the obvious places: here or here Bonus points for code that also links the bibliography to the myJournalFormat.csl file also in the same folder.

Original source