Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

nbconvert fails to convert the vector in Tex #5316

Closed
kunxi opened this Issue · 12 comments

4 participants

@kunxi

In ipython notebook, I created a vector:

$$
\begin{equation}
\theta = \left( \begin{array}{ccc}
\theta_{0} \\
\theta_{1} \\
. \\
. \\
\theta_{n} \end{array} \right)
\end{equation}
$$

and it is persisted in the ipynb correctly:

  "\\begin{equation}\n",
  "\\theta = \\left( \\begin{array}{ccc}\n",
  "\\theta_{0} \\\\\n",
  "\\theta_{1} \\\\\n",
  ". \\\\\n",
  ". \\\\\n",
  "\\theta_{n} \\end{array} \\right)\n",
  "\\end{equation}\n",
  "$$\n",

but nbconvert replace "\" to "\", as:

<span class="math">\[
\begin{equation}
x = \left( \begin{array}{ccc}
x_{0} \
x_{1} \
. \
. \
x_{n} \end{array} \right)
\end{equation}
\]</span>

Basically it renders the theta as theta.transpose().

@minrk
Owner

What version of IPython?

@minrk minrk added the needs-info label
@kunxi

Tried both the ipython 1.1.0 and 2.0.0-dev which is the git tip about March 1st.

@ahmadia

This looks like MathJax is rendering your equation environment twice...

Let me see if I can reproduce on 2.0.0-dev, but I suspect the correct thing to do here is:

\begin{equation}
\theta = \left( \begin{array}{ccc}
\theta_{0} \\
\theta_{1} \\
. \\
. \\
\theta_{n} \end{array} \right)
\end{equation}

That is, remove the $$ blocks, since that's more correctly handled by the equation blocks.

@minrk
Owner

Hm, with current master I think see correct rendering:
screen shot 2014-03-10 at 11 58 20.

What are your pandoc (pandoc --version) and/or node.js (node --version or nodejs --version) versions?

@ahmadia

I'm getting correct rendering too with a week-old master if I use node+Marked on the latest master for both fenced and unfenced. I'm also seeing correct rendering with pandoc 1.10.1 for the fenced version (extra $$), but without the extra fences it doesn't render.

@ahmadia

nbviewer seems to be happy with either version: http://nbviewer.ipython.org/gist/ahmadia/9471973

@kunxi

Interesting. I see the nbviewer renders the equation correctly either with $$ or not, but nbconvert will render nothing if $$ is absent.

pandoc --version
pandoc 1.12.3
Compiled with texmath 0.6.6, highlighting-kate 0.5.6.
Syntax highlighting is supported for the following languages:
actionscript, ada, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog,
clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d,
diff, djangotemplate, doxygen, doxygenlua, dtd, eiffel, email, erlang,
fortran, fsharp, gnuassembler, go, haskell, haxe, html, ini, java, javadoc,
javascript, json, jsp, julia, latex, lex, literatecurry, literatehaskell,
lua, makefile, mandoc, markdown, matlab, maxima, metafont, mips, modelines,
modula2, modula3, monobasic, nasm, noweb, objectivec, objectivecpp, ocaml,
octave, pascal, perl, php, pike, postscript, prolog, python, r,
relaxngcompact, restructuredtext, rhtml, roff, ruby, rust, scala, scheme,
sci, sed, sgml, sql, sqlmysql, sqlpostgresql, tcl, texinfo, verilog, vhdl,
xml, xorg, xslt, xul, yacc, yaml

I do not have node installed, is it required?

@minrk
Owner

It is not required, but it is preferred. In IPython 2.0, we add support for rendering markdown with the exact same code we use in the live notebook, so we should not keep seeing differences between nbconvert and live notebook output. But this code is javascript, hence the node dependency. In the absence of node, pandoc is a fallback.

@ahmadia

@kunxi - If you are using MathJaX with IPython, I strongly recommend you install node.js/node so that the notebook can use Marked.js, which is the same one used by nbviewer, to render your Markdown.

@ahmadia

@minrk - The other issue is that pandoc butchers LaTeX environments being directly passed through from Markdown, so it can be more than superficial.

@kunxi

@ahmadia Thanks, it seems that this is pandoc issue. Once the node is installed, and the nbconvet in 2.0.0-dev branch works perfect regardless $$ presents.

@kunxi

Guys, feel free to close the bug.

@takluyver takluyver closed this
@minrk minrk added this to the no action milestone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.