I wrote a .RMD file that has many figures and tables. Here is the initial info:
---
title: "My Title"
author: ""
date: "5/14/2021"
output: bookdown::pdf_book
bibliography: bibliography.bib
link-citations: yes
---
```{r setup, include=FALSE}
library(knitr)
opts_chunk$set(echo = FALSE,
fig_align = "left",
fig_width = 7,
fig_height = 7,
dev = "png",
cache = FALSE)
```
The file is divided into Chapters (#), Sections (##) and Subsections (###). In each Subsection I have inserted a table and three figures, like this
### President
Some text ...
Figure \@ref(fig:presidentialline) shows ...
f(fig:presidentialmean) shows that ...
Figure \@ref(fig:presidentialvol) has Y ...
```{r presidentialsumm}
kable(Presidential_Summary_BarCharts$Summary,
format='latex',
caption='President Summary Statistics')
```
```{r presidentialline, fig.cap=' Performance by President'}
Presidential_LineChart
```
```{r presidentialmean, fig.cap='President Mean'}
Presidential_Summary_BarCharts$MeanBarChart
```
```{r presidentialvol, fig.cap='President Vol'}
Presidential_Summary_BarCharts$VolBarChart
```
### Governor
Governor Subsection text ...
Government subsection figures and tables, similar to the above
The problem is that the three figures and the table do not stay inside the subsection marked with ###. For example, the PDF file would show the text of the President Subsection and one or more figures then show the text of the Governor Subsection and only then show the remaining figures of the President subsection. The tables tend to be inserted before the appropriate Subsection. Is there a way to force the figures and table in the PDF file to stay within a Subsection demarcated in the .RMD file by ###?