Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

'\\' for equation continuations require an extra '\' in markdown cells #1381

Closed
fperez opened this Issue Feb 5, 2012 · 4 comments

Comments

Projects
None yet
4 participants
Owner

fperez commented Feb 5, 2012

Right now, a markdown cell with continuation equations must be written as:

\begin{eqnarray}
\dot{x} & = \sigma(y-x) \\\
\dot{y} & = \rho x - y - xz \\\
\dot{z} & = -\beta z + xy
\end{eqnarray}

where the \\ eq. continuation markers require a third \. The normal latex code should be:

\begin{eqnarray}
\dot{x} & = \sigma(y-x) \\
\dot{y} & = \rho x - y - xz \\
\dot{z} & = -\beta z + xy
\end{eqnarray}

with only two \\ at the end. This form works OK in Latex() calls, so the issue seems specific to our parsing/escaping of markdown cells.

Contributor

v923z commented Feb 6, 2012

This issue is not related to eqnarray as such. This code also fails, while this is just a simple one-line equation.

$V^{PP}_{\mathbf{k},\mathbf{k'},\mathbf{q}} = \left[ AX_{\mathbf{k+q}}X_{\mathbf{k'}} + B\right]$

By escaping some of the underscores, the expression is rendered properly. What is really odd is that it is enough to escape only one or two underscores, but not all.

This was first raised in this issue, if it is of any relevance: #1275 In the link in #1275, there seems to be a fix via some configuration of MathJax.

Same with the matrix construction, where double -\ is used to delimit rows.

Contributor

v923z commented Feb 14, 2012

As it turns out, this problem is not limited to markdown. The following also produces faulty results:

ipython notebook --profile=sympy

In [1]: eps = Symbol('\epsilon')
In [2]: eps

works (I can't write the output here, because it is a Greek letter:), but

In [1]: alpha = Symbol('\alpha')
In [2]: alpha
Out [3]: lpha

However,

In [1]: alpha = Symbol('\\alpha')
In [2]: alpha

prints a Greek alpha. Now, the question is whether this is really a parsing issue in the front end. It seems that some backslashes disappear, but then I don't see why this never happens in a standard python statement. I have never had problems with something like this

In []: print 'foo\nbar'
        foo
        bar
Owner

fperez commented Feb 15, 2012

No @v923z , that last one is a different story: you need to either escape your backslashes, or use python raw strings. If you want to produce the latex command for the greek letter alpha in a python string, the two valid ways of spelling that are r'\alpha' or '\\alpha', that's it.

The bug is on the javascript handling of markdown, your last point is a misunderstanding of how python handles backslashes in strings.

@minrk minrk closed this May 13, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment