TransWikia.com

Grid alignment syntax

Mathematica Asked on May 20, 2021

This is a simple question, but I just cannot understand the explanation given in the Grid documentation page for how to set different alignments for different parts of a grid. I have a grid with two rows with four columns each, and I would like the top row to be bottom aligned and the bottom row to be top aligned. Or, in general, I want to specify one alignment per row (again, for a two row grid). How do I do this?

One Answer

mat = {{Column[{12, 34}], 123, 1234, 5}, {Column[{1, 2}], 3, 4, 5}};

The default is center aligned rows and columns

mat // Grid[#, Frame -> All] &

enter image description here

For top row to be bottom aligned and the bottom row to be top aligned

mat // Grid[#, Frame -> All,
   Alignment -> {Automatic, {Bottom, Top}}] &

enter image description here

You can specify any desired Alignment

mat // Grid[#, Frame -> All,
   Alignment -> {{Center, Left, Right, Center}, {Bottom, Top}}] &

enter image description here

Correct answer by Bob Hanlon on May 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP