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
相关产品推荐
相关产品推荐

