问题
Considering the following :
Manipulate[
If[Intersection[Row1, Row2] == {},
Style[Plus @@ {Plus @@ Row1, Plus @@ Row2}, Bold, 20],
"Error"],
{{Row1, {1}}, {1, 2, 3, 4, 5}, ControlType -> TogglerBar},
{{Row2, {2}}, {1, 2, 3, 4, 5}, ControlType -> TogglerBar}
]

- I would like the "3" to be centered, is it possible ?
回答1:
Manipulate has its own Alignment option. You can see if that works for you:
Manipulate[
If[Intersection[Row1,Row2]=={},Style[Plus@@{Plus@@Row1,Plus@@Row2},Bold,20],"Error"],
{{Row1,{1}},{1,2,3,4,5},ControlType->TogglerBar},
{{Row2,{2}},{1,2,3,4,5},ControlType->TogglerBar},
Alignment->Center
]

回答2:
Use a Panel
, with the Alignment
option:
Manipulate[
Panel[
If[Intersection[Row1, Row2] == {},
Style[Plus @@ {Plus @@ Row1, Plus @@ Row2}, Bold, 20], "Error"
],
ImageSize -> 150, Alignment -> Center, Appearance -> "Frameless"
],
{{Row1, {1}}, {1, 2, 3, 4, 5}, ControlType -> TogglerBar},
{{Row2, {2}}, {1, 2, 3, 4, 5}, ControlType -> TogglerBar}
]
来源:https://stackoverflow.com/questions/6469288/adding-alignment-to-a-manipulate-ouput-in-mathematica