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

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

    %% AMS-LaTeX Created by Wolfram Mathematica 9.0 : www.wolfram.com\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.


1 Answer 1


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.

  • $\begingroup$ 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. $\endgroup$ Jan 30, 2015 at 19:25
  • $\begingroup$ @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). $\endgroup$
    – Jens
    Jan 30, 2015 at 19:32
  • $\begingroup$ 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$. $\endgroup$ Jan 30, 2015 at 19:40
  • $\begingroup$ @AlexeyBobrick That's probably a completely different issue. You might try this answer instead. $\endgroup$
    – Jens
    Jan 30, 2015 at 19:55
  • $\begingroup$ 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. $\endgroup$ Jan 30, 2015 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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