I am typesetting a document in Chinese with spaces between words, for the purpose of making it easier for learners. Because of this, I am typesetting most of my document with no line-breaks between words. Because Chinese words are generally pretty short, this will generally not cause any big problems.
However, in some parts of my document, I will need to use Chinese line breaks, as defined by \XeTeXlinebreaklocale "zh" (or similar) to avoid over-filled boxes. Basically, those are regular paragraphs of Chinese text, which will not break at all without this option turned on. However, this appears to be a document specific parameter that I can not easily change in only parts of the document.
Any ideas for how I can deal with this problem?
I added to my comment below that I would like to type Chinese text without spaces, as "我喜欢学中文", in which case line breaks would use a Chinese locale, as well as space delimited Chinese (non-standard) "我 喜欢 学 中文", in which case no line breaks are allowed in the middle of words (or possibly only allowed with very high tolerance).
If I just turn on \XeTeXlinebreaklocale "zh" (or use a CJK package, I believe), all words will be broken according to Chinese rules, in which case I risk getting the "中文" in "我 喜欢 学 中文" broken over two lines.
Best Answer
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 onxeCJK
.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
withxeCJK
; andxeCJK
does not change the\XeTeXlinebreaklocale
either.You don't need to care about the line break locale if you use
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. WithxeCJK
, 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 ofxeCJK
.Note:
xeCJK
is not completely compatible withpolyglossia
package for some of the languages. If you meet more problems, ask more questions or contact me. (I am currently the main maintainer ofxeCJK
.)For updated question, see this previous question:
How to write spaces between Korean words with XeCJK?
You can use
space
andnospace
options inxeCJK
, and\CJKspace
and\CJKnospace
option, just likeCJK
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 ofxeCJK
if you are not sure about the options and commands.After all, an example: