[Tex/LaTex] Why are the hyper references pink

colorhyperrefpandoc

I have this in the heading of my document:

  \usepackage[unicode=true,
              colorlinks=true,
              linkcolor=blue]{hyperref}

Yet the links look like this:

enter image description here

Why the pink color when it says blue in the preamble?

There are a number of other things in the full .tex document; I used Pandoc to create this from the original .Rmd file, so perhaps that helps explain it. In any case, I want a more conventional blue link color!

Best Answer

If you check the LaTeX-template of pandoc via pandoc -D latex, you'll see

\hypersetup{breaklinks=true,
            bookmarks=true,
            pdfauthor={$author-meta$},
            pdftitle={$title-meta$},
            colorlinks=true,
            citecolor=$if(citecolor)$$citecolor$$else$blue$endif$,
            urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$,
            linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$,
            pdfborder={0 0 0}
            $if(hidelinks)$,hidelinks,$endif$}

and

$if(toc)$
{
\hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$black$endif$}
\setcounter{tocdepth}{$toc-depth$}
\tableofcontents
}
$endif$

Everything between to $ is preprocessed by pandoc, mostly expanded to the respective variable except for the $if...$s etc., which means the variables citecolor, urlcolor, linkcolor and toccolor (the linkcolor in the TOC only) are used. So in your case you have to put

linkcolor: blue

into your document's YAML-header or provide one of -M|V linkcolor=blue or --metadata|variable=linkcolor:blue. Whether you use M/metadata or V/variable depends on whether you only want to affect the template (via V) or truly set/replace the metadata (via M) which might also influence any filters used or (though not in this case) be output in the resulting document.

Concerning unicode=true, the template has

\ifxetex
  \usepackage[setpagesize=false, % page size defined by xetex
              unicode=false, % unicode breaks when used with xetex
              xetex]{hyperref}
\else
  \usepackage[unicode=true]{hyperref}
\fi

in it, i.e. unicode is set to true unless you're compiling with XeLaTeX. If you don't want this, you'd have to modify the template itself, or the generated TeX-file.

Related Question