I wonder how to use rmarkdown to generate a pdf which has both portrait and landscape layout in the same document. If there is a pure rmarkdown opt
Building upon previous solutions, the following solution does not require an auxiliary header.tex file. All contents are contained in the .Rmd file. The LaTeX commands are instead defined in a header-includes block in the YAML header. More info can be found here.
Also, I noticed that using the lscape LaTeX package rotates the contents of a page, but not the PDF page itself. This is resolved using the pdflscape package.
---
title: "Mixing portrait and landscape WITHOUT a header.tex file"
header-includes:
- \usepackage{pdflscape}
- \newcommand{\blandscape}{\begin{landscape}}
- \newcommand{\elandscape}{\end{landscape}}
output: pdf_document
---
Portrait
```{r}
summary(cars)
```
\newpage
\blandscape
Landscape
```{r}
summary(cars)
```
\elandscape
\newpage
More portrait
```{r}
summary(cars)
```