Referring to good working solution with MWE included in How can I add the word "Chap" before the chapters numbers in the Toc in class report? for adding word 'Chap' before chapter numbers in toc in report class, if I want to color in blue the entire the 'Chap..' line in toc, what must I do? Only the word 'Chap' is in blue and not its title. I would the entire 'Chap' toc line to be in blue.
Modifying the lines for enabling 'Chapter..' word in toc below with \color{blue}
\newlength\mylength
\renewcommand\cftchappresnum{\color{blue}{Chapter~}}
\settowidth\mylength{\bfseries\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylength}
Update 1: (12/28/2022) It does not work when using hyperref
See my MWE
\documentclass{report}
\usepackage{tocloft}
\usepackage{etoolbox}
\usepackage[titletoc]{appendix}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[hyperfootnotes=false,english,colorlinks]{hyperref}
\hypersetup{
colorlinks=true,
citecolor=PineGreen,
linkcolor=red,
urlcolor=blue}
\apptocmd{\appendix}
{\addtocontents{toc}{%
\protect\addtolength\protect\cftchapnumwidth{-\mylength}%
\protect\renewcommand{\protect\cftchappresnum}{\bf\color{red}Appendix~}% changed <<<<
\protect\renewcommand{\protect\cftchapfont}{\bf\color{red}}
\protect\settowidth\mylength{\bfseries\protect\cftchappresnum\protect\cftchapaftersnum}%
\protect\addtolength\protect\cftchapnumwidth{\mylength}}%
}{}{}
\newlength\mylength
\renewcommand\cftchappresnum{\bf\color{blue}Chapter~}
\settowidth\mylength{\bfseries\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylength}
\renewcommand{\cftchapfont}{\bf\color{blue}}
\renewcommand\cftchapaftersnum{:}
\begin{document}
\tableofcontents
\chapter{Intro}
\chapter{Test}
\appendix
\chapter{Conclusions}
\end{document}
Update 2 (12/29/2022)
Okay I have been able to enable the entire Chap line in ToC using response from @David Purton to be in blue but now other entries such as Acknowledgements, Abstracts, Bibliography that are not meant to be chapters but needed to be added to Toc in the same format (think indent and spacing in toc) using \addcontentsline{toc}{chapter}{}
I would want those entries to be in red (appendix toc line in red is ok).
See my new MWE
\documentclass{report}
\usepackage{tocloft}
\usepackage{etoolbox}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage[hyperfootnotes=false,english,colorlinks]{hyperref}
\hypersetup{
colorlinks=true,
citecolor=PineGreen,
linkcolor=red,
urlcolor=blue}
\usepackage[
style=authoryear,
natbib=true,
backend=biber,
dashed=false,
isbn = false,
doi = false,
url = false,
language=auto,
sorting=nyt,
maxbibnames=99,
maxcitenames=2,
uniquelist=false,
uniquename=false]{biblatex}
\addbibresource{biblatex-examples.bib}
% Change ToC settings for Appendix
\apptocmd{\appendix}
{\addtocontents{toc}{%
\protect\renewcommand\protect\cftchapfont{\protect\bfseries}
\protect\addtolength\protect\cftchapnumwidth{-\mylength}%
\protect\renewcommand{\protect\cftchappresnum}{Appendix~}%
\protect\settowidth\mylength{\bfseries\protect\cftchappresnum\protect\cftchapaftersnum}%
\protect\addtolength\protect\cftchapnumwidth{\mylength}}%
}{}{}
% Toc for chapter
\newlength\mylength
\renewcommand\cftchappresnum{Chapter~}
\renewcommand\cftchapfont{\hypersetup{linkcolor=blue}\bfseries}
\settowidth\mylength{\bfseries\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylength}
\renewcommand\cftchapaftersnum{:}
\begin{document}
\section*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
\section*{Acknowledgements}
\addcontentsline{toc}{chapter}{Acknowledgements}
\tableofcontents
\thispagestyle{empty}
\chapter{Intro}
Lorem \citet{sigfridsson}
\section{A section}
\subsection{A subsection}
\chapter{Test}
\addcontentsline{toc}{chapter}{Bibliography}
\printbibliography
\appendix
\chapter{Conclusions}
\end{document}
hyperref
package with thecolorlinks
option? If so, maybe it would suit you to just set the link colour usinglinkcolor=blue
as an option tohyperref
.hyperref
. I just edited to show my MWE. I want only chap line in blue and the rest red so I have to keeplinkcolor=red
. What should I do so that the entire chap line in Toc is in blue.linkcolor
to blue at the start of the TOC and change it to red at the start of the appendices?