# Aligning numbers in array

What am I doing wrong here?:

\documentclass[11pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\begin{document}

\begin{align}
\begin{array}{c|c c c c c}
& R & U & \rho & \eta & \alpha \\
\hline
\mathrm{L} & 1 & 1 & -3 & -1 & 0 \\
\mathrm{M} & 0 & 0 & 1 & 1 & 1 \\
\mathrm{T} & 0 & -1 & -1 & -2 & 1
\end{array}
\end{align}

\end{document}


I hope someone can help! And yes, I have seen some of the other similar questions, but I can't seem to get it to work. I want the numbers in the columns to be aligned under each other.

• Using {c|r r r r r} might be good enough. – Steven B. Segletes Apr 30 '14 at 10:35

I had suggested in my comment to use {c|r r r r r} as the specifier for the array. However, one may not like the fact that the numbers are right aligned relative to the letters above. While a bit inconvenient, one can accomplish centered numbers in the array, if one laps the negative signs to the left, allowing enough array column separation.

\documentclass[11pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\begin{document}

$$\arraycolsep 1.5ex \begin{array}{c|c c c c c} & R & U & \rho & \eta & \alpha \\ \hline \mathrm{L} & 1 & 1 & \llap{-}3 & \llap{-}1 & 0 \\ \mathrm{M} & 0 & 0 & 1 & 1 & 1 \\ \mathrm{T} & 0 & \llap{-}1 & \llap{-}1 & \llap{-}2 & 1 \end{array}$$

\end{document}


For comparison, here is the {c|r r r r r} approach, in which the letters are right-aligned with the numeric entries... slightly less visually appealing in my mind.

p.s. Since you weren't aligning anything, I replaced the align environment with equation.

• What if I wanted to achieve the same thing, but instead using a matrix environment such as pmatrix? – Carsten Gade Apr 30 '14 at 10:44
• @CarstenGade That's a different question ;^) – Steven B. Segletes Apr 30 '14 at 10:45
• Do you know the answer to it? – Carsten Gade Apr 30 '14 at 10:47
• @CarstenGade What I had in mind would not work with the horizontal and vertical rules, so I don't have something ready for you without a bit of thought and luck. – Steven B. Segletes Apr 30 '14 at 10:51
• @StevenSegletes I can maybe live without the horizontal and vertical rules then; say I wanted just the numbers in a matrix, and then show a couple of steps of reducing the matrix - how can I put multiple matrices next to each other in one equation? Is equation the right environment for this or align? – Carsten Gade Apr 30 '14 at 10:58