# Adding spaces in xeCJK for Chinese, Japanese, Korean doesn't work

I followed the answers given in various related questions but none of them solve the problem of adding spaces in xeCJK package.

\documentclass{article}
\usepackage[CJKspace,space,CJKspace=true]{xeCJK}
\usepackage{xunicode}
\setCJKmainfont{Batang}
\renewcommand\CJKglue{}
\makeatletter
\let\xeCJK@ignorespaces\relax
\makeatother
\ExplSyntaxOn
\int_step_inline:nnnn { "AC00 } {1} { "D7A3 } { \char_set_catcode_letter:n {#1} }
\ExplSyntaxOff

\begin{document}
\CJKspace

あいうえお

あ い う え お

일이삼사오

일 이 삼 사 오

\end{document}


None of the Chinese, Japanese, or Korean add any spaces.

the output is as follows:

xelatex cjk.tex
This is XeTeX, Version 3.14159265-2.6-0.99996 (TeX Live 2016) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(./cjk.tex
LaTeX2e <2016/03/31>
Babel <3.9r> and hyphenation patterns for 3 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
...
) (/usr/share/texlive/texmf-dist/tex/xelatex/xecjk/xunicode-extra.def)
(/usr/share/texlive/texmf-dist/tex/xelatex/xecjk/xeCJK.cfg))
*************************************************
* fontspec warning: "script-not-exist"
*
* Font 'Batang' does not contain script 'CJK'.
*************************************************
(./cjk.aux) (/usr/share/texlive/texmf-dist/tex/latex/tipa/t3cmr.fd) [1]
(./cjk.aux) )
Output written on cjk.pdf (1 page).
Transcript written on cjk.log.


Here are what I think are some relevant lines from cjk.log:

. Defining command \xeCJKShipoutHook with sig. '' on line 148.
\g__xeCJK_spacefactor_int=\count116
\l__xeCJK_begin_int=\count117
\l__xeCJK_end_int=\count118
. Defining command \normalspacedchars with sig. 'm' on line 618.
. Defining command \xeCJKOffVerbAddon with sig. '' on line 3443.
\l__xeCJK_verb_exspace_skip=\skip54
. Defining command \CJKspace with sig. '' on line 3753.
. Defining command \CJKnospace with sig. '' on line 3754.
. Redefining command \nobreakspace with sig. '' on line 3910.


I am using Fedora 27 texlive-2016 and other stock packages that come with the repo. What am I missing?

• Have you tried with a different font? If I run your code I see spaces, but I don't have the Batang font so I have to comment out the \setCJKmainfont line. – erik Mar 29 '18 at 14:46
• I just tried with the Batang font and I see spaces in the output. Can you post an image of your output? – erik Mar 29 '18 at 14:59
• I tried all different combinations of the preamble lines to no avail. I haven't touched anything except US letter instead of A4 using texconfig-sys paper letter. – Yusuf N Mar 29 '18 at 15:39
• Sorry but I can't reproduce the problem. My output has spaces. It also has spaces if I remove everything in the preamble except \usepackage[CJKspace]{xeCJK} and \setCJKmainfont{Batang}. Is your package up to date? – erik Mar 29 '18 at 15:52
• Thank you erik for the informative answer. It definitely points to my own setup somehow. Now I have to figure out what is causing this. And it is up to date as of last night. – Yusuf N Mar 29 '18 at 16:02

I finally found an alternate solution: use kotex package instead of xeCJK. It works perfectly for all Chinese, Japanese, and Korean. How do I get Korean (Hangul) characters to typeset in LaTeX ?

It also works perfectly in lyx.

Here is an example how to do all CJK with spacing. I changed the last character of Chinese to show that it works with Chinese too. That character doesn't seem to exist in Korean hanja, so I just set its font to Chinese, and now it shows.

\documentclass{article}
\usepackage{kotex}
\usepackage[english]{babel}
\setmainhangulfont{Batang}
\setmainhanjafont{SimSun}
\begin{document}

あいうえお

あ い う え お

일이삼사오

일 이 삼 사 오

abcde

a b c d e
\end{document}

• Wow, I didn't know Japanese also had characters that Korean and Chinese fonts don't include. I ended up mixing both xeCJK and kotex and now spacing works. I think it is a hack, but at least it works. – Yusuf N Mar 30 '18 at 0:11