# Align baselines of underset elements in display math equation

I am trying to create a display equation showing the coefficients of an example polynomial for use in the quadratic formula. Basically, I want each coefficient of the polynomial to have an arrow pointing to it, and then below that the variable.

I used this code:

\underset{\underset{a}{\uparrow}}{1} x^2-\underset{\underset{b}{\uparrow}}3 x-\underset{\underset{c}{\uparrow}}{10}=\underset{\underset {x}{\uparrow}}{0}


To create this example:

The nested \undersets properly align the arrows and variables with each coefficient in the sample equation.

The only problem is that the baseline of the "b" is much lower than the baseline of the other variables. How do I get the baselines of the underset elements to line up, kind of like in this image:

• Welcome to TeX.SX! Add \mathstrut to all \underset: for instance \underset{\mathstrut a}{\uparrow} – egreg Oct 25 '14 at 20:58
• – barbara beeton Oct 25 '14 at 21:08

Here's an answer using stacks, which I have incorporated into the macro \ptto{}{}. Note: I have made it so that a wide comment does not disrupt the spacing of the equation above. However, if the width of the underset was such that you needed to adjust the spacing of the above equation, then the [F] option to \ptto will accomplish it, as in \ptto[F]{\epsilon}{\mathrm{wide}}.

\documentclass{article}
\usepackage{stackengine}
\stackMath
\setstackgap{L}{.7\baselineskip}
\newcommand\ptto[3][T]{\def\useanchorwidth{#1}\def\stacktype{L}%
\stackunder{#2}{\stackunder{\uparrow}{\scriptstyle#3}}}
\begin{document}
$\ptto{1}{a}x^2 - \ptto{3}{b}x - \ptto{10}{c} = \ptto{0}{x} + \ptto{\epsilon}{\mathrm{wide}}$
\end{document}


Use a strut. In the following command I also set \scriptstyle to avoid the letters to become too small.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\coeff}[2]{%
\underset{\underset{\scriptstyle\mathstrut #2}{\uparrow}}{#1}%
}

\begin{document}

$\coeff{1}{a}x^2-\coeff{3}{b}x-\coeff{10}{c}=0$

\end{document}