【发布时间】:2020-06-30 11:31:20
【问题描述】:
我有一个用 Rmarkdown 编写的 huskydown 文档(基于 thesisdown/bookdown),它被编入 PDF/LaTex,但后来也编入 HTML。
对于文档中的单个页面,我想更改页边距(例如,包括一个非常大的表格/图形/外部 PDF)。 在此页面之后,页边距应恢复为默认值。
我尝试了什么:
---
author: 'Your R. Name'
date: 'May 20xx'
institution: 'Reed College'
division: 'Mathematics and Natural Sciences'
advisor: 'Advisor F. Name'
# If you have more two advisors, un-silence line 7
#altadvisor: 'Your Other Advisor'
department: 'Mathematics'
degree: 'Bachelor of Arts'
title: 'My Final College Paper'
knit: "bookdown::render_book"
site: bookdown::bookdown_site
output:
thesisdown::thesis_pdf: default
---
### Normal page margins again
```{r echo=FALSE, out.width = '100%'}
ggplot(mtcars, aes(x=wt, y=mpg)) +
geom_point()
```
\newpage
### Reduced page margins
```{r, echo = FALSE, results = "asis"}
cat("\\newgeometry{left=1cm,right=1cm,top=1cm,bottom=1cm}")
```
```{r echo=FALSE, out.width = '100%'}
ggplot(mtcars, aes(x=wt, y=mpg)) +
geom_point()
```
```{r, echo = FALSE, results = "asis"}
cat("\\restoregeometry")
```
\clearpage
Restore the page margins
### Normal page margins again
```{r echo=FALSE, out.width = '100%'}
ggplot(mtcars, aes(x=wt, y=mpg)) +
geom_point()
```
# ! Undefined control sequence.
# l.190 \newgeometry
# {left=1cm,right=1cm,top=1cm,bottom=1cm}
我也试过
\newgeometry{left=1cm,right=1cm,top=1cm,bottom=1cm}
<!-- material for this page -->
\clearpage
\restoregeometry
正如@bretauv 所建议的那样。它适用于一个简单的 Rmd 文件,但不适用于我的 huskydown 用例。我最终得到了同样的错误消息。
【问题讨论】:
-
嗨,你检查here了吗?
-
@bretauv 感谢您的链接和您的建议!对我来说,修复只适用于一个简单的 Rmd 文件,但不适用于 thesisdown/bookdown/huskydown。将相应地更新我的 Q。
标签: r r-markdown bookdown