pdflatex, svg conversion, and glue
See original GitHub issueDescribe the problem
My project uses SVG images for pretty much everything, and I’m trying to get it to work with the pdflatex builder.
When the files in question are saved to disk, everything works as expected. Sphinx triggers the image conversion, svgs are converted to pngs, and properly included in the resulting pdf. So far so good.
However, when the images are {glue}
ed in, nothing seems to work, and I only see a placeholder box in the latex (and sphinx doctree files) with something like the following:
<Figure size 720x360 with 1 Axes>
Link to your repository or website
No response
Steps to reproduce
- Use
svg
output format for a matplotlib figure - Create a figure and
{glue}
it into a notebook - Build with the pdflatex builder
The version of Python you’re using
Python 3.9.4
Your operating system
Linux
Versions of your packages
Jupyter Book : 0.11.2
External ToC : 0.2.2
MyST-Parser : 0.13.7
MyST-NB : 0.12.3
Sphinx Book Theme : 0.1.2
Jupyter-Cache : 0.4.3
NbClient : 0.5.4
Also:
sphinx 3.5.4
sphinxcontrib-svg2pdfconverter 1.1.1
sphinx-jupyterbook-latex 0.4.2
Additional context
I’ve also tried adding sphinxcontrib.inkscapeconverter
to my sphinx config, which I use successfully to render SVG images in other sphinx projects on this machine. No luck though.
Since the conversion works for files loaded from disk, but not from glued objects, I’m thinking the problem is probably not the conversion itself, but perhaps deriving from mime type inference on glue objects. (Just a guess though.)
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (5 by maintainers)
Ye, indeed, with the refactor as it stands, things like this will now “just work”. This is because outputs are “glued” (converted to docutils nodes) directly at the document parsing stage, meaning that any subsequent processing triggered by docutils/sphinx/sphinx-extensions (in transforms and post-transforms) will be correctly performed, including in this case image conversion.
This does tie in to https://github.com/executablebooks/MyST-NB/pull/380#pullrequestreview-848479009, though: the refactor currently removes the ability to glue from other document. We could add this pack in some form, e.g. adding “pending” nodes if the key cannot be found in the current document. But then you are back to this issue; of having to create things in the post-transform stage (after all documents have been parsed), whereby docutils/sphinx mechanisms may not trigger
@chrisjsewell is working on a re-factor of MyST-NB, which might impact this? But I am not sure. Check out the PR behind that here: https://github.com/executablebooks/MyST-NB/pull/380