The usual quick-and-dirty workaround when ItemSize
does not do what is expected is to wrap contents into an invisible frame. One can use Framed
with FrameStyle->None
to hide the frame or Pane
. In both cases, a magic number is required to convert between line-height of Grid
and printers points of Framed
/Pane
- it is highly platform-specific (see here). The simplified example with Pane
:
dot = Graphics[{Pink, Disk[]}, ImageSize -> 40];
magic = 10;
tab = {
{"Type", "Name", \[SpanFromLeft], \[SpanFromLeft], dot,
"Esculap", \[SpanFromLeft], \[SpanFromLeft]},
{\[SpanFromAbove], "Dia.",
"Spec", \[SpanFromLeft], \[SpanFromAbove], 8.3 "mm",
Pane[11, {Automatic, 2.7*magic}, Alignment -> Center], "6.3"},
{dot, "Flycatcher", \[SpanFromLeft], \[SpanFromLeft], dot,
"Apus", \[SpanFromLeft], \[SpanFromLeft]},
{\[SpanFromAbove], 6.9 "mm", 17, "9.8", \[SpanFromAbove], 7.8 "mm",
Item[8, ItemSize -> {Automatic, 2.7}], "6.7"}
};
Grid[tab, Spacings -> {Automatic, {{0, -1.1}}},
Alignment -> {Center, Center}, Dividers -> All]
One can get rid of the overhang (gap with missing dividers) by wrapping Item
around the cell:
Item[Pane[11, {Automatic, 2.7*magic}, Alignment -> Center]]
This issue of gaps is only present in version 8. My guess is that as ContentPadding -> True
was added to Pane
in version 8 only, in version 7 a different behaviour is the default for padding inside Pane
that does not introduce these gaps. However, calling the above example with ContentPadding -> False
in v8 does not remove the gaps contradily to my expectations.
An almost identical result can be obtained if given cell is wrapped in Framed
(note the horizontal increase in size of the cell):
Framed[11, ImageSize -> {Automatic, 2.7*magic}, FrameStyle -> None]