2

I am using Rmarkdown (notebook) in Rstudio to generate tables and charts, using about 10 code chunks. The R code is running fine. When I knitr to MS-Word (.docx), the results look pretty good, but in some cases I would like to force a page break to improve the appearance, and sometimes to prevent a table from being split across pages (I am using 'flextable' package to create the tables). I tried the ##### page break approach, which involves creating a Word template file and changing the Header 5 properties, but that did not work. I also notice the following post from 7 years ago, which uses a simple Lua filter to allow page breaks in Word. I admit I have not tried that yet. The question is, is there an updated / easier way to control page breaks when outputting to Word in RMarkdown ? It's such a basic part of document control I am surprised how complicated the solutions are (at least based on the older posts).

Pandoc markdown page break

Any suggestions are welcome.

  • Did you try `\clearpage`? – bttomio Mar 03 '21 at 19:09
  • 1
    I tried \clearpage as you suggested (and also \newpage), but it seems those only work if knit to PDF. When I try those with Word, nothing happens, because I think those commands are part of the Late to PDF conversion. That said, I just reverting to knitting to PDF instead of Word, and now that is working, whereas before when I knit to PDF I was getting a nasty error. For now I will try to knit to PDF and see where it goes. Thanks. – cookie monster Mar 03 '21 at 20:22

0 Answers0