UP | HOME

Export Orgmode File In Chinese

1. Introduction

OrgMode is really cool and export context to latex then processed to PDF is quite straightforwards. However when working with Chinese characters, I need additional packages.

First of all, install the following packages. (I already install the texlive package)

  apt-get install latex-cjk-chinese latex-cjk-xcjk texlive-xetex

2. First solution

Then in the org file, add the following latex options.

  #+LaTeX_HEADER: \usepackage{CJK}
  #+LaTeX_HEADER: \begin{CJK}{UTF8}{gbsn}

One drawback is the \begin{CJK} is added as a header option but it does not have close tag. I discovered this problem when checking with the tex output

People suggest to change to #+LaTeX: \begin{CJK}{UTF8}{gbsn} and append #+LaTex: \end{CJK} to the end of document.

It all works out OK except the title which is Chinese characters are not display at all.

3. Second solution

Turns out XeLaTex has better support for UTF8. Actually I did not figure how to make it work in orgmode until a guy from orgmode mail list point out in this thread.

All I need to do is adding following option to the org document.

#+LATEX_HEADER: \usepackage{xltxtra}
#+LATEX_HEADER: \setmainfont{WenQuanYi Micro Hei}

Also need to customize emacs latex to pdf process.

(setq org-latex-pdf-process
      '("xelatex -interaction nonstopmode -output-directory %o %f"
        "xelatex -interaction nonstopmode -output-directory %o %f"
        "xelatex -interaction nonstopmode -output-directory %o %f"))

PS:

  • The main font has been set may be vary among different systems.
  • How I find a proper font under ubuntu is via command fc-list.

PS <2021-10-26 Tue>

  • This work in MacOS 10.15 in terms of chinese font.

    #+LATEX_HEADER: \setmainfont{STHeiti}
    
  • ctex package also works besides xltxtra

    #+LATEX_HEADER: \usepackage{ctex}
    
  • install ctex

    tlmgr install ctex
    
  • Another useful reference Typefaces in MacOS