You can define a new LaTeX function in the YAML header of your .rmd
file as follows:
\newcommand{\beginsupplement}{
\setcounter{table}{0}
\renewcommand{\thetable}{S\arabic{table}}
\setcounter{figure}{0}
\renewcommand{\thefigure}{S\arabic{figure}}
}
Then type \beginsupplement
when you're ready to start labelling the figures and tables with S1, S2... etc. This solution works fine if you export to PDF only, as it uses LaTeX commands to format the output. It therefore will not work for HTML or Word outputs.
---
title: "title"
author:
- My Namington*
- '*\textit{[email protected]} \vspace{5mm}'
output:
bookdown::pdf_document2
fontsize: 12pt
header-includes:
\usepackage{float} \floatplacement{figure}{H}
\newcommand{\beginsupplement}{\setcounter{table}{0} \renewcommand{\thetable}{S\arabic{table}} \setcounter{figure}{0} \renewcommand{\thefigure}{S\arabic{figure}}}
---
```{r, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(ggplot2)
```
# Main text
Here is the main text of my paper, and a link to a normally-labelled Figure \@ref(fig:irisPlot).
```{r irisPlot, fig.cap="This is a figure caption."}
ggplot(iris, aes(Species, Sepal.Length, colour = Species)) + geom_jitter()
```
\newpage
# Supplementary material {-}
\beginsupplement
Here is the supplement, including a link to a figure prefixed with the letter S Figure \@ref(fig:irisPlot2).
```{r irisPlot2, echo=FALSE, fig.cap= "This is a supplementary figure caption."}
ggplot(iris, aes(Sepal.Width, Sepal.Length, colour = Species)) +
geom_point() +
stat_smooth(method = "lm")
```