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.)
Best Answer
Just use
xeCJK
for Japanese. A simple example: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 thepolyglossia
package with XeLaTeX.polyglossia
is ababel
replacement for XeLaTeX, but font switching is not automatic. Note thatxeCJK
is not compatible withpolyglossia
; 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.)