I'm trying to add and remove nodes in a tikz-qtree through the use of \only in beamer. And it gives weird results.
If I don't use \only I see the figure that I want.
\documentclass{beamer}
\usepackage{tikz-qtree}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\Tree [.root
[.subtree1 ] [.subtree2 ]
]
\end{tikzpicture}
\end{frame}
\end{document}
But if I add an \only the text gets messed up.
\documentclass{beamer}
\usepackage{tikz-qtree}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\Tree [.root
\only<2>{ [.subtree1 ] [.subtree2 ] }
]
\end{tikzpicture}
\end{frame}
\end{document}
Expected output
Equivalent to the output of the code below. Unfortunately, I can't include more than two images due to lack of reputation.
\documentclass{beamer}
\usepackage{tikz-qtree}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\Tree [.root ]
\end{tikzpicture}
\end{frame}
\begin{frame}
\begin{tikzpicture}
\Tree [.root
[.subtree1 ] [.subtree2 ]
]
\end{tikzpicture}
\end{frame}
\end{document}

![root with two child nodes, but weird labels e.g. [.subtree1] instead of subtree1](../../images/752f1743a12f1c317a94657a5034bab8.webp)

\documentclassand\usepackage. – Henri Menke Sep 08 '17 at 07:45{...}is grouping the subnodes in to one. What effect to you exactly need to achieve? Do you mind the spacing of the tree changing with each overlay? Do you want future edges visible? – Andrew Swann Sep 08 '17 at 08:35