【问题标题】:How do I resize an image on markdown?如何在 Markdown 上调整图像大小?
【发布时间】:2020-04-04 05:57:21
【问题描述】:

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

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

但是,我在网上查看,只能找到切换到我的 pdf 文件中没有显示的 html <img src="icon.png" width="200">,或者将宽度和高度附加到末尾:

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

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

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

【问题讨论】:

标签: image rstudio size markdown r-markdown


【解决方案1】:

Pandoc 支持image dimensions:

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

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

【讨论】:

  • 我正在尝试在 rstudio markdown 而不是 pandoc 中执行此操作。当我在 Markdown 中添加该文档时,该文档甚至无法编译。
  • rstudio 在后台使用 pandoc...但您需要最新版本..
【解决方案2】:

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

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-14
    • 1970-01-01
    • 2014-08-14
    • 1970-01-01
    • 1970-01-01
    • 2021-08-15
    • 2012-10-06
    相关资源
    最近更新 更多