R Bookdown 图像消失

R Bookdown image disappears

我遇到了 bookdown 问题,不确定原因。

添加图像时(这些是文件,所以我使用 knitr::include_graphics)像这样:

# This is a minimal example

I want the image "mas.gif". Where is it?
```{r mas, echo=F, fig.cap="image", ref.label="fig:mas"}
knitr::include_graphics("mas.gif")
```

Hmmm...no clue!

该块在 epub、md、tex 和 pdf 文件中消失了。

有什么问题吗?它曾经工作过一段时间...

只需删除 , ref.label="fig:mas",像这样

# This is a minimal example

I want the image "mas.gif". Where is it?
```{r mas, echo=F, fig.cap="image"}
knitr::include_graphics("mas.gif")
```

Hmmm...no clue!

查看 documentation by bookdown 软件包的作者:

If we assign a figure caption to a code chunk via the chunk option fig.cap, R plots will be put into figure environments, which will be automatically labeled and numbered, and can also be cross-referenced. The label of a figure environment is generated from the label of the code chunk, e.g., if the chunk label is foo, the figure label will be fig:foo (the prefix fig: is added before foo). To reference a figure, use the syntax \@ref(label), where label is the figure label, e.g., fig:foo.