# Strange movement of objects when highlighted item in beamer is uncovered

Can anyone explain to me why there is this strange "shift" of objects when passing from the first to the second slide in the below MWE?

\documentclass{beamer}
\usepackage{mathtools}
\usepackage{tikz}

\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}}
},
}

\newcommand*{\tikzarrow}[2]{%
\tikz[
baseline=(A.base),
]\node[
single arrow,
draw,
inner sep=2pt,
top color=white,
bottom color=#1,
] (A) {#2};%
}

\begin{document}

\begin{frame}
\begin{block}{Theorem}
Assume:
\begin{itemize}
\item Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
\end{itemize}

\tikzarrow{yellow}{Then} \tikz[baseline=(A.base)] \node[beameralert=2] (A) {$a+b+c+d+e+f+g=47$.};
\end{block}
\end{frame}

\end{document}


PS: The question is, in a sense, a follow-up of the accepted answer in Highlighting in beamer using TikZ nodes.

-
Related (but not duplicate): tex.stackexchange.com/q/18704/86 – Loop Space Dec 2 '12 at 17:40

With your code you perceive shifts between slides (jumping effect) because I suspect the style beameralert with the addition of inner sep=1pt if displayed just in the second slide changes the dimensions of the node. If I remove it, I get:

Indeed, the beauty of

\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}}
}
}


that avoids jumping effects is that makes the elements of the TikZ picture (nodes, paths or whatever) always present, but only visible in some moments. One perceives jumping effects whenever in different slides elements appears magically only in some moments with their dimensions (at least this is what I've understood reading some questions/answers on the topic here).

Recalling my previous answer Highlighting in beamer using TikZ nodes, it is also possible to use the following style:

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


with the care of setting the default value equal to the background color of the block body. Then:

\documentclass{beamer}
\usepackage{mathtools}
\usepackage{tikz}

\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={block body.bg},
fill on/.style={alt=#1{}{background fill}},
}

\newcommand*{\tikzarrow}[2]{%
\tikz[
baseline=(A.base),
]\node[
single arrow,
draw,
inner sep=2pt,
top color=white,
bottom color=#1,
] (A) {#2};%
}

\begin{document}

\begin{frame}
\begin{block}{Theorem}
Assume:
\begin{itemize}
\item Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
\end{itemize}

\tikzarrow{yellow}{Then} \tikz[baseline=(A.base)] \node[rounded corners,background fill=red!30,fill on=<2>] (A) {$a+b+c+d+e+f+g=47$.};
\end{block}
\end{frame}

\end{document}


will provide the same picture reported above.

-
OK, I understand your explanation of the problem. But I need inner sep=1pt ... Is there any chance of reparing my code so as to prevent the "jumping effect" (I mean without redefining everything)? – lpdbw Dec 2 '12 at 14:45
Yes, of course (maybe from my answer is not clear). The point is that you should be consistent with the dimensions: if you use inner sep=1pt in the beameralert then you should also use in the node \node[beameralert=2,inner sep=1pt]. That allows you to not perceive anymore the problem. – Claudio Fiandrino Dec 2 '12 at 14:48
Ah, sorry, apparently I didn't really understand your answer :-) But now I do and it works fine! Thanks! – lpdbw Dec 2 '12 at 15:02