# Labeled box within equation environment

I wish to create a box within an equation environment, which I can then label. The idea is to emphasize certain portions of the equation and interpret what these parts are doing for me. Ideally, I'll be able to label underneath the boxed region.

Here's an example of where I'm at right now. I can create boxes via a number of methods, but I can't figure out a way to label them:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

$$A = \boxed{B} + \boxed{C + D} + E + F$$

label for B: asdf

label for C+D: fdsa

\end{document}


In this example, I'd like asdf to show up underneath the box around B, and fdsa underneath the box around C+D.

Is this something that is possible to do, and if so how? Thanks!

Note: If it matters, I plan to use this in a beamer presentation, although my example above is in an article doc type - I imagine the method for solving my problem is independent of doc type.

• Welcome to TeX.SX! Have you seen the tcolorbox package? It provides ways to highlight equations and parts. – TeXnician Nov 30 '17 at 18:38

For example, \underset is your friend:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

$$A = \underset{\text{asdf}}{\boxed{B}} + \underset{\text{fdsa}}{\boxed{C + D}} + E + F$$

\end{document}


• I also found that using the \substack environment allows me to split text into multiple lines for the labels. – amquack Nov 30 '17 at 21:27