简体   繁体   中英

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. I'm using bookdown and have been trying to understand the 2.5 tables portion of the documentation.

It says when you add a caption to the kable function it will automatically be labeled an numbered. 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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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