LoginSignup
7
5

More than 5 years have passed since last update.

jupyter notebook を日本語入りの pdf に変換したい

Posted at

こちらの記事の焼き直しなんですけど、
http://qiita.com/tttamaki/items/58ab3250202d2c17e233

いろいろハマったのでメモ代わりに。

ipynb2pdfja.sh
#!/bin/bash

set -eu

tmpdir=$(mktemp -d)
ln -s `pwd`/$1 $tmpdir/
cd $tmpdir

cat <<EOD > jsarticle.tplx
% Default to the notebook output style
((* if not cell_style is defined *))
    ((* set cell_style = 'style_ipython.tplx' *))
((* endif *))

% Inherit from the specified cell style.
((* extends cell_style *))

%===============================================================================
% Latex Article
%===============================================================================

((* block docclass *))
\documentclass[a4paper,dvipdfmx]{jsarticle}
((* endblock docclass *))
EOD

FILENAME=$(basename $1 .ipynb)
jupyter nbconvert --to latex --template jsarticle.tplx $1
extractbb ${FILENAME}_files/*.png
platex ${FILENAME}.tex
dvipdfmx ${FILENAME}.dvi

cd -
cp $tmpdir/${FILENAME}.pdf .
usage
$ ./ipynb2pdf.sh foo.ipynb
7
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
5