Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

r - How to add ewpage in Rmarkdown in a smart way?

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

```{r, results='asis', echo=FALSE}
cat("\newpage")
```

I produce pdf_output. If any1 has any idea please do not hesitate to comment :) ! Thanks

I create pdf like this:

---
title: " "
author: " "
date: "2014"
output: 
   pdf_document:
      includes:
         in_header: naglowek.tex
      highlight: pygments
      toc: true
      toc_depth: 3
      number_sections: true
      keep_tex: true
---
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Simply ewpage or pagebreak will work, e.g.

hello world

ewpage
```{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 <P style="page-break-before: always">. 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...