17

I am unable to use \uncover inside the text of a TikZ node. Here is what I would like to do:

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
    \begin{frame}
        \begin{tikzpicture}[node distance=2cm]
            \node[align=center] (a) {test 1 \\ \uncover<2>{test 12345}};
            \node[align=center,right of=a] (b) {test 2};
            \path[->] (a) edge (b);
        \end{tikzpicture}
    \end{frame}
\end{document}

This gives: "! Package tikz Error: Giving up on this path. Did you forget a semicolon?."

Using \onslide gives the same result. Using \only does work, but because my second line is longer, the node is enlarged and everything else shifts.

I'd be curious to understand why \only works but not \uncover or \onslide, but mostly, I would like to know if there is a simple way (e.g. simpler than having a minipage inside the node text) to prevent the node from changing size.

  • Create the node twice. Once only for slide 1. Once only for slide 2. Then use \phantom for the relevant part of the first slide. ? – cfr Oct 4 '14 at 10:50
16

You need another set of braces:

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
    \begin{frame}
        \begin{tikzpicture}[node distance=2cm]
            \node[align=center] (a) {test 1 \\ {\uncover<2>{test 12345}}};  %wrapped \uncover into {}
            \node[align=center,right of=a] (b) {test 2};
            \path[->] (a) edge (b);
        \end{tikzpicture}
    \end{frame}
\end{document}

enter image description here

| improve this answer | |
2
\documentclass{beamer}
\usepackage{tikz}

\begin{document}
    \begin{frame}
        \begin{tikzpicture}[node distance=2cm]
          \onslide<1>{%
            \node[align=center] (a) {test 1 \\ \phantom{test 12345}};}
          \onslide<2->{%
            \node[align=center] (a) {test 1 \\ test 12345};}
            \node[align=center,right of=a] (b) {test 2};
            \path[->] (a) edge (b);
        \end{tikzpicture}
    \end{frame}
\end{document}

phantom text...

| improve this answer | |

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.