6

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*}
  • 1
    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
11

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*}
        \qquad
    x = \begin{pmatrix}
        \phantom{-} 4 \\
           -3 \\
        \end{pmatrix}
 \end{equation*}

enter image description here

7

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\[
\left(  \begin{array}{@{}r@{}}
    4\\-3
  \end{array}\right)
\]
\end{document}
6
\documentclass[12pt]{article}
\usepackage{stackengine}
\setstackEOL{\\}
\begin{document}
\[
x=\parenVectorstack[r]{4\\-3}
\]
\end{document}

enter image description here

1

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.

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.