I have the following code:
\documentclass[11pt]{article}
\usepackage{tikz}
\begin{document}
\newcount\x \x=-1
\begin{tikzpicture}
\foreach \percentA in {33}
{
\if \percentA \empty \else
\global\advance\x by 1
\draw (\x,0) circle (0.2cm);
\fi
};
\end{tikzpicture}
\end{document}
If I use \if instead of \ifx, this code compiles to an empty document. If I would use 66 instead of 33, it would compile to an empty document as well. But if I would use any other value (like 32 or 34 or 65), it would work just fine, and would draw a circle.
Could somebody tell me why 33 equals to \empty? I know that I should have used \ifx, but I'm wondering why 33 and 66 are so special in this case, because I would expect the same behavior for every number.
\ifexpands tokens until it finds two non-expandable tokens. So\if\percentA \emptyturns into\if33\empty, then3and3are compared and the result is true, so\emptyis executed. – campa Feb 27 '20 at 13:25\percentAto\emptyanyway? Could you please be more explicit about your real aim? – egreg Feb 27 '20 at 13:50\ifx\percent\empty\elseline is completely useless, because with the given data\percentis never empty. Remove it and the final\fi. – egreg Feb 28 '20 at 14:48