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.

I have the following frame in beamer:

\begin{frame}{Language}
\begin{block}{}
    \begin{align*}
    \onslide<1->{
        &\text{Types} & T &::= B | T \to T \\
    }
    \onslide<2->{    
        &\text{Terms} & E &::= A | E\ E | \ldots |
        \tikz[baseline]{
            \node (term-mon) [anchor=base,fill=blue!20]
            {$\mathsf{mon}^{f, g}_h(E)$};
        }
        \onslide<3> {
            \tikz[baseline]\node [fill=blue!20] (term-mon-expl) at ($(term-mon) + (1,2)$)
            {Comments};
        }
    }    
    \end{align*}
\end{block}
\end{frame}

Basically, I want to highlight a part of the formula and display an additional node nearby on the next slide. However, for some reason TikZ ignores my 1cm shift towards x-axis and only shifts the term-mon-expl node towards y-axis, placing it right next to the term-mon node. Why?

share|improve this question
1  
You need to have either the nodes in one TikZ picture or to use the 'remember picture'/'overlay' combo. –  Qrrbrbirlbel Feb 27 '13 at 2:03
    
@Qrrbrbirlbel Thanks, I forgot about overlay. You can post it as an answer, so that I could accept it. –  Skiminok Feb 27 '13 at 2:10
add comment

1 Answer 1

up vote 2 down vote accepted

The following code shows to possibilities to use two nodes that should be placed relative to each other

  • in one TikZ picture with
  • with the remember picture-overlay combo.

Code

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{frame}
  \begin{align*}
    & \text{Types} & T & ::= B | T \to T \\
   \onslide<2->{
    & \text{Terms} & E &::= A | E\ E | \ldots |
      \tikz[
        baseline=(term-mon.base),
        nodes={fill=blue!20}] {
          \node    (term-mon)                                    {$\mathsf{mon}^{f, g}_h(E)$};
          \begin{pgfinterruptboundingbox}
          \node<3> (term-mon-expl) at ([shift={(1,2)}] term-mon) {Comments};
          \end{pgfinterruptboundingbox}
       }
   }
  \end{align*}
\end{frame}
\begin{frame}
  \begin{align*}
   & \text{Types} & T & ::= B | T \to T \\
  \onslide<2->{
   & \text{Terms} & E &::= A | E\ E | \ldots |
     \tikz[baseline,remember picture]
       \node (term-mon) [anchor=base,fill=blue!20] {$\mathsf{mon}^{f, g}_h(E)$};
  }
  \onslide<3> {
     \tikz[baseline,remember picture,overlay]
       \node [fill=blue!20] (term-mon-expl) at ($(term-mon) + (1,2)$) {Comments};
  }
  \end{align*}
\end{frame}
\end{document}

Output

enter image description here

share|improve this answer
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.