16

I'm exporting (publishing) an org-mode document to PDF, and the results look great except for the hyperlinks. They look terrible. partial screenshot

Hyperlinks to the Web look the same, only with a pale blue outline. How can I control the style of links in the exported PDF document? (I don't know LaTeX, but can make simple configuration changes in LaTeX if necessary).

16

Hyperlinks in pdfs exported from org documents are generated by the LaTeX hyperref package. This package is included by default, and options can be set in the customize interface for org-latex-default-packages-alist.

For example, adding the option colorlinks=true to the entry for hyperref will switch from boxed links to coloured links. There are quite a few options you can set, listed in the hyperref manual.

| improve this answer | |
  • This is great! Thank you, that helped immensely. – Sue D. Nymme Jun 3 '15 at 17:14
7

While the previous answers are helpful, I'll add a bit more of an explicit recipe for Org mode.

By default, Org mode adds a rather unhelpful hypersetup section. You can prevent this addition by adding the following line to your .emacs file:

(customize-set-value 'org-latex-with-hyperref nil)

In addition, if you want to pass any options to hyperref or url (which is loaded automically by hyperref), then you can use a command of the form (notice the escaped backslash):

(add-to-list 'org-latex-default-packages-alist "\\PassOptionsToPackage{hyphens}{url}")

This particular command directs the url package to break long URLs at the end of the page over hyphens.

Then, in the Org document itself, we can add the following lines:

#+LaTeX_HEADER: \usepackage[x11names]{xcolor}
#+LaTeX_HEADER: \hypersetup{linktoc = all, colorlinks = true, urlcolor = DodgerBlue4, citecolor = PaleGreen1, linkcolor = black}

The first line adds the xcolor package with X11 color names, and the second line specifies several options for the hyperref package, with the relevant option for this question being colorlinks = true.

See the Package Options section of the hyperref documentation, and the Colors By Name section of the xcolor documentation for more information on the available hyperref settings and X11 color names, respectively.

| improve this answer | |
3

Here's what worked for me.

\usepackage{xcolor}
\PassOptionsToPackage{hyperref,x11names}{xcolor}
\definecolor{electricblue}{HTML}{05ADF3}
\usepackage{tocloft}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
\usepackage[breaklinks=true,linktocpage,xetex]{hyperref} 
\hypersetup{colorlinks, citecolor=electricblue,filecolor=electricblue,linkcolor=electricblue,urlcolor=electricblue}
| improve this answer | |
1

I know this is old and the existing answers are already great. But in case anyone is searching for this and needed a bit more control, here's how to change the hyperref template.

(customize-set-value 'org-latex-hyperref-template "
\\hypersetup{\n pdfauthor={%a},\n pdftitle={%t},\n pdfkeywords={%k},
 pdfsubject={%d},\n pdfcreator={%c},\n pdflang={%L},\n colorlinks=true}\n")

The format elements, as found in ox-latex.el:

  %a for AUTHOR keyword
  %t for TITLE keyword
  %s for SUBTITLE keyword
  %k for KEYWORDS line
  %d for DESCRIPTION line
  %c for CREATOR line
  %l for Language keyword
  %L for capitalized language keyword
  %D for DATE keyword
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.