I have a huskydown document (which is based on thesisdown/bookdown) written in Rmarkdown which is knitted to PDF/LaTex but later also to HTML.
For a single page within the document, I would like to change the page margins (e.g. to include a very large table/figure/external PDF). After this page, the page margins should return to their default values.
What I tried:
---
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}
I also tried
\newgeometry{left=1cm,right=1cm,top=1cm,bottom=1cm}
<!-- material for this page -->
\clearpage
\restoregeometry
as suggested by @bretauv. It works in a simple Rmd file, but not in my use case with huskydown. I ended up with the same error message.
