3

I have a document using article class (please not ask me why don't use report class). The article has TOC, LOF, LOT and Nomenclature.

The MWE:

 \documentclass[12pt,a4paper,twoside] {article}
 \usepackage{color}
 \usepackage{subfigure}
 \usepackage[nottoc]{tocbibind}
 \usepackage[intoc]{nomencl}
 \makenomenclature

 \usepackage{kpfonts} %[uprightRoman, uprightgreeks]
 \usepackage[T1]{fontenc}

 \usepackage[subfigure]{tocloft}
   \setlength\cftbeforefigskip{1 ex} % list of figures
   \setlength\cftbeforetabskip{1 ex} % list of tables
   \setlength\cftbeforesecskip{1 em} % spacing before sec title
   \setlength\cftaftertoctitleskip{1.8 em} 
   \setlength\cftbeforetoctitleskip{4 cm} 
   \setlength{\nomitemsep}{0.5 ex} 

 \usepackage{titlesec}
 \titleformat{\subsection} {\large \bfseries \color{RoyalBlue}} {\thesubsection}{1 ex}{}
 \titleformat{\subsubsection}  {\normalsize  \bfseries  \color{RoyalBlue}}       {\thesubsubsection}{1 ex}{}  %\slshape
 \setcounter{tocdepth}{3}   % table of content depth
\definecolor{RoyalBlue}{RGB}{0, 35, 102}

 \begin{document}
  Hello, world!
  \tableofcontents
  \listoffigures
  \listoftables
  \printnomenclature[2 cm]       
  \section{Introduction}
  \section{DEM}
  \subsection{Math model}
  \subsubsection{Particle collision}
  \nomenclature{DEM}{Distinct Element Method}
\end{document}

The color of section headings and Nomenclature is changed as expected. However the color of Contents and List of Figures etc. remains black.

Having looked through article.cls, I tried

\renewcommand\tableofcontents{%
\section*{\contentsname
     \@mkboth{%
       \MakeUppercase \textcolor{RoyalBlue} {\contentsname} }{\MakeUppercase \textcolor{RoyalBlue}\contentsname}}%
\@starttoc{toc}%
}

However, it turned out not working. By the way, I used tocloft to define the LOF, LOT entries spacing, don't know whether it has some side-effect.

So how to figure this out?

Edit 1: Found out the problem lies with: \usepackage[subfigure]{tocloft} . But I need these packages! Or should I redefine the spacing without the tocloft package?

  • Your MWE does not compile for me, I get ! Undefined control sequence. <argument> \undefinedpagestyle. Instead of subfigure, try the subfig package, it is usually seen as superior. Most important however, load tocloft after subfigure. – mafp Jan 21 '13 at 23:55
  • MWE was edited, now should work. Loading subfigure before tocloft does not work. I suspect tocloft redefines the default commands \contentsname and \tableofcontents. – KOF Jan 22 '13 at 0:24
3

Use

\renewcommand{\cfttoctitlefont}{\color{RoyalBlue}}

to change the color of the ToC to blue. Add other stuff like \Large\bfseries to it, to get bold large title text. Similarly, change \cftloftitlefont for the List of Figures.

  • Thanks, i just searched for the keywords color/colour in the tocloft RADEME, no words found. So I thought no option to change font color, LOL – KOF Jan 22 '13 at 0:23

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.