当编织下面的 RMarkdown 文档时,将显示基本 R 图和
flextable
输出的标题文本。然而,huxtable
输出的标题文本却不是。这是为什么?我该如何解决这个问题?
---
output: bookdown::html_document2
---
## versions
```{r}
packageVersion("huxtable") # 5.5.6
packageVersion("flextable") # 0.9.4
packageVersion("bookdown") # 0.34
packageVersion("knitr") # 1.42
```
## number one
```{r numberone, tab.cap = "My cool huxtable"}
huxtable::hux(head(iris))
```
## number two
```{r numbertwo, tab.cap = "My cool flextable"}
flextable::flextable(head(iris))
```
## number three
```{r numberthree, fig.cap = "My cool figure"}
plot(1)
```
根据上面MGP的评论,这是一个可能的解决方案:
---
output: bookdown::html_document2
---
## number one
```{r numberone, tab.cap = "My cool huxtable"}
caption <- knitr::opts_current$get("tab.cap")
huxtable::hux(head(iris)) |>
huxtable::set_caption(caption)
```