5

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.

3

It seems that your display math(text mode (inline math)) usage is affecting something. If you use a regular math environment it works after two runs.

\documentclass[10pt,xcolor=dvipsnames]{beamer}
\usepackage{mathtools,tikz,lmodern}
\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}
\begin{frame}{ABC}

\[
g(x)\refbox{rb}{$\sim$}{yellow} x^\alpha
\]

\mycallout<1>{rb.north}{$1<2$}{1cm}{230}{1}{yellow}

\end{frame}
\end{document}

enter image description here

  • But why just in the first example? I mean, the second is also display style! – lpdbw Nov 27 '12 at 11:00
  • @lpdbw I don't know (though you don't have text mode in the second example) but it's bad practice to use single lines with align anyway. Also beamer and align don't like each other that much. – percusse Nov 27 '12 at 11:03
  • HHmm, single line in alignwas just for the MWE. Actually, I have many lines and it's not clear how to do it w/o align :-( – lpdbw Nov 27 '12 at 11:05
  • 1
    @lpdbw You don't need to use $...$ inside \text just close one type the math and open another \text so it should work as in your second example. Might be a boxing issue. – percusse Nov 27 '12 at 11:09
  • 1
    OK, yes ... \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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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