小编use*_*688的帖子

Rstudio rmarkdown:单个PDF中的纵向和横向布局

我想知道如何使用rmarkdown生成在同一文档中同时具有纵向和横向布局的pdf.如果有一个纯粹的rmarkdown选择,甚至比使用乳胶更好.

这是一个小的,可重复的例子.首先,.Rmd在RStudio中渲染它(按Knit PDF按钮)会生成包含横向布局中所有页面的pdf:

---
title: "All pages landscape"
output: pdf_document
classoption: landscape
---

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

\newpage
```{r}
summary(cars)
```
Run Code Online (Sandbox Code Playgroud)

然后尝试创建一个混合纵向和横向布局的文档.其中的基本设置YAML是根据此处的"包含"部分完成的.该in_header文件"header.tex"只包含\usepackage{lscape},包建议的knitr景观布置在这里.该.tex文件与文件位于同一目录中.Rmd.

---
title: "Mixing portrait and landscape"
output:
    pdf_document:
        includes:
            in_header: header.tex
---

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

\newpage
\begin{landscape}
Landscape:
```{r}
summary(cars)
```
\end{landscape}

\newpage
More portrait:
```{r}
summary(cars)
```
Run Code Online (Sandbox Code Playgroud)

但是,此代码会导致错误:

# ! You can't use …
Run Code Online (Sandbox Code Playgroud)

pdf r rstudio knitr r-markdown

67
推荐指数
4
解决办法
3万
查看次数

标签 统计

knitr ×1

pdf ×1

r ×1

r-markdown ×1

rstudio ×1