Reputation: 107
---
title: "example"
format:
pdf:
documentclass: article
editor: visual
---
Hello everyone i have a simple problem which is driving me crazy: I want cross reference a table created by a gt table using a caption. Here is my setup:
```{r}
library(tidyverse)
library(gt)
tbl_1 <- tribble(~x, ~y,
1, 2,
3, 4)
```
And lets say i want to create a table from tbl_1 and cross reference it later. Here is my attempt:
```{r}
#| label: tbl-table-1
#| tbl-cap: "table 1"
tbl_1 %>% gt()
```
This gives me:
compilation failed- error
Package array Error: Illegal pream-token (\caption): `c' used.
See the array package documentation for explanation.
Type H <return> for immediate help.
...
l.227 \caption
{\label{tbl-table-1}table 1 }
see example.log for more information.
And if i use the caption argument in the gt function it gives me nothing.
```{r}
#| label: tbl-table-1
tbl_1 %>% gt(caption = "table 1")
```
Does anyone know of a solution or perhaps im doing something wrong?
Upvotes: 4
Views: 2716
Reputation: 6542
This was an issue in Quarto that has been fixed now https://github.com/quarto-dev/quarto-cli/issues/924
Using gt with caption and cross reference should work as espected now if you use Quarto version above 0.9.439
Note that there is still some improvement to be done to gt LaTeX output to be fully compliant with Quarto output and features. Following gt releases will be the best to know when those improvement will be made.
Upvotes: 4