% ruby.sty	$B%k%S$r;H$&$?$a$N%9%?%$%k%U%!%$%k(B
%		by y-takata@ics.osaka-u.ac.jp (~/.TAKABE)
%			Mar. ix, mcmxcii
%			May  viii, mcmxcii modified
%			Feb. viii, mcmxciii modified
%				change glues on the end of ruby
%
% \ruby[<n|p>]{<$B=O8l(B>}{<$B$U$j$,$J(B>}
%     : <$B=O8l(B>$B$N>e$K(B<$B$U$j$,$J(B>$B$rIU$1$k%^%/%m!%(B
%	<$B=O8l(B>$B$N:G>eJU$+$i(B\rubysep $B$@$1>e$K(B<$B$U$j$,$J(B>$B$N%Y!<%9%i%$%s$r(B
%	$B9g$o$9!%(B
%
%	[]$BItJ,$r>JN,$7$?>l9g!$(B<$B=O8l(B>$B$r<+A3$JJ8;z4V3V$GAHHG$7!$(B
%	<$B$U$j$,$J(B>$B$O!$(B
%	(1)<$B=O8l(B>$B$NI}$h$jC;$1$l$P(B<$B=O8l(B>$B$NI}$K9g$o$;$F6QEy3d$jIU$1$9$k!%(B
%	(2)<$B=O8l(B>$B$NI}$h$jD9$1$l$P(B<$B=O8l(B>$B$N:81&$K$O$_=P$5$;$k!%$D$^$j:8(B
%	   $B1&$N8l$N>e$K$+$V$5$;$k!%(B
%  OPTIONS
%   n : (narrow)
%	<$B$U$j$,$J(B>$B$^$?$O(B<$B=O8l(B>$B$N6QEy3d$jIU$1$r$d$a$k!%(B
%   s : (no sticking out)
%	<$B$U$j$,$J(B>$B$,(B<$B=O8l(B>$B$N30$K$O$_=P$5$J$$$h$&$K$9$k!%$9$J$o$A!$(B
%	<$B$U$j$,$J(B>$B$NI}$,(B<$B=O8l(B>$B$h$jD9$$>l9g!$(B<$B$U$j$,$J(B>$B$NI}$K9g$o$;$F(B
%	<$B=O8l(B>$B$r6QEy3d$jIU$1$9$k!%(B
%
% \rubysep
%     : <$B=O8l(B>$B$N:G>eJU$H(B<$B$U$j$,$J(B>$B$N%Y!<%9%i%$%s$N4V$N%0%k!<!%(B
%	$B%G%U%)%k%H$O(B 0pt$B!%(B
%
% \rubysize
%     : $B%+%l%s%H%U%)%s%H$NBg$-$5$KBP$9$k(B<$B$U$j$,$J(B>$B$NBg$-$5$r7h$a$k(B
%	$B%^%/%m!%(B
%
%	$B;29M(B:
%	  $B1|B<@2I'(B: LaTeX $BH~J8=q:n@.F~Lg!$5;=QI>O@<R!%(B
%
\def\ruby{\@ifnextchar [{\@ruby}{\@ruby[]}}
\def\@ruby[#1]#2#3{%
  \setbox\@rubyboxk\hbox{#2}\setbox\@rubyboxr\hbox{\rubysize #3}%
  \@rubyw\wd\@rubyboxk
  \@rubyh\ht\@rubyboxk \advance\@rubyh\dp\@rubyboxr
  \advance\@rubyh\rubysep
  \skip@=0pt plus 1fil % $B6QEy3d$NJ8;z4V%0%k!<(B
  \@tfor \@tempa :=#1\do{%
    \if\@tempa n\skip@\kanjiskip \fi
    \if\@tempa s%
      \ifdim\wd\@rubyboxr >\wd\@rubyboxk \@rubyw\wd\@rubyboxr \fi\fi}%
  \leavevmode\vbox{\kanjiskip\skip@%
    \baselineskip\@rubyh
%   \lineskiplimit=0pt \lineskip=0pt % $B=O8l$H%k%S$,=E$J$k$H$-$N%0%k!<(B
    \hbox to\@rubyw{\hss\unhbox\@rubyboxr\hss}
    \hbox to\@rubyw{\hss\unhbox\@rubyboxk\hss}}}

% $B4A;z$H%k%S$N$9$-$^(B
\newlength{\rubysep} \rubysep=0pt

% $B%k%S$N%U%)%s%H%5%$%:$rA*$V%k!<%k(B
\def\rubysize{%
  \ifx\@currsize\large\scriptsize
  \else\ifx\@currsize\Large\footnotesize
  \else\ifx\@currsize\LARGE\small
  \else\ifx\@currsize\huge\normalsize
  \else\ifx\@currsize\Huge\normalsize
  \else \tiny \fi\fi\fi\fi\fi}

% $B$=$NB>(B
\chardef\@rubyboxk=0
\chardef\@rubyboxr=2
\def\@rubyw{\dimen@}
\def\@rubyh{\dimen@ii}

