My question Drawing an ellipse around an edge in forest resulted in the following code with a forest style circle edge. I want to show and hide this edge for presentations with beamerbut cannot figure out how to do this. I already found visible on but I cannot combine this with the forest style.
\documentclass{beamer}
\usepackage[linguistics]{forest}
\usetikzlibrary{shapes.geometric,fit}
\forestset{%
circle edge/.style={
tikz+={
\node [fit=(.child anchor) (!u.parent anchor), draw=red, ellipse, inner ysep=1.5pt, line
width=0.25mm] {};
}
},
}
\tikzset{
invisible/.style={opacity=0,text opacity=0},
visible on/.style={alt=#1{}{invisible}},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}
\forestset{
visible on/.style={
for ancestors'={
/tikz/visible on={#1},
edge={/tikz/visible on={#1}}}}}
\begin{document}
\frame{
\begin{forest}
[S
[NP$_x$ [he,tier=words]]
[VP
[V x z y
[V x y, circle edge={/tikz/visible on=<3>}
[baked]]]
[NP$_z$ [her,tier=words]]
[NP$_y$ [a cake,roof,tier=words]]]]
\end{forest}
\pause\pause\pause
}
\end{document}
Edit: My solution below works for simple cases like <3->but it fails for <2,4>because of the comma. Is there a way to get the comma through to beamer?

\forestsetvisible onpart here - you aren't using it at all. – cfr Feb 25 '17 at 01:15<2,4>? – Stefan Müller Feb 26 '17 at 08:33toksfor the colour and just need curly brackets to deal with the comma. – cfr Feb 26 '17 at 23:19