I am new to ipython notebook, and I would like to convert my ipynb to pdf. But I get the following error when I try to Download as PDF via LaTex.
nbconvert faile
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:
For Linux, the reported error is due to the lack of XeLatex
, part of the texlive-xetex
package.
Installation in ubuntu will be:
sudo apt install texlive-xetex
I agree that latex installation (at least on windows) is painful and the result in my case was not a great looking document. The ctrl-p
method alone doesn't work great if you're running in JupyterLab, but if you export the notebook to HTML, then print from the browser, choosing PDF, the result is quite good.
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
For Error 500
Debian Or Ubuntu Users:-
First, install in terminal:-
sudo apt-get install texlive-full
then
conda install -c conda-forge pandoc
Here is the full solution that worked for me (for Mac).
brew cask install mactex
$ cd ~/
$ touch .bash_profile
This will open the bash profile on TextEditor
$ open -e .bash_profile
Paste the following to the top and save
export PATH="/Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:$PATH"
Close any notebook you have and reopen it
Here is the notebook explaining it step by step: https://github.com/ybaktir/notes/blob/master/Convert%20Jupyter%20Notebook%20to%20Pdf.ipynb