[XeTeX] CJK goodies in XeLaTeX

Yin Dian yindian at gmail.com
Thu Jan 10 09:48:47 CET 2008


Hi,

On Jan 10, 2008 9:50 AM, Wilfred van Rooijen <wvanrooijen at yahoo.com> wrote:
> Hello all,
>
> I am a new addition to the XeTeX list.
>
> A couple of weeks ago a discussion started on the
> Dutch latex user group about setting Japanese with
> latex. Since I consider learning and reading Japanese
> a hobby, the discussion was interesting for me.
>
> In 2002 I had the pleasure of working in Japan for a
> while. I had to write a paper for a conference, in
> Latex with Japanese. At that time I used ptex, the
> 'patched' latex that is capable of reading EUC-JP
> input. This was teTeX 2.2 time, and I installed
> everything from scratch on Turbolinux. I remember that
> it did work but especially the font trickery took some
> time to get to work. Nowadays, I mainly use OpenOffice
> to write Japanese (I have to write essays for my
> class).
>
> But being a latex afficionado I decided it was time to
> research once and for all the possibilities of
> non-latin typesetting in Japanese. After some
> wikipedia'ing en several google sessions, I understand
> the basics of character encodings etc.
>
> So I researched the latex options and came across the
> usual suspects:
>
> - CJK packages. Seems to work well, full support for
> ruby and associated tricks, many languages per
> document, but issues remain with character coding,
> preprocessors, and the need to explicitly switch
> between languages and fonts
There is a package xCJK, by Mr. Sun Wen-chang, which allows you to use
the CJK package's way to handle CJK typesetting issues, once you set
\XeTeXinputencoding to "bytes". Other CJK-dependent packages such as
CJKpunct and ruby should work pretty well with it. You can find xCJK
at this thread: http://bbs.ctex.org/viewthread.php?tid=40232 (register
required to download).
>
> - latex + UCS. Using the correct combination of
> inputenc and fontenc seems to work, but no line breaks
> in CJK for instance, and very minimal documentation.
> Also availability of fonts is an issue. CJK limited to
> one character set per document.
>
> - Omega/lambda + j-omega + dvipdfmx. Some non-trivial
> patches are needed to work correctly, but once it
> works unicode input is straightforward. Again, some
> issues with fonts remain, and there is no special
> support for CJK typesetting. But: no longer developed
>
> - Hans Hagen pointed me to XeTeX, and after some
> browsing in my texlive I am now able to use it. I have
> installed a bunch of Japanese ttf-files in my home dir
> and it works pretty well. It is definitely the best
> solution to typeset unicode input in a straightforward
> manner to a pdf.
>
> So the question is: are there any CJK goodies for
> XeTeX yet, like \ruby or so? Also, it seems to me that
The nruby.sty requires little change to work with XeTeX and zhspacing
(a package for typesetting Chinese). Here's the patch.
--- nruby.sty~  1994-02-12 23:00:00.000000000 +0800
+++ nruby.sty   2008-01-10 16:32:05.000000000 +0800
@@ -69,7 +69,7 @@
 \def\bx at sparse[#1]#2{\hbox to#1{\op at sparse{#2}}}
 \def\op at sparse#1{\sparse at skip%
  \@ifundefined{jintercharskip}{%
- \kanjiskip=0pt plus 1fil\xkanjiskip=\kanjiskip #1}{%
+ \def\skipzh{\hskip 0pt plus 1fil}\let\skipenzh=\skipzh #1}{%
  \jintercharskip=0pt plus 1fil\jasciikanjiskip=\jintercharskip
 #1}\sparse at skip}
 %

> support for vertical typesetting is necessary. I don't
> think the 'trick' of rotating the characters and then
> rotating a box on the page will always give a good
> result (「 and 」could pose problems).
Rotating really works. The punctuation change requires the font in use
to support Opentype feature +valt or +vhal. A typical font setting is
as follows:
\newfontfamily\myfont[RawFeature={vertical:+vert:+vhal}]{font name}
> What about punctuation symbols in the margin? And how
> about kerning? Is that handled by the font itself?
If the font support Opentype feature +halt and you do want to use
halfwidth punctuations, then there's nothing more needed than applying
the feature. However, if your font doesn't have halfwith alternatives
or you want to use fullwidth punctuations, then something special
should be done to deal with the inter-char tokens between punctuations
and other characters etc. You can refer to zhspacing, which already
solved the problem for Chinese typesetting. (XeTeX 0.997 in
development is required to utilize the inter-char token feature.)
>
> I'd be happy to help if I can contribute anything.
That's great. Always welcome:)

My package zhspacing currently doesn't deal with fonts or
prohibitions(kinsoku) for Japanese kanas, so it may not be suitable
for Japanese typesetting. There is a package jspacing for dealing with
Japanese in XeTeX, but it seems that it's not open to public for
download and I couldn't get it.
>
> Regards,
> Wilfred van Rooijen
>
Regards.

-YIN Dian


More information about the XeTeX mailing list