4

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?

Sektor
  • 3,320
  • 7
  • 27
  • 36
Sofic
  • 673
  • 3
  • 8

3 Answers3

4

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

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
  • 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 04:13
4

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

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
3

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

Jens
  • 97,245
  • 7
  • 213
  • 499