Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Are there any reasons for converting subscriptbox to Tex with space?

ExportString[Subscript[\[Alpha], 1], "TeX"]

    %% AMS-LaTeX Created by Wolfram Mathematica 9.0 :\documentclass{article}\u
sepackage{amsmath, amssymb, graphics, setspace}\newcommand{\mathsym}[1]{{}}\newcommand{\un
icode}[1]{{}}\newcounter{mathematicapage}\begin{document}\[\alpha _1\]\end{document}

Of course, I can remove the space in via the option "BoxRules", and $\alpha _1$ can also rendered well in SE.

But many people would edit my $\alpha _1$ into $\alpha_1$, do you know whether there are any reasons for the default space generated by ExportString?

The same to other boxes.

share|improve this question
up vote 3 down vote accepted

The spaces in LaTeX export are harmless, but I think there is a valid reason to insert them after any control sequence such as \alpha: it is the easiest way to avoid creating undefined control sequences in situations where \alpha is followed by a variables name like b that is not itself a control sequence. Without spaces, this would be translated to \alphab which is obviously undefined.

This problem only arises at the end of control sequences, it's no problem when there are just a couple of variable names like a b. For them, it's permissible to leave out the space entirely and LaTeX will nevertheless treat each single letter as a separate variable. Therefore, ExportString[Subscript[a b, 1], "TeX"] doesn't insert any extra spaces after b. It only does it after symbols that translate to control sequences such as \alpha.

I'm by no means saying that Mathematica's space insertion trick is the prettiest way to export LaTeX, but it's an easy (or you might say lazy) solution.

share|improve this answer
But is there a way to override this space insertion, say, when exporting text infoprmation into pdf? For example, I have a string $a_{min,obs}$, which renders as $a_{min~,obs}$, which doesn't look good. – Alexey Bobrick Jan 30 '15 at 19:25
@AlexeyBobrick The correct way to enter textual subscripts would be to enclose them in quotation marks in the Mathematica expression. I.e., "min" etc. It gets translated to \text{min}, which is the right way to present multi-letter symbols in LaTeX (you should never simply write multi-letter names as plain characters in LaTeX because they're typeset as separate variables). – Jens Jan 30 '15 at 19:32
I should have been a bit more specific here, but I actually intend to export directly from Mathematica into pdf, not into latex however. The problem, though, is very similar to the one above. If I write Subscript["a", "min,obs"] and export it into pdf as part of a table, I get a string, which has an extra space after $min$. – Alexey Bobrick Jan 30 '15 at 19:40
@AlexeyBobrick That's probably a completely different issue. You might try this answer instead. – Jens Jan 30 '15 at 19:55
The function toPDF gives the same space after min. I would think the problem is different, but it seems that extra spaces appear only after operator-like strings, like "min", or "circ" etc. Unlike in this question, however, it is not obvious, at each stage the extra spaces can be removed. – Alexey Bobrick Jan 30 '15 at 20:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.