gt
gt copied to clipboard
`cols_width()` not working when using `cols_merge()` for PDF output
Description
Widths set with cols_width()
isn't respected when using cols_merge()
and when the output is PDF.
Reproducible example
Consider this Quarto document:
---
format: pdf
---
```{r}
#| echo: false
library(gt)
sp500 |>
dplyr::slice(50:55) |>
dplyr::select(-volume, -adj_close) |>
gt() |>
cols_align(
columns = everything(),
align = "right"
) |>
cols_merge(
columns = c(open, close),
pattern = "{1}-{2}"
) |>
cols_merge(
columns = c(low, high),
pattern = "{1}-{2}"
) |>
cols_width(
date ~ px(100),
c("open", "low") ~ px(200)
)
```
Expected result
The table created doesn't respect the widths set:
When output as html, everything looks fine:
Session info
> sessionInfo()
R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)
Matrix products: default
locale:
[1] LC_COLLATE=Danish_Denmark.utf8 LC_CTYPE=Danish_Denmark.utf8 LC_MONETARY=Danish_Denmark.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
time zone: Europe/Copenhagen
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] marginaleffects_0.20.1 patchwork_1.2.0 glue_1.7.0 parameters_0.21.7 ggpomological_0.1.2 epoxy_1.0.0
[7] gt_0.11.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.1 tidyverse_2.0.0
loaded via a namespace (and not attached):
[1] sass_0.4.9 utf8_1.2.4 generics_0.1.3 xml2_1.3.6 lattice_0.22-6 stringi_1.8.4 hms_1.1.3 digest_0.6.35
[9] magrittr_2.0.3 evaluate_0.23 grid_4.4.0 timechange_0.3.0 estimability_1.5.1 mvtnorm_1.2-5 fastmap_1.2.0 processx_3.8.4
[17] ps_1.7.6 fansi_1.0.6 scales_1.3.0 cli_3.6.2 rlang_1.1.4 reprex_2.1.0 munsell_0.5.1 commonmark_1.9.1
[25] yaml_2.3.8 withr_3.0.0 tools_4.4.0 datawizard_0.11.0 tzdb_0.4.0 coda_0.19-4.1 colorspace_2.1-0 bayestestR_0.13.2
[33] vctrs_0.6.5 R6_2.5.1 lifecycle_1.0.4 emmeans_1.10.2 fs_1.6.4 insight_0.20.0 callr_3.7.6 clipr_0.8.0
[41] pkgconfig_2.0.3 pillar_1.9.0 gtable_0.3.5 Rcpp_1.0.12 data.table_1.15.4 xfun_0.44 tidyselect_1.2.1 knitr_1.47
[49] rstudioapi_0.16.0 xtable_1.8-4 htmltools_0.5.8.1 rmarkdown_2.27 compiler_4.4.0 markdown_1.13