xDroid's Blog

XeLaTeX中文配置

按照本懒人一贯懒惰的个性,这篇博文也一定是备份配置向。

  1. 安装LaTeX与XeLaTeX:
    sudo apt-get install texlive texlive-xetex latex-cjk-all
  2. 安装字体包(请使用开源字体):
    sudo apt-get install xfonts-wqy ttf-wqy-zenhei ttf-wqy-microhei
    顺便一提Ubuntu自带的AR PL UMing CN字体可以作为宋体来用。(虽然它的英文字体没有衬线)
  3. 勤勉的Vim党员们可以安装vim-latexsuite而无视下面这一条:
    sudo apt-get install texmaker
    此外还需要对TexMaker中默认的编译命令加以修改,参见第三条内容。
  4. 示例文档:
    \documentclass[11pt]{article}
    \usepackage{xeCJK}
    \setmainfont{Ubuntu}
    \setCJKmainfont{WenQuanYi Micro Hei Mono}
    \parindent 2em
    \begin{document}
      \section{举例}
      \begin{verbatim}
        标点。
      \end{verbatim}
      汉字Chinese数学$x=y$空格
    \end{document}
    编译结果: