# Problem Hyperref Coloring Only TOC

I would like to use the hypperref to create blue links for only toc sections and subsections.

\documentclass[12pt,oneside]{book}
\usepackage{amsmath,amssymb,amsthm,amstext,amscd,amsfonts,amsbsy,amsxtra,latexsym,cite,hyperref}
\usepackage[retainorgcmds]{IEEEtrantools}
\usepackage{ytableau}
\usepackage{titlesec}
\usepackage{mathrsfs}
\usepackage{verbatim}                 % math stuff                 % more math stuff
\usepackage{graphicx}                % including figures
\usepackage[lofdepth]{subfig}        % subfigures
\usepackage[left=1.0in,right=1.0in,%
top=1.0in,bottom=1.0in]{geometry}  % margin control
\usepackage[toc,page]{appendix}      % appendix stuff
\usepackage{times}                   % Times New Roman font
\usepackage{color}                   % colored text
\usepackage{float}
\usepackage[square, numbers]{natbib} % nicer citing
\usepackage{indentfirst}             % indents first paragraph of every section
\usepackage{setspace}                % manual line spacing control
\usepackage{fancyhdr}                % these 5 lines are for header/footer:
\fancypagestyle{plain}{
\pagestyle{plain}
\usepackage{titlesec}                % these 4 lines are for formatting chapter titles:
\titleformat{\chapter}[display]
{\normalfont\Huge\bfseries\centering}
{\vspace{8ex}\chaptertitlename\ \thechapter}{20pt}{\Huge}
\pagestyle{plain}
\usepackage{titlesec}                % these 4 lines are for formatting chapter titles:
\titleformat{\chapter}[display]
{\normalfont\Huge\bfseries\centering}
{\vspace{8ex}\chaptertitlename\ \thechapter}{20pt}{\Huge}

\hypersetup{
}


After some more stuff, I start my document, which minimally looks like this:

\begin{document}
\tableofcontents

\mainmatter
\include{mainmatter/chapter1/chapter1}
\include{mainmatter/chapter2/chapter2}

\backmatter
\include{backmatter/bibliography}

\end{document}


The mainmatter sections are where the problem arises; all equation labels are colored blue, and references (e.g. "[21]") are colored green. Nowhere did I even specify green to be a color, and in the hyppersetup fragment above I specified to create links only for the toc, and not for labels/references within the document.

I didn't include specific matter I had in the main sections because I didn't think it was relevant. Please let me know if I should add any should it help.

• Make a small example that one can compile and that demonstrates the problem. Don't use \include in such an example -- we don't have the files. Remove irrelevant packages. – Ulrike Fischer Mar 19 '16 at 16:16

If the document starts with the TOC you can use \hypersetup{hidelinks} after the table of contents is finished.

\documentclass{book}
\usepackage{blindtext}
\usepackage{hyperref}
\hypersetup{
}
\begin{document}
\tableofcontents
\chapter{First hapter}\label{ch1}
See chapter \ref{ch2}
\chapter{Second chapter}\label{ch2}
See chapter \ref{ch1}
\end{document}


Or you change all colors to black globally and set linkcolor=blue for the TOC locally.

\documentclass{book}
\usepackage{blindtext}
\usepackage{amsmath}
\usepackage{hyperref}
\hypersetup{
citecolor=black,
filecolor=black,
urlcolor=black,
}
\begin{document}
{

• I think you have to live with. Or you use the starred versions \ref*{...} and \pageref*{...} to get references that are not links. – esdd Mar 20 '16 at 17:05