I'm wondering if there is a way I can force a footnote to fit the width of a table (and wrap to a second line) using kable
in R (I'm knitting .Rmd to PDF so the format is latex). I've used both add_footnote()
and footnote()
. The add_footnote
function will actually wrap a footnote to a second line if it extends beyond the width of the table, but it also forces the use of superscripts (which for this sake is something I can't have in my table). footnote
gives me the option to remove the superscript but I'm not sure how to get it to match the formatting of add_footnote
and wrap footnotes that are wider than the table to a second line. Another solution would be to remove the superscripts from add_footnote
\captionsetup[table]{labelformat=empty}
```{r packs}
library(pacman)
p_load(tidyverse,knitr,kableExtra,janitor)
mydf <-data_frame(x=1:4,y=2:5,z=3:6)
fn1='This the footnote 1'
fn2='This is footnote 2 and is much longer'
mydf %>%
kable(format='latex',booktabs=T,
col.names=c('X','Y','Z'),
caption=c('This method stretches', 'my table out in an ugly way')) %>%
kable_styling(latex_options = c('hold_position')) %>%
footnote(general=c(fn1, fn2),general_title="")
mydf %>%
kable(format='latex',booktabs=T,
col.names=c('X','Y','Z'),
caption=c('This method ruins my title', 'and left justifies my table')) %>%
kable_styling(latex_options = c('hold_position')) %>%
footnote(general=c(fn1, fn2),general_title="",threeparttable = T)
mydf %>%
kable(format='latex',booktabs=T,
col.names=c('X','Y','Z'),
caption=c('This is pretty close to perfect', 'if I could remove the superscripts')) %>%
kable_styling(latex_options = c('hold_position')) %>%
add_footnote(c(fn1, fn2))
```
threeparttable
option – Valseadd_footnote
I added "none" tonotation
. You can try it out. – Valsec('alphabet', 'number', 'symbol')
– Ballplayer