bookdowngtsummary

bookdown and gtsummary: Why is chunk name added to table caption?


I have a .Rmd file like this:

---
output:
  bookdown::html_document2
  #html_document
---

```{r mychunkname}
library(gtsummary)
trial %>%
  select(age, grade, response) %>%
  tbl_summary() %>%
  modify_caption(caption = "MY CAPTION")

library(knitr)
trial %>%
  kable(caption = "MY CAPTION")
```

When I change the output format from html_document to bookdown::html_document2, the caption of the first table looks like this in the html file: (#tab:mychunkname)MY CAPTION. Why does that (#tab:mychunkname) part appear, and how do I get rid of that? For crosschecking I included that second table - which has the expected caption in both output formats.

This is new behaviour, possibly introduced in an update of one of the packages? I am on bookdown version 0.41, gtsummary version 2.0.4, R version 4.4.0.


Solution

  • try use options("htmltools.preserve.raw" = FALSE) , found it here https://github.com/rstudio/gt/pull/1800