I have been working on some documents that should render in both HTML and PDF.
For referencing in Latex I have used the \ref{fig:fig1}
style and giving figures a numbered caption.
For referencing in HTML I have tried several other things. Using bookdown::html_document2
enables me to use \@ref(fig:fig1)
.
But this is still not the same text. Is there a way of referencing figures that works in both PDF and HTML and uses the same tag in the source Rmd-file?
I've tried using knitr::opts_knit$get("rmarkdown.pandoc.to")
to create a function that switches between contexts, but this seems unsatisfactory. Are there any better options?
Thanks :)