I want to use the following tikzpicture in an animation, and if the macro \iFrame is unequal to zero, part of it should not be drawn. If I use the following code in the standalone class without the frame environment it works as expected, and if I use \ifnum outside the tikzpicture it also works as expected. However if I use \ifnum inside a tikzpicture inside a frame, compilation stops with a Incomplete \ifx; all text was ignored after line 40. error. I would like to know why.



    axis/.style={-stealth,line width=1.5pt},

        \begin{tikzpicture}[line width = 1pt]
                \filldraw[fill=violet,fill opacity=.5] (0,0) circle (2.2 and 0.6);
                \draw[xaxis] (0,0,0) -- (1,0,0);
                \draw[yaxis] (0,0,0) -- (0,1,0);
                \draw[zaxis] (0,0,0) -- (0,0,1);
                \node[left] {\( \Psi_a \)};
                \coordinate (pa1) at (2,0);
                \fill (pa1) circle (1mm);
                \filldraw[fill=orange,fill opacity=.5] (0,0) circle (2.2 and 0.6);
                \draw[xaxis] (0,0,0) -- (1,0,0);
                \draw[yaxis] (0,0,0) -- (0,1,0);
                \draw[zaxis] (0,0,0) -- (0,0,1);
                \node[above left] {\( \Psi_b \)};
                \coordinate (pb1) at (-2,0);
                \fill (pb1) circle (1mm);
                    \draw[xaxis] (0,0,0) -- (1,0,0);
                    \draw[yaxis] (0,0,0) -- (0,1,0);
                    \draw[zaxis] (0,0,0) -- (0,0,1);
                    \node[above right] {\( \Psi_j \)};
  • 4
    – egreg
    Jul 11, 2018 at 19:52
  • 1
    In addition to what @egreg is saying, you may load \usetikzlibrary{overlay-beamer-styles} and then selectively set the scope invisible,
    – user121799
    Jul 11, 2018 at 20:01
  • @egreg Thanks! Why is that needed and why is it not default behavior? @marmot Thanks for the suggestion, but I plan to use the animate package.
    – Max
    Jul 11, 2018 at 20:18
  • 1
    @MaxSnippe fragile requires the content of the frame be written out to another file and then read back, so (1) you don't usually want all those extra files around and (2) you don't typically want the increase in compilation time from doing it that way. Hence, use it when you need it.
    – cfr
    Jul 11, 2018 at 23:01
  • @egreg Do you want to write an answer? Jul 12, 2018 at 21:16

1 Answer 1


A solution is to use the fragile option to the frame environment, so the contents is written verbatim to an auxiliary file and beamer doesn't get confused while reading the material. I'm not really sure where the problem is, but it surely resides with the “raw” conditional.

Indeed, a different solution to do the conditional like

                \draw[xaxis] (0,0,0) -- (1,0,0);
                \draw[yaxis] (0,0,0) -- (0,1,0);
                \draw[zaxis] (0,0,0) -- (0,0,1);
                \node[above right] {\( \Psi_j \)};

Don't forget the empty braces for the “false” branch. No “raw” conditional is scanned and all goes well. The construction \ifnumequal is defined by etoolbox, which is automatically loaded by beamer.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .