Adding a table of contents to PDF with R plots

前端 未结 3 955
渐次进展
渐次进展 2021-02-09 03:35

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

3条回答
  •  故里飘歌
    2021-02-09 04:03

    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}
    

提交回复
热议问题