3

There are several ways to highlight a line of text with colored background in beamer, for example, using framed or mdframed.

How to animate this highlight, i.e., filling the background color from left to right? (You can use any packages as you will.)

Scenario: You first list a few points, and then (e.g., after a \pause) you emphasize one of them by (progressively) highlighting it.

\documentclass{beamer}
\usepackage{framed, color}
\usepackage{mdframed}
\definecolor{shadecolor}{rgb}{1.0, 0.0, 0.0}

\begin{document}
\begin{frame}
  \begin{shaded}
    A piece of shaded text with red background for highlight.
  \end{shaded}

  \begin{mdframed}[backgroundcolor = yellow]
    A piece of mdframed text with yellow background for highlight.
  \end{mdframed}
\end{frame}
\end{document}
3

An animate-based version:

enter image description here

\documentclass{beamer}

\usepackage{color}
\usepackage{calc}
\usepackage{animate}

\begin{document}
\begin{frame}

  \begin{itemize}
    \item on first
    \item<2-> on second
    \alt<3>{\item
      \begin{animateinline}[autoplay]{24}
        \multiframe{26}{n=0.0+0.04}{
          \makebox[\widthof{\colorbox{yellow}{on third we see something magical}}][l]{%
            \colorbox{yellow}{\makebox[\n\width][l]{on third we see something magical}}%
          }
        }
      \end{animateinline}
    }{\item<4-> 
      \colorbox{yellow}{on third we see something magical}
    }
    \item<4-> on fourth
  \end{itemize}

\end{frame}

\end{document}
2

You could create such an animation with tikz:

\documentclass{beamer}

\usepackage{tikz}

\begin{document}
\begin{frame}
\transduration{0}
\begin{tikzpicture}
\foreach \foreach \x in {0,0.01, ...,1}{
    \fill<+>[red] (0,0) rectangle (\x*\textwidth,1);
}
\node[anchor=west] at (0.25,0.5) {A piece of text with red background for highlight.};
\end{tikzpicture}
\end{frame}
\end{document}

enter image description here

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.