# Align two Grids in a Row

I have data in two Grids with a different number of rows each and want the output to be formatted to have the two grids in a row aligned at the top.

Here is a MWE:

First the headers (same number of column in the grids)

headersLeft = {"h11", "h12", "h13"};
headersRight = {"h21", "h22", "h23"};


next the data:

dataLeft =
Flatten /@
Transpose@({{"one", "two", "three"}, Table[
RandomReal[10, 2], {3}]});
dataRight =
Flatten /@ Transpose@({{"one", "two", "three", "four",
"five"}, Table[RandomReal[10, 2], {5}]});


then:

Row[{Grid[Prepend[dataLeft, headersLeft]],
Grid[Prepend[dataRight, headersRight]]
}, Spacer[20], Alignment -> {Center, Top}]


I get:

Question: How can I get the grids aligned at top? I tried with ItemSize, but this is only good for the sizes of each item (in the Grid). Also Frame is not displayed when given as an option. Same output as shown when using:

Row[{Grid[Prepend[dataLeft, headersLeft]],
Grid[Prepend[dataRight, headersRight]]
}, Spacer[20], Alignment -> {Center, Top}, Frame -> All]


## 2 Answers

Grid[{{Grid[Prepend[dataLeft, headersLeft]], Spacer[20],
Grid[Prepend[dataRight, headersRight]]}},
Alignment -> {Center, Top}, Dividers -> All]


• Sometimes solutions are obvious - if you know them ;-) – mgamer Apr 25 '18 at 6:38

Give each Grid the baseline position 1 or Top:

Row[
{
Grid[Prepend[dataLeft,headersLeft],BaselinePosition->1],
Grid[Prepend[dataRight,headersRight],BaselinePosition->1]
},
Spacer[20]
]


Row[
{
Grid[Prepend[dataLeft,headersLeft],BaselinePosition->Top],
Grid[Prepend[dataRight,headersRight],BaselinePosition->Top]
},
Spacer[20]
]


If you want a frame around the whole Row object, use Frame->True, not Frame->All. If you want a divider between the two grids, then you should use Grid instead of Row, as @Anton does.

• Thank you for the hint about Frame, I messed up with Row and Grid... – mgamer Apr 25 '18 at 6:39