3

I want a fade in (with either timer or keystroke) highlight for a text. Here is the MWE that I was able to do.

\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{tikz}

\newcommand*\myhl[1]{\tikz[baseline=(char.base)]{
    \node[draw=black!40, fill=black!8, anchor=base, rounded corners, inner sep=5pt](char) {{#1}};}}

\begin{document}


\begin{frame}{Frame Title}

\begin{itemize}
\item Dummy text
\item Again dummy text. \only<1>{Text to be highlighted} \only<2>{\myhl{Text to be highlighted}}
\item Dummy text
\end{itemize}

\end{frame}

\end{document}
4

To add a fading effect between the two slides, you can use \transfade<2> (you need to a pdf viewer that supports such transitions, e.g. adobe reader in presentation mode).

In addition you can use the overlay-beamer-styles library to prevent the jumping of the text in between slides.

\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{tikz}

\usetikzlibrary{overlay-beamer-styles}

\newcommand<>\myhl[1]{%
    \tikz[baseline=(char.base)]{%
        \node[alt=#2{fill=black!8,draw=black!40}{fill=bg,draw=bg}, anchor=base, rounded corners, inner sep=5pt](char) {{#1}};%
    }%
}

\begin{document}



\begin{frame}{Frame Title}
\transfade<2>

\begin{itemize}
\item Dummy text
\item Again dummy text. \myhl<2>{Text to be highlighted}
\item Dummy text
\end{itemize}

\end{frame}

\end{document}

enter image description here

EDIT

another version with less padding inside the gray box:

\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{tikz}

\usetikzlibrary{overlay-beamer-styles}

\newcommand<>\myhl[1]{%
    \tikz[baseline=(char.base)]{%
        \node[alt=#2{fill=black!8,draw=black!40}{fill=bg,draw=bg}, anchor=base, rounded corners, inner sep=2pt](char) {{#1}};%
    }%
}

\begin{document}



\begin{frame}{Frame Title}
\transfade<2>

\begin{itemize}
\item Dummy text
\item Again dummy text.\myhl<2>{Text to be highlighted}
\item Dummy text
\end{itemize}

\end{frame}

\end{document}

enter image description here

  • 1
    This is excellent and more than enough what I needed. I was wondering if the space between ‘Again dummy text’ and ‘Text to be highlighted’ can be reduced to normal spacing. – Mithun Mar 7 at 14:16
  • @Mithun There are several possibilities to reduce this space. Should the padding inside the gray box be reduced or should it be moved left where it might overlay the full stop? – user36296 Mar 7 at 14:18
  • Padding inside the gray box can be reduced such that it will not be overlapped with the full stop even though the text is moved left. – Mithun Mar 7 at 14:24
  • Because, if needed, I want to use this effect in a tabular environment. – Mithun Mar 7 at 14:28
  • @Mithun Can you have a look at my edited answer? – user36296 Mar 7 at 14:30

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.