TikZノードテキスト内で\uncoverを使用する

TikZノードテキスト内で\uncoverを使用する

TikZ ノードのテキスト内では使用できません\uncover。私がやりたいことは次のとおりです:

\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}

これは次のようになります: "! パッケージ tikz エラー: このパスを放棄します。セミコロンを忘れましたか?"

を使用すると\onslide、同じ結果が得られます。 を使用すると\only機能しますが、2 番目の行が長いため、ノードが拡大され、他のすべてが移動します。

\onlyは機能するのに や は機能しない理由を理解したいのです\uncover\onslide、何よりも、ノードのサイズが変更されないようにする簡単な方法(たとえば、minipageノード テキスト内に を配置するよりも簡単な方法)があるかどうかを知りたいです。

答え1

別のブレースセットが必要です:

\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}

ここに画像の説明を入力してください

答え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}

ファントムテキスト...

関連情報