# Revision history [back]

U never being defoined, your "minimal example" prints nothong useful...

If I follow you, you are complaining tha Sage formats its expression as it pleases itself. Note that :

sage: print(LatexExpr(r"(1-p)I\,=\,%s"%latex((1-p)*I)))
(1-p)I\,=\,-I {\left(p - 1\right)}


which typesets $$(1-p)I\,=\,-I {\left(p - 1\right)}$$ which is mathematematically correct. The fact that it may be deemed unaesthetic is not something that can be controlled by a program. In other words "beautiful" as no algorithmically usable definition.

This may have been discussed a couple (or more) of times in this site...

Complain fiercely.

BTW, another pet peeve of mine :

sage: print(LatexExpr(r"\frac{1}{\sqrt{2}}\,=\,%s"%latex(1/sqrt(2))))
\frac{1}{\sqrt{2}}\,=\,\frac{1}{2} \, \sqrt{2}


which typesets $$\frac{1}{\sqrt{2}}\,=\,\frac{1}{2} \, \sqrt{2}$$. Now, that's ugly... (but still correct !).

FWIW : rather than typing intricate LatexExpr definition, you'd probably gain much time, sweat, tears and frustration by using SageTeX to integrate your computation in a well (and clearly)--written Latex text.

HTH,