phockett / Quantum-Metrology-with-Photoelectrons-Vol3

Other
4 stars 0 forks source link

Qutip Latex matrix output #8

Open phockett opened 1 year ago

phockett commented 1 year ago

Getting build errors for QuTip objects, specifically matrices.

! Missing } inserted.
<inserted text> 
                }
l.2540 ...& 1.000\\\end{matrix}\right)$\end{split}

? 
! Missing { inserted.
<inserted text> 
                {
l.2540 ...& 1.000\\\end{matrix}\right)$\end{split}

? 
! Missing $ inserted.
<inserted text> 
                $
l.2540 ...& 1.000\\\end{matrix}\right)$\end{split}

? 
! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate 

l.2540 ...& 1.000\\\end{matrix}\right)$\end{split}

Seems like something similar to use of \protect in figure case (https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/276#issuecomment-1102154800) may be required here - something is presumably getting stripped incorrectly during preprocessing. May be to do with mixed nature of object, with text and matrix? In notebook this is clear, but in built output the label text is wrapped too?

Current example from .tex output:

\begin{sphinxVerbatimOutput}

\begin{sphinxuseclass}{cell_output}\begin{equation*}
\begin{split}Quantum object: dims = [[25], [25]], shape = (25, 25), type = oper, isherm = True $ \\ \left(\begin{matrix}1.0 & 0.0 & 0.0 & 0.0 & 0.707 & \cdots & 1.0 & 0.0 & 0.707 & 0.0 & 0.707\\0.0 & 1.000 & 0.0 & 0.0 & 0.0 & \cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 1.0 & 0.0 & 0.0 & \cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.0 & 0.0 & 0.0 & 1.000 & 0.0 & \cdots & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\0.707 & 0.0 & 0.0 & 0.0 & 1.000 & \cdots & 0.707 & 0.0 & 0.0 & 0.0 & 0.0\\\vdots & \vdots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \vdots & \vdots\\1.0 & 0.0 & 0.0 & 0.0 & 0.707 & \cdots & 1.0 & 0.0 & 0.707 & 0.0 & 0.707\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \cdots & 0.0 & 1.000 & 0.0 & 1.000 & 0.0\\0.707 & 0.0 & 0.0 & 0.0 & 0.0 & \cdots & 0.707 & 0.0 & 1.000 & 0.0 & 1.000\\0.0 & 0.0 & 0.0 & 0.0 & 0.0 & \cdots & 0.0 & 1.000 & 0.0 & 1.000 & 0.0\\0.707 & 0.0 & 0.0 & 0.0 & 0.0 & \cdots & 0.707 & 0.0 & 1.000 & 0.0 & 1.000\\\end{matrix}\right)$\end{split}
\end{equation*}
\end{sphinxuseclass}\end{sphinxVerbatimOutput}
phockett commented 1 year ago

For quick builds, add \nonstopmode to preamble (via _config.yml), but should be careful with this, and fix properly!

See https://tex.stackexchange.com/questions/140845/how-can-i-ignore-latex-error-while-compiling

phockett commented 1 year ago

Builds with QuTip matrix output now failing completely after Docker container rebuild (v220423), but was OK in previous version (v130423) - not sure what has changed, but QuTip output produces runaway arg:

! Argument of \split has an extra }.
<inserted text>
                \par
l.2704 ...{array}\right)\end{equation*}\end{split}

Runaway argument?
\collect@body \gather@split Quantum object: dims = [[25], [25]], shap\ETC.
! Paragraph ended before \split was complete.
<to be read again>
                   \par
l.2704 ...{array}\right)\end{equation*}\end{split}

! Missing $ inserted.
<inserted text>
                $
l.2704 ...{array}\right)\end{equation*}\end{split}

! Missing } inserted.
<inserted text>
                }
l.2704 ...{array}\right)\end{equation*}\end{split}

! Missing \endgroup inserted.
<inserted text>
                \endgroup
l.2704 ...{array}\right)\end{equation*}\end{split}

! Missing \endgroup inserted.
<inserted text>
                \endgroup
l.2704 ...{array}\right)\end{equation*}\end{split}

...

(That makes 100 errors; please try again.)
Output written on QM3.pdf (55 pages).
Transcript written on QM3.log.

...

Maybe change in JupyterBook or Sphinx parsing of QuTip output? May need to modify/wrap this somehow... for now just omit it for PDF build testing.

This might be useful: https://github.com/qutip/qutip/pull/2017