I posted this question a long time ago, where I wanted to produce an equation like the second page of this lecture. Now I return to it and I use the answer of this question as follows:
\documentclass{beamer}
\usepackage{mathtools, tikz, lmodern, xparse}
\usetikzlibrary{shapes.geometric, arrows, matrix, positioning, shapes.callouts, shadows}
\tikzset{>=stealth}
\usepackage{amsmath} % For align environement
\usepackage{color} % to define the next colors
\definecolor{blue(munsell)}{rgb}{0.0, 0.5, 0.69}
\NewDocumentCommand{\mycallout}{r<> O{} m m m m m m}{%
\tikz[remember picture, overlay]
{\node[drop shadow, rounded corners, align=left, fill=#8!30, text width=#5,
#2,
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}{Quantum corrections to gauge interactions}
\begin{align*}
&F(\Phi)= \only<1,3>{\alpha} \only<2>{\refbox{rb1}{$\alpha$}{blue}} X+\only<1,2>{g(\Phi)} \only<3>{\refbox{rb2}{$g(\Phi)$}{blue}}
\end{align*}
\only<2>{\mycallout<2>{rb1}{tree level}{2cm}{44-1}{1}{blue}}\only<3>{\mycallout<3>{rb2}{one-loop}{2cm}{50--44}{1}{blue}}
\end{frame}
\end{document}
My question is: since I do not understand the above code I am wondering if this is the best way to write it?
Edit: A nice method is in the anwer of this question
\newcommandbut you would have to use a different syntax. The optional argument would need to come first and the first argument would have to be given in{}rather than<>. Or you could use lower level TeX stuff and\def, but that would not be recommended in a LaTeX document. – cfr Jan 10 '16 at 22:52\NewDocumentCommand?texdoc xparse? – cfr Jan 10 '16 at 22:55\only<>command in the definition of theNewDocumentCommand? – Mohamed Vall Jan 10 '16 at 23:02\NewDocumentCommandand\newcommandwhich is relevant here is that the way the arguments are specified is different. Anything you can do with those arguments within the definition will work the same. So you can just make the changes you want as if it were using\newcommandand ignore the fact that it is using\NewDocumentCommandas you don't want to change anything about the user interface but only what the command does. So there shouldn't be a problem at all. – cfr Jan 10 '16 at 23:10O{ }in\NewDocumentCommand? and how to incorporate the\only<1,2,..>command in the definition of theNewDocumentCommand? – Mohamed Vall Jan 10 '16 at 23:17\only, that just depends what you want it to do. How should I know how to incorporate it when I have no idea what you're trying to do? That bit is just like\newcommand. There's nothing specific about\NewDocumentCommandthere. – cfr Jan 10 '16 at 23:52<>argument to your command, you can't define it with\newcommand. So you either need lower level\def, which isn't recommended, or\NewDocumentCommand. If you don't want to use the<>, then you can just use\newcommandand do away with\NewDocumentCommandaltogether. – cfr Jan 11 '16 at 21:48