Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 2 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

Your Answer

 
discard

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.