2

I'm new to R. Any help would be greatly appreciated.

I would like to rotate a single page to landscape in R markdown (pdf).

In the YAML header I have added the following (based on a previous post):

header-includes:
- \usepackage{pdflscape}
- \newcommand{\blandscape}{\begin{landscape}}
- \newcommand{\elandscape}{\end{landscape}}
output: pdf_document

and then:

\blandscape

where I wish to change to landscape (is it correct that this should not be added to the code chunk?).

However I get an error message:

! LaTeX Error: \begin{landscape} on input line 193 ended by \end{document}.

This is probably a stupid question but do I need to download this package pdflscape? Or what am I doing wrong?

Thanks!

1 Answer 1

2

You should also end your landscape page with \elandscape like this:

---
header-includes:
- \usepackage{pdflscape}
- \newcommand{\blandscape}{\begin{landscape}}
- \newcommand{\elandscape}{\end{landscape}}
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r cars}
summary(cars)
```

\blandscape

## Including Plots

You can also embed plots, for example:

```{r pressure, echo=FALSE}
plot(pressure)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

\elandscape

Output:

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

This rotates the page number to the left side, is there a way to fix this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.