TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to move from p(La)TeX (which was a TeX system specifically tailored to Japanese in a pre-Unicode era) to Xe(La)TeX, and I'm having a problem.

In p(La)TeX, Japanese fonts are only used for non-ASCII characters, and ASCII characters are typeset in Computer Modern, or Times, etc just as in the standard TeX.

I would like to have something similar in Xe(La)TeX. In other words, I would like to have Xe(La)TeX to use different fonts depending on Unicode blocks, say CJK Unified Ideographs or Ethiopic or Cuneiform, see the list here.

Is it possible with XeLaTeX and fontspec? Or do I have to hack the source code of XeTeX to do this?

(A very similar question is asked here, but let me ask it here again, hoping that the situation changed in the last six months.)

share|improve this question
up vote 10 down vote accepted

Just use xeCJK for Japanese. A simple example:

\setCJKmainfont{MS Mincho} % for \rmfamily
おはよう VS Good morning

See also:

How to write Japanese with LaTeX?

xeCJK handles automatic font switching, line breaking, punctuation and spacing between characters. It was originally designed for Chinese typesetting, but works fine for Japanese and Korean as far as I know.

Another package is fontwrap. It uses a Perl script to switch fonts for different Unicode blocks. Personally, I don't like it.

For CJK scripts, xeCJK is suitable. For languages other than east Asian languages, one should use the polyglossia package with XeLaTeX. polyglossia is a babel replacement for XeLaTeX, but font switching is not automatic. Note that xeCJK is not compatible with polyglossia; they both use the \XeTeXinterchartoks mechanism, but it is difficult to make them work together very well now. (At the moment, it doesn't work at all.)

share|improve this answer
Thank you very much, it definitely worked! – Yuji Jun 18 '11 at 1:08
@Alan: Thank you very much. Sorry for my poor English. – Leo Liu Jun 18 '11 at 7:15
your English is fine. And your answers are great (as is all the work you do on xeCJK) so I'm happy to help out in this way. – Alan Munn Jun 18 '11 at 13:50

For the sake of completeness I'd like to add an answer for the more general case of switching not only CJK unicode blocks but also other blocks (as the question implies).

You can use the package ucharclasses that is specifically designed for that. It also allows you to switch other scripts like Arabic, Devanagari or domino pieces. They way it does this also allows you to change typesetting from RTL to LTR and vice versa if one of the other scripts require that.

You can find the package here: http://www.ctan.org/tex-archive/macros/xetex/latex/ucharclasses

share|improve this answer
\XeTeXinterchartoks (what is used by ucharclasses) can't be reliably used to switch text direction, see tug.org/pipermail/xetex/2008-December/011362.html. – Khaled Hosny Oct 21 '11 at 16:50

Your Answer


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.