我想知道是否有一种方法可以强制脚注适应表格的宽度(并换行到第二行),kable
在 R 中使用(我正在将 .Rmd 编织为 PDF,因此格式为乳胶)。我都用过add_footnote()
和footnote()
。如果该add_footnote
函数超出表格的宽度,该函数实际上会将脚注包装到第二行,但它也强制使用上标(为此,我的表格中不能有上标)。 footnote
给了我删除上标的选项,但我不知道如何让它匹配格式add_footnote
并将比表格更宽的脚注换行到第二行。另一种解决方案是从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))
```