haozhu233 / kableExtra

Construct Complex Table with knitr::kable() + pipe.
https://haozhu233.github.io/kableExtra/
Other
681 stars 147 forks source link

Rmarkdown tab.cap not working with kbl #849

Open g-antonello opened 1 month ago

g-antonello commented 1 month ago

Thank you for the packages, it makes table manipulation super versatile. I think I came across an issue, though. I was trying to assign captions to my kbl tables, but Rmarkdown was not able to render them. Below is the .Rmd code I used, which I knitted to html.

Best Giacomo

testTableCaptions.txt

dmurdoch commented 1 month ago

I think there are two issues here. First, kbl() ignores the tab.cap option, but you can specify a caption by including it in the arguments to kbl(), e.g. change your code chunk to

```{r example-table2}
library(kableExtra)
kbl(mtcars[1:5, 1:5], caption = "This is the caption for the table. Done with KableExtra")


The second issue is that this won't match the style of the previous table, and that's likely a problem for you.  I don't know `BiocStyle`, so I am not sure how it is specifying the style that is being shown.  Do you know?  If not, maybe we should contact its author, and see whether this is something `kableExtra` could do or whether one or both packages would need changes to be compatible.