Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

\documentclass[a4paper]{article}

\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{CJK}

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

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

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.

share|improve this question
    
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
add comment

2 Answers

up vote 3 down vote accepted

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:

\documentclass[a4paper]{article}

\usepackage{xeCJK}

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

\begin{document}
This is some English text.
すべての人間は、生れながらにして自由であり、かつ、尊厳と権利とについて平等である。人間は、理性と良心とを授けられており、互いに同胞の精神をもって行動しなければならない。
\end{document}
share|improve this answer
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. –  LianTze Lim Jan 11 '11 at 11:44
add comment

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
\usepackage{fontspec}

\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  

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

\end{document} 
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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