4
$\begingroup$

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?

$\endgroup$

3 Answers 3

4
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ Why do you need Row here? $\endgroup$
    – Mr.Wizard
    Jul 30, 2013 at 21:07
  • $\begingroup$ @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. $\endgroup$
    – m_goldberg
    Jul 31, 2013 at 4:13
4
$\begingroup$

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

$\endgroup$
3
  • $\begingroup$ +1 - cool to use named styles, makes it clearer. $\endgroup$
    – Jens
    Jul 30, 2013 at 21:55
  • 1
    $\begingroup$ 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 $\endgroup$ Jul 30, 2013 at 23:04
  • $\begingroup$ @Mike Great idea! $\endgroup$
    – Mr.Wizard
    Jul 30, 2013 at 23:06
3
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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