Ask Your Question
1

MathJax indentation error

asked 2016-01-08 23:48:35 -0500

collabmath gravatar image

updated 2016-01-12 00:54:17 -0500

I am trying to display latex using python. However, whenever I add a dollar sign and \ I get a indentation error in my my q expression in my sage html interactive. What is the problem?

Here is my code:

x, y = var('x y')
html("<h1>Double Integrator</h1>")
@interact
def interplay(function=input_box(x*y),lower_x_bound=input_box(0),upper_x_bound=input_box(x),lower_y_bound=input_box(0),upper_y_bound=input_box(1),dydx=checkbox(default=False)):
 try:
    if dydx is False:
      result = integral(integral(function, x, lower_x_bound, upper_x_bound),y, lower_y_bound, upper_y_bound)
      print('hello');
      pretty_print(html("hello"))
      q = r"$\int {0}^{1}\int_{2}^{3} {4} \,dx\,dy = {5}$".format(lower_y_bound, upper_y_bound,lower_x_bound, upper_x_bound,function, result)
    else:
      result = integral(integral(function, x, lower_x_bound, upper_x_bound),y, lower_y_bound, upper_y_bound)
      q = r"$ int {0}^{1} int_{2}^{3} {4} ,dx,dy = {5} $".format(lower_y_bound, upper_y_bound,lower_x_bound, upper_x_bound,function, result)

    pretty_print(html("%s" % q))
 except Exception as e :
    print("Please enter better inputs")
    print(e)

Here is my error

 * BackslashOperator() * int {Integer(0)}**{Integer(1)} * BackslashOperator() * int_{Integer(2)}**{Integer(3)} {Integer(4)}  * BackslashOperator() * ,dx * BackslashOperator() * ,dy = {Integer(5)}
IndentationError: unexpected indent
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-01-09 01:11:33 -0500

kcrisman gravatar image

I'm not getting the error you have, but I do get something that doesn't look right. Perhaps you should first take your input box inputs and make them LaTeXed, e.g.

      q = r"$\int_{0}^{1}\int_{2}^{3} {4} \,dx\,dy = {5}$".format(lower_y_bound, upper_y_bound,lower_x_bound, upper_x_bound,latex(function), latex(result))

You were missing an underscore, anyway. How do you get the error you mention?

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-01-08 23:48:35 -0500

Seen: 81 times

Last updated: Jan 12 '16