我正在尝试申请丹尼尔的方法在以下 MWE 中发现树的右下部分。但是,当我将选项传递[visible on=<2->]
给其中一个子项时,它似乎会影响后面的所有代码:之后绘制的子项消失了(这是我想要的),e
右侧边缘的标签消失了(不是我想要的),下一条路径(虚线)也消失了(不是我想要的)。这是什么原因,我该如何解决?
\documentclass{beamer}
\usepackage{tikz}
% Two node styles for game trees: solid and hollow
\tikzset{
solid node/.style={circle,draw,inner sep=1.0,fill=black},
hollow node/.style={circle,draw,inner sep=1.0}
}
% use option [visible on=<+->] to uncover parts of a tikzpicture
\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}
\centering
\begin{tikzpicture}[font=\scriptsize]
\tikzstyle{level 1}=[sibling distance=30mm]
\tikzstyle{level 2}=[sibling distance=12mm]
\tikzstyle{level 3}=[sibling distance=10mm]
\node(0)[hollow node,label=above:1]{}
child{node[solid node]{}
child{node[solid node,label=below:{$\binom{2}{1}$}]{}edge from parent node[left]{$c$}}
child{node[solid node,label=below:{$\binom{-1}{0}$}]{}edge from parent node[right]{$d$}}
edge from parent node[left]{$a\phantom{b}$}
}
child{node[solid node]{}
child{node[solid node,label=below:{$\binom{0}{0}$}]{}edge from parent node[left]{$c$}}
child{node[solid node,label=below:{$\binom{0}{1}$}]{}edge from parent node[right]{$d$}}
edge from parent node[left]{$b$}
}
child{node[solid node,label=right:2]{}
%%%%% The following part of the tree to be uncovered in slide 2 %%%%%
child[sibling distance=20mm,visible on=<2->]{node[solid node,label=left:1]{}
child{node[solid node,label=below:{$\binom14$}]{}edge from parent node[left]{$h$}}
child{node[solid node,label=below:{$\binom03$}]{}edge from parent node[right]{$i$}}
edge from parent node[left]{$f$}
}
child[sibling distance=20mm]{node[solid node,label=right:1]{}
child{node[solid node,label=below:{$\binom04$}]{}edge from parent node[left]{$j$}}
child{node[solid node,label=below:{$\binom23$}]{}edge from parent node[right]{$k$}}
edge from parent node[right]{$g$}
}
edge from parent node[right]{$\phantom{b}e$}
}
;
\draw[dashed](0-1)--(0-2)node[midway,above]{2};
\end{tikzpicture}
\end{frame}
\end{document}
答案1
BaKoMa TeX 10.72(2015 年 3 月 30 日发布)解决了这个问题。
答案2
看起来我的问题与TikZ
或无关Beamer
,而是与 BaKoMa TeX 有关。使用 MikTeX 编译代码时,输出看起来不错,如上所示。但是,当使用 BaKoMa 编译相同的代码时,输出是错误的,如下所示。