11

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:

\enableregime[utf]
\usemodule[chi-00]
\starttext
    你好!
\stoptext

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:

\usemodule[chinese]
\usemodule[chi-simplified]
\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]
\starttext
    \completecontent
    \chapter{你好}
        你好
\endtext

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):

\mainlanguage[chinese]
\definetypeface[Song][rm][Xserif][Adobe Song Std]
\definetypeface[Heiti][ss][Xsans][Adobe Heiti Std]
\definefont[TitleFont][Song]
\setupbodyfont[Song, 12 pt]
\setuphead[chapter][number=yes, style=Heiti]
\starttext
    \chapter{你好}
        你好
\stoptext

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?

1 Answer 1

8
+200

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.

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

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

\setuppagenumber [numberconversion=cn]

\definestructureconversionset [chinese] [numbers] [cn]

\setupheads [sectionconversionset=chinese]

\define[2]\ChineseChapter
  {第#1章 #2}

\setuphead [chapter] [command=\ChineseChapter]

\setupbodyfont [stfangsong,12pt]

\mainlanguage[cn]

\setuppagenumbering[state=start]

\starttext

\startchapter[title={你好}]

你好!

\stopchapter

\completecontent[criterium=all]

\stoptext
2
  • 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, 2012 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, 2012 at 8:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .