# Appearance of Links in hyperref

I'm using the hyperref package, and have got most of it set up nicely. I'm trying to create a contents page linking to all sections and subsections, and again have got this working. The problem is, using the linkcolor=blue, as well as making the links in the contents page blue (which is how I want it), also makes other links within my document (i.e. figure links and equation links) blue, and I cannot work out how to decouple this. Any help would be greatly appreciated.

Although you didn't mention it, I'm assuming you want only the section links to be blue and that other links (equations, figures, etc.) remain black.

You can achieve this by defining all links to be black, using the hypersetup command of the hyperref package. Then, you define a new command (refsec, in my example) that uses blue as a color.

Now, this does create section references in blue, but the section names on the TOC will be black. So in order to avoid this you can put the tableofcontents command inside a group in which you define colorlink to be blue (with the hypersep command). The redefinition will only affect elements inside the group, that is, the TOC.

See the following MWE:

\documentclass{article}
\usepackage{hyperref}
\hypersetup{
citecolor=black,
filecolor=black,
urlcolor=black
}

\newcommand*{\refsec}[1]{%
\begingroup
\hypersetup{
}%
\ref{#1}%
\endgroup
}

\begin{document}

\begingroup
\tableofcontents
\endgroup

\section{First Section}
\label{sec:first}
This is a reference to section \refsec{sec:first}. This is a reference to equation \ref{eq:answer_to_life}.

$$x=42 \label{eq:answer_to_life}$$

\end{document}


which produces the following output:

Of course, you can change the color of other links simply by specifying so with the hypersetup command.

Hope it helps!