See the MWE below. Observation: In the second version the callout is displayed in the first it is not.
Can anyone tell me why this is so?
\documentclass[10pt,xcolor=dvipsnames]{beamer}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{shapes.callouts,shadows}
\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}} % \pgfkeysalso doesn't change the path
},
}
\NewDocumentCommand{\mycallout}{r<> O{opacity=0.8,text opacity=1} m m m m m m}{%
\tikz[remember picture, overlay]\node[drop shadow, rounded corners, align=left, fill=#8!30, text width=#5,
#2,visible on=<#1>,
draw,rectangle callout,anchor=pointer,callout relative pointer={(#6:#7cm)}]
at (#3) {#4};
}
\newcommand{\refbox}[3]{
\tikz[remember picture, baseline=(#1.base)] \node[fill=#3!30,anchor=base,rounded corners] (#1) {#2};
}
\begin{document}
\frame{\frametitle{ABC}
%%%%%%%%%%%%%%%%% with this version the callout is not displayed %%%%%%%%%%%%%%%%
\begin{align*}
&\text{ $g(x)\refbox{rb2711121055}{$\sim$}{yellow} x^\alpha$}
\end{align*}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%% with this version the callout is displayed %%%%%%%%%%%%%%%%%%%%
% \begin{align*}
% \refbox{rb2711121055}{$2+2=4$}{yellow}
% \end{align*}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mycallout<1>{rb2711121055.north}{$1<2$}{1cm}{230}{1}{yellow}
}
\end{document}
PS: The code is based on https://tex.stackexchange.com/a/83786/16865. I don't think the problem has anything to do with the complicated stuff at the beginning of the preamble but, not being sure, I didn't further reduce the example.

alignanyway. Alsobeamerandaligndon't like each other that much. – percusse Nov 27 '12 at 11:03alignwas just for the MWE. Actually, I have many lines and it's not clear how to do it w/oalign:-( – lpdbw Nov 27 '12 at 11:05$...$inside\textjust close one type the math and open another\textso it should work as in your second example. Might be a boxing issue. – percusse Nov 27 '12 at 11:09\begin{align*} &\text{ abc } g(x)\refbox{rb2711121055}{$\sim$}{yellow} \text{ cde } x^\alpha \end{align*}works fine. Maybe you could put something like that in your answer so that I can accept it. – lpdbw Nov 27 '12 at 11:16