# Figure Caption In RMarkdown from Images from URL

Hi: I have a basic document trying to embed images with URLs in an RMarkdown document. I would like to generate cross-references to the images in the text. I've read through the Rmarkdown documentation here. I feel like I am missing something basic. Here is the reproducible code.

---
title: "Test"
author: "Test"
date: "23/01/2020"
output:
pdf_document:
fig_caption: yes
pandoc_args: ["--extract-media", "."]
- \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')


I did find this solution but I thought something easier had been developed, but I guess not!


See \ref{fig:test}.

{r test, fig.cap="\\label{fig:test} Finding the .rproj file for Chapter 3"}
knitr::include_graphics('https://raw.githubusercontent.com/sjkiss/DMJN328/master/images/chapter_3_rproj.png')


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", "."]
{r test, fig.cap="Finding the .rproj file for Chapter 3"}