7

This question is very close to what I want, yet not quite.

The accepted answer offers linkcolor = black, but I do not want to hide all links.

I like my in-line figure numbers and section references in red.

How can I change the link color in the Table of Contents, and only in the Table of Contents to black?

My document goes roughly like so:

...
\usepackage[]{hyperref}
\hypersetup{colorlinks=true,}
...
\begin{document}
\tableofcontents
\chapter*{...}
\chapter{...}
...
\end{document}
14

You can change the settings locally using

{
  \hypersetup{linkcolor=black}
  \tableofcontents
}

or

{
  \hypersetup{hidelinks}
  \tableofcontents
}

enter image description here

Code:

\documentclass{report}
\usepackage{blindtext}% dummy text
\usepackage{amsmath}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,% make the links colored
}
\begin{document}
{
  \hypersetup{linkcolor=black}
  \tableofcontents
}
\chapter{First hapter}\label{ch1}
See chapter \ref{ch2}
\chapter{Second chapter}\label{ch2}
See chapter \ref{ch1}
\end{document}

If you want to remove the links from TOC complettly, you can use option linktoc=none:

\documentclass{report}
\usepackage{blindtext}% dummy text
\usepackage{amsmath}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,% make the links colored
    linktoc=none% <- no links in ToC
}
\begin{document}
\tableofcontents
\chapter{First hapter}\label{ch1}
See chapter \ref{ch2}
\chapter{Second chapter}\label{ch2}
See chapter \ref{ch1}
\end{document}
  • Thanks, this solves my problem, +1. Normally I'd wait to accept, but there really doesn't seem to be much more to add to this. – LLlAMnYP Apr 27 '16 at 10:04

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.