[Tex/LaTex] Alignment accross multiple arrays/vectors

horizontal alignmentvector

I want to align multiple vectors (horizontal arrays), each on a separate line.
Specifically, some values are negative and some positive, and some have a decimal part and some not. I want to align everything (i.e. values 1st value of all arrays etc) at the decimal place, like this:

 ab=[-0.1  3    2.4]  
xyz=[ 3   -2.7 -2  ]  

I have almost achieved this using a single large matrix, with each row containing one vector. Aligning at the decimal point was initially manual, by breaking up each number into the integer and decimal part and putting each in a separate column, but then I found about the dcolumn package that makes it much easier.

However, since I am using one big array to ensure correct horizontal alignement across multiple lines, I cannot have a \left[ part in one column and a \right] in another. The result is that the brackets are input just by '[' and ']' and are a bit small, rather that being automatically enlarged.

I would like to know if there is any other way to force the same horizontal alignment on multiple arrays (within the same 'align' block if required) without using one big matrix. Maybe some way to nest matrices?

I have though about using tabular or tabularx for each vector and set the same column widths on all of them. While this would align the start and end of the vectors, I am 99% certain the values of each column would not be aligned.

Otherwise, some way to have a '\left[ …\right]' block span multiple columns of an array would be usefull.

Thanks in advance

Best Answer

You can nest array environments and use the dcolumn package to achieve the alignment at the decimal point. A little example:

\documentclass{article}
\usepackage{dcolumn}

\newcolumntype{R}{D{.}{.}{2,2}}

\begin{document}
\fontsize{16}{20}\selectfont
\[
\begin{array}{l@{}l@{}l}
  \begin{array}{r}
    ab=[ \\
    xyz=[
  \end{array}
  &
  \begin{array}{@{}RRR@{}}
    -2.3 & 4 & 3.56\\
    5 & -3.5 & -0.5
  \end{array}
  &
  \begin{array}{l}
    ] \\ ]
  \end{array}
\end{array}
\]

\end{document}

Related Question