tikz beamer add tag
Anonymous 1502
Here is my MWE:



```
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\setbeamertemplate{frametitle}[default][center]
\usepackage[many]{tcolorbox}
\usepackage{listings}
\lstdefinestyle{duckstyle}{%
    moredelim=[is][\color{red}]{|}{|},
    mathescape=true,
    escapechar=@,
    basicstyle=\ttfamily,
    columns=fullflexible
}
\lstset{style=duckstyle}
\newcommand{\ubar}[1]{\alt<+>{\underaccent{\bar}{#1}}{#1}}
\tcbuselibrary{skins}
\tcbset{
	arc=0pt,
	outer arc=0pt,
	colback=white,
}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
	shapes,
	tikzmark}
\usetikzlibrary{tikzmark,shapes.geometric}
\usetikzmarklibrary{listings} 

\usepackage{calc}

\newcommand{\Proc}[1]{\textsc{#1}}
\newcommand{\Var}[1]{\ensuremath{\textcolor{varcolor}{#1}}}
\definecolor{varcolor}{RGB}{15,122,183}


\definecolor{titlecolor}{RGB}{29, 110, 174}
\begin{document}
\begin{frame}[t, fragile]{}
Some text written here introducing the slide to the spectators.
\begin{columns}

\begin{column}{5.2cm} %

    \begin{tcolorbox}[top=0pt, left=5pt,right=5pt, colback=blue!5!white, text width=5.2cm, text height=7cm]
\begin{lstlisting}[mathescape, name=misra, basewidth = {.3em}]
Algorithm($\Var{a_1,a_2,\dots,a_m}$)

set $\Var{A}$ = $\emptyset$
\end{lstlisting}
\end{tcolorbox}
\end{column}
    
   
\begin{column}{\textwidth-5cm} %
\vspace{-0.8cm}
\begin{center}
\begin{tcolorbox}[top=0pt, left=5pt,right=5pt, colframe=blue, text width=4cm, text height=0.8cm]
\end{tcolorbox}
\end{center}
\begin{itemize}[<+->] 
\setlength\itemsep{5pt plus 1fill}
\item[] $\tikzmark{step1}A \rightarrow \tilde{f}_A = 1 $
\item[] $C \rightarrow \tilde{f}_A = 1, \tilde{f}_C = 1$
\end{itemize}

\end{column}
    \begin{tikzpicture}[remember picture]
    \draw[->,overlay, dashed] (pic cs:step1) to [bend right]([xshift=0.2cm, yshift=.25\baselineskip]pic cs:line-misra-3-end);
    \end{tikzpicture}
\end{columns}
\end{frame}


\end{document}
```
The arrow from the right column to the code in the left column changes direction as you go from item 1 to item 2.

Why does is it do that and how can it be fixed?
Top Answer
samcarter
This might break other things, but as a workaround you could force listing to reset the linenumber:

