Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205399

How can I create RMarkdown files that render good in PDF and HTML which also contain numbered figures?

$
0
0

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 :)


Viewing all articles
Browse latest Browse all 205399

Trending Articles