# How to write spaces between Korean words with XeCJK?

I'm just trying to get LaTeX output spaces between Korean words. At the moment all it can do is to give long chains of syllables just like in Chinese or in Japanese, ignoring all the spaces I set.

Here is the code:

\documentclass[12pt]{scrartcl}
\usepackage[boldfont,slantfont]{xeCJK}
\usepackage{xunicode,xltxtra}
\usepackage{gb4e}

\setCJKmainfont{Batang} % for \rmfamily

\begin{document}
좋은 아침입니다! 안녕하세요, 저의 이름은 김 입니다.%"Good Morning! My Name is Kim." in Korean
\end{document}


The text output is just like: 좋은아침입니다! 안녕하세요, 저의이름은김입니다. So, spaces will only be processed after punctuation marks.

I know I'm doing something wrong, but I can't tell what exactly.

• Now xeCJK is updated to provide space option and \CJKspace. Check out the code at code.google.com/p/ctex-kit/source/checkout . The package will be uploaded to CTAN some time later. – Leo Liu May 21 '11 at 3:04
• Now xeCJK 2.4.2 is uploaded to CTAN. – Leo Liu Jun 13 '11 at 5:22

Quick fix:

\makeatletter
\let\xeCJK@ignorespaces\relax
\makeatother


In xeCJK 2.4.1 (2011/05/20), you can use:

\usepackage[space]{xeCJK}
\renewcommand\CJKglue{}% get proper linebreaking if spaces are provided


or use \CJKspace to allow spaces between CJK charecters.

Before the new xeCJK updated to CTAN, you can always get the latest code through SVN:

• While you're at it, please change the explicit character class assignments by using the allocation mechanism with \newXeTeXintercharclass so that xeCJK can cooperate with other packages that use character classes. – egreg May 4 '11 at 7:53
• @egreg: Thanks, it does be in the todo list, but it's not urgent. And AFAIK, it's more difficult than you say. The situation is a bit complex: class 1, 2 and 3 are predefined in XeTeX for CJK scripts and punctuations (although we redefined them), and others should be allocated with \newXeTeXintercharclass. Furthermore, this does little help with compatibility with other packages (e.g. polyglossia) --- once we allocate a new character class, we often have to define \XeTeXinterchartoks for all former character classes to make it work well. – Leo Liu May 4 '11 at 10:28
• @sunny: It isn't a new command in fact. In CJK package there are \CJKspace and \CJKnospace, and this is just a reimplementation of that. Prof. Sun, the author of xeCJK, also took part in development of some parts of CJK package. xeCJK borrows many things from CJK. – Leo Liu May 9 '11 at 12:40