12

I was using the hyperref package to link all the references within the LaTeX file, however I wanted to personalize a bit the default colors, so my preamble looks like this

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{epsfig,graphics}
 \usepackage{hyperref}
\usepackage{url}
\hypersetup{colorlinks=true, urlcolor=Cerulean, citecolor=Cerulean}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}

Is it possible to change also the default colors on the one hand of footnotes and on the other hand of references to sections? I could not find such command in

ftp://tug.ctan.org/pub/tex-archive/macros/latex/contrib/hyperref/doc/options.pdf

2 Answers 2

16

You can define a new key footnotecolor which allow you such a setting.

The code is:

\makeatletter
\def\@footnotecolor{red}
\define@key{Hyp}{footnotecolor}{%
 \HyColor@HyperrefColor{#1}\@footnotecolor%
}
\def\@footnotemark{%
    \leavevmode
    \ifhmode\edef\@x@sf{\the\spacefactor}\nobreak\fi
    \stepcounter{Hfootnote}%
    \global\let\Hy@saved@currentHref\@currentHref
    \hyper@makecurrent{Hfootnote}%
    \global\let\Hy@footnote@currentHref\@currentHref
    \global\let\@currentHref\Hy@saved@currentHref
    \hyper@linkstart{footnote}{\Hy@footnote@currentHref}%
    \@makefnmark
    \hyper@linkend
    \ifhmode\spacefactor\@x@sf\fi
    \relax
  }%
\makeatother

After this definition you can use:

\hypersetup{footnotecolor=blue}

If you work with the package etoolbox or xpatch you can make the code clearer. Here the suggestion using etooltbox:

\usepackage{etoolbox}
\makeatletter
\def\@footnotecolor{red}
\define@key{Hyp}{footnotecolor}{%
 \HyColor@HyperrefColor{#1}\@footnotecolor%
}
\patchcmd{\@footnotemark}{\hyper@linkstart{link}}{\hyper@linkstart{footnote}}{}{}
\makeatother

Here an example:

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{epsfig,graphics}
\usepackage{etoolbox}
\usepackage{hyperref}

\hypersetup{colorlinks=true, urlcolor=Cerulean, citecolor=Cerulean}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\makeatletter
\def\@footnotecolor{red}
\define@key{Hyp}{footnotecolor}{%
 \HyColor@HyperrefColor{#1}\@footnotecolor%
}
\patchcmd{\@footnotemark}{\hyper@linkstart{link}}{\hyper@linkstart{footnote}}{}{}
\makeatother
\hypersetup{footnotecolor=blue}

\begin{document}

\section{foo}\label{foo}
\ref{foo}\footnote{footnote}

\section{bar}\label{bar}
\ref{bar}\footnote{footnote}

\end{document}

enter image description here

1
  • @Marco Daniel: Is it possible to remove the footnote color? If yes, how?
    – C.S.
    Commented Nov 8, 2017 at 10:30
4

Please look for the reference. options for appearance of links in hyperref.

One can simply use linkcolor attribute to change the color of footnote.

 \usepackage[colorlinks=true, citecolor=blue, urlcolor=black, linkcolor=cyan]{hyperref} 
1
  • 4
    Does not seem to work for footnotes
    – prosoitos
    Commented Feb 11, 2019 at 4:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .