10

I would like to add my language skills to my CV in the following manner:

Language skills as loading bars

I could of course create an image in Inkscape for every language, and put it in in a most straightforward way, maybe as described in: Micro-graphics inline in text

But from that thread it looks like it could be automated, so that one maybe could write \loadingbar{4.5,5} and get 4.5 filled circles out of five. Maybe also with some optional parameters for size or colors.

I know it reads a little bit like "solve this problem for me", but especially the part with colors I have no idea how to even approach, and also how to do loops in Latex properly. So if anyone wants to take it on as a challenge I would be more than happy :)

3 Answers 3

6

Works only for integer of semi integer values.

\documentclass{report}
\usepackage{tikz}
\newcommand{\grade}[1]{%
\begin{tikzpicture}
\clip (1em-.3em,-.3em) rectangle (5em +.5em ,.3em);
\begin{scope}
\clip (1em-.3em,-.3em) rectangle (#1em +.5em ,.3em);
\foreach \x in {1,2,...,5}{
 \path[fill=red] (\x em,0) circle (.25em);
}
\end{scope}
\foreach \x in {1,2,...,5}{
 \draw (\x em,0) circle (.25em);
}
\end{tikzpicture}%
}
\begin{document}

\begin{tabular}{ll}
Danish: & \grade{5}  \\
English:& \grade{4.5}\\
German: & \grade{3.5}  \\
French: & \grade{0}
\end{tabular}

\end{document}

enter image description here

1
  • Sorry that I disappeared, your solution is great! I tweaked it a little, but that was just design. Thanks a lot! Commented May 24, 2015 at 15:09
8

I've extended the solutions of Sigur and Jürgen B. to support arbitrary floating point values.

\documentclass{report}
\usepackage{tikz}
\definecolor{frontColor}{rgb}{0.22,0.45,0.70}% light blue
\definecolor{backColor}{RGB}{200,200,200}% grey
\newcommand{\gradelong}[6]{%
    \pgfmathtruncatemacro\floored{#1}%
    \pgfmathsetmacro\diff{#1-\floored}%
    \newdimen\diffDim%
    \diffDim = \diff pt%
    \newdimen\numPointsDim
    \numPointsDim = #1 pt
    \newdimen\maxPointsDim%
    \maxPointsDim = #2 pt%
    \begin{tikzpicture}
        \foreach \x in {1, ..., #2}{
            \ifnum \x > \floored \relax%
                \def\fillCol{#6}%
            \else%
                \def\fillCol{#5}%
            \fi%
            \fill[\fillCol] (#3*\x, 0) circle (#4);
        }%
        \ifdim \diffDim > 0 pt \relax%
            \ifdim \numPointsDim > \maxPointsDim \relax%
            \else%
                \pgfmathsetmacro\pos{#3*(\floored+1)}%
                \begin{scope}[xshift=\pos]
                    \clip (-#4,-#4) rectangle ++(#4*2*\diff,#4*2);
                    \fill[#5] (0, 0) circle (#4);
                \end{scope}
            \fi%
        \else%
        \fi%
    \end{tikzpicture}%
}

\newcommand{\grade}[1]{%
    \gradelong%
    {#1}% grade as floating point value
    {5}% max number of points
    {9pt}% spacing between points
    {3pt}% radius of point
    {frontColor}% foreground color
    {backColor}% background color
}

\begin{document}
    \begin{tabular}{ll}
        Danish:  & \grade{5}    \\
        English: & \grade{4.5}  \\
        German:  & \grade{3.75} \\
        French:  & \grade{0.33}
    \end{tabular}
\end{document}

enter image description here

1

... an adaption of @Sigur's solution.

\documentclass{report}
\usepackage{tikz}
\definecolor{frontColor}{rgb}{0.22,0.45,0.70}% light blue
\definecolor{backColor}{RGB}{200,200,200}% grey
\newcommand{\grade}[1]{%
    \begin{tikzpicture}
    \clip (1em-.4em,-.35em) rectangle (5em +.5em ,1em);
    \foreach \x in {1,2,...,5}{
        \path[{fill=backColor}] (\x em,0) circle (.35em);
    }
    \begin{scope}
    \clip (1em-.4em,-.35em) rectangle (#1em +.5em ,1em);
    \foreach \x in {1,2,...,5}{
        \path[{fill=frontColor}] (\x em,0) circle (.35em);
    }
    \end{scope}

    \end{tikzpicture}%
}
\begin{document}

\begin{tabular}{ll}
Danish: & \grade{5}  \\
English:& \grade{4.5}\\
German: & \grade{3.5}  \\
French: & \grade{0}
\end{tabular}

\end{document}

enter image description here

1
  • Welcome to TeX.SX! This is not so much an adaption of Sigur's solution as a small enhancement to allow foreground and background colours.
    – user30471
    Commented May 25, 2018 at 6:59

You must log in to answer this question.

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