Take a look at this document:
\documentclass[twoside]{article}
% For blind text
\usepackage[english]{babel}
\usepackage{blindtext}
% To make sections begin on new page
\usepackage{titlesec}
% Command for new sections beginning on new page
\newcommand{\sectionbreak}{\clearpage}
% Headers
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
% Header on top right on odd pages
\fancyhead[OR]{{\textsc{\leftmark}}\quad\quad\thepage}
% Reader on top left on even pages
\fancyhead[EL]{\thepage\quad\quad{\textsc{\leftmark}}}
\renewcommand{\sectionmark}[1]{\markboth{#1}{}}
% Otherwise colors won't work!
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\begin{document}
\section{Section 1}
\blindtext[2]
\section{Section 2}
\blindtext[2]
\section{Section 3}
\blindtext[2]
\section{Section 4}
\blindtext[2]
\end{document}
Nice, no? But how boooorrrriiing. No color, no nothing. This hasn't had Carliste's magic touch yet. But fortunately, LaTeX supports color, and I'll use them!
Now, there are some ways to change the color of the section according to the section number. However, I want to do something similar, but different: I want to change the color of the header according to the section number, with my own custom colors. Oh, this changes everything.
So, what did I try? I using a nested ifthenelse statement to get the wanted result. I also tried pulling my hair out and browsing answers for hours. But back to the ifthenelse statement – I really don't get why this doesn't work:
\documentclass[twoside]{article}
% For blind text
\usepackage[english]{babel}
\usepackage{blindtext,ifthen}
% To make sections begin on new page
\usepackage{titlesec}
% Command for new sections beginning on new page
\newcommand{\sectionbreak}{\clearpage}
% Headers
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
% yum yum yum
\ifthenelse{\equal{\thesection}{1}}{\fancyhead[OR]{\textcolor{red}{{\textsc{\leftmark}}\quad\quad\thepage}}}{\fancyhead[OR]{\textcolor{blue}{{\textsc{\leftmark}}\quad\quad\thepage}}}
% Reader on top left on even pages
\fancyhead[EL]{\thepage\quad\quad{\textsc{\leftmark}}}
\renewcommand{\sectionmark}[1]{\markboth{#1}{}}
% Otherwise colors won't work!
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\begin{document}
\section{Section 1}
\blindtext[2]
\section{Section 2}
\blindtext[2]
\section{Section 3}
\blindtext[2]
\section{Section 4}
\blindtext[2]
\end{document}
This technically should make the first page header red and the second page header blue, but I think the engine has short-term memory loss (or maybe I'm not using it correctly – this is more likely the correct answer, but I don't want to admit it) but it's all blue, as if it doesn't heed or notice my meticulously crafted ifthenelse statement, which would have been much, much more intricate had it responded to me the first time (i.e. with the example above).
Now I need some help, which preferably doesn't involve the use of xcolor's color series (I mean, it's almost what I want, but unfortunately you're only able to choose the first and last color manually – every other color in between is a user-defined gradation between the first and the last one. Unfortunately this gradation has a mathematical basis and can't be manipulated into using just any random color which satisfies human want (as far as I can tell, anyway).
Also, maybe sometime in the future I would like to expand this to subsections, but I think I'll be able to figure out that bit by myself if I get a proper header with this question :) thanks :)