beamer add tag
topnush
I have a tcolorbox which I want to place just above a tikzpicture which has a number of transitions. However, try as I might I can't do this without error. My MWE has two frames so that it renders. What I want is one frame that has both the tcolorbox and the tikzpicture with all its transitions.

    \documentclass{beamer}
    \usepackage[many, listings]{tcolorbox}
    \usepackage{tikz}
    \usetikzlibrary{calc, overlay-beamer-styles, shadows.blur, matrix}
    \usepackage{listings}
    \lstdefinestyle{duckstyle}{%
        moredelim=[is][\color{red}]{|}{|},
        mathescape=true,
        escapechar=@,
        basicstyle=\ttfamily,
        columns=fullflexible
    }
    \lstset{style=duckstyle}
    \usetikzlibrary{backgrounds, arrows.meta, chains, fit,
    	shapes,
    	tikzmark}
    
    
    \makeatletter
    \newcommand*{\slideinframe}{\number\beamer@slideinframe}
    \makeatother
    
    \def\mylistE{{, ,, , , , , , , , ,  , , , , }}
    \def\mylistD{{, ,, , , , , , , , ,  , , , ,}}
    \def\mylistB{{, ,, , , , , , , , ,  , , , ,}}
    \def\mylistF{{, ,, , , , , , , , ,  , , , ,}}
    \def\mylistC{{, ,, , , , , , , , ,  , , , ,}}
    \def\mylistA{{, ,, , , , , , , , ,  , , , ,}}
    
    
    \begin{document}
    
    
    
    \begin{frame}[t, fragile]
    \begin{tcolorbox}[top=0pt, left=5pt,right=5pt, colback=blue!5!white, text height=1.5cm, text width=7cm]
    \begin{lstlisting}[ mathescape, name=shortestpath, basewidth = {.3em}]
    first line
    for each item in the data
        if blah then foo
    \end{lstlisting}
    \end{tcolorbox}
    
    \end{frame}
    
    
    
    
    \begin{frame}
    
    \begin{tikzpicture}[remember picture, overlay,xshift=0.4cm, yshift=-3cm]
    
    \begin{scope}[every node/.style={fill=black, text=white, circle,thick,draw, minimum size=1.2cm}]
         \node[label={[xshift=0em, yshift=0.5em, text=black,rectangle,minimum size=0.7cm,  ]  \pgfmathparse{\mylistA[\slideinframe-1]}\pgfmathresult},alt=<15->{black}{black},text=white]  (A) at (0,5) {A};
         \node[label={[xshift=0em, yshift=0.5em, text=black,rectangle,minimum size=0.7cm,] \pgfmathparse{\mylistB[\slideinframe-1]}\pgfmathresult},alt=<12->{black}{black},text=white]  (B) at (5,5) {B};
         \node[label={[xshift=0em, yshift=0.5em, text=black,rectangle,minimum size=0.7cm, ] \pgfmathparse{\mylistC[\slideinframe-1]}\pgfmathresult},alt=<16->{black}{black},text=white]  (C) at (10,5) {C};
         \node[label={[xshift=0em, yshift=-6em, text=black,rectangle,minimum size=0.7cm, ] \pgfmathparse{\mylistD[\slideinframe-1]}\pgfmathresult},alt=<9->{black}{black},text=white]  (D) at (0,0) {D};
         \node[label={[xshift=0em, yshift=-6em, text=black,rectangle,minimum size=0.7cm, ] \pgfmathparse{\mylistE[\slideinframe-1]}\pgfmathresult},alt=<2->{black}{black},text=white]  (E) at (5,0) {E};
         \node[label={[xshift=0em, yshift=-6em, text=black,rectangle,minimum size=0.7cm, ]  \pgfmathparse{\mylistF[\slideinframe-1]}\pgfmathresult},alt=<7->{black}{black},text=white]  (F) at (10,0) {F} ;
    \end{scope}
    
    \begin{scope}[>={Stealth[black]},
                  every node/.style={fill=white,circle}]
        \path [-, alt=<7-7>{line width=1.2mm}{}] (A) edge (B);
        \path [-, alt=<6->{line width=1.2mm}{}] (D) edge (B);
        \path [-, alt=<4->{line width=1.2mm}{}] (A) edge (D);
        \path [-, alt=<3->{line width=1.2mm}{}] (D) edge (E);
        \path [-, alt=<11->{line width=1.2mm}{}] (E) edge (F);
        \path [-, alt=<14-14>{line width=1.2mm}{}] (E) edge (B);
        \path [-, alt=<12-12>{line width=1.2mm}{}] (E) edge (C);
        \path [-, alt=<9-9>{line width=1.2mm}{}] (B) edge (C);
        \path [-, alt=<2->{line width=1.2mm}{}] (B) edge (F);
        \path [-, alt=<5->{line width=1.2mm}{}] (F) edge (C);
    \end{scope}
    \end{tikzpicture}
    \pause[16]
    \end{frame}
    
    \end{document}
