r编织的word文档图自动调整大小 [英] r knit word document plots automatically re-sized

查看:111
本文介绍了r编织的word文档图自动调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将绘图添加到Word文档中.当页面尺寸设置为合法且页边距很窄时,我希望该图最大化可用区域.我可以设置fig.width和fig.height,但似乎图会自动调整大小以适合具有正常页边距的默认页面大小(字母).

I am trying to add a plot to a word document. I would like the plot to maximize the area available when the page size is set to legal with narrow margins. I can set the fig.width and fig.height but it seems the plots get automatically re-sized to fit the default page size (letter) with normal margins.

这是一个产生相同结果的示例.rmd文件:

Here is a sample .rmd file that produces the same results:

---
title: "plot-resize"
output: word_document
---

Plot with the height set to 3" and the width to 7.5":

```{r, echo = FALSE, fig.height=3, fig.width=7.5, warning=FALSE, message=FALSE}
plot(cars)
```

However when the word document is created the image is automatically 
re-sized to 79% of this. 

我可以用文字重新调整图的大小,但是不必这么做会很高兴.

I can re-size the plot in word, but it would be nice to not have to.

是否可以在.rmd文件中设置页面大小和页边距?

Is there a way to set the page size and margins in the .rmd file?

是否有一种方法可以确保情节保持在指定的大小,即使它们不适合所创建的Word文档的空白?

Is there a way to ensure that the plots stay at the specified size even if they do not fit within the margins of the created word document?

推荐答案

您可以重做MS Word模板文件-请参见

You can redo the MS Word template file - see http://rmarkdown.rstudio.com/articles_docx.html - you would have to change your margins to narrow (0.5") in the MS Word template file you are using (Under the Layout ribbon). Then, right click on the figure and select size and position, and then adjust scale height and width to 100%. You would then have to save your template file (and don't forget to close it!) and then add this to your YAML:

title: "plot-resize"
output:
  word_document:
    reference_docx: mynew_template.docx

这篇关于r编织的word文档图自动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