Reputation: 431
I am trying to write some code where the user enters in a expression into a sage/python interactive and then my programs display the integral in latex. For example the user might enter in x^2 or sin(x) as bounds in my program. However,neither of these expressions works. when I use sin(x) as bound the s shows up as a bound but the in(X) shows up in the expression being integrated. when I put x^2 as a bound the integral does not show up and I get the message "Double Exponents use braces to clarify". Yet, when I use x as a bound it is displayed just fine.
s = "$\int_{2}^{3} \int_{4}^{5} {0} \,dxdy = {1} $"
p = s.format(function, result,lower_x_bound,upper_x_bound,lower_y_bound,upper_y_bound)
html("%s" %p)
Upvotes: 0
Views: 73
Reputation: 23837
The string LaTeX is currently receiving when you want, say, x^2 as the intended lower bound and x_3 as the intended upper bound is
\int_x^2^x_3
LaTeX is going to have trouble with that. To get your desired output, LaTeX needs to get the string
\int_{x^2}^{x_3}
But the braces you've got right now are getting eaten up by the string formatting step.
So try $\int_{{{2}}}^{{{3}}} ...$
PS: sin(x) should always be put into LaTeX as $\sin(x)$
. If you do $sin(x)$
LaTeX will interpret this as s
times i
times n(x)
, and the formatting will look bad.
Upvotes: 1