The cross-referencing of figures works great thanks to the very helpful package bookdown
from Yihui Xie. And one can reference figures like described in this question
However, I have to separate sets of figures when authoring publications for scientific papers in R. The first set are the figures that go into the publication and the second set are SUPPLEMENTARY FIGURES.
I'd like to have a separate counter for the supplementary figures. Is there a way to do this currently in bookdown
package?
So basically id like
\@ref(fig:figure1) # evaluates to Fig. 1
\@ref(fig:figure2) # evaluates to Fig. 2
\@ref(figS:supplementary-figure1) #evaluates to Fig. S1.
PS. The most important output for me is bookdown::word_document2
Minimal working example:
---
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)
```
\@ref(fig:figure1)
evaluates to "1", not to "Fig. 1": gist.github.com/ClaudiusL/70b8423c0ff41adc09605e302a3daf87 – Equitable