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.

Can anyone describe how one can type Chinese in LaTeX? When I compile this:

\documentclass{article}
\begin{document}
 你好吗?
\end{document}

the resulting document shows nothing. For reference my IME is iBus 1.3.9 on Fedora 13.

share|improve this question
1  
The other questions tagged {cjk} could be of interest. –  Caramdir May 6 '11 at 19:54
add comment

4 Answers

The easiest way is (for Simplified Chinese document only):

% UTF-8 encoding
% Compile with latex+dvipdfmx, pdflatex or xelatex
% XeLaTeX is recommanded
% Some Chinese fonts should be installed in your system (SimSun, SimHei, FangSong, KaiTi)
\documentclass[UTF8]{ctexart}
\begin{document}
文章内容。
\end{document}

It is designed for Chinese typesetting. Font sizes, indentation, name translation, line spacing, ... everything is set.

There might be some problems on Linux with default font setting (for windows). Then you can define the fonts mannually using xeCJK:

\documentclass[UTF8,nofonts]{ctexart}
\setCJKmainfont{SimSun} % or any font you have.
\setCJKsansfont{SimHei}
\setCJKmonofont{FangSong}
\begin{document}
文章内容。
\end{document}

If you just want to typeset only a few Chinese charecter, you can use CJK with pdfLaTeX or xeCJK with XeLaTeX.

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

or

% UTF-8 encoding, pdflatex or latex+dvipdfmx
% Simplified Chinese fonts should be installed
\documentclass{article}
\usepackage{CJKutf8}
\AtBeginDvi{\input{zhwinfonts}}
\begin{document}
\begin{CJK*}{UTF8}{zhsong}
文章内容。
\clearpage\end{CJK*}
\end{document}

or

% UTF-8 encoding
% bad-looking fonts (CJKfonts package)
% latex+dvips, latex+dvipdfm(x) or pdflatex
\documentclass{article}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK*}{UTF8}{gbsn}
文章内容。
\clearpage\end{CJK*}
\end{document}
share|improve this answer
2  
Note: I am one of the developers of ctex bundle and xeCJK. –  Leo Liu May 7 '11 at 3:06
    
I am lucky to find your answer. Thank you very much for the examples! I tried the second example on TeXnicCenter with MikTeX 2.9, it works great with all of the other packages I have been using. I do have two more questions: 1. I can only change fonts to {UTF8}{zhsong},{UTF8}{zhhei},{UTF8}{zhkai} and {UTF8}{zhfs}, but how do I use zhli or zhiyou? 2. Is there a way I can use WinEdt, which still does not support UTF yet? –  ltxsun Jan 22 '12 at 5:26
1  
@ltxsun: I make a mistake, zhli and zhyou are in zhmetrics bundle. Please don't leave more comments here. You may ask a new question for that. And I think it is much better to ask at bbs.ctex.org for pure chinese questions. –  Leo Liu Feb 4 '12 at 7:59
1  
Great. I am using xeCJK now. But there is an indentation of paragraphs at the beginning of a section. I tried to read the manual but it is in chinese. I found an option, but this option does not seem to do the trick. –  Stefan Müller Feb 16 '13 at 9:03
1  
@StefanMüller: indentfirst=false would fix this. I'm sorry but my English is poor and I don't have much time to translate the manual now. –  Leo Liu Feb 20 '13 at 14:00
show 7 more comments

I use Chinese under XeLaTeX and the XeCJK package, which allow the use of CJK together with your own fonts. It's extremely convenient.

First, take a look at the explanation at Chou Pai-hsiang's website. This should get you started.

There are other important comments here on tex.SE about the use of fontspec and getting the full Chinese character set from two or more fonts, but you can worry about those matters later.

share|improve this answer
add comment

I recently ran into this on Fedora 16. You're seeing nothing due to not selecting the correct Chinese font, which is different on Windows, Mac and Linux.

The trick to finding the right font for a language on Linux is:

$ fc-list :lang=zh   

the default Chinese font on Fedora 16 is:

WenQuanYi Zen Hei,文泉驛正黑,文泉驿正黑:style=Regular

and on your Fedora 13 system it's likely to be:

AR PL UMing TW:style=Light
AR PL UMing CN:style=Light

(I'm from Taiwan so I use the Traditional Chinese variant ending in TW. You want "AR PL UMing CN" for simplified Chinese.) To install Chinese fonts etc on Fedora, run:

yum groupinstall 'Chinese Support'

Change your LaTeX source to:

\documentclass{article}
\setromanfont{AR PL UMing CN}
\begin{document}
你好吗?
\end{document}

and you should start seeing Chinese.

The above snippet was to help you diagnose the Chinese font problem. For real work I second the recommendation for the xeCJK package. My personal setup is documented here.

The inability to typeset the same Chinese, Japanese etc LaTeX source across Windows, Mac and Linux due to them having different fonts is a real pain but is not specific to XeTex. It's painful when using latex + dvipdfmx or pdflatex as well.

share|improve this answer
add comment

For ConTeXt users, this is simple.

First, use \mainlanguage[cn] and \setscript[hanzi] in the preamble to set the default language to Chinese. If you want only certain parts of the document to use Chinese, you can use \language[cn]{你好} within the document. If you want to place a little bit of English in the document, use \language[en]{hello} to ensure that the hyphenations appear correctly.

Next, the default fonts usually do not have Chinese characters, so you will need to create a typescript with Chinese fonts, then use \setupbodyfont to select that font. For details, see Getting started with Chinese in ConTeXt.

share|improve this answer
add comment

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.