特定のスライドに既存のTikzノードにスタイルを適用するにはどうすればよいですか
質問
これは私がやろうとしていることです
\begin{tikzpicture}
[node distance = 1cm, auto,font=\footnotesize,
% STYLES
every node/.style={node distance=1.3cm},
comment/.style={rectangle, inner sep= 5pt, text width=4cm, node distance=0.25cm, font=},
module/.style={rectangle, drop shadow, draw, fill=black!10, inner sep=5pt, text width=3cm, text badly centered, minimum height=0.8cm, font=\bfseries\footnotesize\sffamily,rounded corners},
selected/.style={fill=red!40}]
\node [module] (nodeA) {node A};
\node [module, below of=nodeA] (nodeA) {node B};
\only<1>{
\node [comment, text width=6cm, right=0.25 of nodeA] {short description of Node A};
\node [comment, text width=6cm, right=0.25 of nodeB] {short description of Node B};
}
\only<2>{
\node [selected] (nodeA) {};
\node [comment, text width=6cm, right=0.25 of nodeA] {long description of node A};
}
\only<3>{
\node [selected] (nodeB) {};
\node [comment, text width=6cm, right=0.25 of nodeA] {long description of node B};
}
\end{tikzpicture}
問題は
\node [selected] (nodeB) {};
新しいノードを作成しますが、既存のノードにスタイルを適用してもらいたいです。そうする方法はありますか?
もちろん、選択された状態と選択されていない状態のすべてのノードのコピーを持つことができますが、通常のソリューションが本当に必要です。
解決
ノードが描画されると、その外観を変更する方法がないため、これをあなたが望むようにこれを行うことができるとは思いません(私が正しく質問を理解していると仮定して)。ビーマーを使用することをお勧めします \alt
大きい:
\alt<2>{\node[module,selected] at (nodeA) {node A};}{\node[module] at (nodeA) {node A};}
\alt<3>{\node[module,selected] at (nodeB) {node B};}{\node[module] at (nodeB) {node B};}
\node[comment,text width=6cm,right=0.25 of nodeA]{\alt<2>{short description}{long description}};
\node[comment,text width=6cm,right=0.25 of nodeB]{\alt<3>{short description}{long description}};
またはそのようなもの(あなたはそれを動作させるためにセミコロンをいじくり回さなければならないかもしれません、私は現時点でそれをテストすることはできません)。
別のオプションは、実際に新しいノードを描画することです。含める場合
\node[module,selected] at (nodeA) {node A};
中身 \only<2>
, 、ノードAの同じ位置にある赤い背景を除いて、ノードAのように見えるノードを描画します。新しいノードは元のノードAをカバーします。
他のヒント
時々、繰り返しを避けるために、このようなことをするのはいいことかもしれません:
% #1 Overlay specs.
% #2 Style name.
% #4 Style properties.
\def\onlystyle<#1>#2#3{%
\alt<#1>{%
\tikzset{#2/.style = {#3}}
}{%
\tikzset{#2/.style = {}}
}%
}
次に、たとえば、これをフレーム内に置くと:
\onlystyle<2>{selected}{fill = red}
スタイル selected
として定義されます fill = red
アニメーションの2番目のスライド、および他のすべてのスライドにまったく効果のないスタイルとして。次に、次のような読み取り可能なフィギュアを書くことができます。
\begin{tikzpicture}
\node at (0, 0) {A};
\node[selected] at (1, 0) {B};
\node at (2, 0) {C};
\end{tikzpicture}
また、「B」ノードが2番目のスライドで強調表示されます。これにより、ノード定義を大量にコピーする必要はありません。もちろん、それはすべてのアニメーションのニーズに適用することはできませんが、私はこのテクニックを自分の袖に留めたいと思っています。