fig.width和fig.height不适用于R Markdown的knitr Word输出

时间:2016-06-15 18:30:40

标签: r markdown rstudio knitr

对于pdf数字,fig.width和fig.height块选项仅改变我的word文档中2“x2”数字的比例。我似乎无法控制pdf图的大小,因为我可以将从R Markdown编织成的png图形转换为word文档。

---
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))
```

1 个答案:

答案 0 :(得分:0)

更新到最新版本的Pandoc 1.17.1解决了这个问题。现在pdf图像显示正常。