How can I place vertical Chinese text for some of the text in a document?
[Tex/LaTex] Vertical Chinese text with XeTeX
cjkxetex
Related Solutions
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
If you use more than one paragraph Chinese, use our xeCJK
package.
For totally Chinese document, use our documents or packages in ctex
bundle. It is based on xeCJK
.
I have explained this topic in a previous question:
How does one type Chinese in LaTeX?
Of course xeCJK
solve the problem about line breaking. You don't need \XeTeXlinebreaklocale
with xeCJK
; and xeCJK
does not change the \XeTeXlinebreaklocale
either.
You don't need to care about the line break locale if you use
\XeTeXlinebreaklocale "zh"
it does nothing to do with western languages as far as I know. Similarly, using xeCJK
you also don't need to turn off it. Non-CJK text would be untouched. With xeCJK
, it is much easier to set the fonts for Chinese without changing western texts, and you'll get better result for puncuations.
For completeness only, I'll say that you can use \makexeCJKactive
and \makexeCJKinactive
to turn on and off the functions of xeCJK
.
Note: xeCJK
is not completely compatible with polyglossia
package for some of the languages. If you meet more problems, ask more questions or contact me. (I am currently the main maintainer of xeCJK
.)
For updated question, see this previous question:
How to write spaces between Korean words with XeCJK?
You can use space
and nospace
options in xeCJK
, and \CJKspace
and \CJKnospace
option, just like CJK
package do.
I think it is not suggested to suppress line breaks between Chinese characters even if you use \CJKspace
to allow spaces between Chinese characters. If you insist, you can change the definition of \CJKglue
to empty. You can read the document of xeCJK
if you are not sure about the options and commands.
After all, an example:
\documentclass{article}
\usepackage{xeCJK}[2011/05/20]
\setCJKmainfont{SimSun}
\begin{document}
在普通文字之间没有空格
可以避免源代码折行造成
的问题。
\CJKspace
如果 需要 也 可以 保留 空格。
这 对于 汉语 分词 研究 或许 是 有益的。
\end{document}
Best Answer
I know only some discussion for Chinese. There are some discussions and tools for vertical Japanese, but I know little about it.
I'm sorry that vertical typesetting options are still not available in
xeCJK
. It is indeed in the TODO list, but not urgent at all.For vertical typesetting, some techniques are needed:
\rotatebox
fromgraphics
bundle, or use special commands of XeTeX likepdflscape
package do.CJKvert
package do. We can hackxeCJK
to do this.gezhu
package. (not shown in the example below)A full example: