RStudio, knitr, pandoc, Word: how do I get a 'new page' in my docx?
Asked Answered
B

2

10

I am using the RStudio, knitr, pandoc, MS Word combo to get my final results in a docx document.

Occasionally, I would like the report to continue on a new page. I can't find the way to achieve this.

From what I have Googled, it seems to be possible with CSS. I don't know HTML or CSS, but if it is the solution I will learn. Just don't want to take the wrong road...

Bandeen answered 10/4, 2013 at 22:29 Comment(2)
Page-break or "new page" is not supported by Pandoc, as it has no meaning in a bunch of document formats that Pandoc can convert to/from - although there are some ongoing discussions (again): github.com/jgm/pandoc/pull/805Dett
There has been some discussion about how to inject some XML in markdown to create docx pagebreaks with pandoc: groups.google.com/forum/#!topic/pandoc-discuss/FzLrhk0vVbUGiovanna
B
2

Try the LaTeX command \newpage. Pandoc recognizes it and might (not on a computer right now) translate it to a Word page break.

Birthplace answered 11/4, 2013 at 2:50 Comment(3)
I forgot to state I was using markdown... Anyway I first tried \newpage on a line by itself and also between $ signs (as the markdown examples show usage of latex equations in this way), but neither worked... Thank you anywayBandeen
Interestingly, this works when converting to latex and then to pdf. Pandoc doesn't seem to escape the backslash so latex picks up the command. Even more interesting is that the \newpage gets erased when converting to some other format (e.g. HTML).Loveridge
The new page in html not working makes sense though. But also interested in new page and blank page for mobi and epub formats.Fiver
O
1
​```{=openxml}
<w:p>
  </w:pPr>
    <w:r>
      <w:br w:type="page"/>
    </w:r>
</w:p>
​```

Insert this codes in the position of new page you wanted in the .RMD file, and knit the file to word file. It will be translated into a new page break by pandoc, just like a \newpage command using $Latex$.

Orgy answered 17/9, 2019 at 2:56 Comment(1)
Edit your answer to include an explanation of what this does and how it solves the problemEmboly

© 2022 - 2024 — McMap. All rights reserved.