Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaTeX export: Support SVG image files via the svg LaTeX package #2190

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

aravindh-krishnamoorthy
Copy link

@aravindh-krishnamoorthy aravindh-krishnamoorthy commented Nov 12, 2024

Note

PDF via LaTeX also uses the LaTeX output to generate the PDF. However, it continues to be broken even after this PR. It is felt that support for PDF via LaTeX is best done in another PR.

Summary

Jupyter notebooks allow inclusion of SVG images via ![Caption](image.svg). However, for LaTeX export, unlike other image formats, SVG images does not work. This is mainly because \includegraphics doesn't support SVGs yet.

In this PR, a solution is provided via \usepackage{svg}. The fix works by hooking onto \includegraphics to detect SVG images from their file extension and replace the \includegraphics call by \includesvg.

Cautionary areas

The following are the reasons why we have to be cautious before merging this PR.

  • The svg LaTeX package utilizes Inkscape to convert SVGs to PDFs. Hence, the experience for LaTeX export may not be seamless for novice LaTeX users.

@aravindh-krishnamoorthy aravindh-krishnamoorthy changed the title LaTeX and PDF export: Support SVG image files via the svg LaTeX package LaTeX export: Support SVG image files via the svg LaTeX package Nov 13, 2024
@t-makaro
Copy link
Contributor

I looked into using the svg package for nbconvert latex once. It requires running latex with a shell escape which is a no-go. Given that we already have an svg2pdf preprocessor, I think that making that work with markdown cells would be better.

@aravindh-krishnamoorthy
Copy link
Author

I looked into using the svg package for nbconvert latex once. It requires running latex with a shell escape which is a no-go. Given that we already have an svg2pdf preprocessor, I think that making that work with markdown cells would be better.

True! Lemme try to find a fix which uses the svg2pdf preprocessor... it currently preprocesses based on MIME headers of a cell and will also have to be activated for ![xxx](yyy.svg) instead of pandoc. I'll get back (hopefully) soon with a fix.

@t-makaro
Copy link
Contributor

I'm not super familiar with svg2pdf, but it would likely have to handle markdown cells very differently, since you'd need to parse the markdown to find the image first. Hence why this has been an open issue so long.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants