如何在减价时调整图片大小?

时间:2019-12-11 01:05:33

标签: image rstudio size markdown r-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}的标题。

还有其他方法可以更改图像的大小吗?

2 个答案:

答案 0 :(得分:0)

Pandoc支持image dimensions

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

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

答案 1 :(得分:0)

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

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

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

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