moderncv/moderncvskillmatrix.sty

369 lines
21 KiB
TeX

%% start of file `moderncvskillmatrix.sty'.
%% Copyright 2021 David Seus (cryptointerest@posteo.de).
%
% This package provides a skill matrix template for the moderncv package.
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c,
% available at http://www.latex-project.org/lppl/.
%-------------------------------------------------------------------------------
% identification
%-------------------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{moderncvskillmatrix}[2021/01/18 v2.1.0 modern curriculum vitae and letter skill matrix]
% The definitions need to be adjusted depending on which moderncvbody<i-v>.sty style is usde.
% body type options: "moderncvbodyi" (default), "moderncvbodyii", "moderncvbodyiii", "moderncvbodyiv" or "moderncvbodyv"
\@initializeif{\if@moderncvbodyi}\@moderncvbodyifalse
\DeclareOption{moderncvbodyi}{\@moderncvbodyitrue\@moderncvbodyiifalse\@moderncvbodyiiifalse\@moderncvbodyivfalse\@moderncvbodyvfalse}
\@initializeif{\if@moderncvbodyii}\@moderncvbodyiifalse
\DeclareOption{moderncvbodyii}{\@moderncvbodyifalse\@moderncvbodyiitrue\@moderncvbodyiiifalse\@moderncvbodyivfalse\@moderncvbodyvfalse}
\@initializeif{\if@moderncvbodyiii}\@moderncvbodyiiifalse
\DeclareOption{moderncvbodyiii}{\@moderncvbodyifalse\@moderncvbodyiifalse\@moderncvbodyiiitrue\@moderncvbodyivfalse\@moderncvbodyvfalse}
\@initializeif{\if@moderncvbodyiv}\@moderncvbodyivfalse
\DeclareOption{moderncvbodyiv}{\@moderncvbodyifalse\@moderncvbodyiifalse\@moderncvbodyiiifalse\@moderncvbodyivtrue\@moderncvbodyvfalse}
\@initializeif{\if@moderncvbodyv}\@moderncvbodyvfalse
\DeclareOption{moderncvbodyv}{\@moderncvbodyifalse\@moderncvbodyiifalse\@moderncvbodyiiifalse\@moderncvbodyivfalse\@moderncvbodyvtrue}
\DeclareOption*{}% avoid choking on unknown options
\ExecuteOptions{moderncvbodyi}
\ProcessOptions*\relax% \ProcessOptions* processes the options in the order provided (i.e., with the later ones possibly overriding the former ones), while \ProcessOptions processes them in the order of the package
%-------------------------------------------------------------------------------
% required packages
%-------------------------------------------------------------------------------
\RequirePackage{tikz}
\RequirePackage{multirow}
% package arydshln is needed for the dashed lines but is incompatible with fancy style
\if@moderncvbodyv%
% \RequirePackage{arydshln} % incompatible with fancy style
\else%
\RequirePackage{arydshln} % incompatible with fancy style
\fi
% %-------------------------------------------------------------------------------
% % \cvSkill command
% %-------------------------------------------------------------------------------
% The code for the Skilllevel illustration with the little boxes.
% This is idea stolen from the limecv package
\@initializelength{\cvSkillRectangleSize}
\setlength{\cvSkillRectangleSize}{1.2ex}
\newcount\my@repeat@count
\DeclareDocumentCommand{\cvSkill}{m}{%
\begingroup
\my@repeat@count=\z@
\@whilenum\my@repeat@count<#1\do{\tikz\filldraw[color1] (0, 0) rectangle (\cvSkillRectangleSize, \cvSkillRectangleSize);\advance%
\my@repeat@count\@ne\,}%
\my@repeat@count=\numexpr5-\z@\relax
\@whilenum\my@repeat@count>#1\do{\tikz\filldraw[color2!30] (0, 0) rectangle (\cvSkillRectangleSize, \cvSkillRectangleSize);\advance%
\my@repeat@count\m@ne\,}%
\endgroup
}
% %-------------------------------------------------------------------------------
% % \recomputecvskillmatrixlengths
% %-------------------------------------------------------------------------------
% initialise lengths needed for the skillmatrix
\@initializelength{\cvskillwidth}
\@initializelength{\cvskilldescriptorwidth}
\@initializelength{\cvskilllegenddescriptorwidth}
\@initializelength{\cvskillexperiencewidth}
\@initializelength{\skillmatrixcolumnwidth}
\@initializelength{\skillmatrixcommentwidth}
\@initializelength{\skillmatrixcommentpadding}
\@initializelength{\skillmatrixhintscolumnwidth}
\@initializelength{\skilllegendhintscolumnwidth}
% \separatorrulewidth is defined in moderncvbodyv.sty and we need to
% define it to not throw an error in the other cases
\if@moderncvbodyv%
% \RequirePackage{arydshln} % incompatible with fancy style
\else%
\@initializelength{\separatorrulewidth}
\setlength{\separatorrulewidth}{1ex}
\fi
%% DEFINITION \recomputecvskillmatrixlengths
% declare the command \recomputecvskillmatrixlengths empty
\DeclareDocumentCommand{\recomputecvskillmatrixlengths}{}{}%
% the command gets redifined depending on which option is given
\if@moderncvbodyi%
\RenewDocumentCommand{\recomputecvskillmatrixlengths}{}{%
\setlength{\skillmatrixcommentpadding}{1ex}
\setlength{\skillmatrixhintscolumnwidth}{\hintscolumnwidth}
\setlength{\skilllegendhintscolumnwidth}{\hintscolumnwidth}
\setlength{\cvskillwidth}{\widthof{\cvSkill{5}}}
\setlength{\cvskillexperiencewidth}{\widthof{``Jahre''}}
\setlength{\skillmatrixcolumnwidth}{0.45\maincolumnwidth}%
\setlength{\cvskilldescriptorwidth}{\skillmatrixcolumnwidth-\cvskillwidth-\cvskillexperiencewidth}
\setlength{\skillmatrixcommentwidth}{\maincolumnwidth-\skillmatrixcolumnwidth-\skillmatrixcommentpadding}%
\setlength{\cvskilllegenddescriptorwidth}{0.5\maincolumnwidth-\cvskillwidth-\skillmatrixcommentpadding}
}
\fi
\if@moderncvbodyiii%
\RenewDocumentCommand{\recomputecvskillmatrixlengths}{}{%
\setlength{\skillmatrixcommentpadding}{1ex}
\setlength{\separatorcolumnwidth}{\skillmatrixcommentpadding}
\setlength{\skillmatrixhintscolumnwidth}{\widthof{``Language''}}
\setlength{\skilllegendhintscolumnwidth}{\skillmatrixhintscolumnwidth}%
\setlength{\cvskillwidth}{\widthof{\cvSkill{5}}}
\setlength{\cvskillexperiencewidth}{\widthof{``Jahre''}}
\@initializelength{\matrixbodylength}
\setlength{\matrixbodylength}{\maincolumnwidth-\skillmatrixhintscolumnwidth-\separatorcolumnwidth}
\setlength{\skillmatrixcolumnwidth}{0.45\matrixbodylength}%
\setlength{\cvskilldescriptorwidth}{\skillmatrixcolumnwidth-\cvskillwidth-\cvskillexperiencewidth}
\setlength{\skillmatrixcommentwidth}{\matrixbodylength-\skillmatrixcolumnwidth-\skillmatrixcommentpadding}%
\setlength{\cvskilllegenddescriptorwidth}{0.5\matrixbodylength-\cvskillwidth-\skillmatrixcommentpadding}
}
\fi
\if@moderncvbodyiv%
\RenewDocumentCommand{\recomputecvskillmatrixlengths}{}{%
\setlength{\skillmatrixcommentpadding}{1ex}
\setlength{\separatorcolumnwidth}{\skillmatrixcommentpadding}
\setlength{\skillmatrixhintscolumnwidth}{\widthof{``Languagi''}}
\setlength{\skilllegendhintscolumnwidth}{0ex}%\skillmatrixhintscolumnwidth
\setlength{\cvskillwidth}{\widthof{\cvSkill{5}}}
\setlength{\cvskillexperiencewidth}{\widthof{``Jahre''}}
\@initializelength{\matrixbodylength}
\setlength{\matrixbodylength}{\maincolumnwidth-\skillmatrixhintscolumnwidth-\separatorcolumnwidth}
\setlength{\skillmatrixcolumnwidth}{0.45\matrixbodylength}%
\setlength{\cvskilldescriptorwidth}{\skillmatrixcolumnwidth-\cvskillwidth-\cvskillexperiencewidth}
\setlength{\skillmatrixcommentwidth}{\matrixbodylength-\skillmatrixcolumnwidth-\skillmatrixcommentpadding}%
\setlength{\cvskilllegenddescriptorwidth}{0.5\maincolumnwidth-\cvskillwidth-\skillmatrixcommentpadding}
}
\fi
\if@moderncvbodyv%
\RenewDocumentCommand{\recomputecvskillmatrixlengths}{}{%
\setlength{\skillmatrixcommentpadding}{1ex}
\setlength{\skillmatrixhintscolumnwidth}{\widthof{``Languages''}}
\setlength{\skilllegendhintscolumnwidth}{\skillmatrixhintscolumnwidth}
\setlength{\cvskillwidth}{\widthof{\cvSkill{5}}}
\setlength{\cvskillexperiencewidth}{\widthof{``Jahre''}}
\@initializelength{\matrixbodylength}
\setlength{\matrixbodylength}{\maincolumnwidth-\skillmatrixhintscolumnwidth-\skillmatrixcommentpadding}%\skillmatrixhintscolumnwidth
\setlength{\skillmatrixcolumnwidth}{0.45\matrixbodylength}%
\setlength{\cvskilldescriptorwidth}{\skillmatrixcolumnwidth-\cvskillwidth-\cvskillexperiencewidth}
\setlength{\skillmatrixcommentwidth}{\matrixbodylength-\skillmatrixcolumnwidth-\skillmatrixcommentpadding}%
\setlength{\cvskilllegenddescriptorwidth}{0.5\maincolumnwidth-\cvskillwidth-\skillmatrixcommentpadding}
}
\fi
% %-------------------------------------------------------------------------------
% % \cvSkillMatrixLegend
% %-------------------------------------------------------------------------------
\NewDocumentCommand\legendFontSize{}{\scriptsize}
\DeclareDocumentCommand\cvSkillMatrixLegend{s +O{} +O{} +O{} +O{} +O{} +O{} +m}{}%
% The following definition is valid for moderncvbodyi, moderncvbodyii, moderncvbodyiii
\RenewDocumentCommand\cvSkillMatrixLegend{s +O{.25em} +O{basic knowledge} +O{intermediate knowledge with experience in projects} +O{extensive experience in projects} +O{deep expert knowledge} +O{expert/guru} +m}{%
\IfBooleanTF#1{% if a star is given, add dashed line
\begingroup
\arrayrulecolor{color1}
\begin{tabular}{@{}p{\skilllegendhintscolumnwidth}
@{\hspace{\separatorcolumnwidth}}p{\cvskillwidth}@{};{.6pt/1pt}p{\cvskilllegenddescriptorwidth} @{\hspace{2\skillmatrixcommentpadding}}p{\cvskillwidth}@{};{.6pt/1pt}p{\cvskilllegenddescriptorwidth}@{}}%
\raggedleft\hintstyle{#8} & \cvSkill{1}\, & \,{\legendFontSize #3} & \cvSkill{3}\, &\,{\legendFontSize #5 } \\
%
& \cvSkill{2}\, & \,\multirow{2}{\cvskilllegenddescriptorwidth}{{\legendFontSize #4}} & \cvSkill{4}\, &\,{\legendFontSize #6 } \\
%
& & & \cvSkill{5}\, &\,{\legendFontSize #7 }
\end{tabular}%
\endgroup
\par\addvspace{#2}}{
% if no star is given, do not add dashed line
\begin{tabular}{@{}p{\skilllegendhintscolumnwidth}
@{\hspace{\separatorcolumnwidth}}p{\cvskillwidth}@{}p{\cvskilllegenddescriptorwidth} @{\hspace{2\skillmatrixcommentpadding}}p{\cvskillwidth}@{}p{\cvskilllegenddescriptorwidth}@{}}%
\raggedleft\hintstyle{#8} & \cvSkill{1}\, & \,{\legendFontSize #3} & \cvSkill{3}\, &\,{\legendFontSize #5 } \\
%
& \cvSkill{2}\, & \,\multirow{2}{\cvskilllegenddescriptorwidth}{{\legendFontSize #4}} & \cvSkill{4}\, &\,{\legendFontSize #6 } \\
%
& & & \cvSkill{5}\, &\,{\legendFontSize #7 }
\end{tabular}%
\par\addvspace{#2}
}
}
\if@moderncvbodyiv%
\RenewDocumentCommand\cvSkillMatrixLegend{s +O{.25em} +O{basic knowledge} +O{intermediate knowledge with experience in projects} +O{extensive experience in projects} +O{deep expert knowledge} +O{expert/guru} +m}{%
\def\legendString{#8}%
\ifdefempty{\legendString}{%
}{%
\cvitem[0.25em]{\hintstyle{#8}}{}%
}%
\IfBooleanTF#1{% if a star is given, add dashed line
\begingroup
\arrayrulecolor{color1}
\begin{tabular}{@{}p{\skilllegendhintscolumnwidth}
@{\hspace{\separatorcolumnwidth}}p{\cvskillwidth}@{};{.6pt/1pt}p{0.9\cvskilllegenddescriptorwidth} @{\hspace{2\skillmatrixcommentpadding}}p{\cvskillwidth}@{};{.6pt/1pt}p{1.1\cvskilllegenddescriptorwidth}@{}}%
\raggedleft\hintstyle{} & \cvSkill{1}\, & \,{\legendFontSize #3} & \cvSkill{3}\, &\,{\legendFontSize #5 } \\
%
& \cvSkill{2}\, & \,\multirow{2}{\cvskilllegenddescriptorwidth}{{\legendFontSize #4}} & \cvSkill{4}\, &\,{\legendFontSize #6 } \\
%
& & & \cvSkill{5}\, &\,{\legendFontSize #7 }
\end{tabular}%
\endgroup
\par\addvspace{#2}}{
% if no star is given, do not add dashed line
\begin{tabular}{@{}p{\skilllegendhintscolumnwidth}
@{\hspace{\separatorcolumnwidth}}p{\cvskillwidth}@{};{.6pt/1pt}p{0.9\cvskilllegenddescriptorwidth} @{\hspace{2\skillmatrixcommentpadding}}p{\cvskillwidth}@{};{.6pt/1pt}p{1.1\cvskilllegenddescriptorwidth}@{}}%
\raggedleft\hintstyle{} & \cvSkill{1}\, & \,{\legendFontSize #3} & \cvSkill{3}\, &\,{\legendFontSize #5 } \\
%
& \cvSkill{2}\, & \,\multirow{2}{\cvskilllegenddescriptorwidth}{{\legendFontSize #4}} & \cvSkill{4}\, &\,{\legendFontSize #6 } \\
%
& & & \cvSkill{5}\, &\,{\legendFontSize #7 }
\end{tabular}%
\par\addvspace{#2}
}
}
\fi
% in case moderncvbodyv is used we need a redefinition of \cvSkillMatrixLegend
\if@moderncvbodyv%
\DeclareDocumentCommand\@starIndependentTabular{}{}%
\RenewDocumentCommand\cvSkillMatrixLegend{s +O{.25em} +O{basic knowledge} +O{intermediate knowledge with experience in projects} +O{extensive experience in projects} +O{deep expert knowledge} +O{expert/guru} +m}{%
% check whether Argument #8 is given and if so provide it as cvitem
\def\legendString{#8}%
\ifdefempty{\legendString}{%
\vspace*{-\separatorrulewidth}% HACK; I don't understand where the space is coming from, nor what it's exact value is :(
}{%
\cvitem[-0.5em]{#8}{}%
}%
\arrayrulecolor{color1}%
\setlength\arrayrulewidth{\separatorrulewidth}%
\RenewDocumentCommand{\@starIndependentTabular}{}{%
\begingroup%
% \renewcommand{\arraystretch}{1.0}%
\begin{tabular}[t]{@{}p{\hintscolumnwidth}%\skilllegendhintscolumnwidth
@{\hspace{\separatorcolumnwidth}}|@{\hspace{\separatorcolumnwidth}}
p{\cvskillwidth}@{}
p{0.9\cvskilllegenddescriptorwidth} @{\hspace{2\skillmatrixcommentpadding}}
p{\cvskillwidth}@{}p{1.1\cvskilllegenddescriptorwidth}@{}}%
\@moderncvstrut{4pt}{16pt} & \cvSkill{1}\, & \,{\legendFontSize #3} & \cvSkill{3}\, &\,{\legendFontSize #5 } \\
%
& \cvSkill{2}\, & \,\multirow{2}{\cvskilllegenddescriptorwidth}{{\legendFontSize #4}} & \cvSkill{4}\, &\,{\legendFontSize #6 } \\
%
& & & \cvSkill{5}\, &\,{\legendFontSize #7 } \\[#2]% the spacing needs to be inside the cell for the vertical rule to extend correctly
\end{tabular}%
\endgroup%
\par\@aftersectionfalse\ignorespaces%
}%
% because of this weird style and the position of the parameter [#2], the dashed lines of the other version look bad. So no lines.
\IfBooleanTF#1{%
\@starIndependentTabular%
}{%
\@starIndependentTabular%
}
}%
\fi
% %-------------------------------------------------------------------------------
% % \cvSkillMatrixHeadFont
% %-------------------------------------------------------------------------------
\NewDocumentCommand\cvSkillMatrixHeadFont{}{\normalfont}
\DeclareDocumentCommand\cvSkillMatrixHead{+O{} +O{} +O{} +O{} +O{}}{}%
% The following definition is valid for moderncvbodyi, moderncvbodyii, moderncvbodyiii, moderncvbodyiv
\RenewDocumentCommand\cvSkillMatrixHead{O{.25em} +O{Level} +O{Skill} +O{Years} +O{Comment}}{%
\begingroup
\renewcommand{\arraystretch}{1.25}
\arrayrulecolor{color1}
\begin{tabular}{@{}p{\skillmatrixhintscolumnwidth}
@{\hspace{\separatorcolumnwidth}}p{\cvskillwidth}@{}@{}p{\cvskilldescriptorwidth}@{} p{\cvskillexperiencewidth} @{\hspace{\skillmatrixcommentpadding}}p{\skillmatrixcommentwidth}@{}}%
& \centering{\cvSkillMatrixHeadFont #2} & \centering{\cvSkillMatrixHeadFont #3} & \centering{\cvSkillMatrixHeadFont #4} & {\cvSkillMatrixHeadFont #5}
% \\\cdashline{2-5}[.6pt/1pt]
\end{tabular}%
\endgroup
\par\addvspace{#1}
}
% in case moderncvbodyv is used we need a redefinition of \cvSkillMatrixHead
\if@moderncvbodyv%
\RenewDocumentCommand\cvSkillMatrixHead{O{.25em} +O{Level} +O{Skill} +O{Years} +O{Comment}}{%
\arrayrulecolor{color1}%
\setlength\arrayrulewidth{\separatorrulewidth}%
\vspace*{-\separatorrulewidth}% HACK; I don't understand where the space is coming from, nor what it's exact value is :(
\begingroup%
% \renewcommand{\arraystretch}{1.25}%
\begin{tabular}[t]{@{}p{\hintscolumnwidth}%
@{\hspace{\separatorcolumnwidth}}|@{\hspace{\separatorcolumnwidth}}%
p{\skillmatrixhintscolumnwidth}%
@{\hspace{\skillmatrixcommentpadding}}p{\cvskillwidth}@{}%
p{\cvskilldescriptorwidth}@{}%
p{\cvskillexperiencewidth}%
@{\hspace{\skillmatrixcommentpadding}}p{\skillmatrixcommentwidth}@{}}%
& & \centering{\cvSkillMatrixHeadFont#2} & \centering{\cvSkillMatrixHeadFont#3} & \centering{\cvSkillMatrixHeadFont#4} & {\cvSkillMatrixHeadFont#5} \\[#1]% the spacing needs to be inside the cell for the vertical rule to extend correctly
\end{tabular}%
\endgroup%
\par\@aftersectionfalse\ignorespaces%
}
\fi
% %-------------------------------------------------------------------------------
% % \cvSkillMatrixEntry
% %-------------------------------------------------------------------------------
\DeclareDocumentCommand\cvSkillMatrixEntry{s +O{} +m +m +m +m +m}{}%
% The following definition is valid for moderncvbodyi, moderncvbodyii, moderncvbodyiii, moderncvbodyiv
\RenewDocumentCommand\cvSkillMatrixEntry{s +O{.25em} +m +m +m +m +m}{%
%test for the star * in the command
\IfBooleanTF{#1}{% If a star is seen a dotted line is drawn above the entry
\begingroup
\renewcommand{\arraystretch}{1.25}
\arrayrulecolor{color1}
\begin{tabular}{@{}p{\skillmatrixhintscolumnwidth}@{\hspace{\separatorcolumnwidth}}%
p{\cvskillwidth}@{}%
p{\cvskilldescriptorwidth}@{}%
p{\cvskillexperiencewidth} @{\hspace{\skillmatrixcommentpadding}}%
p{\skillmatrixcommentwidth}@{}}%
\cdashline{2-5}[.6pt/1pt]
\raggedleft\hintstyle{#3} &\centering \cvSkill{#4} &\centering {#5} & \centering {#6} &{\itshape#7}%
\end{tabular}%
\endgroup
\par\addvspace{#2}
}{% If no star is seen no line is drawn
\begin{tabular}{@{}p{\skillmatrixhintscolumnwidth}@{\hspace{\separatorcolumnwidth}}%
p{\cvskillwidth}@{}%
p{\cvskilldescriptorwidth}@{}%
p{\cvskillexperiencewidth}%
@{\hspace{\skillmatrixcommentpadding}}%
p{\skillmatrixcommentwidth}@{}}%
\raggedleft\hintstyle{#3} &\centering \cvSkill{#4} &\centering {#5} & \centering {#6} &{\itshape#7}%
\end{tabular}%
\par\addvspace{#2}
}
}
% in case moderncvbodyv is used we need a redefinition of \cvSkillMatrixEntry
\if@moderncvbodyv%
\DeclareDocumentCommand\@starIndependentMatrixEntry{}{}%
\RenewDocumentCommand\cvSkillMatrixEntry{s O{.25em} +m +m +m +m +m}{%
\arrayrulecolor{color1}%
\setlength\arrayrulewidth{\separatorrulewidth}%
\vspace*{-\separatorrulewidth}% HACK; I don't understand where the space is coming from, nor what it's exact value is :(
%test for the star * in the command
\RenewDocumentCommand{\@starIndependentMatrixEntry}{}{
\begingroup%
\renewcommand{\arraystretch}{1.25}%
\begin{tabular}[t]{@{}p{\hintscolumnwidth}%
@{\hspace{\separatorcolumnwidth}}|@{\hspace{\separatorcolumnwidth}}p{\skillmatrixhintscolumnwidth}
@{\hspace{\skillmatrixcommentpadding}}
p{\cvskillwidth}@{}
p{\cvskilldescriptorwidth}@{}
p{\cvskillexperiencewidth} @{\hspace{\skillmatrixcommentpadding}}p{\skillmatrixcommentwidth}@{}}%
% \cline{3-6}%
& \raggedleft\hintstyle{#3} &\centering \cvSkill{#4} &\centering {#5} & \centering {#6} &{\itshape#7}\\[#2]%
\end{tabular}%
\endgroup%
}
\IfBooleanTF{#1}{% the star does not do anything here
\@starIndependentMatrixEntry
}{%
\@starIndependentMatrixEntry
}%
\par\@aftersectionfalse\ignorespaces%
}
\fi
\endinput
%% end of file `moderncvskillmatrix.sty'.