Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

As the title reads, I'd like to color my ToC in let's say red and the references in my document with another color let's say blue.

here's a MWE of my document :

\documentclass{report}

\usepackage{xcolor}
\usepackage{hyperref}

\usepackage{lipsum}

\title{test colors}
\author{Oddant}

\hypersetup{
    colorlinks=true,
    linktoc=all,
    linkcolor=blue
}


\begin{document}

\tableofcontents


\chapter{foo}
\section{bar}
go to \ref{lipsum}
\chapter{oof}
\section{rab}
\label{lipsum}
\lipsum
\end{document}

If you compile the code above you would notice that the ToC is in the same color than the reference in the bar section.

How can I color my ToC in black for instance without installing any extra packages like tocloft ?

Is there any parameters to place in hypersetup to get what I want, i peeked into the documentation of hyperref but I come here with any clue.

share|improve this question
1  
Use \begingroup \hypersetup{linkcolor=red} \tableofcontents \endgroup –  Marco Daniel Feb 24 '13 at 10:49
    
short and concise, can you make a short answer at least to validate the question ? –  Oddant Feb 24 '13 at 11:21
    
Just noted that this seems to be a duplicate of the question tex.stackexchange.com/q/88400 –  e-birk May 26 at 10:26
add comment

1 Answer

The command \hypersetup can be used inside the document body. To setup the color you can change the behvaviour inside a local group or by switching.

  1. Using a local group:

    \begingroup
     \hypersetup{linkcolor=red} 
     \tableofcontents 
    \endgroup
    
  2. Switching:

     \hypersetup{linkcolor=red} 
     \tableofcontents 
     \hypersetup{linkcolor=blue} 
    
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.