2011-08-17 13 views

回答

4

我已經找到了幾種方法來實現我想要的。最直接的解決辦法是:

Grid[Table[[email protected](Range[a]), {a, 1, 4}, {7}], 
Alignment -> {Right, 
    Automatic, {{{2, -1}, {1, 1}} -> Left, {{1, 1}, {2, -1}} -> 
    Center}}, Dividers -> {{2 -> True}, {2 -> True}}] 

enter image description here

其他解決方案包括:

Grid[Table[[email protected][a], {a, 1, 4}, {7}], 
Alignment -> {{Left, {Right}}, 
    Automatic, {{1, 1}, {1, -1}} -> Center}, 
Dividers -> {{2 -> True}, {2 -> True}}] 
Grid[Table[[email protected][a], {a, 1, 4}, {7}], 
Alignment -> {Right, 
    Automatic, {1 -> Left, {{1, 1}, {2, -1}} -> Center}}, 
Dividers -> {{2 -> True}, {2 -> True}}] 
Grid[Table[[email protected][a], {a, 1, 4}, {7}], 
Alignment -> {Right, 
    Automatic, {1 -> Left, {{1, 1}, {1, -1}} -> Center}}, 
Dividers -> {{2 -> True}, {2 -> True}}] 
Grid[Table[[email protected][a], {a, 1, 4}, {7}], 
Alignment -> {Right, 
    Automatic, {{{1, 1}, {1, -1}} -> Center, 1 -> Left}}, 
Dividers -> {{2 -> True}, {2 -> True}}] 

enter image description here

3

它看起來像Alignment使用相同的語法爲GridBackground所以它可能會幫助看看Options > Background的文檔中的Grid的例子。

例如,假設要對齊左底部的第一行和第一列右上角和所有其他項目中的項目,你可以不喜歡

Grid[RandomInteger[10, {5, 5}], ItemSize -> {3, 3}, Frame -> All, 
Alignment -> {Left, Bottom, {{1, 1} -> {Right, Top}}}] 

grid with different alignment for item {1,1}

+0

你已經取得相反的事情正在發生的事情的問題說:我不需要修改表中的第一個元素的排列,但所有其他元素的第一行中的定位和第一列。 – 2011-08-17 14:23:53

+1

@Alexey:設置`{{1,1} - > None}`而不是`{{1,1} - > {Right,Top}`應該可以工作。 – Heike 2011-08-17 14:32:35

+0

同樣,這不是我想要的。但是現在我自己解決了這個問題。無論如何謝謝你。 – 2011-08-17 15:32:02

3

如果我理解你的要求,我贊成這樣做有Item如下:

x = Array[\[HappySmiley] &, {5, 5}]; 

x = ReplacePart[x, 
     i : Except[{1, 1}, {_, 1} | {1, _}] :> 
     Item[x~Extract~i, Alignment -> Left] 
    ]; 

Grid[x, ItemSize -> {3, 3}, Frame -> All] 

enter image description here

相關問題