What do I need to write documents in a CJK language? I'm getting no linebreaks at all on Japanese text. (overfull hboxes, text going off-page)

Here is a (mostly) stripped-down test:



\setmainfont[Mapping=tex-text]{VL Gothic}

\begin{CJK}{UTF8}{VL Gothic}

I'm not sure I'm using the CJK package correctly -- it seems to make no difference. What am I doing wrong?

I am using XeLaTeX.

  • This was supposed to have the tags: cjk japanese, but I'm not allowed to create new tags. – hhaamu Jan 10 '11 at 20:26
  • I have added a {cjk} tag. I don't think a {japanese} tag is needed, as we don't have any tags for other languages either. – Caramdir Jan 10 '11 at 22:38

Use xeCJK instead if you're using XeLaTeX. Also, use \setCJKmainfont for VL Gothic, reserving \setmainfont for selecting a font for non-CJK characters. The CJK environment is not required when using xeCJK.

The following works for me:



\setCJKmainfont{VL Gothic}

This is some English text.
  • 1
    Is that a minimal setting for CJK languages? – Yiannis Lazarides Jan 11 '11 at 1:31
  • 1
    @Yiannis As a matter of fact, fontspec, xunicode and xltxtra are not required. I've edited my answer accordingly. – imnothere Jan 11 '11 at 11:44

You should not combine CJK with XeLaTeX. CJK is designed for LaTeX, you need to install the fonts for TeX system, which is not very easy. xeCJK is a xe-version of CJK, used mainly by simplified Chinese.

XeLaTeX support instinct CJK fonts itself. xeCJK is of course more sophiscated.

\documentclass[a4paper]{article}%save as utf-8, run xelatex

\setmainfont[Mapping=tex-text]{MS P明朝}%I changed the font
\XeTeXlinebreaklocale "ja" % linebreak, otherwise all will in one line
\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt  

すべての人間は、生れながらにして自由であり、かつ、尊厳と権利とについて平等である。人間 は、理性と良心とを授けられており、互いに同胞の精神をもって行動しなければならない。


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.