[英]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.