【发布时间】:2014-11-09 02:00:59
【问题描述】:
我想知道如何使用rmarkdown 在同一文档中生成具有纵向和横向布局的pdf。如果有一个纯粹的rmarkdown 选项会比使用乳胶更好。
这是一个可重现的小例子。首先,在 RStudio 中渲染这个 .Rmd(按 Knit PDF 按钮)会生成一个所有页面都是横向布局的 pdf:
---
title: "All pages landscape"
output: pdf_document
classoption: landscape
---
```{r}
summary(cars)
```
\newpage
```{r}
summary(cars)
```
然后尝试创建一个混合纵向和横向布局的文档。 YAML 中的基本设置是根据 here 的“包含”部分完成的。 in_header 文件'header.tex' 仅包含\usepackage{lscape},建议用于knitr 横向布局here 的包。 .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)
```
但是,此代码会导致错误:
# ! You can't use `macro parameter character #' in horizontal mode.
# l.116 #
# pandoc.exe: Error producing PDF from TeX source
# Error: pandoc document conversion failed with error 43
非常感谢任何帮助。
【问题讨论】:
标签: r pdf rstudio knitr r-markdown