Reputation: 2886
I have a table in RMarkdown that i want to reference
Right Left Center Default
------- ------ ---------- -------
12 12 12 12
123 123 123 123
1 1 1 1
Table: Demonstration of simple table syntax.
Can anyone tell me how to reference it. So basically i want to say Please see table 1.1 for more detail
Upvotes: 4
Views: 982
Reputation: 19867
A solution that does not depend on output format is the pandoc-crossref
filter. Whenever you output a table, add a reference to its caption (here with pander):
```{r}
library(pander)
tb <- table(sample(letters[1:4], 10, replace=TRUE))
pander(tb, caption= "my table {#tbl:mytable}")
```
Then you can reference this table with:
see [@tbl:mytable] for more details
To run the filter, add this to your YAML front matter:
---
output:
pdf_document:
pandoc_args: ["-F=pandoc-crossref"]
---
Pandoc-crossref can be installed with its binaries or through the haskell platform. In the latter case:
cabal update
cabal install pandoc-crossref
Upvotes: 3