[英]How to generate automatic numbering of table titles in word using knit in Rmarkdown?
我正在為我的工作做一個降價報告。 我需要word中的輸出。 雖然使用 KABLE 我可以在我的桌子上放置標題,但它們沒有編號。
我應該在 kable () 或 YAML 中添加什么來自動編號我的表?
我所做的粗略示例:
table(cars$speed) %>%
as.data.frame() %>%
kable(caption = "title",digits = 0, format.args = list( decimal.mark = ",",big.mark = "."),booktabs = T) %>%
kable_styling(latex_options = c("hold_position"))
為此,您需要使用 bookdown 擴展來降價。 以下是您需要的示例 rmarkdown (.Rmd) 文件:
---
output:
bookdown::word_document2
---
See Table \@ref(tab:myfirsttable).
```{r myfirsttable, echo = FALSE}
knitr::kable(head(cars, 3), caption = "First three rows of cars dataset")
```
See Table \@ref(tab:mysecondtable).
```{r mysecondtable, echo = FALSE}
knitr::kable(head(iris, 3), caption = "First three rows of iris dataset")
```
生成后的 word 文檔如下所示:
有關更多信息,請參閱:
https://bookdown.org/yihui/bookdown/a-single-document.html https://bookdown.org/yihui/bookdown/tables.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.