When cross referencing tables and figures in RMarkdown via @ref(tab:...)
and/or @ref(fig:...)
the rendered output will create a link on the number of the respective output. i.e. “Table 1” will only show a link on “1” and likewise “Figure 1” will only show a link on “1”.
Can I extend the linking text so that the link spans the full e.g. “Table 1″/”Figure 1”? If yes, how? I’m looking for a solution that will generically work for both docx and html outputs.
---
output:
officedown::rdocx_document:
base_format: "rmarkdown::word_document"
bookdown::html_document2:
toc: true
toc_float: true
fig_caption: true
number_sections: false
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(ggplot2)
library(flextable)
if (!knitr::is_html_output()) {
library(officedown)
}
```
## My nice iris plot
```{r my-nice-figure, fig.cap = "A really cool figure."}
ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width)) +
geom_point()
```
## My nice iris table
```{r my-nice-table, tab.cap = "A really cool table.", tab.id = "my-nice-table"}
flextable(head(iris))
```
Table @ref(tab:my-nice-table) shows interesting things. The same is true for Figure @ref(fig:my-nice-figure).