2

I would like to restructure my "knowledge" part in the resume (skill level). From the structure I would like to make it similar to this one, only with "flat" rectangles: In-line graphics in text to represent a loading

Unfortunately, I didn't manage to adjust the points to a flat rectangle.

Secondly, I'm still a bit undecided which variant it should be (I need to see it in the finished resume first - but guess it will be variant 2):

Variant 1:

Variant 1

Variant 2:

enter image description here

I would have tried to define the individual rectangles by means of coordinates, i.e. to predefine them "fixed".

For example by means of:

\begin{tikzpicture}

\coordinate (Level1_Start) at (0,2.3);
\coordinate (Level1_14) at (0.5,2.3);       %Level 1 - 1/4
\coordinate (Level1_12) at (1,2.3);         %Level 1 - 1/2
\coordinate (Level1_34) at (1.5,2.3);       %Level 1 - 3/4
\coordinate (Level1_End) at (2,2.3);

\coordinate (Level2_Start) at (2.5,2.3);
\coordinate (Level2_14) at (3,2.3);         %Level 2 - 1/4
\coordinate (Level2_12) at (3.5,2.3);       %Level 2 - 1/2
\coordinate (Level2_34) at (4,2.3);         %Level 2 - 3/4
\coordinate (Level2_End) at (4.5,2.3);


\coordinate (A) at (Level1_Start);
\coordinate (B) at (Level1_14);
\coordinate (C) at (Level1_12);
\coordinate (D) at (Level1_34);
\coordinate (E) at (Level1_End);

\draw[red!50,  line width=6pt] (A) -- (E);  %Draw Level 1 from start to end (6pt red)

\coordinate (A) at (Level2_Start);
\coordinate (B) at (Level2_14);
\coordinate (C) at (Level2_12);
\coordinate (D) at (Level2_34);
\coordinate (E) at (Level2_End);

\draw[red!50,  line width=6pt] (A) -- (B);  %Draw Level 2 from start to 1/4 (6pt red)
\draw[gray!50, line width=4pt] (B) -- (E);  %Draw Level 2 from 1/4 to end (4pt gray)

%and so on
\end{tikzpicture}

With the skills/names etc. I would have done it similarly.

Is there a nicer, more elegant solution for this?

2
  • What is your preferred input? Is it on a scale of 0 to 5 or 0 to 100 or …? Jan 21 at 15:34
  • @Qrrbrbirlbel Basically from 0 to 5, whereby these can be subdivided again in steps of four (quartered). E.G. Main step (1): 0 - 1 Substeps: 0.25, 0.5, 0.75 Main step (2): 1 - 2 Substeps: 1.25, 1.5, 1.75 and so on until: Main step (5): 4 - 5 Substeps: 4.25, 4.5, 4.75
    – PsychoM
    Jan 21 at 15:50

2 Answers 2

3

Here's a suggestion which uses a very specific dash pattern. The gray part is drawn first over the full length which will be covered partly by the red part.

The red part is also the more interesting one, for this I set x to the value of one single bar length so that we can use #2 directly as the x value of a coordinate. However, we need to add the separation space again which is done by the way of xshift.

You can use the values skill bar width, skill bar items and skill bar sep to change the way the values are getting interpreted and drawn.
The styles skill bar, skill bar bg and skill bar fg can be used to change the visualization (other colors, other line widths).

The trim left and trim right key instruct TikZ to produce a diagram that is exactly \linewidth wide. The baseline key is used to align the diagrams vertically and might be adjusted based on which font you actually use.


By default, \tikzskillbar uses a width of \linewidth. This allows it to be used inside a X column of tabularx or any other tabular column with a fixed length (i.e. p, m or b).

I've added loop that shows all steps (though, you can always use any number between 0 and skill bar items).

The subtraction of .00001 avoids rendering issues with integer values since this might lead to slivers of red:
enter image description here


The red part can also be drawn in separate parts with this definition of \tikzskillbar (different x value and disabled skill bar style):

