FMM*_*FMM 4 latex knitr r-markdown
I am having issues when knitting my rmarkdown file to PDF with large plots. The plots get cut when producing the PDF file.
The problem is that I can't find a way to automatically adjust the height and width of all the plots. As I am writing a very large report, I have several plots like this, thus adjusting them separately (through fig.width and fig.height) is out of question.
Is there any package/command that I should use in my YAML or preamble.tex file?
Minimal reproducible example:
---
output: pdf_document
---
## Large Plot
```{r}
library(meta)
data(Fleiss93)
##
m <- metabin(event.e, n.e, event.c, n.c,
data = Fleiss93, studlab = study,
sm = "RR", method = "I")
forest(m)
```
Run Code Online (Sandbox Code Playgroud)
要更改默认设置,请将以下代码块放在文档的早期:
```{r include = FALSE}
knitr::opts_chunk$set(fig.height = 9, fig.width = 7)
```
Run Code Online (Sandbox Code Playgroud)
你也可以使用类似的东西
```{r include = FALSE}
knitr::opts_chunk$set(out.height = "\\textheight", out.width = "\\textwidth")
```
Run Code Online (Sandbox Code Playgroud)
重新缩放图像以尝试完全填充页面。默认情况下knitr会阻止您更改纵横比,但如果您真的想要填充页面、失真和所有内容,请使用
```{r include = FALSE}
knitr::opts_chunk$set(out.height = "\\textheight", out.width = "\\textwidth",
out.extra = "keepaspectratio=false")
```
Run Code Online (Sandbox Code Playgroud)
我建议反对最后的选择;你的情节看起来真的很难看。
更普遍的是:knitr默认值非常好。knitr::opts_chunk$set()当您想要原始默认值时,需要明确指定您使用的每个更改。因此,对于这些奇怪的选项,将选项剪切并粘贴到需要它们的每个块中,并保留默认值可能不是不可能的。