5
$\begingroup$

When I execute this

Grid[{{x, x}, {SpanFromAbove, x}, {SpanFromAbove, x}}, 
 ItemSize -> {{Automatic}, 
  {Automatic, {1 -> Scaled[0.2], 2 -> Scaled[0.4], 3 -> Scaled[0.4]}}}, 
 Frame -> All, 
 Alignment -> {Center, Center}, Spacings -> {{2}, {1}}]

I get an extremely tall grid instead of a normal height grid. Is this a bug or am I doing something wrong? Version 10.0.1 Win8.1 64bit

Update

This just keeps getting worse. I am have used a Pane as some have suggested that the grid needs a sized container for it to work with Scaled. I get back a truncated grid. This is really baffling. Any ideas how to get this to work.

Pane[
 Grid[{{x, x}, {SpanFromAbove, x}, {SpanFromAbove, x}}, 
  ItemSize -> {{{Scaled[0.5]}}, 
   {Automatic, {1 -> Scaled[0.2], 2 -> Scaled[0.4], 3 -> Scaled[0.4]}}}, 
  Frame -> All, Alignment -> {Center, Center}, Spacings -> {{1}, {1}}], 
 ImageSize -> {432, 216}]

Mathematica graphics

It gives a cut off grid. ??? I can just make out the top of the "x" in the first column. It shouldn't be this difficult to have a grid a prescribed size and scale some rows within it. I must be doing something wrong.

$\endgroup$
8
  • 1
    $\begingroup$ Unles you wrap Grid with something with set size, Scaled will refer to WindowSize. $\endgroup$
    – Kuba
    Commented Nov 24, 2014 at 12:40
  • $\begingroup$ So I need to wrap it in a Pane or Panel and that will work? $\endgroup$
    – Edmund
    Commented Nov 24, 2014 at 13:47
  • $\begingroup$ @Edmund The qustion is, what do you need? $\endgroup$
    – Kuba
    Commented Nov 24, 2014 at 13:47
  • $\begingroup$ @Silvia Edmund set Item height not width. specx here is {Automatic} and it is width of items. But for specy he set explicitly 1->Scaled[.4] etc. what means "first row heigth 40% of enclosing region. $\endgroup$
    – Kuba
    Commented Nov 24, 2014 at 13:51
  • 2
    $\begingroup$ @Silvia But I agree, the whole layout management is broken. For example here, Scaled takes something different into account: Framed["x", ImageSize -> {Scaled@1, Scaled@1}] $\endgroup$
    – Kuba
    Commented Nov 24, 2014 at 13:53

1 Answer 1

3
$\begingroup$

My advice, unless it is really basic problem, do not use SpanFrom~. Usually you will face "issues" like that. Next time try with nested Grids.

Like I've said, the whole layout management is broken and everyone who tried do something more complex than simple grid with automatic options will agree.

This is just another example, your case works if vertical heights sum up to: .5...

Framed[
 Grid[{
       {x, x},
       {SpanFromAbove, x},
       {SpanFromAbove, x}},
  ItemSize -> {
               {{[email protected]}},                  (*specX*)
               {[email protected], [email protected], [email protected]} (*specY*)
    }, Frame -> All, Alignment -> {Center, Center}, Spacings -> {0, 0}]
 , 
     ImageSize -> {432, 216}, FrameMargins -> 0, Alignment -> {Left, Top}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.