[Tex/LaTex] How to vertically align undersets

vertical alignment

How to vertically align the numbers beneath (with \underset or otherwise)?

enter image description here

\documentclass{beamer}
\usepackage{amsmath}
\begin{document}

\begin{equation}
\underset{1}{x}=\underset{1}{p_{A|B}}
\end{equation}

\end{document}

Update: This should go into a tabular, which stackunder doesn't seem to be doing well:

enter image description here

Best Answer

Use a longstack (stacktype L). EDITED to use \normalbaselineskip instead of \baselineskip, so that it can appear in tabular, if needed.

\documentclass{beamer}
\usepackage{stackengine}
\def\stacktype{L}
\setstackgap{L}{.7\normalbaselineskip}
\stackMath
\begin{document}
\begin{equation}
\stackunder{x}{\scriptstyle1}=\stackunder{p_{A|B}}{\scriptstyle1}
\end{equation}
\begin{tabular}{cc}
\stackunder{x}{\scriptstyle1}=\stackunder{p_{A|B}}{\scriptstyle1}
&
\stackunder{x}{\scriptstyle1}=\stackunder{p_{A|B}}{\scriptstyle1}
\end{tabular}
\end{document}

enter image description here

Related Question