-
Notifications
You must be signed in to change notification settings - Fork 569
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
SVG images in Markdown are not rendered in latex export #244
Comments
Actually svgs should be converted to pdf using inkscape during the nbconversion. How do you use/embed the svg? |
|
Ok, so I did
when trying to convert to pdf. the generated latex is \begin{figure}[htbp]
\centering
\includegraphics{overfitting_underfitting_cartoon.svg}
\caption{svg\_thing}
\end{figure} |
You are right. In your particular case only the syntax is converted from markdown to latex but the linked content not. |
Is there a reason this is better to have as a jupyter extension rather than as part of core nbconvert preprocessors? @Carreau, @takluyver, @minrk how do we determine what goes in the extensions repo and what is incorporated into core projects? Is there a system for migrating things? This seems like important svg support and may address other issues that I'm having difficulty finding right now. |
I agree with @michaelpacer that this would be good to have in the main repo. |
@michaelpacer sometimes we ask people to make an extension if something is too specific for the main repos, or we're not sure about how to design it. But in this case, it's an extension largely because @juhasch, who maintains the repo with a collection of extensions, got round to doing it. There's no system to migrate things to or from extensions, it would just involve making a pull request like any other feature. Note that we already have svg2pdf conversion, but as @jakobgager said, it doesn't currently handle svgs linked into the notebook in markdown cells. |
Ran into this issue when trying to convert my notebooks contaning SVG images in Markdown into Pdf. |
@romor001 I also ran into trouble with converting SVGs. I hunted down the problem, and indeed: there are two problems: Some specs: I'm using jupyter-nbconvert 6.0.7 on python 3.8.6, windows PC. And here is the first problem, the whitespace in "Program Files" makes the call fail, because it is not enclosed in double quotes or in another way escaped. The second problem is that the initial --export-filename will raise an error because auf an overwriting risk, it should be changed to --export-type. But than you have to change the value (from a filename to just "pdf"). All in all I change the site-packages\nbconvert\preprocessors\svg2pdf.py the following way: @default('command')
def _command_default(self):
self.inkscape_path_string = f'\"{self.inkscape}\"' # added this to escape the whitespace
major_verison = self.inkscape_version.split('.')[0]
export_option = ' --export-type' if int(major_verison) > 0 else ' --export-pdf'
gui_option = '' if int(major_verison) > 0 else ' --without-gui'
to_filename = 'pdf' if int(major_verison) > 0 else to_filename # Need this for backward-capability
return '{inkscape}{gui_option}{export_option}='.format(
inkscape=self.inkscape_path_string, export_option=export_option, gui_option=gui_option
) + f'{to_filename}' + " {from_filename}" # needed to update the string, otherwise it did not work for my (but that is probably my fault) Now converting Jupyter Notebooks works. I'll look at a way to update the package and create a pull request. |
In PR #2190 a workaround is provided that hooks onto I understand that On the other hand, I also do not think messing with So, not sure what's the best way forward here. |
This is a bit of a tricky one I guess.
By default latex doesn't support svg images, but they are a nice format if you want to show vector graphics in a browser. I could convert to png but that seems not great.
there is a svg package that could be used to convert svg packages to pdf on the fly.
The text was updated successfully, but these errors were encountered: