4
$\begingroup$

As titled above, How I can justify and how I can change the space between columns in this Grid specified below:

m=4;   
x={1,2,3,4};
F = Table[i, {i, m}, {j, m - i + 1}]; 
head={"Subscript[x, i]","f(Subscript[x, i])"};
data=Table[0,{m+1}];
data[[1]]=Column[x];
For[i=2,i<=m,i++,
    data[[i]]=Column[F[[i-1]]];
  ];
Grid[Join[{head},{data}],Dividers->{3->Blue,2->Blue},Alignment->Right]

I want the space of elements to increase vertically, but by using the Spacing command it doesn't get increased; and by vertically align I mean for example the 2 number in the following to be aligned center vertically

Grid[{{1, 2, 3}, {4, SpanFromAbove, 6}, {7, 8, 9}}, Frame -> All]

This this what Mathematica gives to me

enter image description here

and this is what I want: (something like this) but according to my codes

enter image description here

I have displayed frames of elements for illustration purposes only below

enter image description here

$\endgroup$
  • $\begingroup$ @Kuba the post has been updated. please take a look. $\endgroup$ – NoMan Feb 1 '15 at 14:30
  • $\begingroup$ Is this what you want? Grid[{{1, 2, 3}, {4, SpanFromAbove, 6}, {7, 8, 9}}, Alignment -> {Center, Center}, Frame -> All] $\endgroup$ – Mike Honeychurch Feb 1 '15 at 21:56
  • $\begingroup$ @MikeHoneychurch Thanks, it works for half of my question! but not according to my main question. $\endgroup$ – NoMan Feb 2 '15 at 7:15
  • $\begingroup$ old, slightly related topic: 25957 $\endgroup$ – Kuba Feb 2 '15 at 8:28
3
$\begingroup$
    (*auxiliary functions*)
wrap = Function[item, Pane[item, {90, 90/GoldenRatio}, FrameMargins -> 0, 
                                 ImageMargins -> 0, Alignment -> Center]
                , Listable];

grid = Grid[#, Spacings -> {0, 0}, Alignment -> {Left, Center}] &;

    (*I don't know what you are doing so I'm making up data:*)
data = wrap@{{2 #, #}, {##2}} & @@ Table[ RandomInteger[{-10, 10}, i]/2, {i, 5, 1, -1}];

lbl = wrap @ {"x_i", "f(x_i)"};


Grid[{
  {grid[{lbl}], ""},
  {grid@Transpose@First@data, 
   grid[{grid[Transpose[{#}]] & /@ Last@data}]}
  }, Spacings -> {0, 0}, 
     Dividers -> {{2 -> {Blue, Thickness@5}}, {2 -> {Blue, Thick}}}, 
     BaseStyle -> {18, Bold, ScriptSizeMultipliers -> 1}]

enter image description here

I love grid.

$\endgroup$
  • $\begingroup$ It's awesome answer, Thank you very much. $\endgroup$ – NoMan Feb 2 '15 at 22:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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