ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 25 Jan 2017 14:45:43 +0100latex Function Prevent Simplificationhttps://ask.sagemath.org/question/9698/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!Wed, 09 Jan 2013 00:42:24 +0100https://ask.sagemath.org/question/9698/latex-function-prevent-simplification/Answer by John Palmieri for <p>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!</p>
https://ask.sagemath.org/question/9698/latex-function-prevent-simplification/?answer=14443#post-id-14443Since 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.Wed, 09 Jan 2013 01:15:41 +0100https://ask.sagemath.org/question/9698/latex-function-prevent-simplification/?answer=14443#post-id-14443Comment by bpeacock for <p>Since you can do <code>x.mul(1/x, hold=True)</code>, you can also do <code>latex(x.mul(1/x, hold=True))</code>.</p>
<p>I suppose you could also write the expression using LaTeX:</p>
<pre><code>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}
</code></pre>
<p>But in general, <code>latex(foo)</code> first computes <code>foo</code>, 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.</p>
https://ask.sagemath.org/question/9698/latex-function-prevent-simplification/?comment=18417#post-id-18417Thats a shame but it makes sense. I guess that would have to be added to the sage preparser. Thanks!Wed, 09 Jan 2013 02:45:27 +0100https://ask.sagemath.org/question/9698/latex-function-prevent-simplification/?comment=18417#post-id-18417Comment by louisgag for <p>Since you can do <code>x.mul(1/x, hold=True)</code>, you can also do <code>latex(x.mul(1/x, hold=True))</code>.</p>
<p>I suppose you could also write the expression using LaTeX:</p>
<pre><code>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}
</code></pre>
<p>But in general, <code>latex(foo)</code> first computes <code>foo</code>, 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.</p>
https://ask.sagemath.org/question/9698/latex-function-prevent-simplification/?comment=36383#post-id-36383Not that I know of, but can see more discussion about this here: http://tex.stackexchange.com/questions/232379/translate-sage-input-to-latex-without-simplifyingWed, 25 Jan 2017 14:45:43 +0100https://ask.sagemath.org/question/9698/latex-function-prevent-simplification/?comment=36383#post-id-36383Comment by sagefan for <p>Since you can do <code>x.mul(1/x, hold=True)</code>, you can also do <code>latex(x.mul(1/x, hold=True))</code>.</p>
<p>I suppose you could also write the expression using LaTeX:</p>
<pre><code>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}
</code></pre>
<p>But in general, <code>latex(foo)</code> first computes <code>foo</code>, 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.</p>
https://ask.sagemath.org/question/9698/latex-function-prevent-simplification/?comment=26137#post-id-26137Is there any new feature today which makes this more easy?Tue, 10 Mar 2015 16:39:38 +0100https://ask.sagemath.org/question/9698/latex-function-prevent-simplification/?comment=26137#post-id-26137