The functionality you want is found within pdf_document2 from the bookdown package.
See the change in the yaml header to specify this output format
---
title: "Test"
author: "Test"
date: "23/01/2020"
output:
bookdown::pdf_document2:
fig_caption: yes
pandoc_args: ["--extract-media", "."]
header-includes:
- \usepackage{caption}
---
Now, up until now I have had you set the working directory by asking that you open an RStudio project file. When you do that, the working directory is the directory of the project file. If you look up in the top-right corner of RStudio, you will see which project file you have opened. See \ref{fig:test}.
```{r test, fig.cap="Finding the .rproj file for Chapter 3"}
knitr::include_graphics('https://raw.githubusercontent.com/sjkiss/DMJN328/master/images/chapter_3_rproj.png')
```