Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to type Chinese in TeX compiled with LaTeX. I have read the previous post. As I have to stick on article as documentclass, the following solution works for me so far:

% UTF-8 encoding
% bad-looking fonts (CJKfonts package)
% latex
\documentclass{article}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK*}{UTF8}{gbsn}
文章内容。
\clearpage\end{CJK*}
\end{document}

It annoys me to have to enclose Chinese characters within an environment (CJK*). Isn't there a solution to type Chinese any time and any place we want, just as English characters?

Edit 1:

I tried the following code within Emacs, I use C-c C-c to launch LaTeX command within Emacs:

% Compile with xelatex
% UTF-8 encoding
\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{SimSun}
\begin{document}
文章内容
\end{document}

It returns an error:

--- TeX said ---
 ********************************************
 * XeTeX is required to compile this document.
 * Sorry!
 ********************************************.
\RequireXeTeX ...********************************}
                                              \endgroup \fi 
l.25 \RequireXeTeX

But I have already done sudo apt-get install texlive-xetex, I have also installed texlive-full.

share|improve this question
2  
can you use xelatex? –  guillem Apr 10 '13 at 10:33
    
It is confusing for me... should I install xelatex or xetex? I am under Ubuntu, and editing a tex under Emacs... –  SoftTimur Apr 10 '13 at 10:42
    
@SoftTimur a tex distribution will probably give you both if you ask for either. you should be using xelatex, though. –  wasteofspace Apr 10 '13 at 10:56
4  
you actually want to launch xelatex command instead of latex (don't know how you do that on emacs, but on the command line is xelatex mydoc) –  guillem Apr 10 '13 at 11:04
3  
You should use xelatex rather than latex, or in emacs, if you are using AucTeX, you can achieve that by adding this code into you .emacs file: (setq TeX-engine 'xetex) –  Timothy Li Apr 10 '13 at 11:42

1 Answer 1

up vote 9 down vote accepted

Using CJK

If you use CJK package, you can use CJK environment at the beginning and the end of the document only once. So you don't need to worry about where to put the CJK environment when you type the text. Say, you can (and you should) simply use

\documentclass{book}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK*}{UTF8}{gbsn}

\chapter{某章}
内容……

\chapter{某章}
内容……

\clearpage\end{CJK*}
\end{document}

Using xeCJK

As is said before, you should use xelatex command instead of latex command. And furthermore, you must specify a Chinese font installed in your Linux OS which can be listed via fc-list command.

It is typical that a default installation of Ubuntu does not have proper Chinese fonts installed. You can install WenQuanYi(文泉驿) and Arphic(文鼎) free fonts via apt-get, or you can manually install other commercial fonts.

Then use fc-list in a console window to get the font list in your OS. A typical list is like:

AR PL UMing TW:style=Light
AR PL UMing HK:style=Light
AR PL UMing CN:style=Light
AR PL UKai CN:style=Book
AR PL UKai HK:style=Book
AR PL UKai TW:style=Book
......
DejaVu Sans Mono:style=Bold
DejaVu Sans Mono:style=Book
DejaVu Sans:style=Bold
DejaVu Sans:style=Book
DejaVu Serif:style=Bold
DejaVu Serif:style=Book
......
WenQuanYi Zen Hei,文泉驛正黑,文泉驿正黑:style=Regular
WenQuanYi Zen Hei Mono,文泉驛等寬正黑,文泉驿等宽正黑:style=Regular

Some of these are Chinese fonts, some are not. You can choose a font name (before the :) to use, for example

% Compile with xelatex
% UTF-8 encoding
\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{AR PL UMing CN} % may be changed
\begin{document}
文章内容
\end{document}

Note that the Chinese font names in different Linux distribution are quite different, e.g. you may get AR PL SungtiL GB for the same Arphic font. So don't just copy my code.

And you need to configure your Emacs to use xelatex instead of latex or pdflatex.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.