Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandoc conversion to PDF not providing colored hyptertext links

Consider the following snippet of a PDF generated from pandoc by way of latex.

Were you able to identify the hypertext links in there? Neither was I... It turns out that the second Kaplan Meier has a fully functional link to an external site. But how do we divine that?

Note that the following option is already in place in the pandoc preamble - without which the hyperlink would not work at all:

link-citations: true

Short of a "real" solution I'll need to hack something to make hints for the links - possibly via font manipulations.

like image 601
WestCoastProjects Avatar asked Nov 14 '19 21:11

WestCoastProjects


2 Answers

If you use a recent version of Pandoc (latest is v2.7.3), just add (for example) these to the commandline:

-V colorlinks=true \
-V linkcolor=blue \
-V urlcolor=red \
-V toccolor=gray

No need to fiddle with the preamble!

You can investigate the built-in LaTeX template shipping with your own Pandoc by this command:

pandoc -D latex | less

Then search for link, url, color etc. to see which variables are pre-defined there. Or:

pandoc -D latex | grep --color -E '(links|color|url|file)'

will give you an idea what other "links" you may want to manipulate.

like image 59
Kurt Pfeifle Avatar answered Oct 22 '22 02:10

Kurt Pfeifle


You can also add to the meta-data colorlinks: true.

---
colorlinks: true
---

[Test](https://stackoverflow.com/a/71426117/2657549)

gives:

enter image description here

like image 26
Clément Avatar answered Oct 22 '22 01:10

Clément