5
$\begingroup$

I am creating a figure for a document using Graphics in which there is Text with some variables and again those same variables with some subscripts. The Text with subscript is automatically Italic. I do not want this, especially because it contrasts with the variables without subscript which are not Italic. How can I change this behaviour?

$\endgroup$
  • 4
    $\begingroup$ PleasePostAPicture.png $\endgroup$ – Öskå Aug 10 '14 at 19:06
  • 2
    $\begingroup$ Does Text[yourtext, FormatType -> StandardForm] give what you need? $\endgroup$ – kglr Aug 10 '14 at 19:06
  • $\begingroup$ Graphics[{Text["P", {0, 0}], Text["\!(*SubscriptBox[(P), (q)])", {1/4, 0}], Text["\!(*SubscriptBox[(P), (q)])", {2/4, 0}, FormatType -> StandardForm]}] Yes, it does. Thank you kguler. $\endgroup$ – LBogaardt Aug 10 '14 at 19:12
  • 1
    $\begingroup$ I recommend Text[Style[Subscript["P", "q"], 32], {2/4, 0}] $\endgroup$ – m_goldberg Aug 11 '14 at 3:31
  • $\begingroup$ Related: (19364) $\endgroup$ – Mr.Wizard May 5 '15 at 4:58
4
$\begingroup$

I think this is nice, easy way to do it that will not affect the displayed font,

Graphics[Text[Style[Subscript["P", "q"], 36], {1/2, 0}], ImageSize -> Tiny]

pq

Update

The OP asks, "Is there an easy way to use this trick within a sentence?"

I ask, what is easy? But here is something using Row and not too difficult.

Graphics[
  Text[Row[{"The variable ", Subscript["P", "q"], " is positive"}], {0, 0}],
  BaseStyle -> {FontSize -> 14},
  AspectRatio -> 1/6,
  ImageSize -> Small]

sentence

$\endgroup$
  • $\begingroup$ Interesting how 'Text[Style[Subscript["P", "q"], 36], {1/2, 0}]' and 'Text[Style[Subscript[P, q], 36], {1/2, 0}]' makes a difference. $\endgroup$ – LBogaardt Aug 12 '14 at 11:07
  • $\begingroup$ It is because in the first case P is a String while in the second case it is a variable. $\endgroup$ – Alexey Popkov Aug 12 '14 at 14:14
  • $\begingroup$ Is there an easy way to use this trick within a sentence? As in something like 'Text["The variable"<>Subscript["P", "q"]<>"is positive", {0, 0}]'. $\endgroup$ – LBogaardt Aug 20 '14 at 18:18
  • $\begingroup$ Well done! Thank you for the quick update. $\endgroup$ – LBogaardt Aug 20 '14 at 22:48
4
$\begingroup$

While I think that m_goldberg's solution is the simplest when you type the text by hands, here is the convenient way to disable italicization of single letters which will work in all cases:

Graphics[Text[
  Style[Subscript[P, q], 36, "SingleLetterItalics" -> False], {1/2, 
   0}], ImageSize -> Tiny]

graph

$\endgroup$
1
$\begingroup$

Use the option FormatType -> StandardForm inside Text.

Using the example in OP's comment:

Graphics[{Circle[], 
          Text[Style["P", 32], {0, 0}], 
          Text[Style[Subscript[P, q], 32], {1/4, 0}], 
          Text[Style[Subscript[P, q], 32], {2/4, 0}, FormatType -> StandardForm]}]

enter image description here

$\endgroup$
  • $\begingroup$ Interesting how 'Text[Style[Subscript["P", "q"], 36], {1/2, 0}]' and 'Text[Style[Subscript[P, q], 36], {1/2, 0}]' makes a difference. $\endgroup$ – LBogaardt Aug 12 '14 at 11:07

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.