Create PDF Hyperlinked Table of Contents inside R -
this first questions on stackoverflow, please let me know if i'm doing wrong.
i'm using r generate lot of large pdf documents. data 580,000 observations, , breaks down in 32 categories each category containing 70 answers between 20 , 300 questions. use 2 loops (i try avoid loops, creating these pdfs way worked). first goes through , creates pdf category title page, second adds page each graph showing results of question. i'm using ggplot2 & "pdf" function.
the script works great, creating 32 pdfs (one each category) custom title page , pages questions in category. add table of contents after title page. know how add page labels , page numbers, need 1 links each question.
i've searched site , google, haven't found way in r. question: adding table of contents pdf r plots talks using rpython. i've come across sources mentioning "hyperref", latex, pandoc, , knitr. know how use kintr in rmarkdown doc, doesn't work i'm trying do. i'm not sure how work of others, solutions using them went on head.
is there not way work creating table of contents or hyperlinks pdf pages inside r, without going other languages?
have tried clicking on section names in table of contents? default, these seem hyperlinked, although there isn't colouration hints @ it.
to see might happening, add / change yaml header add following:
output: pdf_document: keep_tex: true toc: true toc_depth: 3
that intermediate .tex
file kept. if open after knitting, should see references hyperref
in it.
i find table of contents being defined as:
{ \hypersetup{linkcolor=black} \setcounter{tocdepth}{3} \tableofcontents }
which produces hyperlinked toc, "black" hyperlinks!
if want change colour , see them show up, can open tex file in rsudio , change "black" "blue" , have rstudio run "compile pdf" , should see them showing up.
if want page numbers hyperlinked rather description, add following yaml:
header-includes: - \hypersetup{linktocpage}
share & enjoy!
Comments
Post a Comment