Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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{beamerthemeshadow}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{shadows,shapes.arrows}

\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}} 
    },
    beameralert/.style={alt=<#1>{fill=red!30,rounded corners,inner sep=1pt}{},anchor=base},
}

\newcommand*{\tikzarrow}[2]{%
  \tikz[
    baseline=(A.base),            
  ]\node[
    single arrow,                 
    single arrow head extend=2pt, 
    draw,                         
    inner sep=2pt,                
    top color=white,              
    bottom color=#1,              
    drop shadow                   
  ] (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.

share|improve this question
    
Related (but not duplicate): tex.stackexchange.com/q/18704/86 –  Andrew Stacey Dec 2 '12 at 17:40
add comment

1 Answer

up vote 7 down vote accepted

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:

enter image description here

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{beamerthemeshadow}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{shadows,shapes.arrows}

\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,                 
    single arrow head extend=2pt, 
    draw,                         
    inner sep=2pt,                
    top color=white,              
    bottom color=#1,              
    drop shadow                   
  ] (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.

share|improve this answer
    
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
1  
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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