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.

I don't like the way that Mathematica hides the multiplication symbol when two variables appear adjacent in the multiplication, because the space between them isn't always sufficient to clearly see that there are in fact two variables there.

Therefore, I would like to either increase the space between the adjacent variables, or to make the multiplication operator explicit in my output.

Note that InputForm does not suffice because I still want other parts of the expression formatted as usual, and most of the other things I've seen erroneously remove parentheses, thus changing the meaning of the expression, which I would like to avoid.

Here's as far as I have got so far (I've not edited Times to make it easier to see the difference, and because I don't necessarily want to apply this everywhere):

SetAttributes[visibleTimes, Orderless]

MakeBoxes[visibleTimes[a_], StandardForm] := 
 MakeBoxes[a, StandardForm]

MakeBoxes[visibleTimes[a_?NumericQ, b__], StandardForm] := 
 MakeBoxes[Times[a, visibleTimes[b]], StandardForm]

MakeBoxes[visibleTimes[a__], StandardForm] := 
 MakeBoxes[Interpretation[Infix[Hold[a], "*"], Times[a]], StandardForm]

which tries to hide the operator if one of the arguments is numeric. I then test with

a$$1*b (c - 2d)*Exp[10]

Block[{Times = visibleTimes}, a$$1*b (c - 2d)*Exp[10]]

which gives me the not particularly satisfactory

output

I think you'll agree that in the first expression (Out[5]), it is not easy to notice the multiplication between a$$1 and b.

It would also be nice if the resulting output cell could be copied and pasted and evaluated back as input similar to the original.

I also suspect that PrecedenceForm may be able to help here, but I haven't figured out how to get it to work in this context yet.

share|improve this question

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.