如何在降价时调整图像大小?

How do I resize an image on markdown?

我使用以下方法将我在 matlab 中制作的图像导入到 rstudio 中的 markdown 中:

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

但是,我在网上查了一下,只能找到切换到 html <img src="icon.png" width="200"> 的方法,这并没有出现在我的 pdf 文件中,或者将宽度和高度附加到末尾:

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

只需将 {width=250px} 的标题添加到我的图片末尾。

有没有其他方法可以改变图片的大小?

Pandoc 支持 image dimensions:

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

确保您使用的是最新的 pandoc 版本。

另一种选择是使用 knitr::include_graphics() 并使用块选项 out.width 调整大小。 dpi 设置还会更改 html 输出中图像的大小。有关块选项的更多详细信息,请参阅 here

```{r, out.width = '250px'}
knitr::include_graphics('imageFile.png')
```

如果您想在脚本顶部使用此代码,也可以全局设置这些选项。

knitr::opts_chunk$set(out.width="250px")