5

I don't know why, but I can't use \onslide inside a tikz node without having an error ERROR: Package tikz Error: Giving up on this path. Did you forget a semicolon?.. Any idea why?

MWE:

\documentclass[beamer,tikz,preview]{standalone}

\begin{document}
\begin{standaloneframe}
  \begin{tikzpicture}
    % Works:
    \onslide<+>{\node[]{ABC};}
    \onslide<+>{\node[]{ABCDEF};}
    % Does not work:
    \node[]{\onslide<+->{ABC}\onslide<+->{DEF}};
  \end{tikzpicture}
\end{standaloneframe}
\end{document}

-- EDIT -- As my question seems to be misunderstood, I made a better (commented) MWE, the first result is not the one I expect, and the result I want is later, but I'd like a better solution (I don't like to copy/paste stuff).

\documentclass[beamer,tikz,preview]{standalone}
\usetikzlibrary{positioning,overlay-beamer-styles}
\begin{document}
\begin{standaloneframe}
  \begin{tikzpicture}[
      mynode/.style={
        fill=blue!50,
        draw,
        rectangle,
        rounded corners
      }
      ]
    % Bad result, the node does not have the same size in all slides,
    % and also I can't refer to the value at the step before so I get
    % ABCJKL instead of ABCDEFGHIJKL
    \def\mycontents{ABC}
    \only<2>{\xdef\mycontents{\mycontents DEF}}
    \only<3>{\xdef\mycontents{\mycontents GHI}}
    \only<4>{\xdef\mycontents{\mycontents JKL}}
    \node[mynode]{\mycontents};
    % Good result that "simulate" the \uncover, but it is too verbose
    % especially when I need to uncover lot's of things inside
    % (I don't like to copy/paste stuff)
    \node<5>[mynode]{ABC\phantom{DEFGHIJKL}};
    \node<6>[mynode]{ABCDEF\phantom{GHIJKL}};
    \node<7>[mynode]{ABCDEFGHI\phantom{JKL}};
    \node<8>[mynode]{ABCDEFGHIJKL};
    %% The syntax I'd love to use:
    %% \node[mynode]{\uncover<5->{ABC}\uncover<6->{DEF}\uncover<7->{GHI}\uncover<8->{JKL}}
  \end{tikzpicture}
\end{standaloneframe}
\end{document}
tobiasBora
  • 8,684

1 Answers1

7

Thanks for clarifying what you want. You need only to add braces.

\documentclass[beamer,tikz,preview]{standalone}
\begin{document}
\begin{standaloneframe}
  \begin{tikzpicture}
    % Works:
    \node{{\onslide<+->{ABC}\onslide<+->{DEF}}};
  \end{tikzpicture}
\end{standaloneframe}
\end{document}

enter image description here