---
title: "Margin Table R gt Cross-ref Test"
papersize: us-letter
grid:
  margin-width: 3.5in
  gutter-width: 0.25in
format:
  html: default
  typst:
    keep-typ: true
_quarto:
  tests:
    typst:
      ensureTypstFileRegexMatches:
        # Cell option should produce #notefigure (entire figure in margin)
        - ['#notefigure\(', '<tbl-air-r>']
        - []
      ensurePdfRegexMatches:
        - ['Table 1', 'Air Quality']
        - []
      ensurePdfTextPositions:
        - # Table column header in margin, right of body text
          - subject: "Solar"
            relation: rightOf
            object: "This tests"
        - []
      noErrors: default
---

This tests cross-references to margin tables using R gt package.

```{r}
#| column: margin
#| classes: plain
#| echo: false
#| label: tbl-air-r
#| tbl-cap: "NYC Air Quality"

library(gt)

airquality_mini <- head(airquality, 5)

gt(airquality_mini) |>
  tab_header(title = "Air Quality") |>
  cols_label(
    Ozone = "O3",
    Solar.R = "Solar",
    Wind = "Wind",
    Temp = "Temp"
  )
```

As shown in @tbl-air-r, the table appears in the margin with a working cross-reference.

The reference should show "Table 1" or similar.
