[Tex/LaTex] Add another color for a section in Friggeri Resume/CV

colorcvfriggeri-cv

So I'm writing my CV using the friggery CV template. It looks like this:

enter image description here

and can be found here:

http://www.latextemplates.com/template/friggeri-resume-cv

As you can see the sections all start with the first three letters in a nice color. However, in the .cls file there are only six defined colors. I would like to have seven sections and I would like the seventh section to also have a color. I've tried adding a darker blue using the following code:

\definecolor{darkblue}{HTML}{0000FF}

in the beginning, and adding darkblue here:

\ifdefined\@cv@print
  \colorlet{green}{gray}
  \colorlet{orange}{gray}
  \colorlet{purple}{gray}
  \colorlet{brown}{gray}
  \colorlet{red}{gray}
  \colorlet{blue}{gray}
  \colorlet{darkblue}{gray}
  \colorlet{fillheader}{white}
  \colorlet{header}{gray}

and also adding darkblue here:

\newcounter{colorCounter}
\def\@sectioncolor#1#2#3{%
  {%
    \color{%
      \ifcase\value{colorCounter}%
        darkblue\or%
        blue\or%
        red\or%
        orange\or%
        green\or%
        purple\or%
        brown\else%
        headercolor\fi%
    } #1#2#3%
  }%
  \stepcounter{colorCounter}%
}

but when I try to add a section I get an error saying that the color darkblue is not defined. What am I doing wrong? None of the other colors are stated anywhere besides in that fashion.

Best Answer

The list of colors is controlled by \@sectioncolor and this just uses an \ifcase; here's the original definition:

\def\@sectioncolor#1#2#3{%
  {%
    \color{%
      \ifcase\value{colorCounter}%
        blue\or%
        red\or%
        orange\or%
        green\or%
        purple\or%
        brown\else%
        headercolor\fi%
    } #1#2#3%
  }%
  \stepcounter{colorCounter}%
}

You can simply define your colors and add them to the list. In the example below I defined two new colors teal and yellow using

\definecolor{teal}{HTML}{008080}
\definecolor{yellow}{HTML}{FFFF00}
\makeatletter
\def\@sectioncolor#1#2#3{%
  {%
    \color{%
      \ifcase\value{colorCounter}%
        blue\or%
        red\or%
        orange\or%
        green\or%
        purple\or%
        brown\or%
        teal\or%
        yellow\else%
        headercolor\fi%
    } #1#2#3%
  }%
  \stepcounter{colorCounter}%
}
\ifdefined\@cv@print
  \colorlet{green}{gray}
  \colorlet{orange}{gray}
  \colorlet{purple}{gray}
  \colorlet{brown}{gray}
  \colorlet{red}{gray}
  \colorlet{blue}{gray}
  \colorlet{teal}{gray}
  \colorlet{yellow}{gray}
  \colorlet{fillheader}{white}
  \colorlet{header}{gray}
\else
  \colorlet{fillheader}{gray}
  \colorlet{header}{white}
\fi
\makeatother

The code:

\documentclass[]{friggeri-cv} % Add 'print' as an option into the square bracket to remove colors from this template for printing

\addbibresource{bibliography.bib} % Specify the bibliography file to include publications

\definecolor{teal}{HTML}{008080}
\definecolor{yellow}{HTML}{FFFF00}

\makeatletter
\def\@sectioncolor#1#2#3{%
  {%
    \color{%
      \ifcase\value{colorCounter}%
        blue\or%
        red\or%
        orange\or%
        green\or%
        purple\or%
        brown\or%
        teal\or%
        yellow\else%
        headercolor\fi%
    } #1#2#3%
  }%
  \stepcounter{colorCounter}%
}
\ifdefined\@cv@print
  \colorlet{green}{gray}
  \colorlet{orange}{gray}
  \colorlet{purple}{gray}
  \colorlet{brown}{gray}
  \colorlet{red}{gray}
  \colorlet{blue}{gray}
  \colorlet{teal}{gray}
  \colorlet{yellow}{gray}
  \colorlet{fillheader}{white}
  \colorlet{header}{gray}
\else
  \colorlet{fillheader}{gray}
  \colorlet{header}{white}
\fi
\makeatother

\begin{document}

\header{john}{smith}{junior business analyst} % Your name and current job title/field

%----------------------------------------------------------------------------------------
%   SIDEBAR SECTION
%----------------------------------------------------------------------------------------

\begin{aside} % In the aside, each new line forces a line break
\section{contact}
123 Broadway
City, State 12345
Country
~
+0 (000) 111 1111
+0 (000) 111 1112
~
\href{mailto:john@smith.com}{john@smith.com}
\href{http://www.smith.com}{http://www.smith.com}
\href{http://facebook.com/johnsmith}{fb://jsmith}
\section{languages}
english mother tongue
spanish \& italian fluency
\section{programming}
{\color{red} $\varheartsuit$} JavaScript
Python, C++, PHP
CSS3 \& HTML5
\end{aside}

\section{education}

\section{experience}

\section{awards}

\section{communication skills}

\section{interests}

\section{publications}

\section{another section}

\section{yet another section}

\end{document}

The output:

enter image description here

If you want to do the modification in the .cls file, then make a copy of friggeri-cv.cls, save it as myfiggeri-cv.cls, and in this new file change the lines

\ProvidesClass{friggeri-cv}[2012/04/30 CV class]

to

\ProvidesClass{myfriggeri-cv}[2012/04/30 CV class]

next change

\ifdefined\@cv@print
  \colorlet{green}{gray}
  \colorlet{orange}{gray}
  \colorlet{purple}{gray}
  \colorlet{brown}{gray}
  \colorlet{red}{gray}
  \colorlet{blue}{gray}
  \colorlet{fillheader}{white}
  \colorlet{header}{gray}
\else
  \colorlet{fillheader}{gray}
  \colorlet{header}{white}
\fi

to

\definecolor{teal}{HTML}{008080}
\definecolor{yellow}{HTML}{FFFF00}

\ifdefined\@cv@print
  \colorlet{green}{gray}
  \colorlet{orange}{gray}
  \colorlet{purple}{gray}
  \colorlet{brown}{gray}
  \colorlet{red}{gray}
  \colorlet{blue}{gray}
  \colorlet{teal}{gray}
  \colorlet{yellow}{gray}
  \colorlet{fillheader}{white}
  \colorlet{header}{gray}
\else
  \colorlet{fillheader}{gray}
  \colorlet{header}{white}
\fi

and finally, change

\def\@sectioncolor#1#2#3{%
  {%
    \color{%
      \ifcase\value{colorCounter}%
        blue\or%
        red\or%
        orange\or%
        green\or%
        purple\or%
        brown\else%
        headercolor\fi%
    } #1#2#3%
  }%
  \stepcounter{colorCounter}%
}

to

\def\@sectioncolor#1#2#3{%
  {%
    \color{%
      \ifcase\value{colorCounter}%
        blue\or%
        red\or%
        orange\or%
        green\or%
        purple\or%
        brown\or%
        teal\or%
        yellow\else%
        headercolor\fi%
    } #1#2#3%
  }%
  \stepcounter{colorCounter}%
}

save the changes and place myfriggeri-cv.cls somewhere TeX can find it (the easiest is the current working directory); in your .tex document now you say

\documentclass{myfriggeri-cv}
Related Question