I am trying to set up a Grid
with cells that span two rows and are centered on those rows, but I am having troubles with the sizing and, therefore, spacing of the elements. For illustration I can get something that has at least part of the layout right by using TableForm
, but this will not work in practice because the columns do not align, there is no Dividers
option, Item
is not fully supported, etc.
dot = Graphics[{Pink, Disk[]}, ImageSize -> 40];
dat = {{"Angel Falls", "17.7 m", "0.82", "9.2"},
{"Bridalveil Fall", "6.9 m", "0.94", "9.8"},
{"Cascata delle Marmore", "8.25 m", "0.87", "6.3"},
{"Cumberland Falls", "182.0 m", "0.87", "6.3"},
{"Dettifoss", "7.41 m", "0.88", "6.7"}};
table = {dot, {#, {##2}}} & @@@ dat;
TableForm[table, TableSpacing -> None]
Notice that the pink dot is roughly centered between the two lines, and there is no excess space around the text. If the dots are resized the alignment is retained:
Now compare the result of Grid
:
{
{dot, Item[#, Alignment -> Left], \[SpanFromLeft], \[SpanFromLeft]},
{\[SpanFromAbove], Item[#2, Alignment -> "."], #3, #4 "cms"}
} & @@@ dat;
Grid[Join @@ %,
Alignment -> {Center, Center},
Spacings -> {Automatic, 0},
Dividers -> All
]
The spacing and alignment is all wrong because the second element on the first row of each pair (e.g. "Angel Falls") is given the vertical size of the dot. If the dots are a different size the alignment changes:
How can I get the vertical alignment shown in the TableForm
example while retaining all the features of Grid
?
To clarify, it is fine if the lines end up further apart when the size of the dot is increased, but they should remain centered. Also, I expect that when the size of the dot is twice as high as a line of text (or other objects) that there will be no extra space. To fully answer this question I need a way for the cell containing "Angel Falls" to have less height than the dot.
TableForm
a nestedGridBox
likeGridBox[{{GraphicsBox[...],GridBox[...]},{GraphicsBox[...],GridBox[...]}, ...}]
? $\endgroup$