% $B%k%S(B $BH~J8=q(B
%\def\ruby#1#2{%
%  \leavevmode%
%  \setbox0=\hbox{#1}\setbox1=\hbox{\tiny #2}%
%  \ifdim\wd0>\wd1 \dimen0=\wd0 \else \dimen0=\wd1 \fi
%  \hbox{\kanjiskip=\fill
%  \vbox{\hbox to \dimen0{\tiny \hfil#2\hfil}%
%  \nointerlineskip
%  \hbox to \dimen0{\hfil#1\hfil}}}}
%%
\providecommand{\rubyfamily}{}
\def\kanjistrut{\vrule \@height0.88zw \@depth0.12zw \@width\z@}
\newcommand{\ruby}[3][0zw]{%
  \leavevmode
  \dimen1=#1\relax
  \dimen3=\f@size\p@
  \setbox1=\hbox{#2}%
  \setbox3=\hbox{\rubyfamily\fontsize{0.5\dimen3}{0pt}\selectfont #3}%
  \ifdim\dimen1=\z@
    \ifdim\wd1>\wd3 \dimen1=\wd1 \else \dimen1=\wd3 \fi
  \else
    \ifdim\dimen1<\wd1
      \dimen1=\wd1
    \fi
  \fi
  \hbox{%
    \kanjiskip=0pt plus 2fil
    \xkanjiskip=0pt plus 2fil
    \vbox{%
      \hbox to \dimen1{\rubyfamily
        \fontsize{0.5\dimen3}{0pt}\selectfont \kanjistrut
        \ifdim\dimen1<\wd3
          \hss\unhbox3\hss
        \else
          \hfil\unhbox3\hfil
        \fi
      }%
      \nointerlineskip
      \hbox to \dimen1{\kanjistrut\hfil\unhbox1\hfil}}}\hskip\kanjiskip\relax}
\endinput
