- Install the necessary packages:
On Ubuntu
sudo apt-get install texlive texlive-latex-extra texlive-xetex pandoc
- Set the appropriate flags in your notebook:
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.display import set_matplotlib_formats
set_matplotlib_formats('png', 'pdf')
# optional, but suppressing warnings makes for a cleaner output
import warnings
warnings.filterwarnings('ignore')
- Run the shell script
notebook_to_pdf
(located in this folder):
Note: If you are using conda or a virtualenv, make sure to source that environment before running this command
./notebook_to_pdf PATH/TO/<NOTEBOOK_NAME>.ipynb
You should see the file <NOTEBOOK_NAME>.pdf
alongside your notebook!