Ask Your Question
1

latex Function Prevent Simplification

asked 2013-01-09 00:42:24 +0100

bpeacock gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-01-09 01:15:41 +0100

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.

edit flag offensive delete link more

Comments

1

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

bpeacock gravatar imagebpeacock ( 2013-01-09 02:45:27 +0100 )edit

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

sagefan gravatar imagesagefan ( 2015-03-10 16:39:38 +0100 )edit

Not that I know of, but can see more discussion about this here: http://tex.stackexchange.com/question...

louisgag gravatar imagelouisgag ( 2017-01-25 14:45:43 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

3 followers

Stats

Asked: 2013-01-09 00:42:24 +0100

Seen: 1,140 times

Last updated: Jan 09 '13