(This is possible in Rmd to PDF, but not in Rmd to docx as far as I can tell). Reproducibly assigning headers and footers.How to do it (in detail) is the rest of the article, covering all of the above plus Format an Rmd report using the styles reference docx file.Save this document as your style reference docx file.Use R Markdown to create a Word document.The first step towards developing your own Rmd-to-docx superpowers is to heed one sentence from the R Markdown website, “For best results, the reference docx should be a modified version of a docx file produced using R Markdown.” In other words: This post is about how you can learn to do that too (making you happy). I can do reproducible work in R (making me happy) and format the output report in Word (making my collaborators happy). My collaborators, like many folks, use Word and Excel and their work-flows include a lot of point and click, copy and paste, and manual formatting.īut R Markdown (v2) has given me collaboration superpowers! For my portions of the work, I use R and RStudio and my reports are dynamic and reproducible.
Nearly all my professional work is collaborative and nearly all my collaborators are MSOffice users. I assume the reader has RStudio and MSWord installed but otherwise I try not to skip any details. This post is for RStudio users who want to use R Markdown (Rmd) scripts to create Word (docx) documents and would like to improve their control of Word styles and document design.