# TikZ ! Missing number, treated as zero

Hi all, here is a (hopefully not oversimplified) MWE:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\def\A{{3/(2*6)}}
\def\B{{sqrt(5-\A)}}

\filldraw (\A,\B) circle (1pt);
\end{tikzpicture}
\end{document}


I'm getting the error message

! Missing number, treated as zero.
{
l.11 \filldraw ({\A,\B})
circle (1pt);


Can anyone explain what is going on here? How can I fix this?

One way to fix this is

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\pgfmathsetmacro\A{3/(2*6)}
\pgfmathsetmacro\B{sqrt(5-\A)}

\filldraw (\A,\B) circle (1pt);
\end{tikzpicture}
\end{document}


If you insist on \defs, set the braces right:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\def\A{3/(2*6)}
\def\B{sqrt(5-\A)}

\filldraw ({\A},{\B}) circle (1pt);
\end{tikzpicture}
\end{document}

• Your second solution works! Didn't try the first one -- is pgfmathsetmacro recommended over def? – AccidentalFourierTransform Sep 27 '19 at 0:52
• @AccidentalFourierTransform The general rule is that \def should used sparsely. However, the reason is that it overwrites macros without warning (while \newcommand would issue an error message). This objection applies to \pgfmathsetmacro, too, but this one at least parses the expression. In more complex examples this may save some time. The real advantages include the ability to, say, local switch on fpu, which is not needed in this cooked down example. In any case, the braces in your \defs are not set appropriately. – Schrödinger's cat Sep 27 '19 at 2:39