在 Sweave 中制作扁平化的 pdf [英] Making flattened pdfs in Sweave

查看:15
本文介绍了在 Sweave 中制作扁平化的 pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在使用 Sweave 创建 pdf,其中包括一些上面有大量点的图表.我可以很好地获得 pdf,但它似乎已经创建了很多层,因此很难在 Acrobat 或 Reader 中打开文件.当我这样做时,我真的可以看到文件上加载的点.

So I am creating pdfs using Sweave that include some graphs that have a ton of points on them. I can get the pdf well enough, but it seems to have created it with a ton of layers, so it's hard to open the file in Acrobat or Reader. When I do, I literally can watch the points load on the document.

有没有办法在 Sweave 中将 pdf 展平以使其不那么笨重?

Is there a way to flatten the pdf in Sweave so that it's not so bulky?

(请注意,我使用的是 RStudio.我知道我可能应该使用其他东西,但我还没有找到任何可以顺利运行的东西.)

(Note that I am using RStudio. I know I should probably be using something else, but I haven't found anything that has worked this smoothly yet.)

推荐答案

正如 Gavin 所说,没有必要为此切换到 knitr,尽管这样做还有其他好处.但是,您甚至不需要编写自己的保存和包含代码;Sweave 可以为您做到这一点.如果初始文档是:

As Gavin said, there is no need to switch to knitr for this, though there are other advantages to do so. However, you don't even need to write your own saving and including code; Sweave can do that for you. If the initial document is:

documentclass{article}
usepackage[american]{babel}
egin{document}

<<>>=
n <- 100000
DF <- data.frame(x=rnorm(n), y=rnorm(n))
@

<<gen_fig, fig=TRUE>>=
plot(DF)
@

end{document}

然后只需将参数更改为图形块,就可以获得 PNG 而不是 PDF:

Then just by changing the arguments to the figure chunk, you can get a PNG instead of a PDF:

<<gen_fig, fig=TRUE, png=TRUE, pdf=FALSE>>=
plot(DF)
@

在这个简单的示例中,它将我的最终 PDF 从 685K 缩小到 70K.

In this simple example, it shrinks my final PDF from 685K to 70K.

这篇关于在 Sweave 中制作扁平化的 pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