2
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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 $\endgroup$ – Mike Honeychurch Feb 7 '15 at 5:34
  • $\begingroup$ @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. $\endgroup$ – Nasser Feb 7 '15 at 5:51
  • $\begingroup$ 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}] $\endgroup$ – kglr Feb 7 '15 at 6:11
  • $\begingroup$ @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. $\endgroup$ – Nasser Feb 7 '15 at 6:28
  • $\begingroup$ @kguler fyi, I updated the question to only for the font issue. Thanks to your hint, the spacing issue is no longer a problem. $\endgroup$ – Nasser Feb 7 '15 at 6:40
3
$\begingroup$

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

$\endgroup$
  • $\begingroup$ Thanks. I modified my question also to mention the spacing issue only, to reduce confusion. I think your solution is very good. $\endgroup$ – Nasser Feb 7 '15 at 7:11
  • $\begingroup$ @Nasser, my pleasure... thank you for the accept. $\endgroup$ – kglr Feb 7 '15 at 7:19

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.