[Tex/LaTex] Put subscript underneath instead of in the bottomright corner

subscripts

I wonder if there is a way to create an equation like that where the "subscript" is placed underneath instead of in the bottom right corner. I also want the "subscript" to be center aligned with the number above.

enter image description here

Best Answer

A simple realization is with amsmath and \underset:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\[
y=\underset{(20)}{35}\cdot x + \underset{(3)}{39}\cdot z + \underset{(11)}{3859}
\]
\end{document}

enter image description here

However, you see that the first pair is perhaps too wide, because the subscript width is taken into consideration. If the subscript is never much wider than the number, you can use also \mathclap from mathtools; with a new command also the syntax is handier.

\documentclass{article}
\usepackage{mathtools}% also loads amsmath

\newcommand{\twonums}[2]{\underset{\mathclap{(#2)}}{#1}}

\begin{document}
\[
y=\twonums{35}{20}\cdot x + \twonums{39}{3}\cdot z + \twonums{3859}{11}
\]
\end{document}

enter image description here