Jupyter直接转pdf

需要安装Jupyter nbconvert 中文 PDF 模板(github地址 https://github.com/AllanChain/nb-tmpl-ctex,点个免费的星星吧)

Chinese LaTeX/PDF template for Jupyter notebook nbconvert using CTeX.

安装

pip install nb-tmpl-ctex

使用,通过 nbconvert 调用:

# 默认 ctexart
jupyter nbconvert example.ipynb --to pdf --template ctex
# 使用 ctexrep
jupyter nbconvert example.ipynb --to pdf --template ctex --template-file report

如果需要在 Jupyter 网页导出时自动使用 CTeX 模板,需要在 ~/.jupyter/jupyter_nbconvert_config.py 将 ctex 模板设置为默认:

c.LatexExporter.template_name = "ctex"
# c.LatexExporter.template_file = "report"