2

I'm having trouble changing the sections's colors. They all have the same environment rSection defined below :

\newenvironment{rSection}[1]{ 
  \sectionskip
  \MakeUppercase{\bf #1} % Section title
  \sectionlineskip
  \hrule % Horizontal line
  \begin{list}{}{ 
    \setlength{\leftmargin}{1.5em}
  }
  \item[]
}{
  \end{list}
}

But if I manage to set a specific color for this section, every sections will have the same color.. I tried

\begin{rSection}{\protect\textcolor{ForestGreen} Education}

but xcolor doesn't recognize this color but it does for basic text within the section.. How can I solve this ?

6
  • ForestGreen is a color named via dvipsnames or svgnames, so loading \usepackage[dvipsnames,svgnames]{xcolor} should work. Or try \PassOptionsToPackage{svgnames,dvipsnames}{xcolor} best right after \documentclass{...}
    – user31729
    Feb 1, 2019 at 22:03
  • With dvipsnames, but I successfully changed the color to ForestGreen of the text within the section. But trying to change the section's title makes xcolor not recognizing any color.. mayne because capitalized letters ?
    – Rom
    Feb 1, 2019 at 22:06
  • \MakeUppercase is responsible for this, for upper case of ForestGreen, i.e. FORESTGREEN, which is unknown of course. You may need a different interface to your section environment, pushing the color out of the \MakeUppercase argument.
    – user31729
    Feb 1, 2019 at 22:11
  • Besides all: \bf is outdated. Use \bfseries instead
    – user31729
    Feb 1, 2019 at 22:11
  • apart from uppercasing issues \textcolor{ForestGreen} Education is \textcolor{ForestGreen}{E}ducation and would just color E, was that intended? Feb 1, 2019 at 22:19

1 Answer 1

2

Because you gave us no compilable code I can only guess what the commands \sectionskip and \sectionlineskip should do. I simply commented them in the following code.

You can define a second parameter carrying the color name for environment rSection like

\newenvironment{rSection}[2]{% 
% \sectionskip
  \color{#2}\MakeUppercase{\bf #1} % Section title
% \sectionlineskip
  \hrule % Horizontal line
  \begin{list}{}{ 
    \setlength{\leftmargin}{1.5em}
  }
  \item[]
}{
  \end{list}
}

then you can use

\begin{rSection}{Education}{ForestGreen}

to get the green color.

Please see the following compilable code:

\documentclass{article}

\usepackage[svgnames]{xcolor}

\newenvironment{rSection}[2]{% 
% \sectionskip
  \color{#2}\MakeUppercase{\bf #1} % Section title
% \sectionlineskip
  \hrule % Horizontal line
  \begin{list}{}{ 
    \setlength{\leftmargin}{1.5em}
  }
  \item[]
}{
  \end{list}
}


\begin{document}

\begin{rSection}{Education}{ForestGreen}
Text Text Text
\end{rSection}

\begin{rSection}{Education}{red}
Text Text Text
\end{rSection}

\end{document}

and its result:

resulting pdf

If your used class already defined the environment rSection simply create a new one myrSection in your preamble of your document with

\newenvironment{myrSection}[2]{% 
  \sectionskip
  \color{#2}\MakeUppercase{\bfseries #1} % Section title
  \sectionlineskip
  \hrule % Horizontal line
  \begin{list}{}{ 
    \setlength{\leftmargin}{1.5em}
  }
  \item[]
}{
  \end{list}
}

and use it this way in your document:

\begin{myrSection}{Education}{ForestGreen}
Text Text Text
\end{myrSection}
1
  • Thanks you but the whole section have the color I defined, it's not what I wanted, sorry if I was unclear about that. Thanks anway ! Solved it :)
    – Rom
    Feb 1, 2019 at 22:47

You must log in to answer this question.

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