How can I change the colour of my document's section numbering?
I'm sure there is some package that does this, but the simplest way is to redefine the \thesection
command:
\renewcommand\thesection{\color{red}\arabic{section}}
or if you also want the chapter number:
\renewcommand\thesection{\color{red}\thechapter.\arabic{section}}
Similar commands work for \thechapter
, \thesubsection
, etc.
EDIT: A maybe unintended side effect of this is that it also color every reference to the section. To just change it in the section header you can use
\makeatletter
\renewcommand\@seccntformat[1]{\color{red} {\csname the#1\endcsname}\hspace{0.5em}}
\makeatother
In any case you might want to have a look at section 2.2 of the LaTeX Companion and the titlesec
package.
It actually depends on what class you use, for instance, for article.cls, you can have:
\documentclass{article}
\usepackage{color}
\makeatletter
\renewcommand\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\Large\bfseries\color{red}}}
\makeatother
\begin{document}
\tableofcontents
\section{This is a section}
This is a test
\end{document}