2

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}
  • No, it doesn't. What precisely are you trying to achieve? Are you aware of the overlay-beamer-styles library? – user121799 Aug 22 '18 at 3:51
  • I also don't understand what you want, can you make little freehand diagrams that explain what you want to get? – AndréC Aug 22 '18 at 10:46
  • @AndréC I edited my question with a better MWE (I hope) – tobiasBora Aug 22 '18 at 10:54
  • 1
    @tobiasBora Thanks for clarification. You need only to add {...} to achieve that. – user121799 Aug 22 '18 at 11:05
4

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

  • @tobiasBora OK, I added a proposal. – user121799 Aug 22 '18 at 10:22
  • 2
    They're not parentheses. They're braces. – AndréC Aug 22 '18 at 11:25
  • @AndréC I agree. Just copied the wording from the answer I cite. – user121799 Aug 22 '18 at 11:26
  • 1
    I just corrected that answer:) – AndréC Aug 22 '18 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.