wisetc / practice

Practice conclusion
5 stars 0 forks source link

Emacs org-mode 如何导出含有中文的PDF? #44

Open wisetc opened 2 years ago

wisetc commented 2 years ago

Table of Contents

  1. 问题的由来
  2. 安装 texlive-xetex
  3. 设置 latex header 和 font
  4. 配置 emacs 使用 xelatex

本文使用的操作系统是 ubuntu.

如何导出中文PDF?

问题的由来

org-mode 导出PDF使用的是 latex,但是latex对于中文字符的支持不是很好,所以需要用到另外的 xelatex。

安装完 xelatex 就够了吗?No,还得配置emacs及设置org-mode file的latex字体和字集。

安装 texlive-xetex

org-mode 使用 latex 导出PDF,然后 latex 对于中文的支持不是很好,所以需要另外安装 texlive-xetex

sudo apt-get install texlive-xetex

设置 latex header 和 font

然后在 org file的头部需要设置 latex header.

比如我在 ubuntu 下,设置了默认的中文字体为 Noto Serif CJK TC

#+LATEX_HEADER: \usepackage{xeCJK}
#+LATEX_HEADER: \setCJKmainfont{Noto Serif CJK TC}

配置 emacs 使用 xelatex

在 init.el 中也还需要设置

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