Include footnote and repeat_header in kable / kableExtra

5.6k views Asked by At

When I include the repeat_header option (kable_styling) from kableExtra, I lose my footnote. I see in the help files that kable_styling "can get a bit tricky." Is that what I'm experiencing or is there something I'm missing? In the code below, I get no footnote. If I remove the kable_styling, I get the foonote. In my real situation, I have a long table, but best as I can tell, kable_styling is the culprit.

I just updated kableExtra with the github version today (9/18/17)

Thanks!

---
title: "Untitled"
output: 
pdf_document: 
latex_engine: xelatex
---

```{r setup, include=FALSE}
library(knitr)
library(kableExtra)
```

```{r cars,results='asis'}
kable(mtcars,format='latex',booktabs=TRUE,col.names=c("mpg","cyl[note]","disp","hp","drat","wt","qsec","vs","am","gear","carb"),
longtable=T,caption="This is my table caption") %>% 
 add_footnote(c("This is my footnote")) %>% 
 kable_styling(latex_options = c("repeat_header"))
```
1

There are 1 answers

0
petzi On BEST ANSWER

Now it’s recommended to use the new footnote function instead of add_footnote to make table footnotes (see Manual kableExtra, p.18)

The new footnote function has more possibilities:

There are four notation systems in footnote, namely general, number, alphabet and symbol. The last three types of footnotes will be labeled with corresponding marks while general won’t be labeled.

instead of add_footnote(c("This is my footnote")) you could write now e.g.

footnote(general = "This is my footnote")