2016-04-28 608 views
2

我有一个非常大的系统发育树,我很想插入到使用Rmarkdown和knitr编写的补充材料中。我不喜欢跨页面拆分树,我怀疑有人会打印出来,所以我想我只是在我生成的pdf中间有一个大页面。在Rmarkdown文档中更改页面大小

问题是,如何在另一个A4文档中更改一页的页面大小?我对knitr非常陌生,而且我发现了全球纸张尺寸选项,但我正在努力寻找设置Word中各个部分的方法。

(更新)你好其他人有一个建议吗?我尝试了pdfpages包,但是这似乎导致在一个页面上粘贴的pdf大小的一个同样小的数字,也就是说,如果我制作20英寸20英寸的pdf图,然后使用\ includepdf粘贴页面,那么我得到一个20英寸,20英寸,上面有一个小得多的数字(与上面的弹出示例相同)。看起来像knitr或Latex正在迫使图形具有特定的大小,而不管页面大小。有任何想法吗?这里有一个重复的例子:

--- 
title: "Test" 
output: 
    pdf_document: 
     latex_engine: xelatex 
header-includes: 
- \usepackage{pdfpages} 
--- 

```{r setup, include=FALSE} 
require(knitr) 
knitr::opts_chunk$set(echo = FALSE, 
         warning=FALSE, 
         message=FALSE, 
         dev = 'pdf', 
         fig.align='center') 
``` 

```{r mtcars, echo=FALSE} 
library(ggplot2) 
pdf("myplot.pdf", width=20, height=20) 
ggplot(mtcars, aes(mpg, wt)) + geom_point() 
dev.off() 
``` 

#Here's some text on a normal page, the following page is bigger but has a tiny figure. 

\newpage 

\includepdf[fitpaper=true]{myplot.pdf} 

回答

3

你应该能够使用\ejectpage这样的:

--- 
output: pdf_document 
--- 
```{r setup, include=FALSE} 
knitr::opts_chunk$set(echo = TRUE) 
``` 

## R Markdown 

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>. 

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this: 

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

## Including Plots 

You can also embed plots, for example: 

```{r pressure, echo=FALSE} 
plot(pressure) 
``` 

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot. 

\eject \pdfpagewidth=20in \pdfpageheight=20in 
```{r mtcars} 
library(ggplot2) 

ggplot(mtcars, aes(mpg, wt)) + geom_point() 
``` 
\eject \pdfpagewidth=210mm \pdfpageheight=297mm 

Back 

(我只记得出于某种原因在毫米A4高度)

enter image description here

+0

实际上看过这个,即使在改变块选项时,你也无法获得数字来填充新的页面大小。现在我知道要搜索什么,似乎我并不孤单...... http://tex.stackexchange.com/questions/306447/draw-with-pstricks-on-a-large-纸尺寸 我想我可能不得不使用R来将图写入适当大小的PDF然后粘贴页面。 – JimmyK

+0

argh!道歉。我认为这会很容易(我应该知道更好......毕竟这是乳胶)。 – hrbrmstr