2
votes

I'm using Rmarkdownv2 to generate a pdf file with some local images. But it seems that the image was converted to a larger size with lower resolution in the rendered pdf, compared to the html. The code I'm currently using for the image is something like: ![alt text](figures/fig1.png)

Is there any way to control the image size in the pdf? I also tried

pdf_document: fig_height: 1 fig_width: 2

But that didn't work. Thanks in advance.

1

1 Answers

4
votes

You can use the development version of knitr (>= v1.11.22) and the include_graphics() function, e.g.

```{r out.width='70%'}
knitr::include_graphics('figures/fig1.png')
```

If you want a figure caption, just use the chunk option fig.cap = 'A figure caption.'