latex - 如何将样式应用于特定幻灯片上的现有 tikz 节点

标签 latex beamer 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) {};

创建一个新节点,但我希望它应用现有节点的样式。有什么办法吗?

当然,我可以拥有处于选中状态和未选中状态的每个节点的副本,但我真的想要一个正常的解决方案。

最佳答案

我不认为你可以按照你想要的方式做到这一点(假设我正确理解了这个问题),因为一旦绘制了一个节点,就无法改变它的外观。我建议使用 Beamer 的 \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。

关于latex - 如何将样式应用于特定幻灯片上的现有 tikz 节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2979200/

相关文章:

latex - 如何获得取决于 Latex Beamer/tikz 中幻灯片的固定尺寸数字?

date - 使用小型页面时日期水平对齐的问题

r-markdown - 如何在R Markdown Beamer中的目录幻灯片中添加标题

latex - latex 中的 QED 符号

knitr - 将 rmarkdown 文档编织到投影仪演示文稿时如何使用不同目录中的引用书目?

LaTex,Beamer 和 Listings 的问题

python - iPython notebook plantuml 扩展

latex - 如何在 latex 中对齐两个 tikzpicture 图

windows - 如何用 LaTeX 写路径?

latex - 从 markdown 4th header 生成 pdf 的 Pandoc 呈现方式不同