rmarkdown 自动给数字编号

Automatically number figures in rmarkdown

我运行这个代码但是没有编号我的图

## Including Plots

You can also embed plots, for example (Figure \@ref(fig:titanic))

```{r titanic, fig.cap='(ref:titanic)'}
plot(pressure)
```

少了什么?我是否需要加载一个我不知道的库?情节看起来像这样:

我的文件是这样开头的:

---
title: "Untitled"
output:
  html_document:
    fig_caption: true
---

此问题已得到解答here。答案列出了解决问题的几种方法,将文档设置为 bookdown::html_document2 似乎是最简单的解决方案。 IE。修改你的 YAML header:

---
title: "Untitled"
output: bookdown::html_document2
---