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:





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



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!

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.