[XeTeX] xdCJK how to mix occasional Japanese with Chinese and English

Wilfred van Rooijen wvanrooijen at yahoo.com
Tue Apr 24 05:45:20 CEST 2012


Life can be even simpler. Especially of you are not too much interested in the finer details of line-breaking etc. The following works quite OK for me:

\documentclass[]{memoir}

\usepackage{polyglossia}  % will load fontspec 


%--------------------------------------------------------------------
% Setup line breaking etc for Japanese (this should also be satis-
% factory for non-Japanese parts of the text)
%--------------------------------------------------------------------
\setdefaultlanguage{english}
\XeTeXlinebreaklocale "ja"
\XeTeXlinebreakskip=0em plus 0.1em minus 0.01em


%--------------------------------------------------------------------
% Set automatic switch between Roman and CJK font
%--------------------------------------------------------------------
\XeTeXinterchartokenstate = 1

% when going from not CJK to CJK
\XeTeXinterchartoks 0 1   = {\cjkfont}
\XeTeXinterchartoks 0 2   = {\cjkfont}
\XeTeXinterchartoks 0 3   = {\cjkfont}
\XeTeXinterchartoks 255 1 = {\cjkfont}
\XeTeXinterchartoks 255 2 = {\cjkfont}
\XeTeXinterchartoks 255 3 = {\cjkfont}

% when going from CJK to not CJK
\XeTeXinterchartoks 1 0   = {\latinfont}
\XeTeXinterchartoks 2 0   = {\latinfont}
\XeTeXinterchartoks 3 0   = {\latinfont}
\XeTeXinterchartoks 1 255 = {\latinfont}
\XeTeXinterchartoks 2 255 = {\latinfont}
\XeTeXinterchartoks 3 255 = {\latinfont}

\newfontfamily{\cjkfont}  [Mapping=tex-text]{Kozuka Mincho Pr6N}
\newfontfamily{\latinfont}[Mapping=tex-text]{TeX Gyre Termes} 
\newfontfamily{\greekfont}[Mapping=tex-text]{Old Standard} 
\newfontfamily{\codefont} [Mapping=tex-text]{Liberation Mono} 

\setmainfont[Mapping=tex-text]{TeX Gyre Termes}

In this case, if you type a normal sentence, "I live in Tokyo (that is 東京 in Japanese)", it will automatically come out in the correct font, although the switch from CJK to not-CJK sometimes seems to not work perfectly.

Wilfred





________________________________
 From: Atsuhito Kohda <kohda at pm.tokushima-u.ac.jp>
To: xetex at tug.org; jon at newkanji.com 
Sent: Tuesday, 24 April 2012, 9:36
Subject: Re: [XeTeX] xdCJK how to mix occasional Japanese with Chinese and English
 
Hi Jon,

On Mon, 23 Apr 2012 07:26:21 -0600, jon wrote:

> I'm trying to typeset a 300 page English book that includes a lot of
> Chinese and occasional short strings of Japanese. I've been able to
> mix Chinese and English okay, but cannot apply a Japanese font in
> those few places where it is needed.

> Here is the prologue, a pruned version of what I am using for the
> book:
> 
> \documentclass[largecrownvopaper,11pt,onecolumn,twoside,showtrims]{memoir}
> \usepackage{fontspec}
> \usepackage{xltxtra}
> \usepackage[BoldFont,CJKnumbb] {xeCJK}
> \setmainfont[Mapping=tex-text,Numbers=OldStyle]{Linux Libertine O}
> \setsansfont[Mapping=tex-text]{Linux Biolinum O}
> \setCJKmainfont []{AR PL UKai TW}
> \newfontfamily \forjapanese{Ume Mincho}
> \begin{document}
> English
> 
> Chinese 不怕慢只怕站。
> 
> Japanese omiage, futon {\forjapanese お土産、布団}
> \end{document}

I'm not expert of xeCJK but it seems

\setCJKfamilyfont{ume}{Ume Mincho}
\newcommand{\jp}[1]{{\CJKfamily{ume}#1}}

Japanese omiage, futon \jp{お土産、布団}

works for me.  Note in \setCJKfamilyfont, {ume} can be
any name you like but {Ume Mincho} should be real japanese
fonts name.
Further, I don't have every fonts you use so I tested
with another fonts on Debian.

I hope this helps you a bit.

Best regards,            2012-4-24(Tue)

-- 
Debian Developer - much more I18N of Debian
Atsuhito Kohda <kohda AT debian.org>
Department of Math., Univ. of Tokushima


--------------------------------------------------
Subscriptions, Archive, and List information, etc.:
  http://tug.org/mailman/listinfo/xetex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/xetex/attachments/20120423/6367ef4e/attachment-0001.html>


More information about the XeTeX mailing list