Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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}
share|improve this answer
    
Thanks for your reply! However, I've already tried basically what you're doing in the .cls file. When I then try to add another section in my .tex file I get the error "Package xcolor Error: Undefined color `darkblue'". As far as I can tell I'm using the exact same code as you are. So what am I doing wrong exactly? –  Christian May 9 at 22:11
1  
@Christian Please try to compile my code exactly as is (creating a new file, say test.tex, and using the same code as in my answer (not changing the .cls file which is never a good idea unless you change a copy and make the changes there)). Do you still get the error with my code? –  Gonzalo Medina May 9 at 22:14
    
No, using both the friggeri .cls file and your code in the .tex file I get the same output as you. It seems like pretty much all the code in .cls file will need to be in the .tex file for me to be able to add colors though? Or am I misunderstanding you? –  Christian May 9 at 22:33
1  
@Christian All you need to add to the .tex file is the code with the \definecolor command(s) for your new colors and the part between \makeatletter, \makeatother (including those two commands) in my example. –  Gonzalo Medina May 9 at 22:36
1  
@Christian You're welcome. Don't forget that you can accept an answer that you conisder solved your problem by clicking the checkmark to its left. In case of doubt, please see `How do you accept an answer?. –  Gonzalo Medina May 9 at 23:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.