0

Question

Using LaTeX commands for creating Word-Docs with knitr works with \newline. But for new pages \newpage does not work.

Code: New line works. New page NOT

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:
cars
```{r}
summary(cars)
```

\newline

You can also embed plots, for example:

\newpage

```{r, echo=FALSE}
plot(cars)
```

\newline


\newline

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
b4154
  • 353
  • 3
  • 4
  • 14
  • If I use "knit pdf" to create a PDF document then `\newpage` or `pagebreak` works. But I need a word document – b4154 Feb 08 '16 at 10:47
  • I'm not aware of any updates to this comment: http://rmarkdown.rstudio.com/word_document_format.html#comment-1454328060. I'm also not sure if this is a limitation in rmarkdown or in pandoc. – Benjamin Feb 08 '16 at 11:10
  • I will try joel allen's answer at: https://groups.google.com/forum/#!topic/pandoc-discuss/FzLrhk0vVbU . But I do not know how to use his solution with rmarkdown. With pandoc he creates the file after compiling the hs-script with: $ pandoc --filter ./pandoc-word-pagebreak input.md -o output.docx – b4154 Feb 08 '16 at 13:48
  • see [here](http://rmarkdown.rstudio.com/markdown_document_format.html#pandoc_arguments) for help. Basically, you should add `pandoc_args: [ "-F", "./pandoc-word-pagebreak" ]` to your yaml front matter – scoa Feb 08 '16 at 16:39

0 Answers0