1

Considering the following TeX document:

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{trees}

\tikzset{
  invisible/.style={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
  },
}    

\begin{document}
\begin{frame}
      \begin{tikzpicture}[overlay,remember picture,
      level 1/.style={level distance=12mm,every child/.style={edge from parent/.style={->,solid,draw=blue}} },
      level 2/.style={sibling distance=12mm,every child/.style={edge from parent/.style={->,solid,draw=blue}}},
      level 3/.style={sibling distance=8mm,every child/.style={edge from parent/.style={->,solid,draw=blue}}},
      semithick]

      \node[draw=none,text=red] {S}
      child[visible on=<2->] {node[draw=none,text=red] (a)  {T}
        child[visible on=<3>] {node[draw=none,text=red] (b) {L}}
        child[visible on=<4->] {node[draw=none,text=red] (c) {K}}
        };

    \end{tikzpicture}
\end{frame}
\end{document}

The intention is to remove node 'b' and add another node 'c'. Both nodes needs to appear as the children of node a and appear at the same position.

1 Answer 1

2

Not sure I fully understand, but does this do what you want?

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{trees}

\tikzset{
  invisible/.style={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
  },
}    

\begin{document}
\begin{frame}
      \begin{tikzpicture}[overlay,remember picture,
      level 1/.style={level distance=12mm,every child/.style={edge from parent/.style={->,solid,draw=blue}} },
      level 2/.style={sibling distance=12mm,every child/.style={edge from parent/.style={->,solid,draw=blue}}},
      level 3/.style={sibling distance=8mm,every child/.style={edge from parent/.style={->,solid,draw=blue}}},
      semithick]

      \node[draw=none,text=red] {S}
      child[visible on=<2->] {node[draw=none,text=red] (a)  {\only<2,4->{T}\only<3>{L}}
%        child[visible on=<3>] {node[draw=none,text=red] (b) {L}}
        child[visible on=<4->] {node[draw=none,text=red] (c) {K}}
        };

    \end{tikzpicture}
\end{frame}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .