2016-04-28 36 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