3

To alert item by item in a list, I normally use <alert@+>. For instance,

\documentclass{beamer}
\begin{document}
    \begin{frame}
        \begin{itemize}[<alert@+>]
            \item one
            \item two
            \item three
        \end{itemize}
    \end{frame}
\end{document}

Instead of alert, can we draw a box around the item at each step? Like <boxaround@+>.

Say OL
  • 1,793

1 Answers1

2

Based on https://tex.stackexchange.com/a/107209/36296 you could do something like:

\documentclass{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{xparse}

\tikzset{
    invisible/.style={opacity=0,text opacity=0},
    visible on/.style={alt=#1{}{invisible}},
    alt/.code args={<#1>#2#3}{%
        \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} 
    },
}

\tikzset{
    background fill/.style={fill=#1},
    background fill/.default={white},
    fill on/.style={alt=#1{}{background fill}},
}

\tikzset{
    background draw/.style={draw=#1},
    background draw/.default={white},
    draw on/.style={alt=#1{}{background draw}},
}

\tikzset{
    background filldraw/.style args={#1 filled by #2}{draw=#1, fill=#2},
    background filldraw/.default=white filled by white,
    filldraw on/.style={alt=#1{}{background filldraw}},
}

\pgfkeys{/highlight/.cd,
    above right offset/.initial={0.015,0.065},
    above right offset/.get=\aboverightoffset,
    above right offset/.store in=\aboverightoffset,
    below left offset/.initial={-0.015,-0.1},
    below left offset/.get=\belowleftoffset,
    below left offset/.store in=\belowleftoffset,
}

\tikzset{highlighting/.style={
        append after command={
            \pgfextra{
                \path[rounded corners,
                background filldraw=red filled by red!30,% border+filling
                filldraw on=<#1>, % overlay specification
                overlay] ($(\tikzlastnode.south west)+(\belowleftoffset)$) % to have some offset
                rectangle ($(\tikzlastnode.north east)+(\aboverightoffset)$);
            }   
        }
    }
}

\NewDocumentCommand{\highlight}{O{} m}{%
    \pgfkeys{/highlight/.cd,#1}
    \tikz[baseline=(A.base)] 
    \node[highlighting=.,
    inner sep=0pt] (A) {\textcolor{black}{#2}};%  
}


\begin{document}

    \begin{frame}{Itemize with styles}
        \begin{itemize}[<alert@+>]
            \item \highlight{one}
            \item \highlight{two}
            \item \highlight{three}
        \end{itemize}
    \end{frame}

\end{document}

enter image description here


EDIT:

A simplified version using the overlay-beamer-styles library:

\documentclass{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{xparse}

\usetikzlibrary{overlay-beamer-styles}

\pgfkeys{/highlight/.cd,
    above right offset/.initial={0.015,0.065},
    above right offset/.get=\aboverightoffset,
    above right offset/.store in=\aboverightoffset,
    below left offset/.initial={-0.015,-0.1},
    below left offset/.get=\belowleftoffset,
    below left offset/.store in=\belowleftoffset,
}

\tikzset{highlighting/.style={
        append after command={
            \pgfextra{
                \path[rounded corners,
                background filldraw=red filled by red!30,% border+filling
                filldraw on=<#1>, % overlay specification
                overlay] ($(\tikzlastnode.south west)+(\belowleftoffset)$) % to have some offset
                rectangle ($(\tikzlastnode.north east)+(\aboverightoffset)$);
            }   
        }
    }
}

\NewDocumentCommand{\highlight}{O{} m}{%
    \pgfkeys{/highlight/.cd,#1}
    \tikz[baseline=(A.base)] 
    \node[highlighting=.,
    inner sep=0pt] (A) {\textcolor{black}{#2}};%  
}


\begin{document}

    \begin{frame}{Itemize with styles}
        \begin{itemize}[<alert@+>]
            \item \highlight{one}
            \item \highlight{two}
            \item \highlight{three}
        \end{itemize}
    \end{frame}

\end{document}