3

Reference my old questions, How to use LaTeX for typesetting labels and titles in Mathematica and LaTeX and Mathematica.

The problem is simple to explain. When I do this

p = Plot[0, {x, 0, 2},
  Epilog -> Text[
    Style[ToExpression["\\sin(x\\,y)", TeXForm, HoldForm], Large], {1, .5}]
  ]

Mathematica graphics

The spacing between x and y is too large. Is there a way to reduce it?

I am using version 10.0.2 on Windows.

Nasser
  • 143,286
  • 11
  • 154
  • 359
  • I normally use an invisible space for typesetting things such as (x y). Can't help you with the second part. LaTeX fonts always look different to everything else IMO – Mike Honeychurch Feb 07 '15 at 05:34
  • @MikeHoneychurch adding invisible space does not work for TeXForm, it still appears as one letter xy. Screen shot: Mathematica graphics which is the issue mentioned above by Jens about the spacing. – Nasser Feb 07 '15 at 05:51
  • Does the option ZeroWidthTimes->True help with the first issue? I.e., Text[Style[ToExpression["\\sin(x\\,y)", TeXForm, HoldForm], Large, ZeroWidthTimes -> True], {1, .5}] – kglr Feb 07 '15 at 06:11
  • @kguler that is a nice trick. Yes, it helped a lot. Now the spacing is OK and can live with it. I'll update my question with your suggestion so it is all in one place. I guess now only the font issue is left. I am looking to see if there is a font setting to use. – Nasser Feb 07 '15 at 06:28
  • @kguler fyi, I updated the question to only for the font issue. Thanks to your hint, the spacing issue is no longer a problem. – Nasser Feb 07 '15 at 06:40
  • @Nasser, glad to know that it works for version 10.0.2 too -- i had no way of checking. – kglr Feb 07 '15 at 06:43

1 Answers1

4

Using the option ZeroWidthTimes->True in Style solves the spacing problem:

expr = Style[ToExpression["\\sin(x\\,y)", TeXForm, HoldForm], Large, ZeroWidthTimes -> True];

Plot[0, {x, 0, 2}, Epilog -> Text[expr, {1, .5}]]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896
  • Thanks. I modified my question also to mention the spacing issue only, to reduce confusion. I think your solution is very good. – Nasser Feb 07 '15 at 07:11
  • @Nasser, my pleasure... thank you for the accept. – kglr Feb 07 '15 at 07:19