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.
As you can see, first, write pandoc to execute any pandoc command, and then write the file name of a file with extension which you want to convert to a markdown file. The -o stands for output file name and provide name of the file with extension to which it should be converted.
Inserting Citations. You insert citations by either using the Insert -> Citation command or by using markdown syntax directly (e.g. [@cite] or @cite ) . Citations go inside square brackets and are separated by semicolons.
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"
]
---
I had the same problem you have. Perhaps not a real answer to your question, but you might want to take a look at David Gohel's r package ReporteRs http://davidgohel.github.io/ReporteRs/gettingstarted.html He made it easy to let r generate .docx files. I have already had astonishing results!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With