Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing reference for gt table in word document #3600

Closed
4 tasks done
rmflight opened this issue Dec 8, 2022 · 14 comments
Closed
4 tasks done

missing reference for gt table in word document #3600

rmflight opened this issue Dec 8, 2022 · 14 comments
Assignees
Labels
bug Something isn't working crossref tables Issues with Tables including the gt integration
Milestone

Comments

@rmflight
Copy link

rmflight commented Dec 8, 2022

Bug description

---
title: "gt missing reference"
format: docx
---


```{r}
#| label: load_data
data(cars)

library(gt)
```

Now lets try a table in our word document. This should be @tbl-cars.

```{r}
#| label: tbl-cars
#| tbl-cap: Something about cars.
cars |>
  dplyr::slice_head(n = 5) |>
  gt()
```

gt_missing_reference.docx

Rendering the above document (RStudio render button) results in the table reference looking like ?@tbl-cars, and there is no caption.

If I force HTML output (quarto::quarto_render(..., output_format = "html")), I get the expected output of Table 1, as well as the caption.

Software details:

  • R 4.2.1
  • RStudio 2022.12.0-preview+348
  • quarto 1.3.47
  • gt rstudio/gt@d638baa
  • Linux, Pop! OS 22.04 (skinned version of Ubuntu 22.04)

Checklist

  • Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
  • Please format your issue so it is easier for us to read the bug report.
  • Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • Please document the operating system you're running. If on Linux, please provide the specific distribution.
@rmflight rmflight added the bug Something isn't working label Dec 8, 2022
@cscheid cscheid added crossref tables Issues with Tables including the gt integration labels Dec 8, 2022
@cscheid cscheid added this to the v1.4 milestone Feb 27, 2023
@aminadibi
Copy link

Same issue in Windows 11, R 4.2.3, quarto v1.3.294.

@cscheid
Copy link
Collaborator

cscheid commented Mar 29, 2023

@aminadibi we're aware, thank you. We're going to fix this in 1.4.

@cscheid
Copy link
Collaborator

cscheid commented May 23, 2023

In Quarto 1.4's crossref system, this is a duplicate of #1556, #2297, and #3397.

@dakotakliam
Copy link

Is there any kind of workaround for this issue in the meantime?

@cscheid
Copy link
Collaborator

cscheid commented Oct 22, 2023

@dakotakliam This is working right now on 1.4 prereleases: go here and click on "Pre-release" to download an installer. With this version of quarto, I get the following output:

3600

@cscheid cscheid closed this as completed Oct 22, 2023
@schwa021
Copy link

schwa021 commented Nov 26, 2023

This is listed as "completed" - but I just tested it and got a very strange error. I cut/pasted/ran your exact sample code, but when I opened the word doc I got the following:

image

After clicking "Close" in word, the document has an improperly formatted table (does not equal your example)

image

This seems to happen if there is a chunk label and caption (required for cross-referencing)

@mcanouil
Copy link
Collaborator

What version of Quarto and gt are you using exactly?

@schwa021
Copy link

What version of Quarto and gt are you using exactly?

Quarto: 1.4.487
gt: 0.10.0
R: 4.2.2

@mcanouil
Copy link
Collaborator

mcanouil commented Nov 27, 2023

I can reproduce.
The document is malformed at least the table properties.

@mcanouil mcanouil reopened this Nov 27, 2023
@schwa021
Copy link

I can reproduce. The document is malformed.

I'm not sure what this means... is there a problem with quarto, gt, or am I doing something wrong?

@rmflight
Copy link
Author

OK, I thought this is the same issue over in #7151 and #7321. Or am I wrong. It looks like the same thing, where the XML reference gets borked, but it is present, and the table is messed up according to Word.

@mcanouil
Copy link
Collaborator

Indeed, thanks @rmflight (I was looking for them after checking the issue was from gt and possibly Quarto).

(re)Closing this.
@schwa021 See #7151

FYI, the following works properly.

---
title: "gt missing reference"
format: docx
---

```{r}
#| label: load-data
data(cars)

library(gt)
```

Now lets try a table in our word document. This should be @tbl-cars.

```{r}
#| label: tbl-cars
#| tbl-cap: Something about cars.
cars |>
  dplyr::slice_head(n = 5) |>
  knitr::kable()
```

@schwa021
Copy link

Indeed, thanks @rmflight (I was looking for them after checking the issue was from gt and possibly Quarto).

(re)Closing this. @schwa021 See #7151

FYI, the following works properly.

---
title: "gt missing reference"
format: docx
---

```{r}
#| label: load-data
data(cars)

library(gt)

Now lets try a table in our word document. This should be @tbl-cars.

#| label: tbl-cars
#| tbl-cap: Something about cars.
cars |>
  dplyr::slice_head(n = 5) |>
  knitr::kable()

I am sorry, but I'm unable to follow what's happening here (I'm a user, not a developer).

Am I correct in understanding that there is a but, but it's being handled in issue #7151? But when I go to #7151, it seems to suggest the issue is "closed" - but the but is definitely still there.

The example you gave to me above uses kable to produce proper output. But I am having trouble with gt().

Again, my apologies, but it seems i don't understand how to track/follow these issues here.

@mcanouil
Copy link
Collaborator

I'm a user, not a developer

I don't how this matter here, but let's be explicit:

  • The issue right here is about the reference not the table within a Word document.
  • The issue you are having is about gt table itself as you (and anyone) cannot reproduce with for example knitr::kable().
  • The issue is the table from gt/quarto ends up somehow malformed in the rendered Word document.
  • The issue your reported here was already reported elsewhere.

Leading to:

  1. This issue here is actually properly resolved as the reference works
  2. Your issue is actually somewhere else, thus see/follow gt table docx rendering produces uncorrect output #7151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crossref tables Issues with Tables including the gt integration
Projects
None yet
Development

No branches or pull requests

7 participants