Curricula Vitae / RésumésEach section a different color

ModernCV, Friggeri, Plasmati, Classicthesis-CV, and more
Post Reply
templateuser
Posts: 679
Joined: Tue Mar 03, 2015 4:01 pm

Each section a different color

Post by templateuser »

First of all, great job with this template, I love it, thank you so much! However, I'd like to know if it's possible to have sections with different colors in the same page please? Like Education blue and Experience green? Thanks in advance

gcunhase

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Vel
Site Moderator
Posts: 463
Joined: Fri Jun 29, 2012 1:20 am

Each section a different color

Post by Vel »

Hi,

Sure, you can do this with the \color command like this:

Code: Select all

\section{\color{red}{Education}}
Cheers,
Vel
Founder and administrator of LaTeXTemplates.com and LaTeXTypesetting.com
templateuser
Posts: 679
Joined: Tue Mar 03, 2015 4:01 pm

Re: Each section a different color

Post by templateuser »

Thank you, but what about the bar to the left of the section name? It doesn't change color when I use this command. Thank you again :)

gcunhase
User avatar
Vel
Site Moderator
Posts: 463
Joined: Fri Jun 29, 2012 1:20 am

Each section a different color

Post by Vel »

Hi,

This will be a bit trickier to change. The rule color is defined in this line in moderncvclassic.sty:

Code: Select all

\parbox[t]{\hintscolumnwidth}{\strut\raggedleft\raisebox{\baseletterheight}%
{\color{color1}\rule{\hintscolumnwidth}{0.95ex}}}
You'll notice it's hard-coded for the document to be "color1". If you want to be able to change this per section, I'd recommend adding another parameter to \section with the color you'd like to use. You'll then always need to specify the color whenever you use \section in the document.

Good luck!

Cheers,
Vel
Founder and administrator of LaTeXTemplates.com and LaTeXTypesetting.com
CarolinaTL
Posts: 1
Joined: Thu Sep 27, 2018 4:32 am

Each section a different color

Post by CarolinaTL »

Hi, Vel!
I was looking for that rule color line that you said, but I didn't find it, maybe that line code does not exist in the last ModernCV version which is the one I'm using, but I'm not sure. Anyway, in the 2015 version, I think the line that modifies color in a section is found in the file moderncvbodyi.sty, and it is the following:

% styles
\renewcommand*{\sectionstyle}[1]{{\sectionfont\textcolor{color1}{#1}}}
\renewcommand*{\subsectionstyle}[1]{{\subsectionfont\textcolor{color1}{#1}}}
\renewcommand*{\hintstyle}[1]{{\hintfont\textcolor{color0}{#1}}}

However, I don't know how to modify that in order to have a different color in each section, included its bar to the left. tHe reason is that I want make my CV with a 'colorful' ModernCV style. Thus, could you explain me how can I bring your idea "add another parameter to \section with the color you'd like to use. You'll then always need to specify the color whenever you use \section in the document." to life?

Thanks in advance!
Post Reply