title: R Markdown pdf_document2 PDF figure and table numbers by section
body: <p>I want to generate a <code>pdf_document2</code> PDF document in R Markdown where the tables and figures are labeled according to their section number. For instance, the first figure in Section 2 would be Figure 2.1. I can do that with <code>html_document2</code> but not with <code>pdf_document2</code>.</p>
  <p>See below for the code that I have written. Right now the code generates continuous Figure numbers (Figures 1, 2, 3, 4) instead of Figures 1.1, 1.2, 2.1, 2.2.</p>
  <hr />
  <pre><code>---
  title: &quot;Testing Section Numbers&quot;
  author: &quot;Authors&quot;
  date: &quot;January 2019&quot;
  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=&quot;This is my plot&quot;}
  plot(pressure)
  ```
  
  ```{r pressure2, echo=FALSE, fig.cap=&quot;This is my plot&quot;}
  plot(pressure)
  ```
  
  # Including Plots
  
  You can also embed plots, for example:
  
  ```{r pressure3, echo=FALSE, fig.cap=&quot;This is my plot&quot;}
  plot(pressure)
  ```
  
  ```{r pressure4, echo=FALSE, fig.cap=&quot;This is my plot&quot;}
  plot(pressure)
  ```
  </code></pre>