I am using TikZ math library which is great.
However, I can't get my head around this (see MWE).
I missed something from the documentation (https://tikz.dev/library-math)?
\documentclass[tikz]{standalone}
\usetikzlibrary{math}
\begin{document}
\begin{tikzpicture}
\tikzmath{
\a = 2;
\b = 1;
}
\draw[step=1cm,gray,very thin] (0,0) grid (3,2); % just for orientation
\draw (\a, \b) circle (2pt); % no problem here, so \a and \b are fine
\draw [->] (2, 0) arc (0:360:2 and 1); % no problem here
%\draw [->] (2, 0) arc (0:360:\a and \b); % gives me an error after removing comment - why?
\end{tikzpicture}
\end{document}
\draw [->] (2, 0) arc (0:360:{\a} and {\b});. Sometimes, the TikZ parser has a hard time understanding what you tell it when you put macros where it expects letters or numbers. In such cases, it is often a good idea to wrap the macro in curly braces. – Jasper Habicht Jul 25 '23 at 06:58arc, which would bearc[start angle=0, end angle=360, x radius={\a}, y radius={\b}](the curly braces would be optional in this case). – Jasper Habicht Jul 25 '23 at 08:25\draw [->] (2, 0) arc (0:360:\a{} and \b);... – Paul Gaborit Jul 25 '23 at 12:14\draw [->] (2, 0) arc (0:360:\a\space and \b);... – Paul Gaborit Jul 25 '23 at 12:15{\a} and {\b}would lead to the node name{2} and {1}and not2 and 1. TikZ expects<y> and <x>including the spaced aroundandbut the space after\avanishes because it ends the control sequence. – Qrrbrbirlbel Jul 25 '23 at 12:49