latex - Rmarkdown/Bookdown:补充部分的单独数字编号
问题描述
某些类型的文件,例如期刊文章,通常有一个补充部分,其中的数字编号与正文不同。
例如,在主体中,您可能有图 1-5。但是,对于补充部分,编号重新开始,如图 S1、S2、S3 等。
Bookdown 允许交叉引用(\@ref(fig:label)
但我不确定如何在单独的部分重新开始编号。有没有好的方法呢?
解决方案
您可以在文件的 YAML 标头中定义一个新的LaTeX 函数.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")
```
推荐阅读
- python - Python Xlsxwriter 无法正常工作
- janusgraph - 如何在 JanusGraph 中存储 JSON 或嵌套类型?
- c# - 如何在windows Application C#中使用HttpClient.PostJsonAsSync()发送具有多个图像的复杂数据
- css - 在角度 2 中使用引导滑块,动态数据滑块不起作用
- ios - 在 CoreData 中设置 NSFetchRequest 的 fetchOffset 结果不一致
- h2o - 使用 Java POJO/MOJO 和 EasyPredictModelWrapper 基于 H2O 帧的预测
- php - Symfony 路由注解
- python - 使用 html 表单获取列表并将其存储在数据库 SQLalchemy Flask Python 中
- javascript - Skrollr 导致干预错误并改变 body 和 html 的 element.style 溢出:隐藏
- java - 除了实现共识算法之外,从客户端创建服务器的其他方法是什么?