Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align first column and first row in Grid independently from others?

How to specify separate alignments for the first column (excluding first row in this column), first row (excluding first element in this row) and all other elements in the Grid? It is preferable to do this just with Alignment option of Grid preserving tight control given by Item[] with Alignment option for more tight purposes.

P.S. This question comes from previous question but I wish to get individual control over alignments of horizontal and vertical table headings here.

like image 893
Alexey Popkov Avatar asked Oct 17 '25 11:10

Alexey Popkov


1 Answers

I have found several ways to achieve what I want. The most direct solution is:

Grid[Table[Row@(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

Other solutions include:

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

enter image description here

like image 89
Alexey Popkov Avatar answered Oct 18 '25 23:10

Alexey Popkov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!