You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Officer for Rmarkdown:block_caption交叉引用编号显示为0问题

问题原因

你自定义的sfig编号序列没有在officedown的输出配置中注册,且交叉引用的标识格式不符合要求,导致引用无法正确匹配到对应编号,因此显示为0。

解决方法

修改两个位置即可:

  • 在yaml输出配置中补充自定义序列的注册声明
  • 交叉引用的标识改为seq_id:书签名的格式

修改后的完整可运行代码

---
title: "Untitled"
output: 
  officedown::rdocx_document:
    maps:
      seqfields:
        sfig: "sfig"
---

Supplemental figure \@ref(sfig:f-s1). Supplemental figure \@ref(sfig: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)
修改后交叉引用会正常显示对应编号,且补充图序列和正文图片序列完全独立,计数互不干扰。

内容的提问来源于stack exchange,提问作者Alton
相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.10 01:45:03