Converting jupyter notebooks with embedded images to pdf.

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

drag_and_drop

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

img

And after executing the cell, the image is rendered

img

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.

Image.

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…