在 RMarkdown 中引用一个简单的 table

Referencing a simple table in RMarkdown

我想参考 RMarkdown 中的 table

  Right     Left     Center     Default
-------     ------ ----------   -------
     12     12        12            12
    123     123       123          123
      1     1          1             1

Table:  Demonstration of simple table syntax.

谁能告诉我如何引用它。所以基本上我想说的是 see table 1.1 for more detail

不依赖于输出格式的解决方案是pandoc-crossref filter。每当您输出 table 时,添加对其标题的引用(此处带有 pander):

```{r}
library(pander)
tb <- table(sample(letters[1:4], 10, replace=TRUE))
pander(tb, caption= "my table {#tbl:mytable}")
```

然后您可以通过以下方式引用此 table:

see [@tbl:mytable] for more details

对于 运行 过滤器,将其添加到您的 YAML 前端:

---
output:
  pdf_document:
    pandoc_args: ["-F=pandoc-crossref"]
---

Pandoc-crossref可以与其binaries or through the haskell platform一起安装。在后一种情况下:

cabal update
cabal install pandoc-crossref