我的图表和背景环境存在问题,无法突出显示幻灯片“最后”的边缘。
首先我尝试了这个:
\begin{frame}
\frametitle{Graphmodell Beispiel}
\tikzstyle{vertex}=[circle,fill=white!25,minimum size=20pt,inner sep=0pt]
\tikzstyle{selected vertex} = [vertex, fill=red!24]
\tikzstyle{edge} = [draw,thick,-]
\tikzstyle{weight} = [font=\small]
\tikzstyle{selected edge} = [draw,line width=5pt,-,red!50]
\tikzstyle{ignored edge} = [draw,line width=5pt,-,black!20]
\begin{figure}
\begin{tikzpicture}[every node/.style={circle,draw},level 1/.style={sibling distance=30mm},level 2/.style={sibling distance=20mm}
]
%\tikzstyle{every node}=[circle,draw]
\only<1,2>{\node[vertex] (1) {1}
child {node[vertex] (2) {2}
child{node[vertex] (3){3}}
child{node[vertex] (4){4}}
}
child { node[vertex] (5) {5}
child {node[vertex](6) {6}}
child {node[vertex] (7){7}
child{node[vertex] (8){8}}
child{node[vertex] (9){9}}
}
}};
\only<3>{\node[vertex, label=right:$T_{k}$] (1) {1}
child {node[vertex, label=left:$T_{k-in}$] (2) {2}
child{node[vertex] (3){3}}
child{node[vertex] (4){4}}
}
child { node[vertex, label=right:$T_{k-out}$] (5) {5}
child {node[vertex](6) {6}}
child {node[vertex] (7){7}
child{node[vertex] (8){8}}
child{node[vertex] (9){9}}
}
}};
\begin{pgfonlayer}{background}
\pause
\foreach \source / \dest in {1/2,2/4,1/5,5/7,7/8}
\path[selected edge] (\source.center) -- (\dest.center);
\end{pgfonlayer}
\end{tikzpicture}
\end{figure}
\visible<3->{\begin{center}Fahrzeug $k \in k^{+}$ mit Start-Endpunktvektor $(4,8)$\end{center}}
\end{frame}
\only
除了由于使用而不是导致图表的位置略微改变之外,其他都运行良好\visible
。
但是当我替换时,\only
我\visible
不知道如何再“背景化”我的边缘,因为它给了我找不到顶点的错误。
\begin{frame}
\frametitle{Graphmodell Beispiel}
\tikzstyle{vertex}=[circle,fill=white!25,minimum size=20pt,inner sep=0pt]
\tikzstyle{selected vertex} = [vertex, fill=red!24]
\tikzstyle{edge} = [draw,thick,-]
\tikzstyle{weight} = [font=\small]
\tikzstyle{selected edge} = [draw,line width=5pt,-,red!50]
\tikzstyle{ignored edge} = [draw,line width=5pt,-,black!20]
\begin{figure}
\begin{tikzpicture}[every node/.style={circle,draw},level 1/.style={sibling distance=30mm},level 2/.style={sibling distance=20mm}
]
%\tikzstyle{every node}=[circle,draw]
\node{{\visible<1>{[vertex] (1) {1}
child {node[vertex] (2) {2}
child{node[vertex] (3){3}}
child{node[vertex] (4){4}}
}
child { node[vertex] (5) {5}
child {node[vertex](6) {6}}
child {node[vertex] (7){7}
child{node[vertex] (8){8}}
child{node[vertex] (9){9}}
}
}}}};
\only<3>{\node[vertex, label=right:$T_{k}$] (1) {1}
child {node[vertex, label=left:$T_{k-in}$] (2) {2}
child{node[vertex] (3){3}}
child{node[vertex] (4){4}}
}
child { node[vertex, label=right:$T_{k-out}$] (5) {5}
child {node[vertex](6) {6}}
child {node[vertex] (7){7}
child{node[vertex] (8){8}}
child{node[vertex] (9){9}}
}
}};
\begin{pgfonlayer}{background}
\pause
\foreach \source / \dest in {1/2,2/4,1/5,5/7,7/8}
\path[selected edge] (\source.center) -- (\dest.center);
\end{pgfonlayer}
\end{tikzpicture}
\end{figure}
\visible<3->{\begin{center}Fahrzeug $k \in k^{+}$ mit Start-Endpunktvektor $(4,8)$\end{center}}
\end{frame}
有人知道如何摆脱这个困境吗?
附言:感谢 Claudio 提供的格式。我明白你只需要在代码中缩进即可
答案1
正如评论中所说,丹尼尔的做法思维导图 tikzpicture 在 beamer 中 (逐步显示)可以避免所谓的跳跃效应(您感知到的图形的运动);这是一个众所周知的问题,网站上有几个参考资料;其中一些是:
请注意,在您的示例中,您只需将样式visible on
应用于稍后出现的节点(和标签),而不是所有child
节点(如果您想让整个顶点稍后出现,这是必需的)。
代码:
\documentclass{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\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}
\frametitle{Graphmodell Beispiel}
\tikzset{vertex/.style={circle,fill=white!25,minimum size=20pt,inner sep=0pt}}
\tikzset{selected vertex/.style={vertex, fill=red!24}}
\tikzset{edge/.style={draw,thick,-}}
\tikzset{weight/.style={font=\small}}
\tikzset{selected edge/.style={draw,line width=5pt,-,red!50}}
\tikzset{ignored edge/.style={draw,line width=5pt,-,black!20}}
\begin{center}
\begin{tikzpicture}[every node/.style={circle,draw},level 1/.style={sibling distance=30mm},level 2/.style={sibling distance=20mm}
]
\node[vertex] (1) {1}
child {node[vertex] (2) {2}
child{node[vertex] (3){3}}
child{node[vertex] (4){4}}
}
child { node[vertex] (5) {5}
child {node[vertex](6) {6}}
child {node[vertex] (7){7}
child{node[vertex] (8){8}}
child{node[vertex] (9){9}}
}
};
\node[vertex,visible on=<3>, label={[visible on=<3>]right:$T_{k}$}] (1) {1}
child {node[vertex, visible on=<3>, label={[visible on=<3>]left:$T_{k-in}$}] (2) {2}
child{node[vertex] (3){3}}
child{node[vertex] (4){4}}
}
child { node[vertex, visible on=<3>,label={[visible on=<3>]right:$T_{k-out}$}] (5) {5}
child {node[vertex](6) {6}}
child {node[vertex] (7){7}
child{node[vertex] (8){8}}
child{node[vertex] (9){9}}
}
};
\begin{pgfonlayer}{background}
\pause
\foreach \source / \dest in {1/2,2/4,1/5,5/7,7/8}
\path[selected edge] (\source.center) -- (\dest.center);
\end{pgfonlayer}
\end{tikzpicture}
\end{center}
\visible<3->{\begin{center}Fahrzeug $k \in k^{+}$ mit Start-Endpunktvektor $(4,8)$\end{center}}
\end{frame}
\end{document}
结果:
您的示例中通过定义的所有样式\tikzstyle
都已更改\tikzset
为应该使用 \tikzset 还是 \tikzstyle 来定义 TikZ 样式?。