I wrote an article "Download Japanese Jupyter Notebook as PDF" (https://qiita.com/masa-ita/items/8d5ebe8afe0d580af184) more than two years ago, but it seems that it has become useless due to specification changes such as nbconvert. Therefore, I will write the revised version.
It seems that you should install the following modules.
sudo apt install texlive-lang-japanese
sudo apt install texlive-xetex
sudo apt install pandoc
I think it's easiest to install MacTex. In my case, I used MacPorts, so I used the ghostscript installed by MacPorts.
Japanese characters are not displayed in the template attached to nbconvert, so it needs to be corrected.
The template file used to be in the nbconvert installation directory, but now it seems that the directory where it is placed changes depending on the environment. Running the jupyter --path
command will bring up a list of directories where jupyter will search for data files, so it's a good idea to look for these locations.
# jupiter --Execution example of path
$ jupyter --path
config:
/home/basicuser/.jupyter
/usr/local/etc/jupyter
/etc/jupyter
data:
/home/basicuser/.local/share/jupyter
/usr/local/share/jupyter
/usr/share/jupyter
runtime:
/home/basicuser/.local/share/jupyter/runtime
One of the directories listed under data:
above is the location.
In this example
/home/basicuser/.local/share/jupyter/nbconvert/templates/latex
The TeX template file (extension .tex.j2
) was placed in.
The contents of the template file index.tex.j2
file,
tex:index.tex.j2
((=- Default to the notebook output style -=))
((*- if not cell_style is defined -*))
((* set cell_style = 'style_jupyter.tex.j2' *))
((*- endif -*))
((=- Inherit from the specified cell style. -=))
((* extends cell_style *))
%===============================================================================
% Latex Article
%===============================================================================
((*- block docclass -*))
\documentclass[11pt]{article}
((*- endblock docclass -*))
From, change as follows.
tex:index.tex.j2
((=- Default to the notebook output style -=))
((*- if not cell_style is defined -*))
((* set cell_style = 'style_jupyter.tex.j2' *))
((*- endif -*))
((=- Inherit from the specified cell style. -=))
((* extends cell_style *))
%===============================================================================
% Latex Article
%===============================================================================
((*- block docclass -*))
\documentclass[xelatex,ja=standard]{bxjsarticle}
((*- endblock docclass -*))
In the case of a virtual environment such as venv, the installation destination of the template file also differs for each virtual environment. For example, in the case of venv
venv/share/jupyter/nbconvert/templates/latex
Was placed in.
Also, the location of the template file can be specified in jupyter_nbconvert_config.json
. It seems that this file may have been generated in the directories listed in config:
of jupyter --path
above. If you can't find it in the standard location, check for this file.