使用R图将目录添加到PDF [英] Adding a table of contents to PDF with R plots

查看:91
本文介绍了使用R图将目录添加到PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在R中创建大量绘图,并将其另存为PDF(使用grDevices/pdf).创建PDF时,是否有一种简单的方法可将目录(元数据)添加到PDF中?

I'm creating a larger number of plots in R and save them as PDF (using grDevices / pdf). Is there an easy way to add a (meta-data) table of contents to the PDF as it is created?

我并不是要添加单独的页面,而是要在侧边栏中显示一个PDF预览(如Preview.app)的目录,以简化导航.

I don't mean to add a separate page, but a TOC that PDF viewers like Preview.app display in the sidebar to make navigation easier.)

此类目录的示例:

推荐答案

我知道的唯一方法是使用LaTeX,但是您不一定需要Sweave;也许您可以直接使用RPython代码生成LaTeX文件.如果您有两张名为tmp-001.pdftmp-002.pdf的6x6(默认尺寸)图片,这就是制作名为A节的部分,其中两张图片包含两个子部分的方法.

The only way I know is with LaTeX, but you don't necessarily need Sweave; perhaps you could just generate the LaTeX file directly with your RPython code. If you've got two pictures which are 6x6 (the default size) named tmp-001.pdf and tmp-002.pdf, this is how you'd make a section called Section A with two subsections for the two pictures.

\documentclass{article}
\usepackage[paperwidth=6in, paperheight=6in, margin=0in]{geometry}
\usepackage{hyperref}
\usepackage{graphicx}
\parindent 0pt
\begin{document}
\pdfbookmark[1]{Section A}{anchorname_aa}

\pdfbookmark[2]{plot aa}{anchorname_aa}
\includegraphics{tmp-001.pdf}

\newpage
\pdfbookmark[2]{plot bb}{anchorname_bb}
\includegraphics{tmp-002.pdf}

\end{document}

这篇关于使用R图将目录添加到PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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