我想更改 RMarkdown 文档中表格的编号,以便附录中的所有表格在数字前面都有一个“A-”,即:“Table A-2”。
仅在附录中。否则采用正常编号(“表 1”)。
然而,我并没有真正取得任何进展。
这是我的可重现示例:\
---
title: "This is my title"
date: "`r Sys.setlocale(locale = 'English') ; format(Sys.time(), '%B %d, %Y')`"
output: pdf_document
---
```{r echo = F, message = F, warning = F}
library(tidyverse)
library(knitr)
``` #The hash mark must be removed!
# Results
```{r echo = F, message = F, warning = F}
tribble(~column1, ~column2,
"value1", 2,
"value2", 5
)%>%
kable(booktabs=T, caption = "This is the caption of the first table")
```
# Appendix
```{r echo = F, message = F, warning = F}
tribble(~column1, ~column2,
"value1", 6,
"value2", 8
)%>%
kable(booktabs=T, caption = "This is the caption of the second table")
```
这确实是一个 LaTeX 问题,我在here找到了答案。
您在附录标题后添加这些 LaTeX 行:
\setcounter{table}{0}
\renewcommand{\thetable}{A\arabic{table}}
或者,这可以用于对附录中的表格进行编号。只需在附录标题后添加这些行 -
\renewcommand{\thetable}{\thesection\arabic{table}}
\renewcommand{\theHtable}{\thesection\arabic{table}}
\setcounter{table}{0}
这也适用于链接文档中任意位置的表格。