Search code examples
r-markdownbookdownkableextracaptionfootnotes

How to prevent double numbering of tables when using kableExtra footnotes in bookdown?


I'm using kableExtra tables in bookdown to incorporate table footnotes. However, whenever I add a footnote, the table ends up with a double number index. Is there a way to prevent this issue? Any assistance would be greatly appreciated.

Please consider the following MWE (along with a cropped image of the resulting book):

---
title: "Double numbering problem of tables when using footnotes"
site: bookdown::bookdown_site
documentclass: book
---
# Problematic footnotes
## Table 1
```{r table1, echo=FALSE, message=FALSE}
library(kableExtra)
kable((iris[1:2,]),
caption = "This is a table without footnote (and correct numbering).")
```
## Table 2
```{r table2, echo=FALSE, message=FALSE}
kable(iris[1:2,],
caption = "This is a table with a footnote (and **erroneous numbering**).") %>%
footnote(general = "This is my footnote.")
```

enter image description here


Solution

  • use:

    ```{r table3, echo=FALSE, message=FALSE}
    knitr::kable(iris[1:2,], label = NA,
    caption = "This is a table with footnote") %>%
    footnote(general = "This is my footnote.")
    ```
    

    more here https://github.com/haozhu233/kableExtra/issues/831