7

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.

  • 1
    Please provide a Minimum Working Example rather than expecting people to start creating things from scratch! – cfr Aug 9 '14 at 13:31
  • @cfr My attempt is very basic. Just create separate images and use \pause for including each image. I think it will be to naive for the expert latex-ians. – pushpen.paul Aug 9 '14 at 13:35
  • 1
    So? It still saves people having to start with \documentclass.... Note that it matters what the images are, for example. Code shows people what you are trying to do in a way which your question does not at the moment. (If the image is created on-the-fly, that's different than if it is included as an external file.) Moreover, you can set up an MWE using example images which saves people having to do that part of the work. – cfr Aug 9 '14 at 13:39
  • @cfr OK, I am adding it. But I cannot post the actual images, so give me some time to make some edits. – pushpen.paul Aug 9 '14 at 13:42
  • 3
    Excellent. Note that the mwe package provides sample images for this purpose which you can just use \includegraphics{example-image-a} or whatever. That way, you don't need to post images. – cfr Aug 9 '14 at 13:58
8

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.

  • Just an off-topic question: How did you create the animation? – pushpen.paul Aug 9 '14 at 17:15
  • 1
    @pushpen.paul Using ImageMagick; the procedure is described in tex.stackexchange.com/a/23728/3954. – Gonzalo Medina Aug 9 '14 at 17:20
  • Thanks. For the present situation, my problem is solved (as I have already created the images in separate files). Now, for future reference, I need help for creating images on the fly (tikzpicture embedded in one tex file). Should I update this question or create a follow up question? – pushpen.paul Aug 9 '14 at 17:45
  • @pushpen.paul A follow-up one seems the best choice since the new issue is apparently independent from the issue discussed here. – Gonzalo Medina Aug 9 '14 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.