0

我正在使用官员包中的 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)
    ```

这是一个屏幕截图,正确的标题编号以蓝色圈出;错误的交叉引用编号以红色圈出。 在此处输入图像描述

4

1 回答 1

0

我发现如果您使用它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)
    ```

单词输出截图

于 2021-07-31T13:05:37.960 回答