executablebooks / sphinx-jupyterbook-latex

Supporting LaTeX infrastructure for Jupyter Book
https://sphinx-jupyterbook-latex.readthedocs.io
BSD 3-Clause "New" or "Revised" License
28 stars 13 forks source link

BUG: Issue rendering math output from Julia Code #118

Open mmcky opened 1 year ago

mmcky commented 1 year ago

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

```json
   "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