Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried to align the labels on the buttons of a SetterBarto the button centers. This is my code:

lis = {"1", "2", "3", "dsf"};
  Table[lis[[iteration]], {iteration, 1, 4}], 
  BaseStyle -> {Red, Alignment -> {Center, Center}}, {ImageSize -> {100, 50}}]

How do I get the labels of the buttons aligned to their centers? Can any one show me how?

share|improve this question
I see that you have not Accepted any answers. Please read this FAQ. – Mr.Wizard Jan 11 '13 at 8:30
there are some syntax problems with the way you have written your options. Alignment is not an option for BaseStyle. Also no need to use Table. Just use lis or {"1", "2", "3", "dsf"}directly. – Mike Honeychurch Jan 11 '13 at 8:37
up vote 8 down vote accepted
SetterBar[Dynamic[buttonValue], {"1", "2", "3", "dsf"}, BaseStyle -> Red, 
Alignment -> {Center, Center}, ImageSize -> {100, 50}]

Mathematica graphics

share|improve this answer
Nine seconds! :-) – Mr.Wizard Jan 11 '13 at 8:35
yeah just happened to pass by before shutting the computer down and having a beer :) – Mike Honeychurch Jan 11 '13 at 8:35
Enjoy, Mike. . . . – Mr.Wizard Jan 11 '13 at 8:36
This answer works, but I have a small quarrel with it. According to the Mathematica documentation, Alignment and ImageSize aren't valid options for SetterBar and the FrontEnd code editor agrees, highlighting them in red. I infer from this that users can not rely on these options working in the future. – m_goldberg Jan 11 '13 at 21:15
@m_goldberg what you have noticed looks like a bug (red styling) or oversight in the documentation. SetterBar is ultimately just a Grid of Setters and Alignment is a valid option of Setter. – Mike Honeychurch Jan 11 '13 at 21:20

I would change the Table into a Map:

lis = {"1", "2", "3", "dsf"}; 
SetterBar[Dynamic[buttonValue], Style[#, Red] & /@ lis, 
{ImageSize -> {100, 50}}, {Alignment -> Center}]

gives a SetterBar with centered labels.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.