I am trying to setup a basic document with ConTeXt, but I am having difficulty even getting started.

First, I tried the documentation at ConTeXt wiki: Chinese. I tried the sample code on that page:


That compiled without errors, but displayed an empty document.

Next, I tried building a minimal document based on my understanding of the instructions in Chinese in ConTeXt:

\defineunicodefont [SimChi] [SimplifiedChinese] [chinese]
\definefontsynonym [SimChiLiShuRegular] [gbls] [encoding=gbk]
\definefontsynonym [SimChiLiShuSlanted] [gbls] [encoding=gbk]
\definefontsynonym [SimChiLiShuItalic]  [gbls] [encoding=gbk]
\definefontsynonym [SimChiLiShuBold]    [gbls] [encoding=gbk]
\definefontsynonym [SimChiLiShuBoldSlanted] [gbls] [encoding=gbk]
\definefontsynonym [SimChiLiShuBoldItalic] [gbls] [encoding=gbk]

I was unsure which compiler this code was for:

  • With context test.tex, the compiler complained \defineunicodefont was an "Undefined control sequence".
  • With texexec --xtx test.tex, the compiler complained that \setupunicodefont was an "Undefined control sequence".

Finally, I just ignored all of the documentation about using Chinese and tried to build a minimal working document following ConTeXt wiki: Fonts in XeTeX. With this, I finally have some code that compiles (at least with texexec --xtx test.tex):

\definetypeface[Song][rm][Xserif][Adobe Song Std]
\definetypeface[Heiti][ss][Xsans][Adobe Heiti Std]
\setupbodyfont[Song, 12 pt]
\setuphead[chapter][number=yes, style=Heiti]

This code compiles and displays Chinese, but I quickly found some problems:

  • \mainlanguage is set to [chinese], but the document uses English titles (e.g. "Contents"), rather than Chinese titles (e.g. "目录") and Western-style section numbering (e.g. "1, 1.1"), rather than Chinese-style numbering (e.g. "第一章") and all of the other nice language-specific features described in the Chinese in ConTeXt and ConTeXt up-to-date 1999/7 Chinese documentation.
  • When compiling, it ever puts line breaks anywhere, so all sentences run off the page.

How can I create a basic Chinese-language document in ConTeXt (preferably using OpenType fonts)? Are tools such as (or similar to) ctex or xecjk available for ConTeXt?


This is a basic Chinese document for ConTeXt mkiv. You compile it with "context test.tex" (of course, you need to have the STFangSong font). I don't know Chinese, but as far as I can see, numbers and chapter titles are in something that looks like Chinese.

\starttypescript [serif] [stfangsong]
      \definefontsynonym [Serif] [name:stfangsong][features=chinese]

\starttypescript [stfangsong]
      \definetypeface [stfangsong] [rm] [serif] [stfangsong] [default]

\setuppagenumber [numberconversion=cn]

\definestructureconversionset [chinese] [numbers] [cn]

\setupheads [sectionconversionset=chinese]

  {第#1章 #2}

\setuphead [chapter] [command=\ChineseChapter]

\setupbodyfont [stfangsong,12pt]








  • This works quite well. Is there any way to get the chapter titles to use "第一章" or "第1章" instead of just "1" for the numbering? – Village Jan 28 '12 at 5:10
  • I have edited my answer. Again, keep in mind that I don't know Chinese. The code for \definestructureconversionset etc. is quite new and under development, so there isn't a lot of documentation available for it. – Thomas Jan 29 '12 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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