abiyug abiyug - 1 year ago 100
R Question

knitr refer to a figures with a link

When using knitr/Rmarkdown, how does one link to figure within the document? Example figure 10 is on page 10, I want to link to it from page four.

like this:
"Take a look at figure 10" The figure 10 should have a link that can be clicked.

Answer Source

This is probably a duplicate. Anyway, your .rmd file could look more or less like this:

title: "Clickable Reference to Figure"
    fig_caption: yes

Here's a figure:

```{r fig, echo=FALSE, fig.width=4,fig.height=3, fig.cap="\\label{fig:myfig}plotting example"}
plot(runif(100, 0.0, 1.0),type="l")

Take a look at Figure \ref{fig:myfig} for an example of plotting in R.

enter image description here

It is not necessary to specify the page or the precise position of the figure in the document. The link generated in the output by \ref{} directs to that figure.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download