gt
gt copied to clipboard
`tab_spanner()` does not work as intended when output format is docx
Description
when rendered via Quarto with output format as docx, tab_spanner does not work as intended. The spanner column is added to the appropriate row, above the columns specified, however the other columns now are on the same row as the spanner column. Tables render correctly when the format is pdf or html.
Reproducible example
---
title: "quarto gt"
format: docx
---
## Quarto
A table @tbl-gt.
```{r}
#| label: tbl-gt
#| tbl-cap: A Caption
#| echo: false
library(gt)
mtcars |>
head() |>
gt() |>
tab_spanner(
label = "performance",
columns = c(
mpg, cyl, disp
)
)
```
See output docx file: quarto_gt.docx
Expected result
In this case, the expectation is that a row "performance" should appear in the first row, spanning the columns mpg, cyl, and disp. The remaining columns should be on the same row as mpg, cyl, and disp.
See output pdf file: quarto_gt.pdf See output html:
Session info
> packageVersion("gt")
[1] ‘0.6.0.9000’
> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.4
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
loaded via a namespace (and not attached):
[1] compiler_4.2.1 fastmap_1.1.0 cli_3.3.0
[4] htmltools_0.5.3 tools_4.2.1 rstudioapi_0.13
[7] yaml_2.3.5 rmarkdown_2.14.2 knitr_1.39
[10] xfun_0.31 digest_0.6.29 rlang_1.0.4
[13] evaluate_0.15
% quarto --version
1.0.37
% quarto pandoc --version
pandoc 2.18
Ah I see. Yeah, this is a stylistic break from the other formats for sure. We'll try to work on this soon but seeing as there are some critical bugs reported lately, it might take a bit more time to begin on this one.
We've decided that merged cells in Word output, non-spanner column labels is not a priority right now. We may get to this in the future, but we're closing this for now.
@rich-iannone I noticed that cross-reference was broken in the above example. Here is a screenshot from docx.
![](https://user-images.githubusercontent.com/12031874/202876848-861b3319-5f63-4815-a324-60a3f2dbff12.png)
I use quarto 1.2.269 and gt 0.8.0
Here is my sessioninfo
> packageVersion('gt')
[1] ‘0.8.0’
> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Ventura 13.0.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.2.2 fastmap_1.1.0 cli_3.4.1 htmltools_0.5.3 tools_4.2.2
[6] rstudioapi_0.14 yaml_2.3.6 rmarkdown_2.18 knitr_1.41 xfun_0.35
[11] digest_0.6.30 rlang_1.0.6 evaluate_0.18