Jupyter Notebook PDF output support in Chinese

Source: Internet
Author: User
Tags jupyter jupyter notebook

What is Jupyter notebook?

Jupyter Notebook is an upgrade of Ipython Notebook. Jupyter is able to organize real-time code , formulas, and visualizations into cells to form a code-friendly notebook. Jupyter supports both markdown syntax and latex syntax, and can effectively output PDF documents in Rich Text mode

Read more: Jupyter Notebook

Installing Jupyter Notebook

Official recommended Standard process: How to Install Jupyter Notebook

I was installed in the following order, the lack of support, Pip install xxxxxx

    1. Install Python
    2. Install Ipython by pippip install ipython
    3. Install Jupyter by pippip install jupyter
    4. Installing Pandoc
    5. Installing MiKTeX
Chinese support

Jupyter NoteBook export PDF requires latex support, but because of the default template settings, Latex does not recognize Chinese cannot be exported. To solve this problem, you need to convert IPYNB to Tex, then modify the Tex content, and finally generate the PDF file by Xelatex.

    • Compiling IPYNB to Tex
      Ipython nbconvert--to Latex example.ipynb
    • Change Tex, add Chinese support

Insert after \documentclass{article}

    • \usepackage{fontspec, Xunicode, Xltxtra}\setmainfont{microsoft Yahei}
    • Compiling Tex, generating PDF
    • Xelatex Example.tex

Note: PDF generated in this way cannot be wrapped automatically!

Choose another method--directly modify the Tex template file

Open ARTICLE.TPLX (\python27\lib\site-packages\nbconvert\templates\latex\) with a text editor and modify it to \documentclass{ctexart}.

The resulting PDF is as follows: Baidu Cloud

Thank

The solution of this paper comes from

    1. IPython Notebook Solution for the Chinese problem when turning into LaTeX
    2. Compiling Chinese documents with Xelatex/xetex
    3. CTEX Macro Package
    4. Changing style of Pdf-latex output through IPython Notebook conversion
Known Issues

The inserted picture is automatically set to the page width when compiling with Xelatex.

Workaround: Modify Tex to add the appropriate zoom scale.

\includegraphics{figpath}

Modified to:

\includegraphics[scale =. 5]{figpath}

To learn more about Latex, we recommend reading the Latex Notes of the package teacher

Jupyter Notebook PDF output support in Chinese

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.