\newcommand*\tikzskillbar[2][]{%
\begin{tikzpicture}[
  skill bar diagram,#1,skill bar diagram init,
  x=\tsbbarlength+\tsbseplength,skill bar/.code=]
\draw[skill bar bg, dash pattern=on \tsbbarlength off \tsbseplength]
  (0,0) -- (\linewidth,0);
\foreach[parse=true] \step in {0,...,(int(#2)-1)}
  \draw[skill bar fg] (right:\step) -- ++(right:\tsbbarlength);
\draw[skill bar fg] (right:{int(#2-.00001)})
  --++(right:{\tsbbarlength*frac(#2)});
\end{tikzpicture}}

Code

\documentclass[a5paper]{article}
\usepackage{tikz}
\tikzset{
  skill bar width/.initial=\linewidth,
  skill bar items/.initial=5,
  skill bar sep/.initial=1mm,
  skill bar diagram/.style={baseline=+-.75ex,trim left=+0pt},
  skill bar diagram init/.style={
    trim right=\pgfkeysvalueof{/tikz/skill bar width},
    /utils/exec=%
    \pgfmathsetlengthmacro\tsbseplength{\pgfkeysvalueof{/tikz/skill bar sep}}%
    \pgfmathsetlengthmacro\tsbbarlength{%
      (\pgfkeysvalueof{/tikz/skill bar width}-(\pgfkeysvalueof{/tikz/skill bar items}-1)
     *(\pgfkeysvalueof{/tikz/skill bar sep}))/(\pgfkeysvalueof{/tikz/skill bar items})}},
  skill bar/.style={dash pattern=on \tsbbarlength off \tsbseplength},
  skill bar bg/.style={skill bar, draw=gray, line width=2pt},
  skill bar fg/.style={skill bar, draw=red,  line width=6pt}}
\newcommand*\tikzskillbar[2][]{%
\begin{tikzpicture}[skill bar diagram,#1,skill bar diagram init,x=\tsbbarlength]
\draw[skill bar bg](0,0)--(right:{\pgfkeysvalueof{/tikz/skill bar width}});
\draw[skill bar fg](0,0)
  --++([xshift={int(#2-.00001)*\pgfkeysvalueof{/tikz/skill bar sep}}]right:{#2});
\end{tikzpicture}}
\usepackage{tabularx}
\newenvironment*{skilltab}{\tabularx{\linewidth}{@{}lX@{}}}{\endtabularx}
\begin{document}
\section*{Knowledge}
\subsection*{Language}
\begin{skilltab}
  German  & \tikzskillbar{4.5}   \\
  English & \tikzskillbar{3.75}
\end{skilltab}

\subsection*{IT}
\begin{skilltab}
  Word       & \tikzskillbar{4.5}  \\
  Excel      & \tikzskillbar{3}    \\
  Powerpoint & \tikzskillbar{2.25}
\end{skilltab}

\vspace{1em}
\foreach \STEP in {0, ..., 12}{%
  \noindent\tikzskillbar[
    skill bar width=3cm, skill bar sep=.5mm, skill bar items=3]{\STEP/4}\par}
\end{document}

Output

enter image description here

6
  • Thank you very much for your answer. Unfortunately I get an error message: Undefined control sequence. \newcolumn I could not solve it until now. Maybe my installation is too old and I have to reinstall it completely (MiKTex Console: 2.9.7206 and TeXstudio 3.0.1).
    – PsychoM
    Jan 21 at 17:26
  • @PsychoM that command is part of the multicol package since version 1.9 and controls how and where the content goes. Try updating your installation or at least the package. Either way, this doesn't have anything to do with the TikZ solution. I've only tried to mimic your picture. Since you haven't shown how you did it there (maybe class option twocolumn?) I simply used multicols. Jan 21 at 17:49
  • In the meantime I could test your code successfully (finally I reinstalled Miktex completely, an update of TexStudio was not possible). I created the two pictures with an image editor to better illustrate how I imagine it exactly. The code was therefore also only exemplary, in order to represent, how I would have tried to solve it. I apologize if this came across wrong. I will now take a closer look at your code - and try to understand it. Many thanks again.
    – PsychoM
    Jan 21 at 18:53
  • I had to adapt your code a bit: E.g. instead of multicols I use two minipages, because with multicols e.g. "German" and "Word" were not on the same height (horizontal) (before you edit). Furthermore I use \paragraph in the meantime, because subsection is already used. For long texts I use \usepackage{makecell} (line break). But I still didnt understand why you use an optional parameter for \newcommand*\tikzskillbar[2][]{% (The call and usage is still unclear to me).
    – PsychoM
    Jan 22 at 15:51
  • Yeah, I removed all the column stuff. All this answer provides is a \tikzskillbar macro that uses some values and styles to output your diagram. This is also in no relation to (sub)section macros. The first optional argument can be used to use styles for only one diagram to change just that one. If all your bars should look the same you don't need to use it. Jan 23 at 10:50
2

Welcome to TeX.SE!!!

This creates a TikZ macro that draws the desired rectangles and \clips the red ones.

\documentclass{article}
\usepackage{lipsum} % dummy text
\usepackage{tikz}   % beautiful drawings

\newcommand{\level}[1]
{%
  \begin{tikzpicture}[xscale=1.6,yscale=0.4]
    \pgfmathsetmacro\xmax{#1+0.25*int(#1)}
    \foreach\i in {0,...,4}
      \fill[gray] (1.25*\i em,0.25ex) rectangle ++(1em,0.75ex);
    \clip         (0em,-0.75ex)       rectangle ++(\xmax em,2.75ex);
    \foreach\i in {0,...,4}
      \fill[red] (1.25*\i em,-0.25ex) rectangle ++(1em,1.75ex);
  \end{tikzpicture}%  
}

\begin{document}
\lipsum[1]
\begin{table}[ht]\centering
\begin{tabular}{ll}
Word       & \level{4.5}\\
Excel      & \level{3}\\
Powerpoint & \level{2.25}
\end{tabular}
\end{table}

\lipsum[2]
\end{document}

enter image description here

1
  • Thank you very much for your code. I will have a closer look at it too.
    – PsychoM
    Jan 21 at 18:53

You must log in to answer this question.

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