# Grid rows height & SpanFromAbove issue

Bug introduced in 9 or earlier and persisting through 11.3

I would like to understand why the following code produces such a different result (Mathematica 9, Win7). Is this a bug? Is there a way to avoid this line height problem?

Grid[
{{"a", "b", "c", "d"},
{"L1\nL2\nL3", "e", SpanFromLeft, "f"},
{SpanFromAbove, "g", SpanFromLeft, "h"},
{SpanFromAbove, "i", SpanFromLeft, "j"},
{SpanFromAbove, "k", SpanFromLeft, "l"}}, Dividers -> All]


Grid[
{{"a", "b", "c", "d"},
{"L1\nL2\nL3", "e", "m", "f"},
{SpanFromAbove, "g", SpanFromLeft, "h"},
{SpanFromAbove, "i", SpanFromLeft, "j"},
{SpanFromAbove, "k", SpanFromLeft, "l"}}, Dividers -> All]


UPDATE:

Maybe I oversimplified my need making the question difficult to understand. Here is a more practical example of the problem:

Grid[
{{"", SpanFromLeft, "simple\nmodel", "improved\nmodel"},
{"Test\nSim\nParams", "param1 =", 1, SpanFromLeft},
{SpanFromAbove, "param2 =", 2, 3},
{SpanFromAbove, "param3 =", 4, 5},
{SpanFromAbove, "param4 =", 6, 7}}, Dividers -> All]


• Is there any particular reason you didn't put "m" in the first one and what is the expected result? Aug 25, 2014 at 13:32
• The first one more closely matches the real (much bigger) table that I am working on. Aug 25, 2014 at 13:38
• @GustavoDelfino It's not clear what you need: are you saying you have data like the first table but want it to look like the second table? Aug 25, 2014 at 13:40
• I need the same row height for all rows in the first table. For some reason, when I merge two columns this becomes difficult. Aug 25, 2014 at 13:52
• This is a very good question, and I tried for several hours to find an answer. SpanFromLeft in the second row should not trigger SpanFromAbove, there is no apologize for such nasty behaviour. In my opinion it's a bug. Aug 25, 2014 at 20:35

## 1 Answer

I think the problem is that SpanFromLeft match the dimensions of the first cell in the row (which is "Test\nSim\nParams"). the first cell is bigger than the others in the same levels.

you may try some thing like this:

Grid[{
{"", SpanFromLeft, "simple\nmodel", "improved\nmodel"},
{"Test   ", "param1 =", 1, SpanFromLeft},
{"Sim\nParams", "param2 =", 2, 3},
{SpanFromAbove, "param3 =", 4, 5},
{SpanFromAbove, "param4 =", 6, 7}
},
Frame -> {All,
1 -> True, {{{3, 4}, {2, 4}} -> True, {{4, 4}, {2, 4}} -> True}}]


• Your answer is the closest to the updated question. Why don't you show the output ???
– eldo
Aug 25, 2014 at 22:51
• @eld, I was so busy. thanks. Aug 25, 2014 at 23:28
• (+1) Your assumption that SpanFromLeft match the dimensions of the first cell in the row contradicts the following: Grid[{{"","",SpanFromLeft,"simple\nmodel","improved\nmodel"},{"","Test\nSim\nParams","param1 =",1,SpanFromLeft},{"",SpanFromAbove,"param2 =",2,3},{"",SpanFromAbove,"param3 =",4,5},{"",SpanFromAbove,"param4 =",6,7}},Dividers->All]. Now the first cell in the row contains only "" but the heigh of the row is still the same. Aug 26, 2014 at 6:52
• Maybe SpanFromLeft matches the dimensions of the largest cell in the row. Aug 26, 2014 at 18:14