Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I need to stack three objects on top of each other and align the first two to the center and the third one to the left. I've been trying to do this with Column, but it won't let me align the objects differently. The code below should make clear what I'm trying to do:

Column[{Style["Title", FontSize -> 20, "Title"],Graphics@Disk[],Style["Footnote text..."]}, 
  {Center, Center, Left}]

I want the title and the disk to be centered, but the footnotes aligned to the left. Anyone know how to do this?

share
    
You need to accept an answer on this question too :) –  Öskå May 13 at 9:08

2 Answers 2

up vote 7 down vote accepted

You can use Item to specify and individual alignment:

Column[{
  Style["Title", FontSize -> 20, "Title"],
  Graphics@Disk[],
  Item[Style["Footnote text..."], Alignment -> Left]
  }, 
Alignment -> Center]

or use the Alignment specification as per @Oska example. Remember that Column is a GridBox so also see Grid docs for a larger number of options examples.

enter image description here

Column[{
  Style["Title", FontSize -> 20, "Title"],
  Graphics@Disk[],
  Style["Footnote text..."]
  },
 Alignment -> {Center, Center, {{-1, 1} -> Left}}]
share
    
That way requires one less word. Thanks! –  Mas May 5 at 11:40

You can define a list of the expressions you want in your Column and an other, listAlign, of the placement that you wish:

list = {Style["Title", FontSize -> 20, "Title"], Graphics@Disk[], Style["Footnote text..."]};
listAlign = {Center, Center, Left};
Panel@Column[list, Alignment -> {{}, {}, 
  Rule @@@ Thread[{{#, 1} & /@ Range@Length@list, listAlign}]}]

enter image description here

Then, working on a bigger list is much easier:

list = RandomChoice[{Style["Hello", FontSize -> 20, Bold], 
  Style["Hello"], Style["Hello", Tiny]}, 9]~Join~{"Bye"};
listAlign = RandomChoice[{Left, Center, Right}, 10];
Panel@Column[list, 
  Alignment -> {{}, {}, 
    Rule @@@ Thread[{{#, 1} & /@ Range@Length@list, listAlign}]}]

enter image description here

share
    
I see. So separate column every time I want to change the alignment.Thanks –  Mas May 5 at 11:36
    
@Mas check the updated answer, it is now easier :) –  Öskå May 5 at 12:37

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .