# Boxed text explaining a part of equation in beamer

\documentclass[10pt]{beamer}
\usetheme[progressbar=frametitle]{metropolis}
\usepackage[english]{babel}
\usepackage{booktabs}
\usefonttheme[onlymath]{serif}
\setbeamercolor{background canvas}{bg=white}
\setbeamertemplate{footline}[frame number]
\usetheme{Singapore}
\usepackage{xcolor}

\begin{document}

\begin{frame}{Standard Model}
Standard Model(SM) is gauge theory based on the gauge group-
$$G_{SM}= SU(3)_C\times SU(2)_L\times U(1)_Y$$
Complete SM lagrangian can be written as-

$\mathcal{L}_{SM}=\textcolor{blue}{i\overline{\psi}\gamma^{\mu}\mathcal{D}_{\mu}\psi}\pause\textcolor{red}{ -\frac{1}{4}G^{\mu\nu A}G_{\mu\nu}^{A}-\frac{1}{4}W^{\mu\nu I}W_{\mu\nu}^{I}-\frac{1}{4}B^{\mu\nu}B_{\mu\nu}}$
$\pause\textcolor{magenta}{+h_{ij}^{u}\overline{Q}_{i}U_{j} \widetilde{H}+h_{ij}^{d}\overline{Q}_{i} D_{j}H+h_{ij}^{e}\overline{L}_{i}E_{j}H+h.c.}$
\pause

$$\textcolor{violet}{+(\mathcal{D}_{\mu}H)^{\dag}\mathcal{D}_{\mu}H-\mu^{2}H^{\dag}H+\lambda(H^{\dag}H)^{2}}$$
\end{frame}
\end{document}


This code is giving following four slides-

I want boxed description of each term to be included in these slides but previous description should fade away when I jump to next term or next slide. How can I achieve that?

• Could you post a compilable code fragment (i.e including documentclass a.s.o.) this will make it easier for potential helpers – sheß May 20 '16 at 8:36

If you want to add text to just one slide, try \only<>{}

\documentclass{beamer}

\begin{document}

\begin{frame}
Complete SM lagrangian can be written as-
$\mathcal{L}_{SM}=\textcolor{blue}{i\overline{\psi}\gamma^{\mu}\mathcal{D}_{\mu}\psi}\only<1>{~\fbox{explain something}}\pause \textcolor{red}{ -\frac{1}{4}G^{\mu\nu A}G_{\mu\nu}^{A}-\frac{1}{4}W^{\mu\nu I}W_{\mu\nu}^{I}-\frac{1}{4}B^{\mu\nu}B_{\mu\nu}}$
$\pause\textcolor{magenta}{+h_{ij}^{u}\overline{Q}_{i}U_{j} \widetilde{H}+h_{ij}^{d}\overline{Q}_{i} D_{j}H+h_{ij}^{e}\overline{L}_{i}E_{j}H+h.c.}$
\pause
$$\textcolor{violet}{+(\mathcal{D}_{\mu}H)^{\dag}\mathcal{D}_{\mu}H-\mu^{2}H^{\dag}H+\lambda(H^{\dag}H)^{2}}$$
\end{frame}

\end{document}


With a bit of help from https://tex.stackexchange.com/a/205623/36296 you could also explain the terms like this

\documentclass{beamer}

\usepackage{mathtools}

\newcommand<>{\uncoverubrace}[2]{%
\onslide#3 \underbrace{ \onslide<1->%
#1%
\onslide#3 }_{#2} \onslide<1->%
}
\newcommand<>{\uncoverobrace}[2]{%
\onslide#3 \overbrace{ \onslide<1->%
#1%
\onslide#3 }^{#2} \onslide<1->%
}

\begin{document}

\begin{frame}
Complete SM lagrangian can be written as-
$\mathcal{L}_{SM}=\uncoverubrace<1>{\textcolor{blue}{i\overline{\psi}\gamma^{\mu}\mathcal{D}_{\mu}\psi}}{\only<1>{\fbox{matter}}}\pause \textcolor{red}{ -\frac{1}{4}G^{\mu\nu A}G_{\mu\nu}^{A}-\frac{1}{4}W^{\mu\nu I}W_{\mu\nu}^{I}-\frac{1}{4}B^{\mu\nu}B_{\mu\nu}}$
$\pause\textcolor{magenta}{+h_{ij}^{u}\overline{Q}_{i}U_{j} \widetilde{H}+h_{ij}^{d}\overline{Q}_{i} D_{j}H+h_{ij}^{e}\overline{L}_{i}E_{j}H+h.c.}$
\pause
$$\textcolor{violet}{+(\mathcal{D}_{\mu}H)^{\dag}\mathcal{D}_{\mu}H-\mu^{2}H^{\dag}H+\lambda(H^{\dag}H)^{2}}$$
\end{frame}

\end{document}