Reputation: 728
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.
Upvotes: 3
Views: 2398
Reputation: 26823
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, e.g. via the RStudio add-in.
Upvotes: 2