1

Here is a old post: In-line graphics in text to represent a loading bar for language skills in a CV

I tried to adjust the code to have semi-filled circle steps, but failed...

My .cls-file code:

\newcommand{\cvskill}[2]{%
\textcolor{emphasis}{\textbf{#1}}\hfill
\foreach \x in {1,...,5}{%
  \space{\ifnumgreater{\x}{#2}{\color{body!30}}{\color{accent}}\ratingmarker}}\par%
}

My .tex-file code:

\cvskill{German}{5}
\divider

\cvskill{English}{4}
\divider

\cvskill{French}{3}
\divider

\cvskill{Spanish}{1}

Full code: https://www.overleaf.com/read/rgskjktntgdf

How it looks at the moment: current layout

Can someone please help me out?

Thanks, Andreas

Mensch
  • 65,388
Andreas
  • 25
  • 5
  • 1
    The linked answer already provides semi-filled circles. Please explain, what you are trying to change. Also please provide a minimum working example that compiles. – Jojo Apr 16 '20 at 13:07
  • @Jojo

    Here is my project: link

    I want to adjust the code, so that I can fill half circles as in the original post (last pic)

    – Andreas Apr 17 '20 at 08:51
  • 1
    Please do not ask questions twice: https://tex.stackexchange.com/q/539249/16550 and see my answer to your duplicate question here: https://tex.stackexchange.com/a/493970/16550 – Mensch Apr 18 '20 at 19:03
  • There is also this: https://tex.stackexchange.com/questions/11390/drawing-stars-similar-with-tikz – Scott H. Apr 19 '20 at 15:07

1 Answers1

6

I've generalized your linked question for arbitrary floating point values.

To incorporate it into your document, paste this before \begin{document}:

\makeatletter
    \newcommand*{\fsize}{\dimexpr\f@size pt\relax}
\makeatother

\newcommand{\pointslong}[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}[baseline, yshift=0.5*\fsize]
        \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{\points}[1]{%
    \pointslong%
    {#1}% skill level
    {5}% max number of points: 5
    {12pt}% spacing between points
    {4pt}% circle radius
    {accent}% color for filled points
    {body!30}% color for empty points
}

\renewcommand{\cvskill}[2]{%
    \textcolor{emphasis}{\textbf{#1}}\hfill\points{#2}\par%
}

enter image description here

Jojo
  • 1,048
  • Thanks that's what I was looking for. Really appreciate it. Unfortunately, I'm facing a new problem now... the circles are aligned to the bottom of the text instead of to the middle... See screenshot: https://imgur.com/nufOtRl – Andreas Apr 19 '20 at 08:47
  • I've updated the answer. It should now be in the center of the text. You can adapt it by changing the value of yshift to e.g. 5 pt. – Jojo Apr 19 '20 at 14:32