I am creating a CV under Latex (based on the altacv template but it does not have such importance) and in the preamble of my .tex document, I am trying to find a solution to be able to quickly test a configuration of color shades.
Since I discovered the LaTeX3 interface and its functions, I tried to used the \str_case:nn
function to realize a kind of switch case.
But I am not getting the desired result and after compilation, the default colors from the class are used and not the new ones I wished from my configuration in the .tex document.
I fear that it is because I'm trying to use it in the preamble without really "calling it" and not after my \begin{document}
, am I right ? But I don't really see how to realize such call.
Here, is my code. As you can see, I made some variables in order to test if a case was really considered during compilation. Also, I am not sure if the commands used for my grey hue color selection are correct. I am using the xcolor package.
% Available options
\str_const:Nn \l_greyColorHue_str {greyHue}
\str_const:Nn \l_blueColorHue_str {blueHue}
% To modify to choose the switch-case option
\str_set_eq:NN \l_colorHueSelection_str \l_greyColorHue_str
% String to verify if the switch case worked
\str_new:N \l_effectiveColorHue_str
%% Color fields definition
\str_case:nn {\l_colorHueSelection_str}
{
{\l_greyColorHue_str} {
\colorlet{name}{\color[Gray]{15}} % Used for : \name
\colorlet{tagline}{\color[Gray]{13}} % Used for : \tagline
\colorlet{heading}{\color[Gray]{13}} % Used for : \cvsection
\colorlet{headingrule}{\color[Gray]{15}} % Used for : \rule
\colorlet{subheading}{\color[Gray]{13}} % Used for : \cvsubsection, \cvsubsubsection
\colorlet{accent}{\color[Gray]{10}} % Used for : \cvref(#1), \cvskill(#1), \skillfive, \cvachievment(#1), \cvevent(#1), \quote, \printinfo(#1)
\colorlet{emphasis}{\color[Gray]{9}} % Used for : \cvref(#1), \cvskill(#1) \cvachievment(#2), \cvevent(#1)
\colorlet{body}{\color[Gray]{15}} % Used for : all text color
\str_set_eq:NN \l_effectiveColorHue_str \l_greyColorHue_str
}
{\l_blueColorHue_str} {
\colorlet{name}{black} % Used for : \name
\colorlet{tagline}{RoyalBlue} % Used for : \tagline
\colorlet{heading}{RoyalBlue} % Used for : \cvsection
\colorlet{headingrule}{black} % Used for : \rule
\colorlet{subheading}{Navy} % Used for : \cvsubsection, \cvsubsubsection
\colorlet{accent}{MediumBlue} % Used for : \cvref(#2), \cvskill(#2), \skillfive, \cvachievment(#1), \cvevent(#2), \quote, \printinfo(#1)
\colorlet{emphasis}{MidnightBlue} % Used for : \cvref(#1), \cvskill(#1) \cvachievment(#2), \cvevent(#1)
\colorlet{body}{black} % Used for : all text color
\str_set_eq:NN \l_effectiveColorHue_str \l_blueColorHue_str
}
}
Then, I begin my document and return my variable \l_effectiveColorHue_str
to see its content in the generated document.
\begin{document}
[...]
\makecvheader
\ExplSyntaxOn
Selected~coloration~: \\
(~ \str_use:N \l_effectiveColorHue_str ~)
\ExplSyntaxOff
Do you have any idea to make this work or even another solution with "classic" Latex code in order that I can easily switch between different shades of colors for test without overwritting my commands or commenting/Uncommenting my colorlet
selections ?
\str_case_e:nn
instead. As it is, it compares the string\l_colorHueSelection_str
with\l_greyColorHue_str
, rather than the value of these variablesinterface3
is huge :) I will write an answer with a bit more detail for you