gt
gt copied to clipboard
tab_options breaks pdf rendering
Prework
- [x] Read and agree to the code of conduct and contributing guidelines.
- [x] If there is already a relevant issue, whether open or closed, comment on the existing thread instead of posting a new issue.
Description
I have series of the same GT tables in one report. (Same structure and formatting. Different data)
Tables are simple and don't look good stretched to 100% of the page.
I use:
tab_options(table.width = pct(70))
It works exactly as intended when there is only one table in the report.
When there is more than one table it gives:
ERROR:
compilation failed- error
LaTeX Error: Command \holdLTleft already defined.
Or name \end... illegal, see p.192 of the manual.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.656 \newlength\holdLTleft
\newlength\holdLTright\setlength\holdLTleft{\LTle...
see Zestawienie-QC.log for more information.
I'm positive that tab_options(table.width = pct(70))
is the problem.
Without it document renders properly.
Also, when only one table width is formatted in the document it renders properly (but ugly - the first table is formatted, the rest are stretched).
My guess is that formatting the second table doubles some latex tags that can't be doubled. There is this line before every table in resulting .tex file:
\newlength\holdLTleft\newlength\holdLTright\setlength\holdLTleft{\LTleft}\relax\setlength\holdLTright{\LTright}\relax\setlength\LTleft{0.15\linewidth}
Manual removal of every occurrence after the first fixes the document and it starts to render properly.
Reproducible example
It is the same for any table I've tried.
Expected result
Well, it would be nice to be allowed to format more than one table in the report, I guess.
Session info
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)
Matrix products: default
locale:
[1] LC_COLLATE=Polish_Poland.utf8 LC_CTYPE=Polish_Poland.utf8 LC_MONETARY=Polish_Poland.utf8
[4] LC_NUMERIC=C LC_TIME=Polish_Poland.utf8
time zone: Europe/Warsaw
tzcode source: internal
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] ggnewscale_0.4.10 svglite_2.1.3 wesanderson_0.3.7 hrbrthemes_0.8.7 gtExtras_0.5.0 gt_0.10.1
[7] janitor_2.2.0 lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2
[13] readr_2.1.5 tidyr_1.3.1 tibble_3.2.1 ggplot2_3.5.0 tidyverse_2.0.0 renv_1.0.7
loaded via a namespace (and not attached):
[1] gtable_0.3.4 xfun_0.43 paletteer_1.6.0 tzdb_0.4.0
[5] vctrs_0.6.5 tools_4.3.2 generics_0.1.3 parallel_4.3.2
[9] curl_5.2.1 fansi_1.0.6 pkgconfig_2.0.3 lifecycle_1.0.4
[13] farver_2.1.1 compiler_4.3.2 textshaping_0.3.7 munsell_0.5.1
[17] fontawesome_0.5.2 snakecase_0.11.1 httpuv_1.6.15 fontquiver_0.2.1
[21] fontLiberation_0.1.0 sass_0.4.9 htmltools_0.5.8.1 yaml_2.3.8
[25] Rttf2pt1_1.3.12 pillar_1.9.0 later_1.3.2 crayon_1.5.2
[29] extrafontdb_1.0 gfonts_0.2.0 mime_0.12 fontBitstreamVera_0.1.1
[33] tidyselect_1.2.1 digest_0.6.35 stringi_1.8.3 rematch2_2.1.2
[37] showtextdb_3.0 extrafont_0.19 fastmap_1.1.1 grid_4.3.2
[41] colorspace_2.1-0 cli_3.6.2 magrittr_2.0.3 crul_1.4.2
[45] utf8_1.2.4 withr_3.0.0 promises_1.3.0 gdtools_0.3.7
[49] scales_1.3.0 bit64_4.0.5 showtext_0.9-7 timechange_0.3.0
[53] sysfonts_0.8.9 bit_4.0.5 ragg_1.3.0 hms_1.1.3
[57] shiny_1.8.1.1 knitr_1.46 rlang_1.1.3 Rcpp_1.0.12
[61] xtable_1.8-4 glue_1.7.0 httpcode_0.3.0 xml2_1.3.6
[65] vroom_1.6.5 rstudioapi_0.16.0 jsonlite_1.8.8 R6_2.5.1
[69] systemfonts_1.0.6
This is the same issue as closed #1580. It's fixed in the development version and will be in v10.2.
Duplicate of #1580