vincentarelbundock / modelsummary

Beautiful and customizable model summaries in R.
http://modelsummary.com
Other
911 stars 75 forks source link

output="latex" and kableExtra - again #785

Closed cportner closed 3 months ago

cportner commented 3 months ago

In the NEWS, it is suggested that to revert to the original behavior of modelsummary when using kableExtra, we use config_modelsummary(factory_default = "kableExtra"). However, this still breaks my original code since that relied on the original LaTeX output (as used to be the suggested way of doing things). This is related to the #776 issue.

The following code (with output = "latex") used to be produce the correct table. Now, with the suggested factory_default gives me a blank tex file.

ancova %>% 
  modelsummary(
    title = "ANCOVA Estimation of Treatment Effect on Total Births in 2014 Wave \\label{tab:ancova}",
    coef_rename = rename_vars,
    gof_map = list(
      list("raw" = "nobs", "clean" = "Number of observations", "fmt" = my_big_f),
      list("raw" = "# FE", "clean" = "Number of subdistricts", "fmt" = my_big_f)
    )
  ) %>% 
  kable_styling() %>%
  footnote(
    threeparttable = TRUE,
    general = "\\\\footnotesize{Standard errors clustered at branch level and shown in parentheses. Subdistrict fixed effects included in all estimations}",
    general_title = "\\\\footnotesize{Note:}",
    footnote_as_chunk = TRUE,
    escape = FALSE
  ) %>%
  add_header_above(c(" " = 2, "Age Group" = 4)) %>%
  save_kable(here("tables", "ancova.tex"))

If I add output = "latex" back in inside modelsummary, I get

Error in if (kable_format %in% c("pipe", "markdown")) { : 
  argument is of length zero
wachtermh commented 3 months ago

You have to use config_modelsummary(factory_latex = "kableExtra") when using output = "latex".

vincentarelbundock commented 3 months ago

Thanks @wachtermh !

cportner commented 3 months ago

Thank you. Can you update the NEWS (https://github.com/vincentarelbundock/modelsummary/blob/main/NEWS.md#200) so that it shows the correct command and specify that you still need the output = "latex"? Right now, the news show

config_modelsummary(factory_default = "kableExtra")

instead of

config_modelsummary(factory_latex = "kableExtra")