I am using rmarkdown, pandoc and knitr to create a pdf including chunks of r code. Within a code chunk I have a for loop which prints a number of graphs and some statistical out
See below a reduced and reproducible example. The answer and some general remarks:
results='asis' in the chunk options.\n) after \\pagebreak or else "ValueForV" will be pasted directly after "\linebreak", which results in an Undefined control sequence error.\newpage and \pagebreak are in a separate line by using linebreaks \n before.Escape \newpage and \pagebreak (i.e., \\newpage, \\pagebreak).
---
title: "test"
output: pdf_document
---
```{r, echo=FALSE, results='asis'}
for (i in 1:3) {
print(ggplot2::qplot(i, i+1))
cat("\n\n\\pagebreak\n")
writeLines("ValueForV")
}
```