Skip to content

rmarkdown cross-referencing #15

Closed
Closed

Description

@fawda123

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")
```

Activity

  1. glin commented on Nov 29, 2019

    @glin
    Owner

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

    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:

    reactable(iris, caption = "(#tab:mytable) This is my table")
  2. fawda123 commented on Dec 1, 2019

    @fawda123
    Author

    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!

  3. changed the title [-]rmardown cross-referencing[/-] [+]rmarkdown cross-referencing[/+] on Dec 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions