# Reformatting a table to save vertical space

To save vertical space, how can I convert a $$c$$ column $$r=kn$$ row table to a $$ck$$ column $$n$$ row table? E.g., a $$6=3\cdot2$$ row $$3$$ column table to a $$3\cdot3=9$$ column $$2$$ row table;

a11 a12 a13
a21 a22 a23
a31 a32 a33
a41 a42 a43
a51 a52 a53
a61 a62 a63


to

a11 a12 a13 a31 a32 a33 a51 a52 a53
a21 a22 a23 a41 a42 a43 a61 a62 a63


TIA.

mat = Array[Symbol["a" <> ToString@# <> ToString@#2] &, {6, 3}];

TeXForm @ MatrixForm @ mat


$$\left( \begin{array}{ccc} \text{a11} & \text{a12} & \text{a13} \\ \text{a21} & \text{a22} & \text{a23} \\ \text{a31} & \text{a32} & \text{a33} \\ \text{a41} & \text{a42} & \text{a43} \\ \text{a51} & \text{a52} & \text{a53} \\ \text{a61} & \text{a62} & \text{a63} \\ \end{array} \right)$$

mat2 = Join[## & @@ Partition[mat, 2], 2];

mat2 // MatrixForm // TeXForm


$$\left( \begin{array}{ccccccccc} \text{a11} & \text{a12} & \text{a13} & \text{a31} & \text{a32} & \text{a33} & \text{a51} & \text{a52} & \text{a53} \\ \text{a21} & \text{a22} & \text{a23} & \text{a41} & \text{a42} & \text{a43} & \text{a61} & \text{a62} & \text{a63} \\ \end{array} \right)$$

Also:

 mat3  = Join @@@ Transpose[Partition[mat, 2]];

mat4 = Join @@@ Multicolumn[mat, {2, Automatic}][[1]]

mat4  == mat3  == mat2

 True

• Thanks. After some testing I found ´Transpose[Partition[mat, {Length[mat]/4, 3}]] // TableForm´ to be the answer, where the '4' defines the number of "repetition blocks" of the columns, placed in horisontal direction. Naturally the length of mat must be a multiple of '4', in this case 24, giving a 6 row table.
– mf67
Commented Aug 22, 2020 at 1:20
• I discovered that TeXForm gives a somewhat peculiar output. Is there any way to make this into a tabular format, instead of sub-tabular/arrays inside an array?
– mf67
Commented Aug 22, 2020 at 1:24

Another more complex method :-)

$$\left( \begin{array}{ccc} \text{a11} & \text{a12} & \text{a13} \\ \text{a21} & \text{a22} & \text{a23} \\ \text{a31} & \text{a32} & \text{a33} \\ \text{a41} & \text{a42} & \text{a43} \\ \text{a51} & \text{a52} & \text{a53} \\ \text{a61} & \text{a62} & \text{a63} \\ \end{array} \right)$$

 mat={{a11, a12, a13}, {a21, a22, a23}, {a31, a32, a33}, {a41, a42,
a43}, {a51, a52, a53}, {a61, a62, a63}};

Flatten /@ Transpose@ArrayReshape[mat, {3, 2, 3}] // MatrixForm


$$\left( \begin{array}{ccccccccc} \text{a11} & \text{a12} & \text{a13} & \text{a31} & \text{a32} & \text{a33} & \text{a51} & \text{a52} & \text{a53} \\ \text{a21} & \text{a22} & \text{a23} & \text{a41} & \text{a42} & \text{a43} & \text{a61} & \text{a62} & \text{a63} \\ \end{array} \right)$$