1

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}

\firstname{John} % Your first name
\familyname{Smith} % Your last name
\title{Curriculum Vitae}

%%%%% added lines
\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: enter image description here

Although, without those added lines, it looked like this: enter image description here

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?

Thanks in advance!

Edit: added MWE and changed the text.

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

1 Answer 1

3

You can create a rainbow rule with

\newcommand{\RainbowRule}{\vspace*{-1ex}\begin{tikzpicture}
\path[shading=rainbow] (0,0) rectangle ++ (\textwidth,1pt);
\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}
\usetikzlibrary{shadings}
\pgfdeclarehorizontalshading{rainbow}{100bp}{%
  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}
\path[shading=rainbow] (0,0) rectangle ++ (\textwidth,1pt);
\end{tikzpicture}}

\firstname{John} % Your first name
\familyname{Smith} % Your last name
\title{Curriculum Vitae}

%%%%% added lines
%\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}

enter image description here

1
  • 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.
    – psyguy
    Jan 13, 2020 at 9:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .