\hypersetup{linkbordercolor=black}
before \tableofcontents
changes the link colour to black (also for links to Figures and Tables occurring in the TOC). Enclosing \hypersetup
and \tableofcontents
in a group (either by enclosing in curly braces {...}
or by using \begingroup\hypersetup...\tableofcontents\endgroup
) keeps the change local. (Using "plain colour names" like black
requires the xcolor
package.)
If the colorlinks=true
option of the hyperref
package is used, \hypersetup{linkcolor=black}
must be used instead of \hypersetup{linkbordercolor=black}
.
MWE:
\documentclass{article}
\usepackage{xcolor}
\usepackage{hyperref}
\begin{document}
{\hypersetup{linkbordercolor=black}
% or \hypersetup{linkcolor=black}, if the colorlinks=true option of hyperref is used
\tableofcontents
}
% \hypersetup{linkbordercolor=red}
% is not necessary because the colour is only changed in the group
\section{First Section starting at page \pageref{s1}\label{s1}}
\ref{s1}
\end{document}
Because you are using "black" (and assuming your text is written in black) also
{\hypersetup{hidelinks}
\tableofcontents
}
would be possible, which would - well, hide the links in the TOC.
As mentioned in the comments, with all the link colouring commented out, you get the correct result. Thus, locally use the hidelinks
option when the \tableofcontents
is evoked (inspired by this). I.e. write:
{
\hypersetup{hidelinks}
\tableofcontents%
}
The complete code then should be:
\documentclass{book}
\usepackage{tikz}
\usepackage{titletoc}
\usepackage{titlesec}
\usepackage{hyperref}
%
\definecolor{doc}{RGB}{0,60,110}
\definecolor{myblueii}{RGB}{63,200,244}
%~~~~~~~~~~~~~~~~~Hyperref Settings~~~~~~~~~~~~~~~~~~~~~~
\hypersetup{%
pdfborder = {0 0 0},
colorlinks,
citecolor=red,
filecolor=green,
linkcolor=myblueii,
urlcolor=cyan!50!black!90
}
%~~~~~~~~~~~~~~~~~~~~~Fancy ToC~~~~~~~~~~~~~~~~~~~~~~
\contentsmargin{0cm}
\titlecontents{chapter}[0pc]
{\addvspace{30pt}%
\begin{tikzpicture}[remember picture, overlay]%
\draw[fill=myblueii,draw=myblueii, rounded corners] (-4,-.1) rectangle (-0.15,.5);%
\pgftext[left,x=-2.7cm,y=0.2cm]{\color{white}\Large \chaptertitlename\ \thecontentslabel};%
\end{tikzpicture}\color{myblueii}\large\bfseries}%
{}
{}
{\hspace*{6pt}\titlerule\hspace*{6pt}\large\bfseries \thecontentspage
\begin{tikzpicture}[remember picture, overlay]
\draw[fill=doc!25,draw=myblueii, rounded corners=0pt] (2pt,0) rectangle (6,0.1pt);
\end{tikzpicture}}%
\titlecontents{section}[2.4pc]
{\addvspace{1pt}}
{\contentslabel[\thecontentslabel]{2.4pc}}
{}
{\hfill\small \thecontentspage}
[]
\titlecontents{subsection}[4.8pc]
{\addvspace{1.0pt}}
{\contentslabel[\thecontentslabel]{2.4pc}}
{}
{\hfill\small\thecontentspage}
[]
\makeatletter
\renewcommand{\tableofcontents}{%
\chapter*{%
\vspace*{-20\p@}%
\begin{tikzpicture}[remember picture, overlay]%
\pgftext[right,x=15cm,y=0.2cm]{\color{myblueii}\Huge \contentsname};%
\draw[fill=myblueii,draw=myblueii, rounded corners=15pt] (13,-.75) rectangle (20,1);%
\clip (13,-.75) rectangle (20,1);
\pgftext[right,x=15cm,y=0.2cm]{\color{white}\Huge \contentsname};%
\end{tikzpicture}}%
\@starttoc{toc}}
\makeatother
%~~~~~~~~~~~~~~~~~Main Document~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
{
\hypersetup{hidelinks}
\tableofcontents%
}
\chapter{rkbnjg}
\section{ljkihb;kjb}
\url{http://www.google.com}
\section{lkhb;hkb}
\section{;kjbkjb}
\subsection{;kjblkhjblhkb}
\subsection{lhjbljh}
\subsection{;jbnlkhjblbh}
\section{ljhblkhbj}
\subsection{ljhblhjkblkbh}
\chapter{kgjb}
\chapter{;kjdfb543}
\end{document}
which outputs:
Best Answer
There are many ways to achieve this, one way which
is to use
{ \hypersetup{hidelinks} \tableofcontents }
. Pay attention to the curly brackets around the code, this puts the\hypersetup
together with the table of contents inside a group, so it will not effect the remaining document.