Aligning inline math to top of line, with text around it

I am trying to align inline math to the top of a line of text. Currently I have the following:

\documentclass[varwidth]{standalone}
\begin{document}
\begin{enumerate}
\item
Solve the system
$\begin{array}{r} a2-3x_1+5x_2 = 0 \\ 1+x_2 = 0 \\ x_3-2x_1 = 0 \end{array}$ in $\textbf{R}^3$.
\end{enumerate}
\end{document}


This is the result:

I would like for the top line of the array to be at the same vertical level as the text before and after it, instead of centered. I tried just making extra columns in the array with the text, but then that doesn't align with the item number of enumerate (it just vertically centers the whole thing). Other solutions I've found don't quite solve my problem, for instance this solution doesn't seem to allow text in the same line after it.

• Beware! It should be \mathbf{R}. If you try \emph{We work in $\textbf{R}^{3}$}, you'll know why. – egreg Apr 6 '17 at 7:13
• @egreg great point, thank you. Not too long ago I was still using {\bf R}... – Jānis Lazovskis Apr 6 '17 at 18:22

All you need to do is change \begin{array}{r} to \begin{array}[t]{r}.

\documentclass[varwidth,border=1pt]{standalone}
\begin{document}
\begin{enumerate}
\item
Solve the system
$\begin{array}[t]{r} a2-3x_1+5x_2 = 0 \\ 1+x_2 = 0 \\ x_3-2x_1 = 0 \end{array}$ in $\mathbf{R}^3$.
\end{enumerate}
\end{document}


You can use a stack.

\documentclass[varwidth,border=1pt]{standalone}
\usepackage[usestackEOL]{stackengine}
\stackMath
\begin{document}
\begin{enumerate}
\item
Solve the system
$\Longunderstack[r]{ a2-3x_1+5x_2 = 0 \\ 1+x_2 = 0 \\ x_3-2x_1 = 0 }$ in $\mathbf{R}^3$.
\end{enumerate}
\end{document}


If you need alignment points, you can use a TABstack:

\documentclass[varwidth,border=1pt]{standalone}
\usepackage{tabstackengine}
\TABstackMath
\TABbinary
\begin{document}
\begin{enumerate}
\item
Solve the system
$\tabbedLongunderstack[r]{ 2&-3x_1&+5x_2& =& 0 \\ 1&&+x_2& =& 0 \\ &-2x_1&& + x_3 =& 0 }$ in $\mathbf{R}^3$.
\end{enumerate}
\end{document}