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.

The instruction :

DisplayForm[RowBox[List[0,1,Superscript[2,3],Superscript[1,2],a]]]

displays a gap between the first two items of the list

enter image description here

but if one is careful not to have two consecutive integers, there is no gap

DisplayForm[RowBox[List[0,a,1,Superscript[2,3],Superscript[1,2],a]]]

enter image description here

I would like to know if there is a way to disable (locally) the space inserted by Mathematica between two integers in this case to have something like that:

enter image description here

I would like the result to stay a TagBox or InterpretationBox, easy to copy/paste, if possible.

share|improve this question
    
Out of upvotes for another 5 hours, otherwise +1, it's an interesting question. –  rcollyer Jan 18 '12 at 18:24
1  
@rcollyer Let me do that for you. I have some left ;-) –  Sjoerd C. de Vries Jan 18 '12 at 18:33
    
@SjoerdC.deVries, I just needed a little patience. I've got 40 more upvotes to burn, who wants them? –  rcollyer Jan 19 '12 at 2:54

3 Answers 3

up vote 6 down vote accepted

Why not use ToBoxes (or MakeBoxes) to construct boxes, instead of doing it yourself?

DisplayForm[
 ToBoxes[Row[List[0, 1, Superscript[2, 3], Superscript[1, 2], a]]]]

Mathematica graphics

share|improve this answer
    
You are right, this is the correct way in general. The trouble was that I created these expressions incrementally, wanting to keep an easy way to retrieve the data into it, and got lost in the process. –  ogerard Jan 18 '12 at 22:35

This is caused by the AutoMultiplicationSymbol option in the front end.

SetOptions[$FrontEnd, AutoMultiplicationSymbol -> False]

Will make the space disappear.

share|improve this answer
2  
or just use Style rather than set it globally: DisplayForm[ Style[RowBox[List[0, 1, Superscript[2, 3], Superscript[1, 2], a]], AutoMultiplicationSymbol -> False]] –  Mike Honeychurch Jan 18 '12 at 22:22
    
I agree that setting the options globally for a FrontEnd or a Notebook is not what is wanted in general. @mike : Or one can define/use a style with this option turned false. –  ogerard Jan 18 '12 at 22:38
    
@ragfield : your answer is correct and welcome because it outlines the mechanism causing the space in the first place. But Brett's answer is the one I will accept as it points out a more idiomatic way of producing the kind of objects I wanted initially. –  ogerard Jan 18 '12 at 22:42
2  
You can also interpose "\[InvisibleSpace]" between arguments, which instructs the FE that we are definitely not doing multiplication. The advantage to "\[InvisibleSpace]" is that it can be applied more selectively. If you look at how the Row typesets in Brett's solution, you'll see that's what it's doing. –  John Fultz Feb 6 '12 at 17:17
    
@John More specifically: 2\[InvisibleSpace]3 is interpreted as multiplication by the FrontEnd but is shown as 23 instead of 2×3. –  Alexey Popkov Apr 9 '12 at 9:44

I thought it might have to do with reserving space for an invisible plus sign. In that case wrapping the 1 in NumberForm would get rid of this nagging space (adding an explicit NumberSigns isn't necessary as NumberForm already has the correct default value for this option).

DisplayForm[RowBox[List[0, NumberForm[1], Superscript[2, 3], Superscript[1, 2], a]]]

Mathematica graphics

But this leaves me wondering why the space isn't there when you precede it with a character 'a'.

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.