1
votes

I have an Rmd file and want to convert it into a PDF with knitr-pandoc-latex. Here's a small example that works as intended:

---
title: "Minimal Working Example"
author: Author Psaroudakis
date: "August 27th 2018"
output: pdf_document
---

```{r boxplot, dev='pdf'}
boxplot(mtcars$disp ~ mtcars$cyl)
```

that is knitted to:

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

which can be easily turned into a PDF with pandoc. But if I want to resize the plot with out.width, knitr turns it into HTML code, but I want to create a PDF, not a HTML page!

…    
```{r boxplot, dev='pdf', out.width='50%'}
boxplot(mtcars$disp ~ mtcars$cyl)
```

is rendered to:

---
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" />

Does anybody have a solution for this? I've tried opts_knit$set(out.format="latex"); but it didn't make any difference. Thank you in advance!

1

1 Answers

0
votes

I don't see a problem. When I create your test document, and run

rmarkdown::render("test.Rmd")

(or click on Knit in RStudio), I get the figure at the requested width. Perhaps your unstated method of converting to PDF is the problem?