2

I wish to display some numbered balls, but somehow, whether it's from my missuse of tkz-euclide or foreach, I failed to label the balls correctly.

Here is a MWE.

\documentclass{article}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}[scale=0.5]
\tkzDefPoints{0/0/B1, 2/0/B2, 4/0/B3, 6/0/B4}
\tkzDefPoints{1/1.732/B5, 5/1.732/B6}
\foreach \color/\numero [count=\index] in {blue/1, orange/2, orange/1, green/1, orange/3, blue/2} {
    \tkzDrawCircle[R, color=black, fill=\color!40](B\index, 1cm)
    \tkzLabelPoint[anchor=center](B\index){\numero}
}
\end{tikzpicture}
\end{document}

enter image description here

1 Answer 1

4

You should avoid using macros like \color, which gets used when dealing with the colors internally, as loop variable. If you use e.g. \coloro instead there is no problem.

\documentclass{article}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}[scale=0.5]
\tkzDefPoints{0/0/B1, 2/0/B2, 4/0/B3, 6/0/B4}
\tkzDefPoints{1/1.732/B5, 5/1.732/B6}
\foreach \coloro/\numero [count=\index] in {blue/1, orange/2, orange/1, green/1, orange/3, blue/2} {
    \tkzDrawCircle[R, color=black, fill=\coloro!40](B\index, 1cm)
    \tkzLabelPoint[anchor=center](B\index){\numero}
}
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.