我正在尝试使用Quarto创建具有交叉引用的表格,这些表格在MS Word中呈现
到目前为止,使用flextable得到最美观的表格
然而,我还没有成功使交叉引用起作用
这里是qmd文件内容,显示了从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)
flextable
在与quarto
一起使用时存在一些问题,有一些解决方法,但并不完美。请参见github issue thread。此外,表格标题和交叉引用在quarto中也无法正常工作,请参见此github issue。建议暂时尝试其他软件包。 - shafeeflextable
和huxtable
,但不幸的是,在quarto中使用这两个包进行表格交叉引用并不起作用。 - shafee