You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Here's a cross-reference for Table \@ref(tab:mytable).
```{r}
reactable(iris, label = "mytable")
```
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: rstudio/bookdown#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)
<caption>(#tab:mytbl-2) This is my table</caption>
```{r}
reactable::reactable(head(iris))
```
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:
reactable(iris, caption="(#tab:mytable) This is my table")
Reacted by Marcus W Beck, Bangyou Zheng and Ido Bar
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!
Activity
glin commentedon Nov 29, 2019
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: rstudio/bookdown#313. Looks like there are a couple options for cross-referencing outside of the table.
For example, you could use a figure instead:
Or manually add a caption with the special label:
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:fawda123 commentedon Dec 1, 2019
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:
I agree though, it would be super cool to have a caption argument where you can specify the label. Thanks!
[-]rmardown cross-referencing[/-][+]rmarkdown cross-referencing[/+]