6
$\begingroup$

Rationale: Imagine you would like to create a publication quality figure in Mathematica, from under Linux. Naturally, it will contain text/labels.

Problem: Here is a simple string "Amin,new".

Export it into pdf with Export command, and get instead: $\text{Amin ,new}$

Note that space before comma!

Question: How to avoid it?

Some ideas:

As pointed out here: The space in default output of `ExportString` to Latex

It seems like mathematica inserts extra spaces into strings when it recognizes command-like structures.

For example, this string "Xgkx,new" gets exported rather successfully with no extra spaces.

Additionally, the extra space does not occur if "," is removed, but does occur if "," is replaced by ":", ";" or probably other thin symbols.

This way, avoiding certain string sequences circumvents the problem, but is there a better way to solve it?

System: Ubuntu 14.04, Mathematica 10.0.2

Note: The problem does not occur on Mac, Windows, or in (Linux + Mathematica 9). Hence, it must be a bug (Wolfram support informed).

$\endgroup$
  • 1
    $\begingroup$ How exactly do you export? I can not reproduce your observation str = "Amin,new"; Export["str.pdf", str], works fine, without the extra space (my System: Mac OS X. MMA 10.0.2.0 $\endgroup$ – mgamer Jan 31 '15 at 11:54
  • $\begingroup$ @mgamer: Exactly this way, Export["str.pdf","amin,new"]. It seems therefore that it is a bug, and it is system-dependent. $\endgroup$ – Alexey Bobrick Jan 31 '15 at 13:57
  • $\begingroup$ Windows 8 x64, Mathematica 10.0.1.0 - no spaces. Sorry for a dumb question, but... are you positive it's not a problem of Ubuntu's pdf viewer? AFAIK there's no Adobe Reader there (except under Wine)? Could you see if that particular .pdf file that displays so badly in Ubuntu behaves any better under Mac? Under official Adobe Reader? $\endgroup$ – gaazkam Jan 31 '15 at 16:13
  • 1
    $\begingroup$ Adobe Reader 11.0.10 on Windows shows a big fat nasty space. All right, so it's not just Okular. $\endgroup$ – gaazkam Jan 31 '15 at 19:39
  • 1
    $\begingroup$ There are a number of weird spacing and positioning issues when exporting mildly complex formulas to PDFs. Just like you, I wanted to use these formulas as labels or annotations in publication figures. My workaround now is to use LaTeX to create these labels, through a small package I wrote. You might find it useful too, until the bug gets fixed. $\endgroup$ – Szabolcs Apr 1 '15 at 14:08
4
$\begingroup$

As confirmed by WRI, it is a bug, which is specific to Linux and which was introduced in version 10.0.2.

No workaround known yet except for two possible recommendations, especially when it comes to plot labels:

  1. Avoid using commas or other short symbols like ":", ";" or maybe even "|".
  2. Try renaming your variables so that string sequences before the short symbol does not resemble commands.

Edit: The bug is still there in MMA 10.1

$\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.