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

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

    Simply \newpage or \pagebreak will work, e.g.

    hello world
    \newpage
    ```{r, echo=FALSE}
    1+1
    ```
    \pagebreak
    ```{r, echo=FALSE}
    plot(1:10)
    ```
    

    This solution assumes you are knitting PDF. For HTML, you can achieve a similar effect by adding a tag

    . Note that you likely won't see a page break in your browser (HTMLs don't have pages per se), but the printing layout will have it.

提交回复
热议问题