2017-08-02 79 views
1

我正在尝试添加已经在PDF中创建的封页。在封面页中更改页边空白尺寸

```{r echo=FALSE,out.width='8.27in',out.height='11.69in'} 
knitr::include_graphics('CoverPage.pdf') 
``` 

我想改变第一页只的边缘。你能帮我解决这个问题吗?

下进行尝试,但它改变了整个文档的页边距:

geometry: "left=3cm,right=3cm,top=2cm,bottom=2cm" 

回答

2

如果你的罚款与您的RMD文件中的一些裸露乳胶,那么可以很容易地使用geometry package实现。在包含封面之前只需定义一个newgeometry,之后再定义restoregeometry(几乎像英文一样)。

--- 
output: 
    pdf_document 
--- 
```{r, echo = FALSE, results = "asis"} 
cat("\\newgeometry{left=3cm,right=3cm,top=2cm,bottom=2cm}") 
knitr::include_graphics("CoverPage.pdf") 
cat("\\restoregeometry") 
``` 

\clearpage 

Note the position of the page number. Restoring the margins was successful! 

它使用块选项results="asis"cat()打印原料乳胶和一个额外的反斜杠逃脱反斜线是很重要的。