gpt4 book ai didi

r-markdown - 如何在适用于 pdf 和 html 输出的 bookdown 文档的表格标题中插入引用

转载 作者:行者123 更新时间:2023-12-02 06:50:19 24 4
gpt4 key购买 nike

我使用 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}."
)
```

虽然使用 \\@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)."
)
```

最佳答案

您可以使用 text references , 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)"
)
```

关于r-markdown - 如何在适用于 pdf 和 html 输出的 bookdown 文档的表格标题中插入引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46670422/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com