```
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\setbeamertemplate{frametitle}[default][center]
\usepackage[many]{tcolorbox}
\usepackage{listings}
\lstdefinestyle{duckstyle}{%
    moredelim=[is][\color{red}]{|}{|},
    mathescape=true,
    escapechar=@,
    basicstyle=\ttfamily,
    columns=fullflexible
}
\lstset{style=duckstyle}
\newcommand{\ubar}[1]{\alt<+>{\underaccent{\bar}{#1}}{#1}}
\tcbuselibrary{skins}
\tcbset{
	arc=0pt,
	outer arc=0pt,
	colback=white,
}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
	shapes,
	tikzmark}
\usetikzlibrary{tikzmark,shapes.geometric}
\usetikzmarklibrary{listings} 

\usepackage{calc}

\newcommand{\Proc}[1]{\textsc{#1}}
\newcommand{\Var}[1]{\ensuremath{\textcolor{varcolor}{#1}}}
\definecolor{varcolor}{RGB}{15,122,183}

\makeatletter
\gdef\lst@SetFirstNumber{%
    \ifx\lst@firstnumber\@undefined
%        \@tempcnta 0\csname\@lst no@\lst@intname\endcsname\relax
        \@tempcnta=1%
        \ifnum\@tempcnta=\z@ \else
            \lst@nololtrue
            \advance\@tempcnta\lst@advancenumber
            \edef\lst@firstnumber{\the\@tempcnta\relax}%
        \fi
    \fi}%
\makeatother


\definecolor{titlecolor}{RGB}{29, 110, 174}
\begin{document}
\begin{frame}[t, fragile]{}
Some text written here introducing the slide to the spectators.
\begin{columns}

\begin{column}{5.2cm} %

    \begin{tcolorbox}[top=0pt, left=5pt,right=5pt, colback=blue!5!white, text width=5.2cm, text height=7cm]
\begin{lstlisting}[mathescape, name=misra, basewidth = {.3em}]
Algorithm($\Var{a_1,a_2,\dots,a_m}$)

set $\Var{A}$ = $\emptyset$
\end{lstlisting}
\end{tcolorbox}
\end{column}
    
   
\begin{column}{\textwidth-5cm} %
\vspace{-0.8cm}
\begin{center}
\begin{tcolorbox}[top=0pt, left=5pt,right=5pt, colframe=blue, text width=4cm, text height=0.8cm]
\end{tcolorbox}
\end{center}
\begin{itemize}[<+->] 
\setlength\itemsep{5pt plus 1fill}
\item[] $\tikzmark{step1}A \rightarrow \tilde{f}_A = 1 $
\item[] $C \rightarrow \tilde{f}_A = 1, \tilde{f}_C = 1$
\end{itemize}

\end{column}
    \begin{tikzpicture}[remember picture]
    \draw[->,overlay, dashed] (pic cs:step1) to [bend right]([xshift=0.2cm, yshift=.25\baselineskip]pic cs:line-misra-3-end);
    \end{tikzpicture}
\end{columns}
\end{frame}


\end{document}
```

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

Answer #2
user 3.14159
Since you are loading `tcolorbox`, you can use its `listings` library, which seems to automatically take care of the issue that is described below in detail.
```
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\setbeamertemplate{frametitle}[default][center]
\usepackage[most,listings,skins]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,tikzmark,shapes.geometric}
\usetikzmarklibrary{listings}
\tcbset{
    arc=0pt,
    outer arc=0pt,
    colback=white,
}
\lstdefinestyle{duckstyle}{%
    moredelim=[is][\color{red}]{|}{|},
    mathescape=true,
    escapechar=@,
    basicstyle=\ttfamily,
    columns=fullflexible
}
\lstset{style=duckstyle}
\newtcblisting{mybox}[2][]{% 
colback=blue!5!white, 
colframe=black, 
fonttitle=\bfseries,
listing options={style=duckstyle,#2}, 
#1}
%
\newcommand{\Proc}[1]{\textsc{#1}}
\newcommand{\Var}[1]{\ensuremath{\textcolor{varcolor}{#1}}}
\definecolor{varcolor}{RGB}{15,122,183}
\definecolor{titlecolor}{RGB}{29, 110, 174}
%
\newcommand<>\Connect[3][]{%
 \only#4{\begin{tikzpicture}[remember picture,overlay,#1]
\draw[->,overlay, dashed] (#2) to [bend right]
	([xshift=0.2cm, yshift=.25\baselineskip]pic cs:line-misra-#3-end);
\end{tikzpicture}}}
%
\begin{document}
\begin{frame}[t, fragile]
\frametitle{Pft}
Some text written here introducing the slide to the spectators.
\begin{columns}[t]%
\begin{column}{5.4cm}%
\begin{mybox}[listing only]{name=misra,mathescape,basewidth={.3em}}
Algorithm($\Var{a_1,a_2,\dots,a_m}$)

set $\Var{A}$ = $\emptyset$
For each $\Var{i}$
pft
\end{mybox}
\end{column}
%
\begin{column}{\dimexpr\textwidth-5.5cm} %
\begin{center}
\begin{tcolorbox}[top=0pt, left=5pt,right=5pt, colframe=blue, text width=4cm, text height=0.8cm]
\end{tcolorbox}
\end{center}
\begin{itemize}[<+->]
\setlength\itemsep{5pt plus 1fill}
\item[] $\tikzmarknode{A1}{A} \rightarrow \tilde{f}_A = 1$\Connect{A1}{3}
\item[] $C \rightarrow \tilde{f}_A = 1, \tilde{f}_C = 1$
\item[] $\tikzmarknode{A2}{A} \rightarrow \tilde{f}_A = 2, \tilde{f}_C = 1$
\Connect{A2}{4}
\end{itemize}
\end{column}
\end{columns}
\end{frame}
\end{document}  

```

![ani.gif](/image?hash=251982d1f897a166ec5dc727e7e6b834e06ffff8e9e8f0b92fc1131c52ee21d9)

Among other things, this approach also has the advantage that you do not have to tune the width of the `tcolorbox`.


If you do not want to use the `listings` library of `tcolorbox`, things are more complicated. As pointed out in [this post](https://tex.stackexchange.com/questions/164932/problem-with-listings-when-using-line-numbers-name-and-beamer-overlays), there is a problem when using `listings` in beamers: the line numbers get confused. So one can reset them by hand, see also [this post](https://tex.stackexchange.com/a/559303). I also tried to clean up a bit and define a command `\Connect` that is supposed to make life easier, and use `\tikzmarknode` where appropriate.


```
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\setbeamertemplate{frametitle}[default][center]
\usepackage[many]{tcolorbox}
\usepackage{listings}
\lstdefinestyle{duckstyle}{%
    moredelim=[is][\color{red}]{|}{|},
    mathescape=true,
    escapechar=@,
    basicstyle=\ttfamily,
    columns=fullflexible
}
\lstset{style=duckstyle}
\newcommand{\ubar}[1]{\alt<+>{\underaccent{\bar}{#1}}{#1}}
\tcbuselibrary{skins}
\tcbset{
    arc=0pt,
    outer arc=0pt,
    colback=white,
}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,tikzmark,shapes.geometric}
\usetikzmarklibrary{listings}

\newcommand{\Proc}[1]{\textsc{#1}}
\newcommand{\Var}[1]{\ensuremath{\textcolor{varcolor}{#1}}}
\definecolor{varcolor}{RGB}{15,122,183}


\definecolor{titlecolor}{RGB}{29, 110, 174}
\begin{document}
\begin{frame}[t, fragile]{}
Some text written here introducing the slide to the spectators.
\begin{columns}[t]%
\begin{column}{5.4cm}%
\begin{tcolorbox}[top=0pt, left=5pt,right=5pt, colback=blue!5!white, 
text width=4.5cm, text height=7cm]
\begin{lstlisting}[firstnumber=1,mathescape, name=misra, basewidth = {.3em}]
Algorithm($\Var{a_1,a_2,\dots,a_m}$)

set $\Var{A}$ = $\emptyset$
For each $\Var{i}$
pft
\end{lstlisting}
\end{tcolorbox}
\end{column}
%
\begin{column}{\dimexpr\textwidth-5.5cm} %
\begin{center}
\begin{tcolorbox}[top=0pt, left=5pt,right=5pt, colframe=blue, text width=4cm, text height=0.8cm]
\end{tcolorbox}
\end{center}
\newcommand<>\Connect[3][]{%
 \only#4{\begin{tikzpicture}[remember picture,overlay,#1]
\draw[->,overlay, dashed] (#2) to [bend right]
	([xshift=0.2cm, yshift=.25\baselineskip]pic cs:line-misra-#3-end);
\end{tikzpicture}}}
\begin{itemize}[<+->]
\setlength\itemsep{5pt plus 1fill}
\item[] $\tikzmarknode{A1}{A} \rightarrow \tilde{f}_A = 1$\Connect{A1}{3}
\item[] $C \rightarrow \tilde{f}_A = 1, \tilde{f}_C = 1$
\item[] $\tikzmarknode{A2}{A} \rightarrow \tilde{f}_A = 2, \tilde{f}_C = 1$
\Connect{A2}{4}
\end{itemize}
\end{column}
\end{columns}
\end{frame}
\end{document}
```

![ani.gif](/image?hash=fe5c6dde2400b9973594e3bb0c6f2dceaf15c70c34916629d4482783064c237a)

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.