MacOS Jupyter Notebook 输出PDF中文支持

Install Jupyter

$ pip install jupyter

Launch Notebook

$ jupyter notebook

Install pandoc

There is a package installer at pandoc's download page. If you later want to uninstall the package, you can do so by downloading this script and running it with perl uninstall-pandoc.pl.

Install LaTex / MiKTeX

For PDF output, you'll also need LaTeX. Because a full MacTeX installation takes more than a gigabyte of disk space, we recommend installing BasicTeX and using the tlmgr tool to install additional packages as needed. If you get errors warning of fonts not found, try

$ sudo tlmgr install collection-fontsrecommended

Also fix other potential problems

$ sudo tlmgr install mathpazo palatino enumitem collectbox adjustbox ucs

Update BasicTex and Install CTEX Packages

$ sudo tlmgr update --self

$ sudo tlmgr update --all

$ sudo tlmgr install ctex

$ sudo tlmgr install latexmk

$ sudo fmtutil-sys --all (only fix fonts problem)

Make sure no Errors occurred!

Modify template article.tplx

$ find / -name 'article.tplx'

my_tplx_dir = '/anaconda/lib/python2.7/site-packages/nbconvert/templates/latex/article.tplx'

$ vim your_tplx_dir

Change the document class to

\documentclass{ctexart}

or

\documentclass{article}

\usepackage{ctex}

Modify nbconvert settings pdf.py

$ find / -name 'pdf.py'

my_pdf_dir = '/anaconda/pkgs/nbpresent-3.0.2-py27_0/lib/python2.7/site-packages/nbpresent/exporters/pdf.py'

$ vim your_pdf_dir

Change the latex_command to

latex_command = List([u"xelatex", u"{filename}"], config=True,

help="Shell command used to compile latex.")

Reboot your Jupyter or System

Jupyter Notebook supports Markdown, if you prefer to LaTex, the following articles may help

部署MAC上的Sublime Text+LaTex中文环境

References:

https://github.com/jgm/pandoc/blob/master/INSTALL.md

https://kurubot.github.io/blog/2017/jupyter-installation

https://felixfan.github.io/RMarkdown-Chinese-PDF/

http://www.blogs8.cn/posts/WvAy5f7

你可能感兴趣的:(MacOS Jupyter Notebook 输出PDF中文支持)