我想通过以下方式将我的语言技能添加到我的简历中:
我当然可以在 Inkscape 中为每种语言创建一个图像,并以最直接的方式放入其中,可能如下所述: 文本内嵌微图形
但从该线程来看,它似乎可以自动化,因此也许可以写入 \loadingbar{4.5,5} 并得到 5 个圆中的 4.5 个实心圆。也许还可以使用一些可选参数来设置大小或颜色。
我知道这听起来有点像“帮我解决这个问题”,但尤其是颜色部分,我甚至不知道如何处理,也不知道如何在 Latex 中正确进行循环。所以如果有人想把它当作一个挑战,我会非常高兴 :)
答案1
仅适用于半整数值的整数。
\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}
答案2
\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}
答案3
...@Sigur 解决方案的改编。
\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}