question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pdflatex, svg conversion, and glue

See original GitHub issue

Describe 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

  1. Use svg output format for a matplotlib figure
  2. Create a figure and {glue} it into a notebook
  3. 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:open
  • Created 2 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisjsewellcommented, Jan 11, 2022

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

1reaction
choldgrafcommented, Jan 11, 2022

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to include SVG diagrams in LaTeX? - TeX
You can't directly include svg vectorgraphics. You always have to convert them. Conversion at the moment is easiest with inkscape, because it offers...
Read more >
LaTeX to SVG - viereck.ch
Convert LaTeX equations to SVG using MathJax. Your LaTeX equation. equationeqnarrayalignarray. x = \sin \left( \frac{\pi}{2} \right). Rendered equation (SVG).
Read more >
How to convert LaTeX code to SVG code or SVG file with ...
I want to be able to take a line of LaTeX code and turn it into SVG code, or (even better) an actual...
Read more >
Wikipedia:Graphics Lab/Resources/PDF conversion to SVG
Before learning how to convert PDF images to SVG images it may be useful to learn how to extract images from PDF documents...
Read more >
How to Use SVG Images in LaTeX
It's free and open source software, available for Linux, Windows and macOS. We need Inkscape to convert from svg to pdf, png, ps...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found