# latex Function Prevent Simplification

Hi, I am trying to use the latex function without the subject simplifying before it converting to LaTeX. This is similar to the hold=True for algebra functions. For example, I want latex(x/x) to return \frac{x}{x} rather than 1. Thanks so much!

edit retag close merge delete

Sort by » oldest newest most voted Since you can do x.mul(1/x, hold=True), you can also do latex(x.mul(1/x, hold=True)).

I suppose you could also write the expression using LaTeX:

sage: LatexExpr(r"\frac{%s}{%s}" % (latex(x), latex(x)))
\frac{x}{x}
sage: LatexExpr(r"\frac{%s}{%s}" % (latex(factor(x^2+3*x + 2)), latex(x)))
\frac{{\left(x + 1\right)} {\left(x + 2\right)}}{x}


But in general, latex(foo) first computes foo, which means that typically it will get simplified, and then it computes its LaTeX representation. So I don't think there is a simple way to do what you want.

more

1

Thats a shame but it makes sense. I guess that would have to be added to the sage preparser. Thanks!

Is there any new feature today which makes this more easy?