sphinx-jupyterbook-latex icon indicating copy to clipboard operation
sphinx-jupyterbook-latex copied to clipboard

BUG: Issue rendering math output from Julia Code

Open mmcky opened this issue 2 years ago • 0 comments

Describe the bug

There is an issue when using julia from tools_and_techniques/geom_series.md (QuantEcon Lecture)

```{code-cell} julia
# Creates algebraic symbols that can be used in an algebraic expression
@variables g, r, x0
G = (1 + g)
R = (1 + r)
p0 = x0 / (1 - G * R ^ (-1))
print("Our formula is")
p0
```

When building the Julia lectures if there is generated math from code the ipynb json blob is

   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Our formula is"
     ]
    },
    {
     "data": {
      "text/latex": [
       "$$ \\begin{equation}\n",
       "\\frac{x0}{1 + \\frac{-1 - g}{1 + r}}\n",
       "\\end{equation}\n",
       " $$"
      ],
      "text/plain": [
       "x0 / (1 + (-1 - g) / (1 + r))"
      ]
     },

which gets wrapped in tex as

\begin{sphinxuseclass}{cell_output}
\begin{sphinxVerbatim}[commandchars=\\\{\}]
Our formula is
\end{sphinxVerbatim}
\begin{equation*}
\begin{split} \begin{equation}
\frac{x0}{1 + \frac{-1 - g}{1 + r}}
\end{equation}
 \end{split}
\end{equation*}
\end{sphinxuseclass}\end{sphinxVerbatimOutput}

and xelatex really does not like nested equation environments.

Is this something we could fix in sphinx-jupyterbook-latex?

maybe for Julia we should have nowrap for all math blocks that are generated by code

Reproduce the bug

See Above

List your environment

Julia issue

mmcky avatar Jan 20 '23 01:01 mmcky