# Disable colorlinks locally (or just for the ToC)

Basically, I want to disable the colorlinks option (from the hyperref package) for the ToC, but keep it enabled for the rest of a (memoir) document.

This question has a workaround based on issuing \hypersetup{linkcolor=black} before \tableofcontents, but this doesn’t work for my case, since I already colour certain parts of the ToC, and hyperref’s colouring overrides this. Example:

\documentclass{memoir}

\usepackage{xcolor}
\usepackage{varioref}

\renewcommand{\cftchapterfont}{\color{orange}\sffamily\bfseries}

\begin{document}

\tableofcontents*

\bigskip

\chapter{Hello}
\label{chap:hello}

\section{Foo}
\section{Bar}

\section{Baz}

\chapter{Goodbye}

\section{Qux}

\end{document}


Note that the chapter 1 hyperlink is not coloured, since colorlinks=false. If I change it to true and remove hidelinks, I get:

I want a combination of the two, with orange chapter names and black section names in the ToC, and light blue hyperlinks in the rest of the document. Issuing \hypersetup{colorlinks=false} before \tableofcontents has no effect; it only results in the following warning:

Package hyperref Warning: Option colorlinks' has already been used,
setting the option has no effect on input line 13


Is it possible to somehow disable colorlinks locally, or to make the ToC colouring commands (\cftchapterfont) override its effect? The solution needs to work with the memoir package (and ToC commands).

• You could use locally \hypersetup{hidelinks} May 21 '14 at 10:27
• @UlrikeFischer Brilliant! It never occured to me that hidelinks could be used locally when colorlinks could not. If you add it as an answer, I’ll accept it. May 21 '14 at 10:33

You could use locally \hypersetup{hidelinks}`