How to add \newpage in Rmarkdown in a smart way?

后端 未结 3 1722
终归单人心
终归单人心 2020-12-02 06:24

I wonder if one could simply use LaTeX \\newpage command in R markdown v2 in a different way than this:

```{r, results=\'asis\', echo=FALSE}
cat         


        
3条回答
  •  星月不相逢
    2020-12-02 06:46

    In the initialization chunk I define a function

    pagebreak <- function() {
      if(knitr::is_latex_output())
        return("\\newpage")
      else
        return('
    ') }

    In the markdown part where I want to insert a page break, I type

    `r pagebreak()`
    

提交回复
热议问题