Ask Your Question

unrecognised tex code

asked 2011-09-17 11:51:07 +0100

Dirk Danckaert gravatar image

updated 2011-09-18 00:49:05 +0100

kcrisman gravatar image

Trying to prettyprint the output of a notebook cell I type this code:

view('$m=\mathrm{rico}\,l=\frac{\Delta y}{\Delta x}=\,'+latex((y2-y1)/(x2-x1))+'$')

I see that AskSage renders the latex code correctly, but in my browser, the \frac command is not recognised and the output looks like

... rac${\Delta y}{\Delta x}$ ...

The fraction generated by the latex()-command however IS rendered correctly.

To be perfectly clear: this is the unrendered code:

view('$m=\mathrm{rico}\,l=\frac{\Delta y}{\Delta x}=\,'+latex((y2-y1)/(x2-x1))+'$')

It seems as if my keyboard codes are misinterpreted. I noticed, e.g., that ':' in a piece of latex code is rendered as '.' - this may be related, or maybe not.

One other question: can I include latex commands such as '\begin{aligned}...\end{aligned}'? (Doesn't work here: \b is not recognised, same as \f).

Oh, and this must be important: latex is flawlessly rendered in TEXT-cells, including the {aligned} environment. It's only in sage-code cells that I experience these problems.

edit retag flag offensive close merge delete



I've had this happen a lot. Thanks for asking and answering so that others can find it.

kcrisman gravatar imagekcrisman ( 2011-09-18 00:49:00 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2011-09-17 12:30:53 +0100

Dirk Danckaert gravatar image

updated 2011-09-17 15:39:38 +0100

OK, got it: in sage-code cells you have to escape the backslashes.


\frac{a}{b} doesn't work, but

\\frac{a}{b} does.

Another example: in an 'aligned' environment you need 4 backslashes to make a linebreak:

\\begin{aligned} ... \\ \\ ... \\end{aligned}
edit flag offensive delete link more



You could use an "r" before the quote to 'escape' it also: view(r'$\tau = \nu$') works, too.

John Palmieri gravatar imageJohn Palmieri ( 2011-09-17 13:40:19 +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


Asked: 2011-09-17 11:51:07 +0100

Seen: 322 times

Last updated: Sep 17 '11