9

I was using hyperref package so 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}

Then my question would be whether is possible to change also the default colors of footnoes on one hand and references to section in the other. I couldn't find the command on

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

13

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

  • @Marco Daniel: Is it possible to remove the footnote color? If yes, how? – crskhr Nov 8 '17 at 10:30
2

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} 
  • Does not seem to work for footnotes – prosoitos Feb 11 '19 at 4:30

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.