Bookdown and rendering kable tables to a word document

Viewed 1050

I am trying to generate a Word document from a bookdown file. All seems to work well, apart from the last chunk where I'm attempting to knit a kable table. There seems to be a problem generating tables that run over a page. If I try to render:

library(kableExtra)
tab <- bind_rows(mtcars,mtcars,mtcars)
kableExtra::kable(tab) %>% 
      kable_styling(full_width = T, font_size = 12) %>%
      column_spec(1, bold = T) 

I get the following error:

Error: Functions that produce HTML output found in document targeting docx output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:

  always_allow_html: true

My yaml config is as follows:

# Config parametres for word rendering      
bookdown::word_document2:
  split_by: chapter
  toc: yes
  toc_depth: 3

If I add always_allow_html: true I still get the same error.

0 Answers
Related