Search code examples
imagerstudiosizemarkdownr-markdown

How do I resize an image on markdown?


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?


Solution

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