添加 Table 标题编号 R-Markdown

Add Table Caption Number R-Markdown

我无法理解如何将 table 的图形标题编号添加到 R-Markdown 中的 table。我正在使用 bookdown 并且一直在尝试理解文档的 2.5 tables 部分。

它说当您向 kable 函数添加标题时,它会自动标记为编号。但是,我只得到没有数字的标签的 "text" 部分。

---
title: "test"
author: "x"
date: "February 20, 2019"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)

```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

```{r libraries, echo=FALSE}
library(tidyverse, warn.conflicts = T)
library(kableExtra)
library(bookdown)
```


```{r example, echo=T}

head(pressure) %>%
  kable(caption = "Pressure",
        booktabs = T) %>%
  kable_styling(full_width = F)

```

非常感谢您帮助理解如何执行此操作。

由于 output header,您没有使用 bookdown,而是 rmarkdown::html_document()。您需要将 header 更改为

---
title: "test"
author: "x"
date: "February 20, 2019"
output: bookdown::html_document2
---

以便在单个文件项目中使用 bookdown 功能。对于实际书籍,让 bookdown 包 set-up 成为您的骨架是个好主意,例如通过 RStudio add-in.