简体   繁体   English

添加表格标题编号 R-Markdown

[英]Add Table Caption Number R-Markdown

I am having trouble understanding how to add a table of figure caption number to a table in R-Markdown.我无法理解如何在 R-Markdown 中将图形标题编号表格添加到表格中。 I'm using bookdown and have been trying to understand the 2.5 tables portion of the documentation.我正在使用bookdown并一直试图理解文档的2.5 表部分。

It says when you add a caption to the kable function it will automatically be labeled an numbered.它说当你向kable函数添加标题时,它会自动被标记为编号。 However, I am only getting the "text" portion of the label without the number.但是,我只得到标签的“文本”部分而没有数字。

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

```

Your help in understanding how to do this is greatly appreciated.非常感谢您帮助理解如何做到这一点。

You are not using bookdown but rmarkdown::html_document() due to the output header.由于output标题,您没有使用bookdown而是rmarkdown::html_document() You need to change your header to您需要将标题更改为

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

in order to use bookdown features within a single file project.为了在单个文件项目中使用bookdown功能。 For actual books it is a good idea to let the bookdown package set-up a skeleton for you, eg via the RStudio add-in.对于实际的书籍,最好让bookdown包为您设置一个骨架,例如通过 RStudio 插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM