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?
R Markdown adds a figure ID when generating figures via R, but not for pure Markdown images. In this case, you can add an ID yourself:
The id can be chosen freely, but should start with
fig:.If you'd like a keep everything in pure Markdown, but don't want to add identifiers manually, you can use a pandoc Lua filter:
Use by adding a
pandoc_argsparameter to your output settings: