Skip to content

gt outputs code that produces illegal unit of measure error when generating pdf in Quarto #1417

@dmonder

Description

@dmonder

Prework

Description

Describe the bug clearly and concisely.

With the following Quarto document, I get an illegal unit of measure when generating a PDF but not for HTML or DOCX.

```{r}
require(gt)

data.frame(Group = c("Group 1", "% Group 2"), `% Total` = c(100, 61.4)) |>
    gt( rowname_col = "Group" ) |>
    tab_stub_indent( contains("%"), indent=2 )
```

Reproducible example

  • Post a minimal reproducible example so the maintainer can troubleshoot the problems you identify. A reproducible example is:
    • Runnable: post enough R code and data so any onlooker can create the error on their own computer.
    • Minimal: reduce runtime wherever possible and remove complicated details that are irrelevant to the issue at hand.
    • Readable: format your code according to the tidyverse style guide.

See code chunk above. When running Quarto on this file, it produces the following output:

processing file: Quarto_Error.qmd
1/1 [unnamed-chunk-1]
output file: Quarto_Error.knit.md

pandoc
  to: latex
  output-file: Quarto_Error.tex
  standalone: true
  pdf-engine: xelatex
  variables:
    graphics: true
    tables: true
  default-image-extension: pdf

metadata
  documentclass: scrartcl
  classoption:
    - DIV=11
    - numbers=noendperiod
  papersize: letter
  header-includes:
    - '\KOMAoption{captions}{tableheading}'
  block-headings: true


Rendering PDF
running xelatex - 1
  This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode

updating tlmgr

updating existing packages
ERROR:
compilation failed- error
Illegal unit of measure (pt inserted).
<to be read again>
                   p
l.215 \hspace*{10px}
                     \% Group 2 & 61.4 \\

see Quarto_Error.log for more information.

Expected result

What should have happened? Please be as specific as possible.

To generate a valid PDF file with table that looks like the following:

262756773-3cdd9836-2408-4115-a92e-1e01f218f00f

Session info

End the reproducible example with a call to sessionInfo() in the same session (e.g. reprex(session_info = TRUE)) and include the output.

R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] gt_0.9.0

loaded via a namespace (and not attached):
 [1] rstudioapi_0.15.0 knitr_1.43        xml2_1.3.5        magrittr_2.0.3   
 [5] tidyselect_1.2.0  R6_2.5.1          rlang_1.1.1       fastmap_1.1.1    
 [9] fansi_1.0.4       dplyr_1.1.2       tools_4.2.2       xfun_0.40        
[13] utf8_1.2.3        cli_3.6.1         htmltools_0.5.6   digest_0.6.33    
[17] tibble_3.2.1      lifecycle_1.0.3   htmlwidgets_1.6.2 vctrs_0.6.3      
[21] glue_1.6.2        evaluate_0.21     rmarkdown_2.24    compiler_4.2.2   
[25] pillar_1.9.0      generics_0.1.3    jsonlite_1.8.7    pkgconfig_2.0.3  

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions