Published December 9, 2020 | https://doi.org/10.59350/2h8mp-vq244

Converting jupyter notebooks with embedded images to pdf.

Feature image

Inserting images in a jupyter notebook is just drag and drop:

This will automagically produce the image link at the drop position.

And after executing the cell, the image is rendered

So far so good. But ever tried to convert a notebook with embedded images to pdf or html (slides)?

My first guess was: Menu -> File -> Export Notebook As -> PDF.

However, this immediately runs into Error 500 tracing back to latex not being able to locate the image attachment:5444....

Next try: nbconvert:

Open terminal, run

jupyter nbconvert --to pdf Untitled.ipynb

You guessed it, same error.

Next thought: search the web Most close to a solution (which I have not tried out to be honest) on github: https://github.com/jupyter/nbconvert/issues/699

Final resort: pandoc

pandoc --to pdf --from ipynb -o Untitled.pdf Untitled.ipynb

Bam, nicely rendered pdf with images.

.

Questions? Ah, yes, what's that figure about? That's a little investigation about the total counts of github repos over the years compared to repos with the term 'bio' in the title or description. But that goes back to another story…

Additional details

Description

Inserting images in a jupyter notebook is just drag and drop: This will automagically produce the image link at the drop position. And after executing the cell, the image is rendered So far so good. But ever tried to convert a notebook with embedded images to pdf or html (slides)? My first guess was: Menu -> File -> Export Notebook As -> PDF.

Identifiers

UUID
829c7fb3-526b-492d-a743-0832a33b4a3c
GUID
https://mpievolbio-scicomp.pages.gwdg.de/blog/post/2020-12-09_pandoc_vs_nbconvert/
URL
https://mpievolbio-scicomp.pages.gwdg.de/blog/post/2020-12-09_pandoc_vs_nbconvert/

Dates

Issued
2020-12-09T01:00:00
Updated
2020-12-09T01:00:00