Top Answer
samcarter
Placing multiple elements in one frame is easier if you don't use the `overlay` option, this way each elements can have its natural size. The `overlay` option does anyway not seem necessary as none of the animated elements is right at the border of the image, so the image size is constant. 

```
\documentclass{beamer}
\usepackage[many, listings]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{calc, overlay-beamer-styles, shadows.blur, matrix}
\usepackage{listings}
\lstdefinestyle{duckstyle}{%
    moredelim=[is][\color{red}]{|}{|},
    mathescape=true,
    escapechar=@,
    basicstyle=\ttfamily,
    columns=fullflexible
}
\lstset{style=duckstyle}
\usetikzlibrary{backgrounds, arrows.meta, chains, fit,
    shapes,
    tikzmark}


\makeatletter
\newcommand*{\slideinframe}{\number\beamer@slideinframe}
\makeatother

\def\mylistE{{, ,, , , , , , , , ,  , , , , }}
\def\mylistD{{, ,, , , , , , , , ,  , , , ,}}
\def\mylistB{{, ,, , , , , , , , ,  , , , ,}}
\def\mylistF{{, ,, , , , , , , , ,  , , , ,}}
\def\mylistC{{, ,, , , , , , , , ,  , , , ,}}
\def\mylistA{{, ,, , , , , , , , ,  , , , ,}}


\begin{document}



\begin{frame}[t, fragile]
\begin{tcolorbox}[top=0pt, left=5pt,right=5pt, colback=blue!5!white, text height=1.5cm, text width=7cm]
\begin{lstlisting}[ mathescape, name=shortestpath, basewidth = {.3em}]
first line
for each item in the data
    if blah then foo
\end{lstlisting}
\end{tcolorbox}

\vskip-1cm
\begin{tikzpicture}
\begin{scope}[every node/.style={fill=black, text=white, circle,thick,draw, minimum size=1.2cm}]
     \node[label={[xshift=0em, yshift=0.5em, text=black,rectangle,minimum size=0.7cm,  ]  \pgfmathparse{\mylistA[\slideinframe-1]}\pgfmathresult},alt=<15->{black}{black},text=white]  (A) at (0,5) {A};
     \node[label={[xshift=0em, yshift=0.5em, text=black,rectangle,minimum size=0.7cm,] \pgfmathparse{\mylistB[\slideinframe-1]}\pgfmathresult},alt=<12->{black}{black},text=white]  (B) at (5,5) {B};
     \node[label={[xshift=0em, yshift=0.5em, text=black,rectangle,minimum size=0.7cm, ] \pgfmathparse{\mylistC[\slideinframe-1]}\pgfmathresult},alt=<16->{black}{black},text=white]  (C) at (10,5) {C};
     \node[label={[xshift=0em, yshift=-6em, text=black,rectangle,minimum size=0.7cm, ] \pgfmathparse{\mylistD[\slideinframe-1]}\pgfmathresult},alt=<9->{black}{black},text=white]  (D) at (0,0) {D};
     \node[label={[xshift=0em, yshift=-6em, text=black,rectangle,minimum size=0.7cm, ] \pgfmathparse{\mylistE[\slideinframe-1]}\pgfmathresult},alt=<2->{black}{black},text=white]  (E) at (5,0) {E};
     \node[label={[xshift=0em, yshift=-6em, text=black,rectangle,minimum size=0.7cm, ]  \pgfmathparse{\mylistF[\slideinframe-1]}\pgfmathresult},alt=<7->{black}{black},text=white]  (F) at (10,0) {F} ;
\end{scope}

\begin{scope}[>={Stealth[black]},
              every node/.style={fill=white,circle}]
    \path [-, alt=<7-7>{line width=1.2mm}{}] (A) edge (B);
    \path [-, alt=<6->{line width=1.2mm}{}] (D) edge (B);
    \path [-, alt=<4->{line width=1.2mm}{}] (A) edge (D);
    \path [-, alt=<3->{line width=1.2mm}{}] (D) edge (E);
    \path [-, alt=<11->{line width=1.2mm}{}] (E) edge (F);
    \path [-, alt=<14-14>{line width=1.2mm}{}] (E) edge (B);
    \path [-, alt=<12-12>{line width=1.2mm}{}] (E) edge (C);
    \path [-, alt=<9-9>{line width=1.2mm}{}] (B) edge (C);
    \path [-, alt=<2->{line width=1.2mm}{}] (B) edge (F);
    \path [-, alt=<5->{line width=1.2mm}{}] (F) edge (C);
\end{scope}
\end{tikzpicture}
\pause[16]
\end{frame}

\end{document}
```

![document.gif](/image?hash=07f251e411f4be2c9b8572f407f6612153f548fc8e84a2c461feae763f83e88f)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.