Since Sphinx 8.2, sphinx.ext.mathjax loads MathJax 4 by default (https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js). MathJax 4 enforces a check that MathJax 3 did not: an AMS equation structure (eqnarray, align, align*, gather, multline) may not be nested inside another one. Both ways in which our notebooks produce display math do exactly that nesting:
- Sphinx wraps every math block —
$$ ... $$ as well as a {math} directive, labelled or not — in \begin{equation}\begin{split} ... \end{split}\end{equation} (see sphinx.util.math.wrap_displaymath).
IPython.display.Math wraps its input in $\displaystyle ... $.
The result is that the equation is replaced by a red Erroneous nesting of equation structures on the rendered page. Only inner environments are allowed in these positions: aligned, alignedat, gathered, split, array, pmatrix, cases. Note that the pages still rendered correctly under MathJax 3, so this regression came in silently with a Sphinx upgrade.
Affected
| File |
$$ blocks |
Math() with a hand-written environment |
sp.multiline_latex() |
docs/005/index.ipynb |
|
|
1 |
docs/009/index.ipynb |
|
|
4 |
docs/010/index.ipynb |
1 |
|
|
docs/011/index.ipynb |
|
|
7 |
docs/013/index.ipynb |
|
|
1 |
docs/014/index.ipynb |
|
|
6 |
docs/015/index.ipynb |
3 |
2 |
1 |
docs/017/index.ipynb |
|
|
1 |
docs/021/index.ipynb |
22 |
|
2 |
docs/024/index.ipynb |
|
|
1 |
docs/027/index.ipynb |
1 |
|
|
docs/033/index.ipynb |
4 |
|
|
Fix
For the Markdown cells and the hand-written Math(R"\begin{eqnarray}...") strings: replace the environment with aligned and collapse eqnarray's three-column alignment &=& to &=.
For sp.multiline_latex() there is no keyword fix — its only environments are align*, eqnarray and IEEEeqnarray, and all three are illegal inside Math(). Replace those calls with ampform.io.aslatex, which renders into aligned: Math(aslatex({lhs: rhs}, terms_per_line=n)).
Since these reports are pinned and rebuilt from their own environments, the fix can be applied file by file.
Since Sphinx 8.2,
sphinx.ext.mathjaxloads MathJax 4 by default (https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js). MathJax 4 enforces a check that MathJax 3 did not: an AMS equation structure (eqnarray,align,align*,gather,multline) may not be nested inside another one. Both ways in which our notebooks produce display math do exactly that nesting:$$ ... $$as well as a{math}directive, labelled or not — in\begin{equation}\begin{split} ... \end{split}\end{equation}(seesphinx.util.math.wrap_displaymath).IPython.display.Mathwraps its input in$\displaystyle ... $.The result is that the equation is replaced by a red Erroneous nesting of equation structures on the rendered page. Only inner environments are allowed in these positions:
aligned,alignedat,gathered,split,array,pmatrix,cases. Note that the pages still rendered correctly under MathJax 3, so this regression came in silently with a Sphinx upgrade.Affected
$$blocksMath()with a hand-written environmentsp.multiline_latex()docs/005/index.ipynbdocs/009/index.ipynbdocs/010/index.ipynbdocs/011/index.ipynbdocs/013/index.ipynbdocs/014/index.ipynbdocs/015/index.ipynbdocs/017/index.ipynbdocs/021/index.ipynbdocs/024/index.ipynbdocs/027/index.ipynbdocs/033/index.ipynbFix
For the Markdown cells and the hand-written
Math(R"\begin{eqnarray}...")strings: replace the environment withalignedand collapseeqnarray's three-column alignment&=&to&=.For
sp.multiline_latex()there is no keyword fix — its only environments arealign*,eqnarrayandIEEEeqnarray, and all three are illegal insideMath(). Replace those calls withampform.io.aslatex, which renders intoaligned:Math(aslatex({lhs: rhs}, terms_per_line=n)).Since these reports are pinned and rebuilt from their own environments, the fix can be applied file by file.