0

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

Mohamed Vall
  • 1,166
  • You could use \newcommand but 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
  • Wouldn't it be simpler to just look up the documentation for \NewDocumentCommand? texdoc xparse? – cfr Jan 10 '16 at 22:55
  • @cfr thank you for your answer. I don't understand it :( . So can you tell for example how to change the horizontale position of the comment and can one incorporate the \only<> command in the definition of the NewDocumentCommand ? – Mohamed Vall Jan 10 '16 at 23:02
  • Yes. I mean, the only difference between \NewDocumentCommand and \newcommand which 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 \newcommand and ignore the fact that it is using \NewDocumentCommand as 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:10
  • @cfr Ok, can I remove O{ } in \NewDocumentCommand? and how to incorporate the \only<1,2,..> command in the definition of the NewDocumentCommand ? – Mohamed Vall Jan 10 '16 at 23:17
  • You can remove it if you don't need an optional argument. As for the \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 \NewDocumentCommand there. – cfr Jan 10 '16 at 23:52
  • @cfr what I want is the best way to write the code in the question (I edited the question and made it more direct ) – Mohamed Vall Jan 11 '16 at 06:04
  • If you want to use the <> 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 \newcommand and do away with \NewDocumentCommand altogether. – cfr Jan 11 '16 at 21:48

0 Answers0