I'm having trouble exporting a kable table with LaTex using save_kable() function after I add the caption = argument in kable() function.
I thought it was because I recently updated my R version, RStudio version, TeX version, and everything that could cause errors, but then I switch to R Servers (R 4.3.2 currently), which I never touched upon before. I got the same error message that says "! LaTeX Error: Something's wrong--perhaps a missing \item." If I delete the caption =, I was able to export the table in LaTex. Here is a minimum example.
library(tidyverse)
library(kableExtra)
library(magick)
dt <- mtcars[1:5, 1:6]
dt %>%
kbl("latex",caption = "Recreating booktabs style table") %>%
save_kable(file = "a.png")
Any help would be appreciated!
I do get the same error when including the
captionargument inkable(). There are alternatives to this, that don’t require Latex. You could usegt::gt()to create a nice table and then save it withgtsave().