I am running into an issue where the TOC is not appearing in my HTML output of an Rmd if I include HTML documents from certain source. For example, if I make a table with kable
and save to an HTML:
library(kableExtra)tbl <- kable(mtcars) %>% kable_styling(bootstrap_options = "striped", font_size = 12)save_kable(tbl, file = "testkable_tbl.html")
Then try and read the HTML into an Rmd:
---title: "Untitled"author: "User"date: "`r Sys.Date()`"output: html_document: toc: TRUE toc_depth: 4 toc_float: TRUE---# hello```{r}htmltools::includeHTML("testkable_tbl.html")```
The TOC does not appear.This issue is not exclusive to kable
as I have had this issue including HTML documents from other sources.
Could someone explain why this issue appears with some HTML documents and not others (no issues with including HTML documents made with gt
) and tell me if there is a work around to include HTML tables from kable
and other sources in my Rmd without the TOC disappearing?