Converting Jupyter Notebooks to PDFs (debugging pdflatex errors)

Jessica YungData Science

I had problems converting my .ipynb file to PDF with Jupyter’s method which uses pdflatex (see below for why it didn’t work), so I used an alternative method:

Alternative Method
  1. I exported the file to HTML (File -> Download as -> HTML) and then
  2. Converted the HTML file to a PDF on http://html2pdf.com/. It is free and worked well.
    1. Watch out for where it splits pages. It may slice off the top pixel of the first line of text on a page (e.g. if the page split is in the middle of a paragraph) and make the text harder to read.

Why Jupyter’s method (pdflatex) didn’t work

By pdflatex, I mean using Jupyter Notebook’s method of converting '.ipynb files to PDFs. (File -> Download as -> PDF via LaTeX)

  1. It doesn’t convert HTML tables to LaTeX tables. Each of my table cells was translated into a new line.
  2. It threw errors at me because of # in my Raw cells. It also accused me of having $ in my raw cells even though I could find none.
My Solutions

I fixed the latter issue with the #s by converting the Raw cells into code cells (and not running the code cells). I then converted the remaining raw code cells of table-separated values into Markdown cells.

There was no straightforward solution to the former issue with tables, so I used html2pdf instead. If anyone has a solution, please post it in the comments! 🙂

Error Messages for Reference

# Error:

$ Error:
Both errors were followed by