How to add a page break in word document generated by RStudio & markdown

Giorgio Spedicato picture Giorgio Spedicato · Jul 10, 2014 · Viewed 21.1k times · Source

I writing a Word document with R markdown in R Studio. I can get many things, but at the moment I am not figuring out how can I get a page break. I have found solutions but only for rendered latex / pdf document that it is not my case.

Answer

Sungpil Han picture Sungpil Han · Aug 18, 2016

There is an easier way by using a fifth-level header block (#####) and a docx template defined in YAML.

After creating headingfive.docx in Microsoft Word, you select Modify Style of the Heading 5, and then select Page break before in the Line and Page Breaks tab and save the headingfive.docx file.

Page break before

---
title: 'Making page break using fifth-level header block'
output: 
  word_document:
    reference_docx: headingfive.docx
---

In your Rmd document, you define reference_docx in the YAML header, and now you can use the page-breaking #####.

Please see below.

https://www.r-bloggers.com/r-markdown-how-to-insert-page-breaks-in-a-ms-word-document/