Closed fawda123 closed 4 years ago
Interesting, I didn't know you could cross-reference tables until now. Is that a bookdown-specific feature?
I looked up how it's done for other HTML widgets like DT, and found this: https://github.com/rstudio/bookdown/issues/313. Looks like there are a couple options for cross-referencing outside of the table.
For example, you could use a figure instead:
Refer to table \@ref(fig:mytbl-1)
```{r mytbl-1, fig.cap="This is my table"}
reactable::reactable(head(iris))
Or manually add a caption with the special label:
Refer to table \@ref(tab:mytbl-2)
reactable::reactable(head(iris))
Here are a couple more ways I played around with: https://gist.github.com/glin/955b5f95fbd13b042ce39d475a1b49ff
In the future, it'll likely be possible to add a caption within the table. But I'm not sure about specifically supporting the `(#tab:label)` label when it's so specific to bookdown. Maybe something like this would work:
```r
reactable(iris, caption = "(#tab:mytable) This is my table")
Awesome, thanks for the options. And you're correct, I was using bookdown::html_document2
. Sorry for not making that clear.
I ended up going with the manual table caption with reference:
## Manual table caption
Refer to table \@ref(tab:mytbl-2)
<caption>(#tab:mytbl-2) This is my table</caption>
```{r}
reactable::reactable(head(iris))
I agree though, it would be super cool to have a caption argument where you can specify the label. Thanks!
Hi there, great package! I'm curious if you'll offer support for cross-referencing tables in RMarkdown documents rendered in HTML. Something like this perhaps: