1

Currently I am using the following code to give my Section Numbers a different colour (I am using the xcolor package):

\documentclass{article}

\usepackage[dvipsnames]{xcolor}
\definecolor{darkmidnightblue}{rgb}{0, 0.2, 0.4}

\makeatletter
\renewcommand\@seccntformat[1]{\color{darkmidnightblue} {\csname 
the#1\endcsname}\hspace{0.5em}}
\makeatother

\begin{document}

\section{\textcolor{darkmidnightblue}{Section}}
\subsection{\textcolor{MidnightBlue}{Subsection}}

\end{document}

However, I understand that as it is, it also applies the same scheme to the other section levels. I am trying to make the Subsection have a different colour to the Section, but it turns out like this:

Section Number and Text are dark blue. Subsection text is light blue, but Subsection Number is still dark blue.

I would like the Subsection Number to be the same colour as the text. Can this code be modified to alter each section level independently, or will I need to use different commands altogether?

Elliot

E Vale
  • 11
  • 1
    Please provide a complete minimal example that is compilable. Depending on the document class (KOMA, memoir, standard, ...) there are different solutions. – Dr. Manuel Kuehner Apr 05 '17 at 19:16
  • Please provide a MWE so we can help you :) – astronat Apr 05 '17 at 19:18
  • See http://tex.stackexchange.com/questions/68376 for example. – Dr. Manuel Kuehner Apr 05 '17 at 19:23
  • I have edited the code, it should now be useable by yourselves. – E Vale Apr 05 '17 at 19:32
  • 1
    Please clarify your objective (right now, it's not very clear): Are you trying to give the section-level numbers a different color from the subsection-level numbers, while keeping the color of the section and subsection headers black (the default), or are you trying to assign different colors to section-level header strings (both number and label) and to subsection-level headers (both number and label)? – Mico Apr 05 '17 at 19:57

0 Answers0