Coloured \tableofcontents ok except for subsection page number
Roger Price <[email protected]> Fri, 29 Aug 2025 10:15:34 +0200 (CEST)
| Newsgroups | gmane.comp.tex.texhax |
|---|---|
| Message-ID | <[email protected]> |
I would like my table of contents to appear in a dark red, so I defined
\newcommand{\Section}[1]{\textcolor{DARKRED}{\section{#1}}}
\newcommand{\Subsection}[1]{\textcolor{DARKRED}{\subsection{#1}}}
and specified
\Section{Introduction}
bla bla
\Section{Data communications}
bla bla
\Subsection{Error control}
bla bla
\textcolor{DARKRED}{\tableofcontents}
This worked well until I added the \Subsection to the document. I run pdflatex
three times and in the PDF I see
Contents
1 Introduction 1
2 Data communications 4
2.1 Error control . . . . . . . . . . . . . . 5
Everything is correctly coloured _except_ for the "5" on the last line, which is
black.
Further testing with repeated \Subsection and \Subsubsection shows that only the
page number of Subsection and Subsubsection is not coloured. Everything else is
ok, including the . . . The .toc file contains no colouring instructions.
Should I be able to colour a table of contents like this?, or is there some
other way? Any hint would be very welcome.
Roger