![](/img/trans.png)
[英]How to bring caption (with transperancy) into an image in r markdown
[英]R Markdown image caption not showing
在 R Markdown 中,我正在尝试为图像添加标题,但未显示。 使用 RStudio 和“Knit to HTML”代码和 HTML 的屏幕截图如下。 没有标题,即使它在括号中。
# First test
## SubHeader 1
kl;jdafkjjdsfajk;
![literally the most amazing apple ever](C:/Users/.../Stemilt-Cosmic-Crisp-Apple-2019.jpg)
这个类似的问题没有答案,但看起来需要“fig.cap”。 我尝试将{r fig.cap = "caption2- literally the most amazing apple ever"}
添加到代码中(如上面的第 5 行)但它不起作用,它只是打印了输入的确切文本、花括号和全部。
也许我想太多了,但我看到 HTML output 文档,你需要fig_caption: true
在你的 YAML 中,以便用标题渲染该图。 在 R markdown 报告中发布图像时,我使用了一些软件包。
---
title: "test"
output:
html_document:
fig_caption: true
---
```{r setup, fig.cap="This is a screenshot",fig.align = 'center', warning=FALSE, message=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(ggplot2)
library(cowplot)
library(magick)
ggdraw() +
draw_image("delete.png")
```
您可以将fig.cap
参数用于带有knitr::include_graphics
的 R 代码块,或者通过 markdown 图像链接提供标题。
一个最小的例子:
---
title: "Untitled"
output: html_document
---
# Option 1: `fig.cap` with `include_graphics`
```{r echo=FALSE, fig.cap = "Figure caption"}
knitr::include_graphics("https://mathworld.wolfram.com/images/gifs/rabbduck.jpg")
```
# Option 2: The markdown way way
![Figure caption](https://mathworld.wolfram.com/images/gifs/rabbduck.jpg)
生产
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.