When knitting the below RMarkdown document the caption texts for both the base R plot and the flextable
output are shown. The caption text for the huxtable
output is, however, not. Why is that and how can I fix this?
---
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)
```
Based on MGP's comment above this is a possible solution:
---
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)
```