Qua*_*bex 2 caption cross-reference r-markdown bookdown
我使用bookdown生成html和pdf格式的文档。如何在表格标题中插入对文档部分的引用?
使用\\ref{sec:FirstSection}pdf_book可以正常工作(但gitbook不能):
---
title: "Test"
output: bookdown::pdf_book
---
# A section {#sec:FirstSection}
The dataset in Table \@ref(tab:aTable) contains some data.
# Another section
```{r, aTable, echo = FALSE}
knitr::kable(
cars[1:5, ],
caption = "See Section \\ref{sec:FirstSection}."
)
```
Run Code Online (Sandbox Code Playgroud)
同时使用\\@ref(sec:FirstSection)gitbook可以正常工作(但pdf_book不能)
---
title: "Test"
output: bookdown::gitbook
---
# A section {#sec:FirstSection}
The dataset in Table \@ref(tab:aTable) contains some data.
# Another section
```{r, aTable, echo = FALSE}
knitr::kable(
cars[1:5, ],
caption = "See Section \\@ref(sec:FirstSection)."
)
```
Run Code Online (Sandbox Code Playgroud)
您可以使用文本引用,即bookdown提供的Markdown扩展。
---
title: "Test"
output: bookdown::gitbook
---
# A section {#sec:FirstSection}
The dataset in Table \@ref(tab:aTable) contains some data.
# Another section
(ref:aTable-caption) See Section \@ref(sec:FirstSection).
```{r, aTable, echo = FALSE}
knitr::kable(
cars[1:5, ],
caption = "(ref:aTable-caption)"
)
```
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
675 次 |
| 最近记录: |