利用XeTex快速实现linux下的latex中文支持

linux下配置latex的中文支持似乎很麻烦,比如参看http://www.idurun.com/?p=336

有一种快速的解决方案是使用XeTex。假设你的系统已经安装了基本的tex系统比如texlive,通过(ubuntu下使用apt-get install)

yum install texlive-xetex texlive-texmf-xetex xdvipdfmx

这时就可以编写中文文档了。

比如编写sample.tex

\documentclass{article}
\usepackage{fontspec}
\setmainfont{文鼎PL中楷Uni}
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt
\begin{document}
\title{这是Xe\TeX 编排的中文}
\author{http://asc.2dark.org}
\maketitle
你好world!
很不幸,我是很长很长很长很长很长的一段文字;真的很长很长很长很长很长很长很长很长很长很长很长,看不下去了吧。
\end{document}

其中的字体是系统现有的中文字体,根据你自己的系统情况选择;我这里使用的是“文鼎PL中楷Uni”。可用

fc-list

查看系统中已经安装的字体,从中找出中文字体使用。

编译:

xelatex smaple.tex
evince sample.pdf

 看看是不是成功了!