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

Citations in gt table captions not resolved #2297

Closed
4 tasks done
njbart opened this issue Sep 5, 2022 · 3 comments
Closed
4 tasks done

Citations in gt table captions not resolved #2297

njbart opened this issue Sep 5, 2022 · 3 comments
Assignees
Labels
bug Something isn't working crossref
Milestone

Comments

@njbart
Copy link

njbart commented Sep 5, 2022

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() 
```

```{r}
#| 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, 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

  • 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.
@njbart njbart added the bug Something isn't working label Sep 5, 2022
@cscheid cscheid added this to the v1.2 milestone Sep 6, 2022
@cscheid
Copy link
Collaborator

cscheid commented Sep 6, 2022

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
Copy link

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
Copy link
Collaborator

cscheid commented Sep 19, 2023

This document now renders cleanly on main:

image

@cscheid cscheid closed this as completed Sep 19, 2023
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
Projects
None yet
Development

No branches or pull requests

4 participants