5

If I use the ruby package to supply furigana for a kanji character, it seems to glue the characters right adjacent to the kanji closely together and preventing line breaks, creating odd and possibly excess spacing.

Is this a bug in the package and can I somehow fix it? Are there alternatives? (I found pxrubrica but that seems to be for platex only.)

\documentclass[12pt]{standalone}

\usepackage{setspace}

\usepackage{xeCJK}
\setCJKmainfont{Hiragino Mincho Pro}
%\setCJKmainfont{VL Gothic}

\usepackage{ruby}
\renewcommand\rubysep{-0.7em}

\begin{document}
\fbox{
\parbox{25em}{
\doublespacing
\ruby{青}{あお}いスーツ、\ruby{白}{しろ}いシャツ、\ruby{赤}{あか}いネクタイが\ruby{男}{だん}\ruby{性}{せい}\ruby{従}{じゆう}\ruby{業}{ぎよう}\ruby{員}{いん}\ruby{全
}{ぜん}\ruby{員}{いん}の\ruby{必}{ひつ}\ruby{需}{じゆ}\ruby{品}{ひん}だ。
}}
\end{document}

rendering of previous code

  • I'm not surprised that hyphenation isn't possible when furigana is used. TeX hyphenates words, not sequences of boxes. – egreg Oct 12 '14 at 12:23
  • 1
    Tht ruby package is not fully compatible with xeCJK. Actually, the luatexja package is much better than xeCJK in Japanese typesetting. luatexja contains an addon package luatexja-ruby. It provides functionality of furigana annotation. You can check their manuals for details. – Qing Lee Oct 12 '14 at 14:07
1

ruby package is not implemented correct. I think this code piece will solve the problem:

\usepackage{ruby}
\let\oldruby\ruby
\def\ruby#1#2{\oldruby{#1}{#2}\futurelet\next\addCJKglue}
\def\addCJKglue{\ifx\next\ruby \CJKglue \fi}

See also Displaying pinyin over Chinese characters, without impacting word spacing

  • It is tricky. luatexja-ruby is more powerful. – Qing Lee Oct 12 '14 at 14:30
  • FWIW, in addition to your monkeypatch, I had to supply the package with the nooverlap option for proper rendering. Previously nooverlap and overlap did not seem to have much effect. – oals Oct 12 '14 at 15:24
  • @QingLee: Indeed. But luatexja-ruby requires LuaTeX. It would be nice if some Japanese developer (e.g. 八登崇之) could provide a better solution for XeTeX. – Leo Liu Oct 12 '14 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.