# Extra spaces when exporting strings into pdf (bug, linux)

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).

• 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 – mgamer Jan 31 '15 at 11:54
• @mgamer: Exactly this way, Export["str.pdf","amin,new"]. It seems therefore that it is a bug, and it is system-dependent. – Alexey Bobrick Jan 31 '15 at 13:57
• 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? – gaazkam Jan 31 '15 at 16:13
• Adobe Reader 11.0.10 on Windows shows a big fat nasty space. All right, so it's not just Okular. – gaazkam Jan 31 '15 at 19:39
• 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. – Szabolcs Apr 1 '15 at 14:08