R Markdown pdf_document2 Номера рисунков и таблиц в формате PDF по разделам

Я хочу создать pdf_document2 PDF-документ в R Markdown, где таблицы и рисунки помечены в соответствии с номерами их разделов. Например, первым рисунком в разделе 2 будет рис. 2.1. Я могу сделать это с html_document2, но не с pdf_document2.

См. Ниже написанный мной код. Прямо сейчас код генерирует непрерывные номера рисунков (рисунки 1, 2, 3, 4) вместо рисунков 1.1, 1.2, 2.1, 2.2.


title: "Testing Section Numbers"
author: "Authors"
date: "January 2019"
output:
  bookdown::pdf_document2:
    fig_caption: yes
    latex_engine: xelatex
    number_sections: true
    toc: yes
    toc_depth: 2
editor_options:
  chunk_output_type: console
link-citations: yes
linkcolor: blue
subparagraph: yes
citecolor: blue
urlcolor: blue
---

# R Markdown

```{r pressure1, echo=FALSE, fig.cap="This is my plot"}
plot(pressure)
```

```{r pressure2, echo=FALSE, fig.cap="This is my plot"}
plot(pressure)
```

# Including Plots

You can also embed plots, for example:

```{r pressure3, echo=FALSE, fig.cap="This is my plot"}
plot(pressure)
```

```{r pressure4, echo=FALSE, fig.cap="This is my plot"}
plot(pressure)
```

person yaleeconjournal    schedule 20.12.2018    source источник


Ответы (1)


Клуджи-решение - добавить в заголовок несколько команд LaTeX:

header-includes:
  \let\counterwithout\relax
  \let\counterwithin\relax
  \usepackage{chngcntr}
  \counterwithin{figure}{section}
person yaleeconjournal    schedule 20.12.2018