Bug introduced in 6.0 and persisting through 11.0.1 or later
Grid
ang ItemStyle
are new in 6.0
I would expect the following to output the same grids
{Grid[{{1, 2}, {3, 4}}, ItemStyle -> {, , {{1, 1} -> Directive[30]}},
Background -> {, , {{1, 1} -> Red}}, Frame -> All],
Grid[{{1, 2}, {3, 4}},
ItemStyle -> {, , {{1, 1} -> Directive[Background -> Red, 30]}},
Frame -> All],
Grid[{{NumberForm@1, 2}, {3, 4}},
ItemStyle -> {, , {{1, 1} -> Directive[Background -> Red, 30]}},
Frame -> All]}
instead of
Update:
The following should all produce identical grids and in fact they (almost) do - provided you mix and match between different Mathematica versions:
{Grid[{{1, 2}, {3, 4}},ItemStyle -> {None, None,{{1, 1} -> Directive[30]}},Background -> {, , {{1, 1} -> Red}}, Frame -> All],
Grid[{{1, 2}, {3, 4}},ItemStyle -> {{} , {},{{1, 1} -> Directive[Background -> Red, 30]}}, Frame -> All],
Grid[{{NumberForm@1, 2}, {3, 4}},ItemStyle -> {Automatic,Automatic, {{1, 1} -> Directive[Background -> Red, 30]}}, Frame -> All],
Grid[{{Item[1, BaseStyle -> {Background -> Red, FontSize -> 30}],2}, {3, 4}},Frame -> All],
Grid[{{Item[Style[1, 30], Background -> Red], 2}, {3, 4}},Frame -> All]}
V6:
V7
V8
V9
The "almost" is that the second Grid - perhaps the cleanest implementation - is yet to fire but perhaps in V10 ...?
(As a side note, n.b. the alternative padding (None
,Automatic
,{}
,,
}) to reach the cell specification in the ItemStyle
option - maybe one day argument positions might more seamlessly combine with their structure? )
Upshot: There seems to be a bug in combining values for the Background
option with other styling within a single Directive
but this can be easily overcome by using both specifications as per the first Grid above.
An improperly formatted directive with head Symbol was encountered
$\endgroup$Grid[{{1, 2}, {3, 4}}, ItemStyle -> {None, None, {{1, 1} -> Directive[30]}}, Background -> {None,None, {{1, 1} -> Red}}, Frame -> All]
is OK. No error. $\endgroup$