quarto-dev / quarto-dev/quarto-cli
Adding #| label: for tables in chunks messes up gt table formatting for docx
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Bug description
Whenever I try to reference tables and figures by adding something like #| label: tbl-example to a R chunk that produces a table using gt, I get an error message when opening the produced file with Word and it messes up the table formatting (columns becoming one character wide, lacking table dividing lines etc.).
Steps to reproduce
The following works without an issue
---
title: "Minimal example"
format: docx
number-sections: true
number-depth: 3
editor: source
execute:
echo: false
tbl-cap-location: top
---
# Intro
<!-- In @tbl-example you see the numbers. -->
In the table below you see the numbers.
```{r}
#| tbl-cap: The numbers
library(gt)
data.frame(category=c("A", "B", "C"),
numbers = 1:3) |>
gt()
```
It produces this:
In contrast, this:
---
title: "Minimal example"
format: docx
number-sections: true
number-depth: 3
editor: source
execute:
echo: false
tbl-cap-location: top
---
# Intro
In @tbl-example you see the numbers.
```{r}
#| tbl-cap: The numbers
#| label: tbl-example
library(gt)
data.frame(category=c("A", "B", "C"),
numbers = 1:3) |>
gt()
```
runs without an error or warning, but when I try to open the resulting document wiht Word, I get
and the table in the resulting document has messed up formatting (looks even worse in more complex tables):
Expected behavior
Both example should essentially produce the same output, just one having a reference to the table.
Actual behavior
Error message about "Word found unreadale content..." and messed up table formatting.
Your environment
- IDE RStudio 2024.09.1 Build 394
- OS Microsoft Windows 11 Enterprise 10.0.26100 Buld 26100
- R version 4.4.1 (2024-06-14 ucrt)
- gt version gt_0.11.1
Quarto check output
quarto check
Quarto 1.5.57
[>] Checking versions of quarto binary dependencies...
Pandoc version 3.2.0: OK
Dart Sass version 1.70.0: OK
Deno version 1.41.0: OK
Typst version 0.11.0: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
Version: 1.5.57
Path: C:\local\RStudio-2024.09.1-394\resources\app\bin\quarto\bin
CodePage: 1252
[>] Checking tools....................OK
TinyTeX: (not installed)
Chromium: (not installed)
[>] Checking LaTeX....................OK
Tex: (not detected)
[>] Checking basic markdown render....OK
[>] Checking Python 3 installation....(None)
Unable to locate an installed version of Python 3.
Install Python 3 from https://www.python.org/downloads/
[>] Checking R installation...........OK
Version: 4.4.1
Path: C:/Users/<*******ANONYMIZED*******>/AppData/Local/Programs/R/R-4.4.1
LibPaths:
- C:/Users/<*******ANONYMIZED*******>/AppData/Local/R/win-library/4.4
- C:/Users/<*******ANONYMIZED*******>/AppData/Local/Programs/R/R-4.4.1/library
knitr: 1.48
rmarkdown: 2.28
[>] Checking Knitr engine render......OK
C:\Users\<*******ANONYMIZED*******>\OneDrive - <*******ANONYMIZED*******>>quarto check
Quarto 1.5.57
[>] Checking versions of quarto binary dependencies...
Pandoc version 3.2.0: OK
Dart Sass version 1.70.0: OK
Deno version 1.41.0: OK
Typst version 0.11.0: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
Version: 1.5.57
Path: C:\local\RStudio-2024.09.1-394\resources\app\bin\quarto\bin
CodePage: 1252
[>] Checking tools....................OK
TinyTeX: (not installed)
Chromium: (not installed)
[>] Checking LaTeX....................OK
Tex: (not detected)
[>] Checking basic markdown render....OK
[>] Checking Python 3 installation....(None)
Unable to locate an installed version of Python 3.
Install Python 3 from https://www.python.org/downloads/
[>] Checking R installation...........OK
Version: 4.4.1
Path: C:/Users/<*******ANONYMIZED*******>/AppData/Local/Programs/R/R-4.4.1
LibPaths:
- C:/Users/<*******ANONYMIZED*******>/AppData/Local/R/win-library/4.4
- C:/Users/<*******ANONYMIZED*******>/AppData/Local/Programs/R/R-4.4.1/library
knitr: 1.48
rmarkdown: 2.28
[>] Checking Knitr engine render......OK
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal Quarto .qmd examples in the report, rendering both the unlabeled and labeled R gt tables to docx. Compare the generated documents and verify that the labeled version opens in Word without the unreadable-content error or damaged table formatting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100