4

I have written the following matrix on Latex:

enter image description here

However, I would like the different elements to be aligned vertically, i.e.:

enter image description here

I have been unable to accomplish this. My code is the following:

\[\phi_1(\mathbf{x}) = 
    \left(
    \begin{array}{l}
        x_1^2
        \\
        \sqrt{2}x_1x_2
        \\
        x_2^2
        \end{array}
   \right)\]

Do you know how could I fix this?

0

1 Answer 1

5

l columns are left-aligned, while c columns are center aligned, so just change l to c in the array specification. That said, I'd rather use pmatrix from amsmath here.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\phi_1(\mathbf{x}) = 
    \left(
    \begin{array}{c}
        x_1^2
        \\
        \sqrt{2}x_1x_2
        \\
        x_2^2
        \end{array}
   \right)
\]
With \texttt{pmatrix}:
\[
\phi_1(\mathbf{x}) = 
    \begin{pmatrix}
        x_1^2
        \\
        \sqrt{2}x_1x_2
        \\
        x_2^2
        \end{pmatrix}
\]
\end{document}

enter image description here

1
  • Well thank you then, I should have thought about it... May 9, 2016 at 13:52

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.