I'm struggling with flextables adhering to each other when I render them in a for loop in my rmarkdown notebook. The output is docx (officedown::rdocx_document to be precise). This is my code:
dt <- head(iris)
for (i in 1:10) {
flextable_to_rmd(flextable(dt))
}
The result is a set of flextables but without any space between them and it causes problems when a table spans over two pages. It get unreadable for more complex tables.
The only workaround I found is adding cat("--")
as the las line inside the for loop. Is there more elegant solution to this?
This code let you add an empty Word paragraph after each table.
---
title: "Untitled"
output: word_document
---
```{r results='asis'}
library(flextable)
dt <- head(iris)
for (i in 1:10) {
flextable_to_rmd(flextable(dt), text_after = "<w:p/>")
}
```