This article is for my memorization about converting ipynb to PDF

I had to report paper work commited with python.

then I used jupyter and I found out nbconvert function.

If you have nbcovert and jupyter, it is easy to convert ipynb to PDF.

the way to convert ipynb to PDF is the following :

jupyter nbconvert –to pdf file_name.ipynb

Another way is using template like this:

jupyter nbconvert –to pdf –template what_you_want_to_use file_name.ipynb

refert to the following of help message of jupyter nbconvert.

Both HTML and LaTeX support multiple output templates. LaTeX includes
    'base', 'article' and 'report'.  HTML includes 'basic' and 'full'. You
    can specify the flavor of the format used.
    
    > jupyter nbconvert --to html --template basic mynotebook.ipynb

as metioned, the process above is under where you installed nbconvert , pandoc and etc.

If not, install them below

  1. nbconvert

pip3 install nbcovert

  1. Pandoc

sudo apt-get install pandoc

then run it to convert ipynb to PDF if you suceed!

Congradulation! you are done.

BUT if you get error message like me as follows:

OSError: xelatex not found on PATH, if you have not installed xelatex you may need to do so. Find further instructions at https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex.

just visit the URL, https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex.

you will find out how to install TeX, if you are linux user, type in the following

sudo apt-get install texlive-xetex

Then you could convert ipynb to PDF with prompt like two wasy below.

jupyter nbconvert –to pdf file_name.ipynb

The line above is my case that I used.

Another way is using template like this:

jupyter nbconvert –to pdf –template what_you_want_to_use file_name.ipynb

you could convert ipynb to a lots of format in Jupyter on web browser,

File - Download as - PDF via LaTex or etc.

In my case, when I used PDF via I had another error, Korean language problem like this:

The solution of the problem is fixing template, base.tplx like this:

\usepackage{kotex}
%\usepackage[T1]{fontenc}

After typing in kotex like above, Korean Language problem would be resolved.

The location of base.tplx is under lib/python3.5/site-packages/nbconvert/templates/latex.

depending on when you install python with root(sudo) or –user. The location of base.tplx is different

If root(suod), The python site-packages is under /usr/lib

If –user, The python site-packages is under ~/.local/lib

Reference