Skip to content

Issue with sub_missing() when exporting to PDF #1107

@ddsjoberg

Description

@ddsjoberg

Hello! 🍁

A gtsummary user reported an error when exporting to PDF in R markdown (https://stackoverflow.com/questions/74334481). Below is an abridged example illustrating the error. Thank you!! ❤️

---
title: "test"
author: "Tengku Hanis"
date: "`r Sys.Date()`"
output: pdf_document
---

```{r pressure, echo=FALSE}
devtools::dev_mode(on = TRUE)
packageVersion("gt")

# build regression model
mod <- lm(mpg ~ ., data = mtcars)
summary(mod)

# summarize with gtsummary
x <- gtsummary::tbl_regression(mod, intercept = TRUE) 

# this is the data frame I want to print
x$table_body

# but this fails when exporting to PDF 
x$table_body |> 
  gt::gt(groupname_col = NULL, caption = NULL) |> 
  gt::sub_missing(columns = gt::everything(), missing_text = "")
```

This is the error I see in the RStudio IDE "Render" tab.

processing file: delete.Rmd

output file: delete.knit.md

"C:/Program Files/RStudio/bin/quarto/bin/tools/pandoc" +RTS -K512m -RTS delete.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output delete.tex --lua-filter "C:\PROGRA~1\R\R-42~1.2\library\RMARKD~1\RMARKD~1\lua\PAGEBR~1.LUA" --lua-filter "C:\PROGRA~1\R\R-42~1.2\library\RMARKD~1\RMARKD~1\lua\LATEX-~1.LUA" --self-contained --highlight-style tango --pdf-engine pdflatex --variable graphics --variable "geometry:margin=1in" --include-in-header "C:\Users\SjobergD\AppData\Local\Temp\Rtmp2bPSuA\rmarkdown-str68382b4620f6.html" 
! Undefined control sequence.
<argument> ...al \expandafter \let \cmrsideswitch 
                                                  \@tempa \fi \fi 
l.142 (Intercept)
                  & (Intercept) & intercept &  & label &  & 32 & 32 & generi... 

Error: LaTeX failed to compile delete.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See delete.log for more info.
Execution halted
Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.2 (2022-10-31 ucrt)
#>  os       Windows 10 x64 (build 19042)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_United States.utf8
#>  ctype    English_United States.utf8
#>  tz       America/New_York
#>  date     2022-11-06
#>  pandoc   2.18 @ C:/Program Files/RStudio/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cli           3.4.1   2022-09-23 [1] CRAN (R 4.2.1)
#>  digest        0.6.30  2022-10-18 [1] CRAN (R 4.2.1)
#>  evaluate      0.17    2022-10-07 [1] CRAN (R 4.2.1)
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.2.0)
#>  fs            1.5.2   2021-12-08 [1] CRAN (R 4.2.0)
#>  glue          1.6.2   2022-02-24 [1] CRAN (R 4.2.0)
#>  highr         0.9     2021-04-16 [1] CRAN (R 4.2.0)
#>  htmltools     0.5.3   2022-07-18 [1] CRAN (R 4.2.1)
#>  knitr         1.40    2022-08-24 [1] CRAN (R 4.2.1)
#>  lifecycle     1.0.3   2022-10-07 [1] CRAN (R 4.2.1)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.2.0)
#>  purrr         0.3.5   2022-10-06 [1] CRAN (R 4.2.1)
#>  R.cache       0.16.0  2022-07-21 [1] RSPM (R 4.2.0)
#>  R.methodsS3   1.8.2   2022-06-13 [1] CRAN (R 4.2.0)
#>  R.oo          1.25.0  2022-06-12 [1] CRAN (R 4.2.0)
#>  R.utils       2.12.1  2022-10-30 [1] CRAN (R 4.2.1)
#>  reprex        2.0.2   2022-08-17 [1] RSPM (R 4.2.0)
#>  rlang         1.0.6   2022-09-24 [1] CRAN (R 4.2.1)
#>  rmarkdown     2.17    2022-10-07 [1] CRAN (R 4.2.1)
#>  rstudioapi    0.14    2022-08-22 [1] CRAN (R 4.2.1)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.2.0)
#>  stringi       1.7.8   2022-07-11 [1] CRAN (R 4.2.1)
#>  stringr       1.4.1   2022-08-20 [1] CRAN (R 4.2.1)
#>  styler        1.8.0   2022-10-22 [1] CRAN (R 4.2.1)
#>  withr         2.5.0   2022-03-03 [1] CRAN (R 4.2.0)
#>  xfun          0.34    2022-10-18 [1] CRAN (R 4.2.1)
#>  yaml          2.3.6   2022-10-18 [1] CRAN (R 4.2.1)
#> 
#>  [1] C:/Program Files/R/R-4.2.2/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions