wenn ich in der Anwendung der \drawBalls im Dokument Komma-Zahlen(z.B. 2.3) für den Parameter \x übergebe , crashed die Grafik. Mit Ganzzahlen funktioniert es einwandfrei. Würde mich über die Lösung freuen.
Diese ursprüngliche Idee hatte -obwohl gut nachvollziehbar- nicht funktioniert:
\ifthenelse{{\x + \offset} >\xAmount}{\def\currentX{\x+\offset-10}}{\def\currentX{\x + \offset}};
Danke
BX
\documentclass{article} \usepackage{tikz, ifthen, calc} \newcounter{mySum} \def\offset{0} \def\xAmount{1} \newcommand{\drawBalls}[1]{ \begin{tikzpicture} \foreach \x/\mytext/\mycolor in {#1}{ \setcounter{mySum}{\x + \offset}; \ifthenelse{\value{mySum} >\xAmount}{\def\currentX{\x+\offset-10}}{\def\currentX{\x + \offset}}; \node[ circle, shading=ball, ball color=\mycolor, minimum width=1cm, text=white, font=\itshape ] (ball) at (\currentX,0) {\mytext};} \end{tikzpicture} } \begin{document} \drawBalls{1/Rot/red,3/Gelb/yellow,5/Gruen/green} %%%%%%%%%%%%%%%%%%%%% Problem %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %\drawBalls{1.5/Text/red,3.4/in/yellow,5.7/Kugel/blue} float Values (i.e: .3) are not working... \end{document}