Вы можете определить новую функцию LaTeX в заголовке YAML вашего .rmd
файла следующим образом:
\newcommand{\beginsupplement}{
\setcounter{table}{0}
\renewcommand{\thetable}{S\arabic{table}}
\setcounter{figure}{0}
\renewcommand{\thefigure}{S\arabic{figure}}
}
Затем введите \beginsupplement
, когда вы будете готовы начатьмаркировка рисунков и таблиц с помощью S1, S2 ... и т. д. Это решение отлично работает, если вы экспортируете только в PDF, поскольку для форматирования вывода используются команды LaTeX.Поэтому он не будет работать для выходных данных HTML или Word.
---
title: "title"
author:
- My Namington*
- '*\textit{email@example.com} \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")
```
![enter image description here](https://i.stack.imgur.com/PkgWw.png)