Top] ...">

How to align Row [] elements with bottom or top in Mathematica?

When I write

Row[ { Framed@Column [{1,2}], Framed@ "123"}, Alignment->Top] 

Mathematica graphics

or

 Row[ { Framed@Column [{1,2}], Framed@ "123"}, Alignment->{Left,Top}] 

Mathematica graphics

in any case, nothing happens. The default alignment is the center, and the elements are listed according to the environment.

 Grid[ {{ Framed@Column [{1,2}], Framed@ "123"}}, Alignment->Top] 

Mathematica graphics

works just fine, but Grid[] is redundant when Row[] enough.

The help system says that alignment should work (the {Left,Baseline} list as an example), but it doesn't seem to be mutable. I am using v8.0.4.

+4
source share
2 answers

The Alignment parameter in Row does not align individual elements on their own, but rather these elements in an external bounding box. This can be seen with

 Framed@Row [{ Framed@Column [{1, 2}], Framed@ "123"}, ImageSize -> {150, 150}, Alignment -> {Left, Top}] 

enter image description here

 Framed@Row [{ Framed@Column [{1, 2}], Framed@ "123"}, ImageSize -> {150, 150}, Alignment -> {Center, Bottom}] 

enter image description here

Use a Grid instead.

+3
source

As Mr.Wizard Grid said, probably your best bet, but if you want to use Row , you can do something like

 Row[Pane[#, BaselinePosition -> Top] & /@ { Framed@Column [{1, 2}], Framed@ "123"}] 

aligning elements at the top

Note that Framed also has a BaselinePosition option, so for this specific example, you can also do something like

 Row[Framed[#, BaselinePosition -> Top] & /@ {Column[{1, 2}], "123"}] 

but Pane works anyway.

+4
source

Source: https://habr.com/ru/post/1384603/


All Articles