[Tex/LaTex] Creating interactive slide (beamer)

beamer

I want to create an interactive slide, which will have two parts:

  1. In the left side, some comments will be given in enumerate environment (one will be highlighted at each overlay)
  2. In the right side, an image will accompany the currently highlighted text (say, an arrow will be shown in that image)

For example, have a look at frame numbered 23 of this file.

Screen-shot:

What is the best way to do this?

As per asked, this is (a short version of) what I am trying…

MWE

\documentclass{beamer}

\begin{document}
\begin{frame}
\begin{minipage}{0.2\textwidth}
\begin{enumerate}
\item this is 1
\item this is 2
\end{enumerate}
\end{minipage}
\hfill
\begin{minipage}{0.75\textwidth}
\only<1> {\includegraphics[width=.75\textwidth]{fig4-2}}
\only<2> {\includegraphics[width=.75\textwidth]{fig4-3}}
\end{minipage}
\end{frame}
\end{document}

The images are:

fig4-2

fig4-3

Update


As @GonzaloMedina replies on the left-hand-side part (that solves my current problem), now I am left with dynamically creating the images. That means, rather than creating each image separately and then including is a tiresome and monotonous job. There should be some better way to reproduce one image from its predecessor. To complete the whole question, as per his (Gonzalo Medina) suggestion, I am creating this follow-up question.

Best Answer

Here's one way to do it:

enter image description here

The code:

    \documentclass{beamer}
    \usepackage{tikz}
    \usetikzlibrary{tikzmark}

    \newcounter{tmp}
    \newcommand<>\Highlight[1]{%
    \stepcounter{tmp}%
    \only#2{\begin{tikzpicture}[remember picture,overlay]
    \fill[green!60!black,opacity=0.5] 
      ([xshift=-.2em,yshift=2ex]pic cs:start-\thetmp)
        rectangle  
      ([xshift=.2em,yshift=-1ex]pic cs:end-\thetmp);
    \end{tikzpicture}}%
    \tikzmark{start-\thetmp}#1\tikzmark{end-\thetmp}%
    }

    \begin{document}

    \begin{frame}

    \begin{minipage}{0.2\textwidth}
    \begin{enumerate}
    \item \Highlight<+>{this is 1}
    \item \Highlight<+>{this is 2}
    \item \Highlight<+>{this is 3}
    \item \Highlight<+>{this is 4}
    \item \Highlight<+>{this is 5}
    \end{enumerate}
    \end{minipage}
    \hfill
    \begin{minipage}{0.75\textwidth}
    \only<1> {\includegraphics[width=.75\textwidth]{fig4-2}}
    \only<2> {\includegraphics[width=.75\textwidth]{fig4-3}}
    \only<3> {\includegraphics[width=.75\textwidth,height=0.7cm]{example-image-a}}
    \only<4> {\includegraphics[width=.75\textwidth,height=0.7cm]{example-image-b}}
    \only<5> {\includegraphics[width=.75\textwidth,height=0.7cm]{example-image-c}}
    \end{minipage}
    \end{frame}

    \end{document}

Using the tikzmark library, the \Highlight command places a colorized rectangle in the background. I assumed here that the text to be highlighted spans no more than a line; otherwise, a modification on the definition will be required; for example,

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{tikzmark}

\newcounter{tmp}
\newcommand<>\Highlight[1]{%
\stepcounter{tmp}%
\only#2{\begin{tikzpicture}[remember picture,overlay]
\fill[green!60!black,opacity=0.5] 
  ([xshift=-.2em,yshift=2ex]pic cs:start-\thetmp)
    rectangle  
  ([xshift=.2em,yshift=-1ex]pic cs:end-\thetmp);
\end{tikzpicture}}%
\tikzmark{start-\thetmp}#1\hfill\tikzmark{end-\thetmp}%
}

\begin{document}

\begin{frame}

\begin{minipage}{0.3\textwidth}
\begin{enumerate}
\item \Highlight<+>{this is 1 and some other text}
\item \Highlight<+>{this is 2}
\item \Highlight<+>{this is 3}
\item \Highlight<+>{this is 4}
\item \Highlight<+>{this is 5}
\end{enumerate}
\end{minipage}
\hfill
\begin{minipage}{0.65\textwidth}
\only<1> {\includegraphics[width=\linewidth]{fig4-2}}
\only<2> {\includegraphics[width=\linewidth]{fig4-3}}
\only<3> {\includegraphics[width=\linewidth,height=0.7cm]{example-image-a}}
\only<4> {\includegraphics[width=\linewidth,height=0.7cm]{example-image-b}}
\only<5> {\includegraphics[width=\linewidth,height=0.7cm]{example-image-c}}
\end{minipage}
\end{frame}

\end{document}

enter image description here

The code needs two or thee runs to stabilize.