How to Add \Newpage in Rmarkdown in a Smart Way

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

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 <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.

Inserting a blank page after a title page in RMarkdown

Try adding an invisible character and \pagebreak before the TOC:

 

\pagebreak

This did the trick for me. Good luck with the thesis!

How t o enter properly instructions to widen margins a page for RMarkdown pdf.doc

If you want to make a special margin in your file (knitting to pdf), then try this LaTeX-solution:

Add this package to the header:

header-includes: 
\usepackage{geometry}

Make a special margin for some pages (you also can use mm, cm):

\newgeometry{top=1in,left=1in,bottom=1in,right=1in}

And after return to your previous style:

\restoregeometry  

An example to you:

---
title: "R"
header-includes:
- \usepackage{geometry}
output:
pdf_document: default
---

\newgeometry{top=1in,left=5in,bottom=1in,right=1in}

```{r}
options(width = 100)
matrix(runif(100), ncol = 20)
```
\restoregeometry

\newpage
\newgeometry{top=1in,left=0in,bottom=1in,right=1in}

```{r}
options(width = 100)
matrix(runif(100), ncol = 20)
```
\restoregeometry

\newpage
\newgeometry{top=5in,left=1in,bottom=1in,right=1in}

```{r}
options(width = 100)
matrix(runif(100), ncol = 20)
```
\restoregeometry


Related Topics



Leave a reply



Submit