11

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}

enter image description here

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

enter image description here

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).

2
  • 1
    You could use locally \hypersetup{hidelinks} May 21, 2014 at 10:27
  • 1
    @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, 2014 at 10:33

1 Answer 1

13

You could use locally \hypersetup{hidelinks}

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.