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.

In the following Manipulate, the style (font?) of the a changes between when it is a control label and when it is a label in the graphics.

Is there a way to make the 'control a' look like the 'graphics a'?

Manipulate[
 Graphics[{
  Style[Text["a", {0, 0}], Italic, 14]},
  Axes -> False, PlotRange -> 3, ImageSize -> {100, 100}, 
  GridLines -> None],

 {{a, 0, Style[Text["a"], Italic, 14]}, 0, 100, 1}] 

I can't find anything in the stylesheet, that can help me. I have set the font of Output to 'Georgia', but I assume that I need to select the font somewhere else too?

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

Another way to do it; perhaps simpler than Jens method.

Manipulate[Graphics[
   {Style[Text["a", {0, 0}], Italic, 14]},
   Axes -> False, PlotRange -> 3, ImageSize -> {100, 100}, GridLines -> None],
 {{a, 0, Style["a", Italic, 14, FontFamily -> "Times"]}, 0, 100, 1}]

manipulate

share|improve this answer
    
Why do you need Row here? –  Mr.Wizard Jul 30 '13 at 21:07
    
@Mr.Wizard. Thanks for pointing it out. Just a bad habit I've gotten into, writing Row[{...}] automatically when I start a labeling expression because it makes editing the label to add further elements easy. I have edited the answer to remove the offending `Row. –  m_goldberg Jul 31 '13 at 4:13
add comment

It seems to me that there is a simpler form than shown in the other two answers, but I may be forgetting something.

Using Style[..., "Graphics"] seems more accurate to me than simply using a fixed typeface, and cleaner than the FormBox/TraditionalForm construct.

(Font made big for greater visibility.)

Manipulate[
  Graphics[{Style[Text["a", {0, 0}], Italic, 30]}, Axes -> False,
    PlotRange -> 3, ImageSize -> {100, 100}, GridLines -> None],
  {{a, 0, Style["a", "Graphics", Italic, 30]}, 0, 100, 1}
]

enter image description here

  • For even greater brevity, if one accepts a fixed typeface, you can use style "TI" (Times italic), e.g. Style["a", "TI", 30]

  • You can use LabelStyle (thanks, Mike) to affect all labels at once

Example:

Manipulate[
  Graphics[{Style[Text["a", {0, 0}], Italic, 30]}, Axes -> False,
    PlotRange -> 3, ImageSize -> {100, 100}, GridLines -> None],
  {a, 0, 100, 1},
  LabelStyle -> {"TI", 30}
]

enter image description here

share|improve this answer
    
+1 - cool to use named styles, makes it clearer. –  Jens Jul 30 '13 at 21:55
1  
I'd do it that way (named style) as well. Maybe also add a variation in which you make use of LabelStyle rather than use Style within the Manipulate label. Makes it cleaner IMO –  Mike Honeychurch Jul 30 '13 at 23:04
    
@Mike Great idea! –  Mr.Wizard Jul 30 '13 at 23:06
add comment

The default form for Text in Graphics is TraditionalForm, but it's not the same in the slider label of Manipulate. So you have to hard-code the desired form and also the fonts, if desired. For example, with Times font:

Manipulate[
 Graphics[{Style[Text["a", {0, 0}], FontFamily -> "Times", Italic, 
    14]}, Axes -> False, PlotRange -> 3, ImageSize -> {100, 100}, 
  GridLines -> None], {{a, 0, 
   DisplayForm@
    FormBox[StyleBox["a", FontFamily -> "Times"], TraditionalForm]}, 
  0, 100, 1}]

fonts

share|improve this answer
add comment

Your Answer

 
discard

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.