3

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.

1
  • 1
    Using {c|r r r r r} might be good enough. Apr 30, 2014 at 10:35

1 Answer 1

4

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}

\begin{equation}
\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{equation}

\end{document}

enter image description here

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.

enter image description here

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

6
  • What if I wanted to achieve the same thing, but instead using a matrix environment such as pmatrix? Apr 30, 2014 at 10:44
  • @CarstenGade That's a different question ;^) Apr 30, 2014 at 10:45
  • Do you know the answer to it? Apr 30, 2014 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. Apr 30, 2014 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? Apr 30, 2014 at 10:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .