前置条件
安装了如下依赖
- pandoc(pandoc.org/)
- miktex(miktex.org/download)
- pip install nbconvert
使用jupyter保存
使用命令行保存
jupyter nbconvert your_notebook.ipynb --to pdf
报错处理
如果遇见 nbconvert.exporters.pdf.LatexFailed: PDF creating failed, captured latex output: Failed to run "xelatex notebook.tex -quiet" command: xelatex: security risk: running with elevated privileges miktex-dvipdfmx: security risk: running with elevated privileges等报错可以使用如下方式处理
先导出成html
jupyter nbconvert --to html your_notebook.ipynb
然后用浏览器打开,在打印成pdf就可以了