添加表标题编号R-Markdown

问题描述 投票:2回答:1

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

它说当你为kable函数添加一个标题时,它会自动标记为编号。但是,我只获得标签的“文本”部分而没有数字。

---
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)

```

非常感谢您帮助理解如何做到这一点。

r r-markdown bookdown kable
1个回答
1
投票

由于bookdown标题,你没有使用rmarkdown::html_document()output。您需要将标题更改为

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

为了在单个文件项目中使用bookdown功能。对于实际书籍,最好让bookdown包装为您设置骨架,例如:通过RStudio加载项。

© www.soinside.com 2019 - 2024. All rights reserved.