gpt4 book ai didi

knitr - 在 bookdown :html_document2 中没有使用 pander 的表格编号

转载 作者:行者123 更新时间:2023-12-01 11:19:27 25 4
gpt4 key购买 nike

当与 bookdown::html_document2 一起使用时,pander 不包括表格编号。我错过了一些选择吗?

---
title: "Pander Table Numbering"
output: bookdown::html_document2
---

# Chapter 1

```{r}
library(knitr)
library(pander)
# Table 1.1
kable(head(iris), caption = "Iris with kable")
# Another Table 1.1 (ok, same chunk = same table)
kable(head(mtcars), caption = "Mtcars kable")
```

```{r}
# No table number
pander(head(iris), caption = "Iris with pander")
```

```{r}
# Table 1.2
kable(head(mtcars), caption = "Mtcars kable")
```

最佳答案

来自 https://bookdown.org/yihui/bookdown/tables.html

If you decide to use other R packages to generate tables, you have to make sure the label for the table environment appears in the beginning of the table caption in the form (\#label) (again, label must have the prefix tab:).



这里的原因是 pander::pander()不产生正确的 (\#tab:***) .你可以向 的作者报告这个bug驯鹿 .
kable(head(iris), caption = "Iris with kable")
Table: (\#tab:unnamed-chunk-1)Iris with kable

Sepal.Length Sepal.Width Petal.Length Petal.Width Species
------------- ------------ ------------- ------------ --------
5.1 3.5 1.4 0.2 setosa
4.9 3.0 1.4 0.2 setosa
4.7 3.2 1.3 0.2 setosa
4.6 3.1 1.5 0.2 setosa
5.0 3.6 1.4 0.2 setosa
5.4 3.9 1.7 0.4 setosa
pander(head(iris), caption = "Iris with pander")
-------------------------------------------------------------------
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
-------------- ------------- -------------- ------------- ---------
5.1 3.5 1.4 0.2 setosa

4.9 3 1.4 0.2 setosa

4.7 3.2 1.3 0.2 setosa

4.6 3.1 1.5 0.2 setosa

5 3.6 1.4 0.2 setosa

5.4 3.9 1.7 0.4 setosa
-------------------------------------------------------------------

Table: Iris with pander

关于knitr - 在 bookdown :html_document2 中没有使用 pander 的表格编号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45651426/

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