1

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

![figure description here \label{fig:fig1}](../images/static/imageFile.png)

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:

![figure description here \label{fig:fig1}](../images/static/imageFile.png){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?

Waylan
  • 37,164
  • 12
  • 83
  • 109
Fallen
  • 23
  • 1
  • 6

2 Answers2

4

Pandoc supports image dimensions:

![figure description](imageFile.png){width=250}

Make sure you're using a recent pandoc version.

mb21
  • 34,845
  • 8
  • 116
  • 142
  • I'm trying to do this in rstudio markdown and not pandoc. The document doesn't even compile when I add that in markdown. – Fallen Dec 11 '19 at 14:04
  • rstudio is using pandoc under the hood... but you need a recent version.. – mb21 Dec 11 '19 at 15:27
0

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")
joshpk
  • 729
  • 4
  • 11