For those who need something that works for Word DOCX, here is a belated answer, based on this Restart Figure Numbering for Appendix / Supplementary Material in bookdown.
---
output: officedown::rdocx_document
---
```{r setup, include=FALSE}
pacman::p_load(officedown, officer, knitr)
knitr::opts_chunk$set(echo = FALSE)
## Custom function to restart numbering at the start of each new chapter.
## You could also just do this manually!
new_chapter <- function(){
if(!exists("chapter_count")) chapter_count <<- 0
chapter_count <<- chapter_count + 1
}
```
# Chapter 1: Red section
```{r fig.id="red-plot1"}
new_chapter()
barplot(1:8, col = "red4")
block_caption("Some red bars",
style = "Figure",
autonum = run_autonum(seq_id = 'fig',
start_at = 1, ##restart
bkm = 'red-plot1',
pre_label = paste0("Figure ", chapter_count, ".")))
```
Figure `r chapter_count`.\@ref(fig:red-plot1) shows some red bars.
# Chapter 2 : Blue section
```{r fig.id="blue-plot1"}
new_chapter()
barplot(1:8, col = "dodgerblue3")
block_caption("Some blue bars",
style = "Figure",
autonum = run_autonum(seq_id = 'fig',
start_at = 1, ##restart
bkm = 'blue-plot1',
pre_label = paste0("Figure ", chapter_count, ".")))
```
Figure `r chapter_count`.\@ref(fig:blue-plot1) shows some blue bars.
```{r fig.id="blue-plot2"}
barplot(8:1, col = "dodgerblue3")
block_caption("More blue bars",
style = "Figure",
autonum = run_autonum(seq_id = 'fig',
bkm = 'blue-plot2',
pre_label = paste0("Figure ", chapter_count, ".")))
```
Figure `r chapter_count`.\@ref(fig:blue-plot2) shows some more blue bars.
# Supplementary section
```{r fig.id="supp-plot1"}
barplot(1:4, main = "Supplementary bars" )
block_caption("Some supplementary bars",
style = "Figure",
autonum = run_autonum(seq_id = 'fig',
start_at = 1, ##restart count
bkm = 'supp-plot1',
pre_label = "Figure S"))
```
Figure S\@ref(fig:supp-plot1) shows some supplementary bars