Using lua filter is as easy as a new yaml header line.
This example should work if you download the lua filter your working directory where the rmd file is compiled
download.file("https://github.com/pandoc/lua-filters/raw/master/pagebreak/pagebreak.lua", destfile = "pagebreak.lua", mode = "wb")
After that, you just add this lua filter using pandoc_args option and use \newpage (the latex syntax) whereever you want in the document. This will be parsed and replaced by the correct page break syntax of you desired output format.
---
title: "test-lua-pagebreak"
author: "C. Dervieux"
date: "29/07/2019"
output:
word_document:
pandoc_args: ["--lua-filter=pagebreak.lua"]
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
\newpage
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
This is working for me and this document will work with pdf_document, html_document, and any other...
I'll try to suggest a PR for that in Rmardown but I am not sure how they feel about adding a lua script inside the package. Will see.