Home > Mobile >  RMarkdown Change numbering for tables in PDF document
RMarkdown Change numbering for tables in PDF document

Time:09-01

I want to change the numbering of the tables in the RMarkdown document so that all tables in the appendix have an "A-" in front of the number, thus: "Table A-2".
Only in the appendix. Otherwise with normal numbering ("Table 1").
However, I am not really getting anywhere.
Here is my reproducible example:\

---
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")
```

enter image description here

CodePudding user response:

This is really a LaTeX question, and I found the answer here.

You add these LaTeX lines after your Appendix title:

\setcounter{table}{0}
\renewcommand{\thetable}{A\arabic{table}}
  • Related