When I print large flextable to Word using Officer, the header will appear on a separate page than the table itself. For example
test = read.table(text = 'columnA columnB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB
TextA TextB',
sep = ",",
header = T)
test = test %>% flextable()
read_docx() %>%
body_add_par("Table Test", style = "table title") %>%
body_add_flextable(value = test) %>%
print(doc, target = paste0("../../Table Test.docx"))
Generates this:
One answer suggested the solution was to change Knitr options to the following:
knitr::opts_chunk$set(tab.topcaption = TRUE,
ft.split = T,
ft.keepnext = F)
But this doesn't seem to work. Doesn't anybody have any ideas?