# A way to mark things in math mode

I want to mark the weight function in an equation, using something similar to \underbrace. Using this piece of code:

(x^2y')' + \lambda \underbrace{x^2}_{\text{Weight function}}y = 0


I get

.

I don't want such a big space between the x² and the other parts of the equation. I wouldn't mind, for example, having an arrow leading downwards, and there to write the description. Is there any way to do what I describe?

-

Here I've played around with different ways of highlighting x² without resorting to any (major) additional packages. There are ways of doing it more elegantly (using tikz, for example):

\documentclass{article}
\usepackage{grahpicx}% http://ctan.org/pkg/graphicx
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
$(x^2y')' + \lambda \underbrace{x^2}_{\text{\makebox[0pt]{Weight function}}}y = 0$

$(x^2y')' + \lambda \mathop{\rlap{\resizebox{1em}{\ht\strutbox}{\underbrace{\phantom{x^2}}}}x^2}_{\text{\makebox[0pt]{Weight function}}}y = 0$

$(x^2y')' + \lambda \begin{array}[t]{@{\,}c@{\,}} x^2 \\ \downarrow \\ \makebox[0pt]{\scriptsize Weight function} \end{array} y = 0$

$(x^2y')' + \lambda \begin{array}[t]{@{}c@{}} \setlength{\fboxsep}{1pt} \fbox{x^2} \\ \downarrow \\ \makebox[0pt]{\scriptsize Weight function} \end{array} y = 0$

$(x^2y')' + \lambda \underset{\text{\makebox[0pt]{Weight function}}}{\underset{\downarrow}{x^2}} y = 0$
\end{document}


Option 1 is fairly basic. Option 2 sets a fake x² with a appropriate \underbrace, but resizes it to the width of 1em, before typesetting the rest of the expression as \mathop. Options 3 & 4 use an array to stack symbols. Option 5 uses a stacked-\underset.

-
Thanks! It's weird that we have to use an array to do such a basic thing. Do you think it is possible to combine the first and last one, i.e. do that brace and the arrow? –  Hugo Jan 28 '12 at 19:40
@Hugo: I've added a "resized \underbrace" option. I don't think it would look good to have an \underbrace and a \downarrow, since they both are arrow-like. –  Werner Jan 28 '12 at 20:03
That does look good. Thanks! :-) –  Hugo Jan 28 '12 at 20:06

The mathtools package gives the command \mathclap, which can be used to give

\documentclass{article}

\usepackage{mathtools}

\begin{document}
$(x^2y')' + \lambda \underbrace{x^2}_{\mathclap{\text{Weight function}}}y = 0$
\end{document}

-
Thank you. That does narrow the gap, but still isn't quite what I wanted. –  Hugo Jan 28 '12 at 19:37
I find this to be the cleanest solution of all the offered ones. –  tohecz Jan 28 '12 at 23:11
\let\hw\hidewidth
$$(x^2y')'+\lambda \underbrace{\mathop{x^2}}_{\hw\fam0 Weight~function\hw} y = 0$$