3

I wrote the following tikz code

\documentclass[10pt]{beamer}
\usetheme{Warsaw}
\usetikzlibrary{calc, shapes, snakes, decorations.markings, patterns, , arrows.meta}
\usetikzlibrary{backgrounds} % For testing with "framed" option to look at the bounding box
\newcommand{\smallbead}[1]{\draw[fill] #1 circle [radius=0.1em]}

\begin{document}
\begin{frame}
\begin{figure}[H]
    %\label{}
    \centering
    \begin{tikzpicture}[
    single arrow/.style = {decoration={markings, mark=at position 0.5 with {\arrow{>}}}, postaction={decorate}},
    double arrow/.style = {decoration={markings, mark=at position 0.5 with {\arrow{>>}}}, postaction={decorate}},
    hatched/.style = {pattern=north west lines, opacity=0.3},
    ]
\begin{scope}[xshift=2cm]
        \coordinate (F1) at (-1, 2);
        \coordinate (F2) at (1, 2);
        \coordinate (E1) at (-2, 1);
        \coordinate (E3) at (0, 1);
        \coordinate (E2) at (2, 1);
        \coordinate (V) at (0, 0);

        \node [circle, above left] at (F1) {$f_1$};
        \node [above right] at (F2) {$f_2$};
        \node [left] at (E1) {$e_1$};
        \node [right] at (E2) {$e_2$};
        \node [above] at (E3) {$e_3$};
        \node [below] at (V) {$v$};

        \smallbead{(F1)};
        \smallbead{(F2)};
        \smallbead{(E1)};
        \smallbead{(E2)};
        \smallbead{(E3)};
        \smallbead{(V)};
        \draw [single arrow] (V) [bend left] to (E1);
        \draw [single arrow] (V) [bend right] to (E1);
        \draw [single arrow] (V) [bend left] to (E3);
        \draw [single arrow] (V) [bend right] to (E3);
        \draw [single arrow] (V) [bend left] to (E2);
        \draw [single arrow] (V) [bend right] to (E2);
        \draw [single arrow] (E1) to (F1);
        \draw [single arrow] (E1) to (F2);
        \draw [single arrow] (E2) to (F1);
        \draw [single arrow] (E2) to (F2);
\end{scope}
\end{tikzpicture}
\end{frame}
\end{document}

to generate the following diagram
enter image description here

I want to use this diagram while giving a presentation.

For better exposition, I want to display diagram not in one single frame but in 3 different frames.

The first frame is supposed to display only the dots and their labels.

The second frame is supposed to display the contents of the first frame along with the arrows from the lowest level to the intermediate level.

The third frame is supposed to display the whole of the diagram.

Of course, I can achieve this my writing 3 different codes, one for each frame. But is there a smarter way?

EDIT: I have used a user-defined command \smallbead to but dots at the places I want.

8
  • 3
    you can hide parts of the picture with \only<slidenumber>{content}, e.g. for a line only on the second and third slide: \only<2-3>{ \draw [single arrow] (E2) to (F2);}
    – crateane
    Commented Apr 7, 2016 at 6:11
  • 1
    what is \smallbead?
    – rpapa
    Commented Apr 7, 2016 at 6:12
  • 2
    @caffeinemachine It would be better if you provide a full MWE, including all headers, definitions, \begin{document} etc....
    – crateane
    Commented Apr 7, 2016 at 6:18
  • 2
    It would definitely be much more useful if you provided the definition of \smallbead, so it doesn't have to reverse-engineered. Same for the single arrow style. It is boring and wasting time having to go through a lot of work just to make a snippet compilable (we often like to test solutions before posting). As Faekynn says, a complete minimal working example is much better. On some occasions, although perhaps not this one, I'll grant you that, an MWE is essential to be able to answer the question. Commented Apr 7, 2016 at 6:34
  • 1
    I use the answer in tex.stackexchange.com/a/55849/38080 extensively for this kind of things. Works perfectly... (See also ctan.org/pkg/aobs-tikz)
    – Rmano
    Commented Apr 7, 2016 at 8:38

2 Answers 2

1

@Faekynn solution to suit your example

\documentclass{beamer}

\usepackage{tikz}

\begin{document}

\frame{\frametitle{unnumbered lists}
\begin{tikzpicture}[xshift=2cm]
\only<1-3>{
        \coordinate (F1) at (-1, 2);
        \coordinate (F2) at (1, 2);
        \coordinate (E1) at (-2, 1);
        \coordinate (E3) at (0, 1);
        \coordinate (E2) at (2, 1);
        \coordinate (V) at (0, 0);
        }
\only<2-3>{
        \node [circle, above left] at (F1) {$f_1$};
        \node [above right] at (F2) {$f_2$};
        \node [left] at (E1) {$e_1$};
        \node [right] at (E2) {$e_2$};
        \node [above] at (E3) {$e_3$};
        \node [below] at (V) {$v$};
} 
\only<3>{
        \draw [->] (V) [bend left] to (E1);
        \draw [->] (V) [bend right] to (E1);
        \draw [->] (V) [bend left] to (E3);
        \draw [->] (V) [bend right] to (E3);
        \draw [->] (V) [bend left] to (E2);
        \draw [->] (V) [bend right] to (E2);
        \draw [->] (E1) to (F1);
        \draw [->] (E1) to (F2);
        \draw [->] (E2) to (F1);
        \draw [->] (E2) to (F2);
        }

\end{tikzpicture}

}

\end{document}
1
  • 2
    Unrelated note: @-pings doesn't work in questions/answers, only comments. Commented Apr 7, 2016 at 6:34
0

You can use the \only command to show some content only a some slides of a frame. This works for everything, not only for tikz-pictures.

I also cleand up the code a little bit to contain only relevant things for the picture....

\documentclass[]{beamer}
\usepackage{tikz}
\usetikzlibrary{decorations.markings, arrows.meta}
\newcommand{\smallbead}[1]{\draw[fill] #1 circle [radius=0.1em]}

\begin{document}
\begin{frame}
    \begin{tikzpicture}[ single arrow/.style = {decoration={markings, mark=at position 0.5 with {\arrow{>}}}, postaction={decorate}},  ]
        \coordinate (F1) at (-1, 2);
        \coordinate (F2) at (1, 2);
        \coordinate (E1) at (-2, 1);
        \coordinate (E3) at (0, 1);
        \coordinate (E2) at (2, 1);
        \coordinate (V) at (0, 0);

        \node [circle, above left] at (F1) {$f_1$};
        \node [above right] at (F2) {$f_2$};
        \node [left] at (E1) {$e_1$};
        \node [right] at (E2) {$e_2$};
        \node [above] at (E3) {$e_3$};
        \node [below] at (V) {$v$};

        \smallbead{(F1)};
        \smallbead{(F2)};
        \smallbead{(E1)};
        \smallbead{(E2)};
        \smallbead{(E3)};
        \smallbead{(V)};

        \only<2->{  % show this content only from the second slide onwards
        \draw [single arrow] (V) [bend left] to (E1);
        \draw [single arrow] (V) [bend right] to (E1);
        \draw [single arrow] (V) [bend left] to (E3);
        \draw [single arrow] (V) [bend right] to (E3);
        \draw [single arrow] (V) [bend left] to (E2);
        \draw [single arrow] (V) [bend right] to (E2);
        }
        \only<3>{ % only on third slide
        \draw [single arrow] (E1) to (F1);
        \draw [single arrow] (E1) to (F2);
        \draw [single arrow] (E2) to (F1);
        \draw [single arrow] (E2) to (F2);
       }
\end{tikzpicture}
\end{frame}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .