我正在使用officer包中的run_autonum和block_caption为我的补充图形创建图形标题,然后交叉引用它们(希望成为与非补充图形不同的系列,以便重新开始编号)。图标题中的编号非常有效(1,2,...)。但是,当交叉引用时,该数字显示为0。
下面是一个reprex Rmd文件:
---
title: "Untitled"
output:
officedown::rdocx_document
---
Supplemental figure \@ref(f-s1). Supplemental figure \@ref(f-s2)
```{r, echo=FALSE}
library(officer)
sfig_num <- run_autonum(seq_id = "sfig",
pre_label = "Figure S",
bkm="f-s1")
block_caption("A figure caption.",
style = "Image Caption",
autonum = sfig_num)
sfig_num <- run_autonum(seq_id = "sfig",
pre_label = "Figure S",
bkm="f-s2")
block_caption("A figure caption.",
style = "Image Caption",
autonum = sfig_num)
```这是一个截图,正确的标题编号用蓝色圈出;错误的交叉引用编号用红色圈出。

发布于 2021-07-31 13:05:38
我想,如果你使用r run_reference(bkm-id)而不是bookdown风格的\@ref(bkm-id),那么编号就会起作用:
---
title: "Untitled"
output:
officedown::rdocx_document
---
```{r echo=FALSE, warning=FALSE}
library(officer)
library(officedown)
```
Supplemental figure `r run_reference("fs1")`. Supplemental figure `r run_reference("fs2")`
```{r, echo=FALSE, warning=FALSE}
sfig_num <- run_autonum(seq_id = "sfig",
pre_label = "Figure S",
bkm="fs1")
block_caption("A figure caption.",
style = "Image Caption",
autonum = sfig_num)
sfig_num <- run_autonum(seq_id = "sfig",
pre_label = "Figure S",
bkm="fs2")
block_caption("A figure caption.",
style = "Image Caption",
autonum = sfig_num)
```

https://stackoverflow.com/questions/68579449
复制相似问题