I imported an image that I made in matlab into markdown in rstudio by using:

However, I looked online and could only find either switching to html <img src="icon.png" width="200">
which doesn't show up on my pdf file, or appending the width and height to the end:
{width=250px}
Just adds the caption of {width=250px} to the end of my image.
Is there any other way I can change the size of the image?
Another option is to use knitr::include_graphics()
and adjust the size using the chunk option out.width
. The dpi
setting would also change the size of the image in html output. See here for more details on the chunk options.
```{r, out.width = '250px'}
knitr::include_graphics('imageFile.png')
```
You can also set these options globally if you want to with this code at the top of the script.
knitr::opts_chunk$set(out.width="250px")