How to prevent Jupyter Notebook PDF from printing out of bounds?

In the Jupyter Notebook via "File-Download as - PDF via LaTeX (.pdf)", I downloaded my laptop in pdf format. However, many of my code blocks are printed outside the margins of a PDF page, i.e. For longer lines of code, they are cut out on the right border of the pdf page. Any way to fix this so that I can have a read PDF document (other than manually adding hard returns for each line or the method suggested in this post ? Thanks!

+5
source share
1 answer

I had the same problem. Ultimately, I found the answer to:

http://www.markus-beuckelmann.de/blog/customizing-nbconvert-pdf.html

This is mainly due to the addition of a custom latex pattern that wraps strings. It also adjusts some font sizes, so there is less need for wrapping.

I found one error. There is no final macro line in his code:

((*- endmacro *)) 

I put the file in ~ / anaconda2 / lib / python2.7 / site-packages / nbconvert / templates / latex. The location depends on your installation. I am using anaconda 4.3.1 (Jupyter 4.3.1 too?)

In fact, what I did was renamed to the existing article.tplx, changed the "extends" article.tplx "reflects the new name and wrote a new template as article.tplx. This way I can change the templates without restarting the server.

0
source

All Articles