I'm trying to create tables with cross-references in Quarto that are rendered in MS Word
So far I get the best looking tables with flextable
However, I haven't managed to get the cross-references to work yet
Here's the qmd file contents showing an example adapted from https://ardata-fr.github.io/flextable-book/captions-and-cross-references.html
---
title: "Cross-reference example"
format: docx
editor: visual
---
```{r include=FALSE}
library(knitr)
library(flextable)
opts_chunk$set(echo = FALSE)
# example from https://ardata-fr.github.io/flextable-book/captions-and-cross-references.html
```
```{r}
ft <- qflextable(head(airquality))
```
# Captions
Now, let's add a caption with `set_caption`:
```{r ft.align="left"}
library(officer)
set_caption(ft,
caption = "airquality dataset",
style = "Table Caption",
autonum = run_autonum(seq_id = "tab", bkm = "tab1"))
```
Or use kintr chunk options:
```{r ft.align="center", tab.cap='airquality dataset', tab.id='tab2', label='tab2'}
ft
```
Or build label into caption:
```{r ft.align="center", tab.cap='airquality dataset {#tab:tab3}'}
ft
```
# Cross-references
* This is a reference to flextable \@ref(tab:tab1).
* This is a reference to flextable \@ref(tab:tab2).
* This is a reference to flextable \@ref(tab:tab3).
# Links
* This is a link to [flextable](#tab:tab1)