邊緣消失的 Tikz 圖

邊緣消失的 Tikz 圖

我在 的框架上有一個圖表beamer,用 繪製tikz,我想在一段時間後將其拆除。原始圖表如下所示:

\begin{frame}{Eksempel}
\begin{tikzpicture}[node distance=1.45cm, thick,
                      main node/.style={circle, draw, font=\sffamily\bfseries}]

    \node[main node] (1)                    {1};
    \node[main node] (3) [below left  of=1] {3};
    \node[main node] (4) [below right of=1] {4};
    \node[main node] (2) [above right of=4] {2};
    \node[main node] (6) [below right of=4] {6};

     %\draw[->, visible on=<2->] (1) -- (2);
     \path[->]
    (1) edge (2)
    (4) edge (2)
    (6) edge (2)
    (1) edge (3)
    (4) edge (1)
    (3) edge (4);
  \end{tikzpicture}
\end{frame}

我想讓邊緣消失,邊緣消失後,沒有更多邊緣的節點變綠。例如,在下一張投影片上,節點 2 的所有邊都應該消失,而在下一張投影片上,節點 2 本身應該會消失。

我嘗試過類似visible on或 之類的東西onslide,但它們都給我錯誤訊息。另外,人們也許可以使用\pause,但是如果我拆解一張圖而不是往裡面放東西,這就很奇怪了。

答案1

這可以作為一個起點。

(在...的幫助下https://tex.stackexchange.com/a/6155/263192

在此輸入影像描述

\documentclass{beamer}
\usepackage{tikz}

\tikzset{onslide/.code args={<#1>#2}{% from https://tex.stackexchange.com/a/6155/263192
  \only<#1>{\pgfkeysalso{#2}}
}}

\begin{document}
\begin{frame}{Eksempel}
\begin{tikzpicture}[
    node distance=1.45cm, thick,
    main node/.style={circle, draw, font=\sffamily\bfseries}
]
    \node[main node] (1)                    {1};
    \node[main node] (3) [below left  of=1] {3};
    \node[main node] (4) [below right of=1] {4};
    \node<-3>[main node,onslide=<3>{green}] (2) [above right of=4] {2};
    \node<-4>[main node] (6) [below right of=4] {6}; % <-4> forces an additional overlay in which node 2 disappears

    \path<1>[->] (1) edge (2)
        (4) edge (2)
        (6) edge (2);
    \path[->] (1) edge (3)
        (4) edge (1)
        (3) edge (4);
\end{tikzpicture}
\end{frame}
\end{document}

相關內容