Convert Ipynb To Pdf In Jupyter
Answer :
A simple and surprisingly good solution is to print the notebook to pdf through the browser with ctrl+p
. Just make sure your plots and figures are not on interactive mode otherwise they will not be displayed (set them to %matplotlib inline
).
Exporting jupyter notebooks through latex is quite troublesome and takes a lot of tinkering to get something remotely close to publish ready. When I absolutely need publication quality I do it on a latex editor, but this tutorial goes in great length about doing it on jupyter.
A few useful tips to get better results:
- Higher resolution plots
- Hide your code-cells from the pdf
- Take a look at these extensions to improve your jupyter documents
For Mac OS X, the solution for me was to install MacTex first and then export the path to find it:
### TeX
export PATH="/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:$PATH"
You can add this to your .bash_profile
or similar config file to load it every time.
See more here https://github.com/jupyter/nbconvert/issues/406
As said by Thomas K in the comments, you need to have Latex installed, and after add the path to the directory containing pdflatex.exe
file to the PATH
variable of your system.
I have looked for a lightweight distribution and tried installing TeXworks, but I didn't find any pdflatex.exe
file.
So I have tried TeX Live, which worked fine creating the pdflatex.exe
file under the target installation directory. This path should be like C:\...\texlive\2016\bin\win32
.
Finally, you should just add this path to the PATH
environment variable of your system (you can use the link shared by Thomas K).
As said here, you need to quit jupyter notebook and open a new command prompt after making any path changes, in order for jupyter to find the newly added item to the PATH
.
Then, in Jupyter, you can check your environment variables by running the following (refer to this link for details):
import os
os.environ['PATH'].split(';')
and check if it contains the path to pdflatex.exe
file.
If you get some trouble when exporting your notebook to pdf due to missing files/packages (this happened to me), refer to this link to search and install them under TeX Live.
Comments
Post a Comment