I am trying to develop a rmarkdown report for my data analysis that could be knitted both in word_document and pdf_document. Bookdown works really well for captions and automatic numbering (https://bookdown.org/yihui/bookdown/). The only main issue left is how to do page breaks that could work for both.
For pdf, i use xelatex from tinytex and \newpage
works great. For Word, I use section 5 page break and customize the style (incl. page break and white font).
I could use Edit > Find... and Replace All, but as I am still developing the report and need to test frequently that the output looks great in both formats.
Is there any way I could either:
- do the replace all in a R function,
- edit the tex template to have section 5 not display in pdf outputs (\newpage in not shown in ms word), or
- apply a magic command to force a page break compatible with all formats?
Thanks!
Here is a reproducing example of R Markdown file:
---
title: "Untitled"
author: "Me"
date: "November 15, 2018"
output:
pdf_document: default
word_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Some text.
I want a page break after this.
\newpage
##### page break
This should be the first sentence of the new page.
Some more text.
pandoc_args = ['--lua-filter=<PATH_TO_FILTER>
below bothpdf_document
andword_document
. – tarleb