【发布时间】:2018-07-05 02:44:20
【问题描述】:
我正在使用 RMarkdown 创建一个 html 文件(我的首选格式)。然后我使用officer包创建一个powerpoint(PPT)(其他人的首选格式),读取在我编织文档时自动创建和保存的.png图像(我相信这是指定fig.path时的默认值)。
为了在整个 PPT 图中获得一致的字体大小,我在每个 knitr 块中指定 fig.width, out.width 等以等于相关的 PPT 占位符尺寸。例如,如果 PPT 占位符是 5.29 英寸高 x 5.89 英寸宽,那么在我指定的 knitr 块中,out.height="5.29in", out.width="5.89in", fig.height=5.29, fig.width=5.89)。这似乎适用于 PPT 文件,但它会导致 HTML 文件的数字非常小。有没有办法让 knitr 代码同时适用于 html 和 PPT,而无需专门保存图像,例如使用 ggsave()?
以下是一些自动生成的测试代码:
---
title: "Test_Figure_Size"
output:
html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(fig.path = "Delete_Me/", echo=FALSE)
```
When you include out.height, out.width the figure is extremely small in the knitted html document, but perfectly sized as a .png file.
```{r pressure, echo=FALSE, out.height="5.29in", out.width="5.89in", fig.height=5.29, fig.width=5.89}
plot(pressure)
```
【问题讨论】:
标签: r r-markdown knitr