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

后端 未结 3 1716
终归单人心
终归单人心 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:49

    You can make the pagebreak conditional on knitting to PDF. This worked for me.

    ```{r, results='asis', eval=(opts_knit$get('rmarkdown.pandoc.to') == 'latex')}
    cat('\\pagebreak')
    ```
    

提交回复
热议问题