# How to align numbers in parentheses

This code aligns the 4 and the -3 roughly centered, i.e., the 4 is centered above the -3. I would like the 4 and the 3 to be perfectly vertically aligned, with the negative sign out to the left and the left parenthesis accommodating. How can I do this?

 \begin{align*}
x = \begin{pmatrix}
4 \\
-3 \\
\end{pmatrix}
\end{align*}

• use array and a r-aligned column (note this is horizontal alignment rather than vertical alignment, vertical alignment refers to aligning to the top or the bottom of a box) – David Carlisle Jan 27 at 21:28

Here are two ways: either use a \phantom{-} for the number without a – (to be used for each such number), or load mathtools and use its pmatrix* environment, which allows for an optional alignment specifier:

\begin{equation*}
x = \begin{pmatrix*}[r]
4 \\
-3 \\
\end{pmatrix*}
x = \begin{pmatrix}
\phantom{-} 4 \\
-3 \\
\end{pmatrix}
\end{equation*}


\documentclass{article}

\usepackage{amsmath}

\begin{document}

$\left( \begin{array}{@{}r@{}} 4\\-3 \end{array}\right)$
\end{document}

\documentclass[12pt]{article}
\usepackage{stackengine}
\setstackEOL{\\}
\begin{document}
$x=\parenVectorstack[r]{4\\-3}$
\end{document}


Another way to align 4 and -3 vertically at the right, would be to adopt a simple package called spalign. Looking the screenshot you can see the result.

\documentclass{article}
\usepackage{spalign}
\begin{document}
\spalignvector[r]{4 -3}
\end{document}