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.

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

2 Answers 2

up vote 7 down vote accepted

Just use xeCJK for Japanese. A simple example:

\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{MS Mincho} % for \rmfamily
\begin{document}
おはよう VS Good morning
\end{document}

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
1  
\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

 
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.