TL;DR
If you want to convert Jupyter Notebook (possibly, with Japanese script included) to pdf, do the following
- move to new directory
- inside it, create the subdirectories
./notebooks
and./pdfs
- save your notebook under the name
./notebooks/notebook.ipynb
- run the command
docker run nailbiter/jupyter-latex-pdf
- pick up the generated pdf from
./pdfs/notebook.pdf
Purpose
In my work, I sometimes need to convert the Jupyter Notebook to PDF. While this is easy to do in general via jupyter nbconvert
, if the Notebook contains Japanese script, experience shows,
that often the additional processing is required.
In my experience, the approach that works is to convert Notebook to tex
file first, and then use XeTeX to create the PDF. However, this requires installing the number of big dependencies, most notably XeTeX and Japanese
fonts. In order to encapsulate these dependencies from contaminating the system, I have put up together simple Docker image, which does exactly that.
Codes
References
While working on this post, I have used the data from the following sources: