{"id":1680,"date":"2016-02-10T18:57:50","date_gmt":"2016-02-10T23:57:50","guid":{"rendered":"http:\/\/unitstep.net\/?p=1680"},"modified":"2016-02-10T18:57:50","modified_gmt":"2016-02-10T23:57:50","slug":"converting-an-ipython-notebook-to-pdf","status":"publish","type":"post","link":"https:\/\/unitstep.net\/blog\/2016\/02\/10\/converting-an-ipython-notebook-to-pdf\/","title":{"rendered":"Converting an IPython Notebook to PDF"},"content":{"rendered":"

If you have an IPython Notebook (*.ipynb<\/code> file), you may want to convert to PDF<\/acronym> for distribution. If you read the documentation for ipython nbconvert<\/code><\/a>, it seems fairly straightforward:<\/p>\n

$ ipython nbconvert --to PDF<\/acronym> <your notebook>.ipynb<\/code><\/pre>\n

However, if you run that, you’re likely to run into an error asking to you install Pandoc; this is because nbconvert<\/code> relies on an intermediate conversion to LaTeX first, and then to the final PDF<\/acronym> output. Pandoc is used for this. To install on OS X:<\/p>\n

$ brew install pandoc<\/code><\/pre>\n

Running the conversion again yields another error, suggesting you need the pdflatex<\/code> command; Pandoc doesn’t include any built-in support for LaTeX->PDF<\/acronym>, so you’ll need a LaTeX install. The Pandoc documentation<\/a> suggests BasicTeX:<\/p>\n

$ brew cask install basictex<\/code><\/pre>\n

Trying conversion results in another failure. Turns out, you need to install some more LaTeX packages<\/a>:<\/p>\n

$ sudo tlmgr update --self\r\n$ sudo tlmgr install adjustbox\r\n$ sudo tlmgr install collectbox\r\n$ sudo tlmgr install ucs<\/code><\/pre>\n

After this, you should be able to do your conversion and have a fairly-decent PDF<\/acronym> output based on your IPython Notebook:<\/p>\n

$ ipython nbconvert --to PDF<\/acronym> <your notebook>.ipynb<\/code><\/pre>","protected":false},"excerpt":{"rendered":"

If you have an IPython Notebook (*.ipynb file), you may want to convert to PDF for distribution. If you read the documentation for ipython nbconvert, it seems fairly straightforward: $ ipython nbconvert –to PDF <your notebook>.ipynb However, if you run that, you’re likely to run into an error asking to you install Pandoc; this is […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[403,277],"tags":[],"_links":{"self":[{"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/posts\/1680"}],"collection":[{"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/comments?post=1680"}],"version-history":[{"count":4,"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/posts\/1680\/revisions"}],"predecessor-version":[{"id":1734,"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/posts\/1680\/revisions\/1734"}],"wp:attachment":[{"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/media?parent=1680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/categories?post=1680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitstep.net\/wp-json\/wp\/v2\/tags?post=1680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}