quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.87k stars 317 forks source link

Citations in gt table captions not resolved #2297

Closed njbart closed 1 year ago

njbart commented 2 years ago

Bug description

Citations in captions provided inside R chunks are properly resolved for figures (which is amazing, many thanks), but not for gt tables.

Example:

---
format: html
references:
- id: author:2015
  author:
    - family: Author
      given: Ann
  edition: '2'
  issued:
    - year: 2015
  language: en-US
  publisher: A publisher
  publisher-place: A place
  title: A book
  type: book
---

```{r}
#| label: fig-airquality
#| fig-cap: 'Temperature and ozone level [Source: @author:2015, 67].'
#| warning: false
#| echo: false
library(ggplot2)
ggplot(airquality, aes(Temp, Ozone)) + geom_point() 
#| label: tbl-gt
#| tbl-cap: 'A toy example tibble for testing with gt [Source: @author:2015, 77].'
#| warning: false
#| echo: false
library(gt)
library(tidyverse)
exibble %>%
  gt()
Col1 Col2 Col3
A B C
E F G
A G G

: My Caption [Source: @author:2015, 87]. {#tbl-letters}



Output (just the caption lines, as visible in a browser window), note the unresolved citation in Table 1:

> Figure 1: Temperature and ozone level (Source: Author 2015, 67).

> Table 1: A toy example tibble for testing with gt [Source: @author:2015, 77]

> Table 2: My Caption (Source: Author 2015, 87).

The same results are seen when trying flextable or huxtable. kable, however, works as expected.

Given that quarto seems to be [committed to supporting all popular table packages, in particular gt](https://github.com/quarto-dev/quarto-cli/issues/1556#issuecomment-1219621832), it would be great if quarto could be made to support citations in gt table captions as well as it does for figure captions. Making this work for flextable and huxtable would of course be highly welcome as well.

---

RStudio 2022.07.1+554 "Spotted Wakerobin" Release (7872775ebddc40635780ca1ed238934c3345c5de, 2022-07-22) for macOS
Mozilla/5.0 (Macintosh; Intel Mac OS X 11_6_8) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.10 Chrome/69.0.3497.128 Safari/537.36

quarto -v
1.1.179

### Checklist

- [X] 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.
- [X] Please [format your issue](https://yihui.org/issue/#please-format-your-issue-correctly) so it is easier for us to read the bug report.
- [X] Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- [X] Please document the operating system you're running. If on Linux, please provide the specific distribution.
cscheid commented 2 years ago

Definitely a bug. Crossrefs are a major target for our 1.2 release, so hopefully we'll address this in the next few weeks.

michellesculley commented 1 year ago

I just wanted to piggyback on this issue as I am have the same problem with table cross references using gt. Running the code above from njbart works if I render the document as html, but not as a docx. Tthe gt table is created but not given a label ("unable to resolve crossref @tbl-gt") when I render a docx. I am using the Quarto 1.3.361, Rstudio version 2002 .02.3 "Prairie Trillium" and R version 4.2.1 "Funny-Looking Kid" test.docx

cscheid commented 1 year ago

This document now renders cleanly on main:

image