如何在bookdown / knitr / Rmarkdown中添加交叉引用的补充数字

时间:2019-09-02 08:34:20

标签: r r-markdown knitr bookdown cross-reference

感谢谢益辉(Yihui Xie)提供的非常有用的软件包bookdown,对数字的交叉引用非常有用。并且可以参考本question

中所述的图形

但是,在为R撰写科学论文的出版物时,我必须将数字分开。第一组是出版物的数字,第二组是辅助数字。

我想为补充数字另设柜台。目前bookdown软件包中有没有办法做到这一点?

所以基本上像

\@ref(fig:figure1) # evaluates to Fig. 1
\@ref(fig:figure2) # evaluates to Fig. 2
\@ref(figS:supplementary-figure1) #evaluates to Fig. S1. 

PS。对我来说最重要的输出是bookdown::word_document2

最小工作示例:

---
title: "MWD"
output: bookdown::word_document2
---

# Results
This text refers to Fig. \@ref(fig:fig1main). 
We also want to refere here to Fig. \@ref(fig:fig2main).

In some cases we also need supplementary data. Please see Suppl. Fig. S\@ref(fig:fig1supp).

Please note that the 'S' before the reference should optimally NOT be there and ideally one should write:

```
Fig. \@ref(fig:fig1supp) 
```

what would evaluate to Fig. S1. 


# Figures


```{r fig1main, fig.cap="First Main Figure"}
plot(1)
```


```{r fig2main, fig.cap="Second Main Figure"}
plot(1)
```

# Supplementary data

```{r fig1supp, fig.cap="This is a supplementary figure and it should be called Fig. S1 and not Fig 3."}
plot(1)
```

0 个答案:

没有答案
相关问题