# Beamer's \visible inside a TikZ node

I'm using beamer for creating presentations. Inside a TikZ node I'd like to make a part of the content appears afterwards. I'm using the \visible command for doing so (I don't want the content to move when the hidden part is made visible).

Here's a small example:

\documentclass{beamer}
\usepackage{tikz}\begin{document}

\begin{frame}
\visible<+->{You know\dots}
\begin{tikzpicture}
\node{I'm \visible<+->{very} happy. };
\end{tikzpicture}
\end{frame}
\end{document}


The compilation fails on a classic TikZ error Giving up on this path. Did you forget a semicolon?. However if I replace \visible by \only or \alt the output is produced flawlessly. But that's not what I want :)

There's a possible workaround which consists in defining a new visible command, based on \alt:

\newcommand<>\myvisible[1]{\alt#2{#1}{\phantom{#1}}}


But \phantom may have some undesirable side effects (with line breaks for example).

Do you have any better solution? Thanks!

-

The problem arises due to the grapping of arguments of the node together with the \visible command.

In beamer a good advice is to

1. Try and insert another group
2. Try with the fragile option for the frame
3. Combine 1. and 2.

You simply need to add another group inside.

\node {{ I'm \visible<+->{very} happy. }};
% or
\node {\bgroup \dots \egroup};


This will correctly produce your decired result.

-
Thanks, option 1 works, but not in every case. In TikZ if you add another group in a node, you can't add new lines anymore : \node[align=center]{{a\\b}}; doesn't compile. Should I ask another question on that issue? –  kelux Jul 20 '12 at 19:47
@kelux, then just do: \node[align=center] {I'm {\visible<+->{very}}\\happy.};. Just don't have \visible spanning two lines. –  zeroth Jul 22 '12 at 15:31