# Rainbow color for horizontal lines of moderncv (banking theme)

I was thinking of adding a sprinkle of the pride rainbow in my CV without making it too bold. Thus, I thought it would be better to subtly embed it within the horizontal lines between sections in moderncv. I am using the banking style.

I have found this MWE to change the color of horizontal lines in moderncv (taken from here):

\documentclass[11pt,a4paper,sans]{moderncv}

\moderncvstyle{banking}
\moderncvcolor{blue}

\usepackage[scale=0.75]{geometry}

\title{Curriculum Vitae}

\colorlet{titlerulecolor}{orange}
\usepackage{titlesec}
\titleformat{\section}{\Large\scshape\raggedright}{}{0em}{}[{\color{titlerulecolor}\titlerule}]
\titlespacing{\section}{0pt}{3pt}{3pt}
%%%%%

\begin{document}

\makecvtitle

\section{Education}

\cventry{2011--2012}{Masters of Commerce}{The University of California}{Berkeley}{\textit{GPA -- 8.0}}{First Class Honours}
\section{Masters Thesis}

\cvitem{Title}{\emph{Money Is The Root Of All Evil -- Or Is It?}}

\subsection{A subsection}
\cvitem{Supervisors}{Professor James Smith \& Associate Professor Jane Smith}

\end{document}


However, this solution messes up the titles and the dashed line for the subsection. This example makes this output:

Although, without those added lines, it looked like this:

And for rainbow colors in TeX, I have found this answered question about the rainbow coloring of a single letter, and this one about defining a rainbow-gradient macro.

How can I make the horizontal lines that rainbow-colored? Preferably, the outcome color should consist of discrete colors (red, orange, yellow, green, royal blue, violet) rather than a gradient.

P.S. Is it also possible to increase the line widths so they become a bit more visible?

Edit: added MWE and changed the text.

• Rather than various links please put together one minimal working example that show what you have tried. – Schrödinger's cat Jan 12 at 17:31
• @Schrödinger'scat I added an MWE and changed the text a bit. – ManuHaq Jan 12 at 18:25
• Don't you get errors when you run your code? – Schrödinger's cat Jan 12 at 18:34
• @Schrödinger'scat yes I do, will comment below your answer. – ManuHaq Jan 13 at 9:25

You can create a rainbow rule with

\newcommand{\RainbowRule}{\vspace*{-1ex}\begin{tikzpicture}
\end{tikzpicture}}


where 1pt specifies the width of the rule.

\documentclass[11pt,a4paper,sans]{moderncv}

\moderncvstyle{banking}
\moderncvcolor{blue}

\usepackage[scale=0.75]{geometry}

\usepackage{tikz}
rgb(0bp)=(1,0,0);
rgb(26bp)=(1,0,0);
rgb(33bp)=(1,.5,0);
rgb(40bp)=(1,1,0);
rgb(47bp)=(0,1,0);
rgb(54bp)=(0,1,1);
rgb(61bp)=(0,0,1);
rgb(68bp)=(1,0,1);
rgb(75bp)=(.5,0,.5);
rgb(100bp)=(.5,0,.5)}

\newcommand{\RainbowRule}{\vspace*{-1ex}\begin{tikzpicture}
\end{tikzpicture}}

\title{Curriculum Vitae}

%\colorlet{titlerulecolor}{orange}
\usepackage{titlesec}
\titleformat{\section}{\Large\scshape\raggedright}{}{0em}{}[{\RainbowRule}]
\titlespacing{\section}{0pt}{3pt}{3pt}
\titleformat{\subsection}{\large\scshape\raggedright}{}{0em}{}[{\vspace*{-1ex}\dotfill}]
\titlespacing{\subsection}{0pt}{2pt}{2pt}
%%%%%

\begin{document}

\makecvtitle

\section{Education}

\cventry{2011--2012}{Masters of Commerce}{The University of California}{Berkeley}{\textit{GPA -- 8.0}}{First Class Honours}
\section{Masters Thesis}

\cvitem{Title}{\emph{Money Is The Root Of All Evil -- Or Is It?}}

\subsection{A subsection}
\cvitem{Supervisors}{Professor James Smith \& Associate Professor Jane Smith}

\end{document}


• Awesome! Yes, I forgot to mention that the initial solution in MWE (also with your added lines) throws an error at the line of \subsection{}, saying Missing number, treated as zero. Illegal unit of measurement (pt inserted)., plus some Undefined control sequence.. Is there a fix to that? Non-rainbow (e.g., same as moderncvcolor) dotted line for subsection would also be fine. – ManuHaq Jan 13 at 9:35