I would like to cross-reference an image which I include with the markdown  syntax.
I would like to be able to cross-reference this image as \@ref(fig:caption-with-spaces).
I am using bookdown::pdf_document2.
Is this possible?
Labels can be attached to images included in markdown using the syntax {#fig:anchor_name}.
That said, there are two further options
\includegraphics command.include_graphics function.A LaTeX solution would look something like:
\begin{figure}
\includegraphics{path/to/picture.png}
\caption{Caption with spaces}
\label{fig:example}
\end{figure}
A knitr solution would look like
```{r, fig.cap = "Caption with spaces", label="example"}
knitr::include_graphics("path/to/picture.png")
```
With both of these solutions you can cross-reference the resulting image with \ref{fig:example}.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With