For pdf figures, the fig.width and fig.height chunk options are only changing the proportions of the 2"x2" figure in my word document. I can't seem to control the size of the pdf figure as I can with png figures knitted from R Markdown into a word document.
---
title: "Controlling PDF figure size in MS Word output"
output: word_document
---
```{r global_options, include=FALSE}
knitr::opts_chunk$set(fig.path='02_Figs/', fig.show='asis', dev = 'pdf',
include=FALSE, warning=FALSE, message=FALSE)
```
# Fig. 1. Small Plot
```{r include=TRUE, echo=FALSE, fig.width=2, fig.height=3, fig.keep='high'}
with(mtcars, plot(mpg~wt))
```
# Fig. 2. Big Plot
```{r include=TRUE, echo=FALSE, fig.width=4, fig.height=6, fig.keep='high'}
with(mtcars, plot(mpg~wt))
```
Updating to the latest version of Pandoc 1.17.1 solved this problem. Now pdf images display fine.
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