Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing word template for knitr in Rmarkdown

I'm using Rstudio to make a markdown document which I want to convert to a word document. I would like to change word template that is automatically generated when you knit to Word. For example, I want the margins to be narrow when I knit to word.

I'm on a Windows 64 bit, with Windows 7.

like image 570
LeslieKish Avatar asked Apr 03 '15 21:04

LeslieKish


People also ask

How do I change a document in R Markdown?

To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.

How can you compile the R Markdown document using knitr package?

The usual way to compile an R Markdown document is to click the Knit button as shown in Figure 2.1, and the corresponding keyboard shortcut is Ctrl + Shift + K ( Cmd + Shift + K on macOS). Under the hood, RStudio calls the function rmarkdown::render() to render the document in a new R session.

How do I make an R Markdown template?

You can create a template for every homework assignment or exercise that you want your students to work through. And they can access all of these templates easily when they go to File > New File > R Markdown . And then select From Template from the dialogue box menu. Your custom R Markdown template will appear there.


1 Answers

I prepared a video for this task. Please see if it helps. Basically you generate a Word document from an arbitrary R Markdown document, then modify the styles in the Word output document, and use this document as the template for future R Markdown documents.

like image 199
Yihui Xie Avatar answered Oct 12 '22 21:10

Yihui Xie