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}
\usepackage[colorlinks=false, hidelinks, linkcolor=cyan]{hyperref}
\usepackage[nameinlink]{cleveref}
\renewcommand{\cftchapterfont}{\color{orange}\sffamily\bfseries}
\begin{document}
\tableofcontents*
\bigskip
See \cref{chap:hello} for more information.
\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).
Best Answer
You could use locally
\hypersetup{hidelinks}