# Changing toc colors

I need to set the same color as in the two screenshots:

As you can see, theorems and figures numbers are in blue, cites in red and the toc is in black with its number in blue. How can achieve this combination?

These are the parameters I've got to change:

{\hypersetup{
filecolor=blue,
urlcolor=blue,
citecolor=blue,
%pdfpagemode=FullScreen,
}

\documentclass{book}
\usepackage{xcolor}
\colorlet{RED}{black} % don't color running headers
\colorlet{BLUE}{black}
\usepackage[titles]{tocloft}
\renewcommand{\cftchappresnum}{\color{red}}
\renewcommand{\cftchappagefont}{\bfseries\color{red}}

\begin{document}

\frontmatter
\tableofcontents

\mainmatter
\chapter[\color{red}This is the first chapter]{This is the first chapter}
\section{section}
\section{section}
\section{section}
\end{document}

• Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – DG' Nov 3 '19 at 20:22
• I know! But the thing is that I have a whole thesis document. I will have to make something up then, I guess – Delan Nov 3 '19 at 20:27
• You can try \Blinddocument from blindtext with the relevant parts of your preamble to make something to play with. – DG' Nov 3 '19 at 20:47

Setting the parameters like this:

\hypersetup{
filecolor=blue,
urlcolor=blue,
citecolor=red,
}


does what you want. The line linktoc=page sets the table of contents such that only the page numbers (and not the chapter/section titles) are hyperlinks. This results in only the page numbers being colored in blue. See also here.

If you want particular references or citations to not be colored (for example in a minitoc), you can surround the relevant code like this (notice the curly braces {} surrounding the whole block):

{\hypersetup{linkcolor=black} % and/or citecolor=black
\minitoc % or any other content whose refs are not to be colored
}


Here is a minimum working example:

\documentclass{book}
\usepackage{hyperref}
\usepackage{xcolor}
\usepackage[titles]{tocloft}

\usepackage{minitoc}

\usepackage{theorem}

\newtheorem{theorem}{Theorem}

\hypersetup{
filecolor=blue,
urlcolor=blue,
citecolor=red,
%pdfpagemode=FullScreen,
}

\begin{document}
\dominitoc

\frontmatter

\tableofcontents

\mainmatter
\chapter{This is the first chapter}

\minitoc
}

\section{section}
This is a citation~\cite{ref1}. Theorem~\ref{thm1} provides some interesting information.
\begin{theorem}\label{thm1}
Rain gets you wet.
\end{theorem}
\section{section}
\section{section}

\bibliographystyle{alpha}

\begin{thebibliography}{Smi19}

\bibitem[Smi19]{ref1}
John Smith.
\newblock Citing in red.
\newblock {\em Journal of Hyperlink Colors}, 2019.

\end{thebibliography}

\end{document}


• Right now it works fantastic. The table of contents is all black. I also have a mini table of contents mintoc, there any chance to keep the minitoc numbers in black as well? – Delan Nov 4 '19 at 0:38
• @Delan You can surround your \minitoc command like this: {\hypersetup{linkcolor=black} \minitoc }. See updated answer. – wimi Nov 4 '19 at 8:50