In Jupyter Notebook, via "File- Download as - PDF via LaTeX (.pdf)", I downloaded my notebook as a pdf file. However, many of my code blocks get printed outside of the PDF page margins - i.e. for longer code lines, they get cut out at the pdf page right border. Any way to fix this so that I can have a readable PDF doc (other than manually add hard returns for each line or the way suggested in this post? Thanks!
I was having the same problem. Ultimately, I found the answer at:
http://www.markus-beuckelmann.de/blog/customizing-nbconvert-pdf.html
Basically, it involves adding a custom latex template that wraps lines. He also adjusts some of the font sizes so that the need for wrapping is less.
I did find one bug. His code is missing the final end macro line:
((*- endmacro *))
I put the file in ~/anaconda2/lib/python2.7/site-packages/nbconvert/templates/latex . The location will vary depending on your installation. I'm using anaconda 4.3.1 (Jupyter 4.3.1 as well?)
Actually what I did was rename the existing article.tplx, changed the "extends 'article.tplx' " reflect the new name, and wrote the new template as article.tplx . That way I can change the templates without having to restart the server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With