我有一个Rmd文件,想要使用knitr-pandoc-latex将其转换为PDF。这是一个按预期工作的小例子:
---
title: "Minimal Working Example"
author: Author Psaroudakis
date: "August 27th 2018"
output: pdf_document
---
```{r boxplot, dev='pdf'}
boxplot(mtcars$disp ~ mtcars$cyl)
```
针织的:
---
title: "Minimal Working Example"
author: Author Psaroudakis
date: "August 27th 2018"
output: pdf_document
---
```r
boxplot(mtcars$disp ~ mtcars$cyl)
```
![plot of chunk boxplot](figure/boxplot-1.pdf)
这可以很容易地变成带有pandoc的PDF。但如果我想用out.width
调整情节大小,knitr会把它变成HTML代码,但我想创建一个PDF,而不是HTML页面!
…
```{r boxplot, dev='pdf', out.width='50%'}
boxplot(mtcars$disp ~ mtcars$cyl)
```
呈现为:
---
title: "Minimal Working Example"
author: Author Psaroudakis
date: "August 27th 2018"
output: pdf_document
---
```r
boxplot(mtcars$disp ~ mtcars$cyl)
```
<embed src="figure/boxplot-1.pdf" title="plot of chunk boxplot" alt="plot of chunk boxplot" width="50%" type="application/pdf" />
有人有解决方案吗?我尝试过opts_knit$set(out.format="latex");
,但没有任何区别。先感谢您!
我没有看到问题。当我创建您的测试文档并运行时
rmarkdown::render("test.Rmd")
(或点击RStudio中的Knit),我得到所需宽度的数字。也许你未说明的转换为PDF的方法是问题?