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.-title: 'Making page break using fifth-level header block'output:worddocument:referencedocx: headingfive.docx-In your Rmd document, you define referencedocx in the YAML header, and now you can use the page-breaking #####.Please see below. What you are trying to do is force a 'page break' or 'new page' in a word document generated with Pandoc. Sungpil's article was close, but didn't quite work. This was the best solution I found for this:Even better, the author included the Word template to make this work.
![]() ![]()
The R-blogger's link to his template is broken, and the header is formatted wrong. Some notes I took:1) You might need to include the whole path to the word template in your Rmd header, like so: output:worddocument:referencedocx: C:/workspace/myproject/mystyles.docx2) The template at the link above changed some of the default style settings so you'll need to change them back.
Referencedocx: Use the specified file as a style reference in producing a docx file. For best results, the reference docx should be a modified version of a docx file produced using pandoc. Pass 'default' to use the rmarkdown default styles. See the online documentation for additional details on using the worddocument format.
![]() Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |