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.

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 often require a combination of CJK characters with both low and high codepoints in the same line of text. (Here "low" means "in the Basic Multilingual Plane" or BMP, with codepoint lower than hex 10000.) I do not own a single typeface that contains all the CJK characters in forms I like, so I use two typefaces that look the same and together cover (apparently) all the CJK characters.

In a line of text containing both types of character, TeX requires explicit instructions as to which typeface to use: if a particular typeface does not contain a desired character, the only way to display the corresponding glyph is to specify a different typeface for that character.

My practice has been to assign my normal (BMP) font with \setCJKmainfont and then a secondary font, which contains all of the high-codepoint characters, with \setCJKsansfont. The nuisance is that in composing my document, I must manually assign the CJK sans font to the high-codepoint characters.

My question is whether there is a simple procedure that would choose the correct typeface, depending on which of them actually contains the required characters — without my manually changing the typeface.

share|improve this question
up vote 5 down vote accepted

We are sorry that xeCJK does not have this feature now. You can use zhspacing instead for this purpose. Maybe we'll add this feature to xeCJK in the future, but it requires quite a lot of code.

Using zhspacing:

% 𣴑 is \symbol{146075}

You can also use xeCJK with a simplified font switching syntax, if you do use xeCJK (in ctex, for example):




enter image description here

New solution, April 20:



It is inspired by http://d.hatena.ne.jp/zrbabbler/20110220/1298209702 . You can also use zxjafbfont.sty directly.

I would add the feature to xeCJK using this method some time later, with better user interface.

May 4, 2011

Now new option and user command is available. (will be updated at CTAN soon)


\usepackage[fallback]{xeCJK}[2011/05/01] % ver 2.3.19
% NOTE: "rm" for \setCJKmainfont, "sf" for \setCJKsansfont, "tt" for \setCJKmonofont
%       and others for \setCJKfamilyfont.

share|improve this answer
Thanks. I'm very grateful for everything that xeCJK has made possible for me, and will make do in the mean time. – brannerchinese Apr 18 '11 at 16:57
Note: one may need to install a Unicode CJK ExtB font to display the source code in the browser and editor. – Leo Liu Apr 18 '11 at 16:59
@Leo is it possible to use XeTeXintercharclass and XeTeXinterchartoks to do the switch? (Or is this the "lots of code" solution you have in mind?) – Alan Munn Apr 18 '11 at 17:16
@Alan: xeCJK and zhspacing both use \XeTeXintercharclass and \XeTeXinterchartoks heavily. In xeCJK, there are already 7 different character classes. Thus it requires a lot of code to add a new class. – Leo Liu Apr 18 '11 at 17:38
I add a fallback option to xeCJK v2.3.19, one can checkout latest version at code.google.com/p/ctex-kit/source/checkout before it is updated at CTAN. – Leo Liu May 4 '11 at 5:29

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.