欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

jupyter notebook导出pdf并支持中文

程序员文章站 2022-04-15 21:55:24
1. jupyter提供导出的格式有.py、.html、.md、.pdf等。 2.需要先安装MiKTeX,Windows版一路next安装就行,安装包有190MB,安装过程还是耗费些时间的,下载路径:https://miktex.org/download 3.ipynb文件编译为tex,在命令行中定 ......

1. jupyter提供导出的格式有.py、.html、.md、.pdf等。

jupyter notebook导出pdf并支持中文

 

 2.需要先安装miktex,windows版一路next安装就行,安装包有190mb,安装过程还是耗费些时间的,下载路径:

3.ipynb文件编译为tex,在命令行中定位到要转换的jupyter文件的路径下,输入:

  jupyter nbconvert --to latex yournotebookname.ipynb

4.手动编辑latex文件,为了能支持输出中文,需要改一下tex文件,在编辑器(我用的是notepad++)打开刚才生成的latex文件,在\documentclass{article}(没有这一句就在\documentclass[11pt]{ctexart} 的后面插入下面的语句)后面插入:

  \usepackage{fontspec, xunicode, xltxtra}
  \setmainfont{microsoft yahei}
  \usepackage{ctex}

jupyter notebook导出pdf并支持中文

 

 5.转latex为pdf,随后在命令行下输入:

  xelatex yournotebookname.tex

jupyter notebook导出pdf并支持中文