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.Sun, 18 Sep 2011 00:49:00 +0200unrecognised tex codehttps://ask.sagemath.org/question/8325/unrecognised-tex-code/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.Sat, 17 Sep 2011 11:51:07 +0200https://ask.sagemath.org/question/8325/unrecognised-tex-code/Comment by kcrisman for <p>Trying to prettyprint the output of a notebook cell I type this code:</p>
<p>view('$m=\mathrm{rico}\,l=\frac{\Delta y}{\Delta x}=\,'+latex((y2-y1)/(x2-x1))+'$')</p>
<p>I see that AskSage renders the latex code correctly, but in my browser, the \frac command is not recognised and the output looks like</p>
<p>... rac${\Delta y}{\Delta x}$ ...</p>
<p>The fraction generated by the latex()-command however IS rendered correctly.</p>
<p>To be perfectly clear: this is the unrendered code:</p>
<pre><code>view('$m=\mathrm{rico}\,l=\frac{\Delta y}{\Delta x}=\,'+latex((y2-y1)/(x2-x1))+'$')
</code></pre>
<p>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.</p>
<p>One other question: can I include latex commands such as
<code>'\begin{aligned}...\end{aligned}'</code>?
(Doesn't work here: \b is not recognised, same as \f).</p>
<p>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.</p>
https://ask.sagemath.org/question/8325/unrecognised-tex-code/?comment=21244#post-id-21244I've had this happen a lot. Thanks for asking and answering so that others can find it.Sun, 18 Sep 2011 00:49:00 +0200https://ask.sagemath.org/question/8325/unrecognised-tex-code/?comment=21244#post-id-21244Answer by Dirk Danckaert for <p>Trying to prettyprint the output of a notebook cell I type this code:</p>
<p>view('$m=\mathrm{rico}\,l=\frac{\Delta y}{\Delta x}=\,'+latex((y2-y1)/(x2-x1))+'$')</p>
<p>I see that AskSage renders the latex code correctly, but in my browser, the \frac command is not recognised and the output looks like</p>
<p>... rac${\Delta y}{\Delta x}$ ...</p>
<p>The fraction generated by the latex()-command however IS rendered correctly.</p>
<p>To be perfectly clear: this is the unrendered code:</p>
<pre><code>view('$m=\mathrm{rico}\,l=\frac{\Delta y}{\Delta x}=\,'+latex((y2-y1)/(x2-x1))+'$')
</code></pre>
<p>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.</p>
<p>One other question: can I include latex commands such as
<code>'\begin{aligned}...\end{aligned}'</code>?
(Doesn't work here: \b is not recognised, same as \f).</p>
<p>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.</p>
https://ask.sagemath.org/question/8325/unrecognised-tex-code/?answer=12656#post-id-12656OK, got it: in sage-code cells you have to ***escape*** the backslashes.
Example:
`\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}Sat, 17 Sep 2011 12:30:53 +0200https://ask.sagemath.org/question/8325/unrecognised-tex-code/?answer=12656#post-id-12656Comment by John Palmieri for <p>OK, got it: in sage-code cells you have to <strong><em>escape</em></strong> the backslashes. </p>
<p>Example:</p>
<p><code>\frac{a}{b}</code> doesn't work, but</p>
<p><code>\\frac{a}{b}</code> does.</p>
<p>Another example: in an 'aligned' environment you need 4 backslashes to make a linebreak:</p>
<pre><code>\\begin{aligned} ... \\ \\ ... \\end{aligned}
</code></pre>
https://ask.sagemath.org/question/8325/unrecognised-tex-code/?comment=21247#post-id-21247You could use an "r" before the quote to 'escape' it also: view(r'$\tau = \nu$') works, too.Sat, 17 Sep 2011 13:40:19 +0200https://ask.sagemath.org/question/8325/unrecognised-tex-code/?comment=21247#post-id-21247