texlive[43943] Master/texmf-dist: pxrubrica (20apr17)

commits+karl at tug.org commits+karl at tug.org
Thu Apr 20 23:10:01 CEST 2017


Revision: 43943
          http://tug.org/svn/texlive?view=revision&revision=43943
Author:   karl
Date:     2017-04-20 23:10:01 +0200 (Thu, 20 Apr 2017)
Log Message:
-----------
pxrubrica (20apr17)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/platex/pxrubrica/README-ja.md
    trunk/Master/texmf-dist/doc/platex/pxrubrica/README.md
    trunk/Master/texmf-dist/doc/platex/pxrubrica/pxrubrica-en.pdf
    trunk/Master/texmf-dist/doc/platex/pxrubrica/pxrubrica-en.tex
    trunk/Master/texmf-dist/doc/platex/pxrubrica/pxrubrica.pdf
    trunk/Master/texmf-dist/source/platex/pxrubrica/pxrubrica.dtx
    trunk/Master/texmf-dist/tex/platex/pxrubrica/pxrubrica.sty

Modified: trunk/Master/texmf-dist/doc/platex/pxrubrica/README-ja.md
===================================================================
--- trunk/Master/texmf-dist/doc/platex/pxrubrica/README-ja.md	2017-04-20 21:09:43 UTC (rev 43942)
+++ trunk/Master/texmf-dist/doc/platex/pxrubrica/README-ja.md	2017-04-20 21:10:01 UTC (rev 43943)
@@ -45,6 +45,10 @@
 更新履歴
 --------
 
+  * Version 1.2  〈2017/04/20〉
+      - 自動切換のモノルビ・熟語ルビ。
+      - 安全モード。
+      - LuaTeX-ja の縦組のサポート。
   * Version 1.1  〈2017/04/10〉
       - XeTeX/LuaTeX のサポート。
       - 両側ルビの処理を改良。

Modified: trunk/Master/texmf-dist/doc/platex/pxrubrica/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/platex/pxrubrica/README.md	2017-04-20 21:09:43 UTC (rev 43942)
+++ trunk/Master/texmf-dist/doc/platex/pxrubrica/README.md	2017-04-20 21:10:01 UTC (rev 43943)
@@ -47,6 +47,10 @@
 Revision History
 ----------------
 
+  * Version 1.2  〈2017/04/20〉
+      - Mono-ruby and jukugo-ruby with switching.
+      - Safe mode.
+      - Support for vertical writing in LuaTeX-ja.
   * Version 1.1  〈2017/04/10〉
       - Support for XeTeX/LuaTeX.
       - Improve the process of two-side ruby.

Modified: trunk/Master/texmf-dist/doc/platex/pxrubrica/pxrubrica-en.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/platex/pxrubrica/pxrubrica-en.tex
===================================================================
--- trunk/Master/texmf-dist/doc/platex/pxrubrica/pxrubrica-en.tex	2017-04-20 21:09:43 UTC (rev 43942)
+++ trunk/Master/texmf-dist/doc/platex/pxrubrica/pxrubrica-en.tex	2017-04-20 21:10:01 UTC (rev 43943)
@@ -8,8 +8,8 @@
 \newcommand*{\Eg}{E.\,g.\mbox{}}
 \newcommand*{\eg}{e.\,g.\mbox{}}
 \newcommand*{\ie}{i.\,e.\mbox{}}
-\newcommand*{\myfileversion}{1.1}
-\newcommand*{\myfiledate}{2017/04/10}
+\newcommand*{\myfileversion}{1.2}
+\newcommand*{\myfiledate}{2017/04/20}
 \newsavebox{\myexample}
 \begin{document}
 
@@ -44,7 +44,13 @@
 \item Jukugo ruby (\Opt{j} option): one ruby block per kanji, but read as whole.\\
 \Eg\quad
 \verb+\ruby[j]{$B9&?}(B}{$B$/(B|$B$8$c$/(B}+ $\rightarrow$ \ruby[j]{$B9&?}(B}{$B$/(B|$B$8$c$/(B}\quad
-\verb+\ruby[j]{$B<7LLD;(B}{$B$7$A(B|$B$a$s(B|$B$A$g$&(B}+ $\rightarrow$ \ruby[j]{$B<7LLD;(B}{$B$7$A(B|$B$a$s(B|$B$A$g$&(B}
+\verb+\ruby[j]{$B<7LLD;(B}{$B$7$A(B|$B$a$s(B|$B$A$g$&(B}+ $\rightarrow$ \ruby[j]{$B<7LLD;(B}{$B$7$A(B|$B$a$s(B|$B$A$g$&(B}\\
+The current implementation uses the following strategy:
+if none of the ruby string per a kanji causes protrusion,
+then the whole is typeset as mono-ruby;
+otherwise, the whole is typeset as group-ruby,
+ignoring the ruby grouping.
+
 \item A \verb+|+ symbol in a ruby string denotes the boundary of reading for each kanji
 (\ie\ $B9&(B = $B$/(B and $B?}(B = $B$8$c$/(B).
 It is not needed in group ruby.

Modified: trunk/Master/texmf-dist/doc/platex/pxrubrica/pxrubrica.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/platex/pxrubrica/pxrubrica.dtx
===================================================================
--- trunk/Master/texmf-dist/source/platex/pxrubrica/pxrubrica.dtx	2017-04-20 21:09:43 UTC (rev 43942)
+++ trunk/Master/texmf-dist/source/platex/pxrubrica/pxrubrica.dtx	2017-04-20 21:10:01 UTC (rev 43943)
@@ -20,7 +20,7 @@
 %<*driver>
 \ProvidesFile{pxrubrica.dtx}
 %</driver>
-  [2017/04/10 v1.1 PX Japanese-style ruby]
+  [2017/04/20 v1.2 PX Japanese-style ruby]
 %<*driver>
 \documentclass{jsarticle}
 \usepackage{doc}
@@ -46,6 +46,7 @@
 \newcommand*{\Note}{\par\noindent $B"((B\ }
 \providecommand*{\pTeX}{p\TeX}
 \providecommand*{\upTeX}{u\pTeX}
+\providecommand*{\pdfTeX}{pdf\/\TeX}
 \providecommand*{\XeTeX}{XeTeX}
 \providecommand*{\LuaTeX}{Lua\TeX}
 \inhibitxspcode`$B!?(B=0
@@ -165,7 +166,9 @@
 %     \texttt{H} &                 & $B3HD%8*IU$-(B\\
 %     \texttt{m} & \fro{mono}      & $B%b%N%k%S(B\\
 %     \texttt{g} & \fro{group}     & $B%0%k!<%W%k%S(B\\
-%     \texttt{j} & \fro{jukugo}    & $B=O8l%k%S(B
+%     \texttt{j} & \fro{jukugo}    & $B=O8l%k%S(B\\
+%     \texttt{M} &                 & $B<+F0 at ZBX%b%N%k%S(B\\
+%     \texttt{G} &                 & $B<+F0 at ZBX%0%k!<%W%k%S(B
 %   \end{tabular}\qquad
 %   \begin{tabular}[t]{l@{ }ll}
 %     \texttt{P} & \fro{primary}    & $B>eB&G[CV(B\\
@@ -192,6 +195,11 @@
 %   $B$*$h$S$=$NJR2>L>!K$rBP1~$NHs>.=q$-2>L>(B
 %   $B$KJQ49$9$k!#(B
 %   |F| $B;XDj$O$3$N5!G=$rL58z$K$9$k!#(B
+% \item |M| $B$*$h$S(B |J| $B$N;XDj$O(B
+%   $B!V%0%k!<%W%k%S$H%b%N!&=O8l%k%S$N4V$G<+F0E*$K at Z$jBX$($k!W(B
+%   $B at _Dj$G$"$k!#(B
+%   $B6qBNE*$K$O!"%k%S$N%0%k!<%W$,(B1$B$D$7$+$J$$>l9g$O(B |m| $B$*$h$S(B |g|$B!"(B
+%   $BJ#?t$"$k>l9g$O(B |g| $B$HEy2A$K$J$k!#(B
 % \end{itemize}
 %
 % \jmeta{$B8eJd=u at _Dj(B}$B$O0J2<$NCM$N2?$l$+!#(B
@@ -267,9 +275,20 @@
 % $B2#AH$N>l9g!"?FJ8;zNs$N>eB&$H2<B&$K%k%S$rIU$9!#(B
 % $B=DAH$N>l9g!"?FJ8;zNs$N1&B&$H:8B&$K%k%S$rIU$9!#(B
 %
-% $BN>B&%k%S$O>o$K!JC1=c!K%0%k!<%W%k%S$H$J$k$N$G!"(B
-% \jmeta{$B%*%W%7%g%s(B}$B$NCf$N(B |m|$B!"(B|g|$B!"(B|j| $B$N;XDj$OL5;k$5$l$k!#(B
+% $BN>B&%k%S$G=O8l%k%S$r;H$&$3$H$O$G$-$J$$!#(B
+% $B$9$J$o$A!"(B\jmeta{$B%*%W%7%g%s(B}$BCf$G(B |j|$B!"(B|J| $B$O;XDj$G$-$J$$!#(B
 %
+% \Note 1.1$BHG0JA0$G$O>o$K%0%k!<%W%k%S$N07$$$G$"$C$?!#(B
+% $B5lHG$H$N8_49$N$?$a!"N>B&%k%S$N>l9g$K$O<+F0 at ZBX%b%N%k%S!J(B|M|$B!K$r(B
+% $B4{DjCM$H$9$k!#(B
+% \footnote{$B$D$^$j!"5lMh$N;HMQ$G$O%0%k!<%W%k%S$H07$o$l$k$?$a!"(B
+%   $B%k%S$N%0%k!<%W$O(B1$B$D$K$7$F$$$k$O$:$G!"$3$l$O?7HG$G$b$=$N$^$^(B
+%   $B%0%k!<%W%k%S$H07$o$l$k!#(B
+%   $B0lJ}$G!"%b%N%k%S$r;H$$$?$$>l9g$O%0%k!<%W$rJ#?t$K$9$k$O$:$G!"(B
+%   $B$3$N;~$O<+F0E*$K%b%N%k%S$K$J$k!#(B
+%   $B$J$N$G7k6I!"4pDl%b!<%I!J(B\texttt{g}$B!"(B\texttt{m}$B!K$r;XDj$9$k(B
+%   $BI,MW$OL5$$$3$H$K$J$k!#(B}
+%
 % \item |\atruby[|\jmeta{$B%*%W%7%g%s(B}|]{|\jmeta{$B?FJ8;z(B}^^A
 % |}{|\jmeta{$B>eB&%k%SJ8;z(B}|}{|\jmeta{$B2<B&%k%SJ8;z(B}|}|
 % 
@@ -280,9 +299,13 @@
 %
 % \subsection{$BF~NOJ8;zNs$N%0%k!<%W$N;XDj(B}
 %
-% $BF~NOJ8;zNs!J?FJ8;zNs!&%k%SJ8;zNs!K$NCf$G!V(B\texttt{\vb}$B!W$O(B
+% $BF~NOJ8;zNs!J?FJ8;zNs(B
+% \footnote{$B8e=R$NDL$j!"8=:_$NHG$G$O?FJ8;zNs$rJ#?t%0%k!<%W$K$9$k(B
+%   $B;HMQK!$OB8:_$7$J$$$?$a!"?FJ8;zNsCf$G$O!V(B\texttt{\vb}$B!W$O;H$o$l$J$$!#(B}%
+% $B!&%k%SJ8;zNs!K$NCf$G!V(B\texttt{\vb}$B!W$O(B
 % $B%0%k!<%W$N6h at Z$j$H$_$J$5$l$k!J$?$@$7(B |{ }| $B$NCf$K$"$k$b$N$O(B
 % $BJ8;z$H$_$J$5$l$k!K!#(B
+%
 % $BNc$($P!"%k%SJ8;zNs(B
 %\begin{quote}\begin{verbatim}
 %$B$8$f$/(B|$B$4(B
@@ -389,6 +412,8 @@
 % \item |\rubysetup| $B$G$N at _Dj$ON_ at Q$9$k!#(B
 %   $BNc$($P!"=i4|>uBV$+$i!"(B|\rubysetup{hmf}| $B$H(B |\rubysetup{<->}| $B$r(B
 %   $B<B9T$7$?>l9g!"4{DjCM at _Dj$O(B |<hmPef>| $B$H$J$k!#(B
+% \item $B$3$N at _Dj$K4X$o$i$:!"N>B&%k%S$G$O!V<+F0 at ZBX%b%N%k%S!J(B|M|$B!K!W(B
+%   $B$,4{Dj$H$7$F;XDj$5$l$k!#(B
 % \end{itemize}
 %
 % \item |\rubyfontsetup{|\jmeta{$BL?Na(B}|}|
@@ -438,6 +463,25 @@
 %
 % \begin{itemize}
 % 
+% \item |\rubysafemode|$B!?(B|\rubynosafemode|
+%
+% $B0BA4%b!<%I$rM-8z!?L58z$K$9$k!#(B
+% $B!N4{Dj(B = $BL58z!O(B
+% \begin{itemize}
+% \item $BK\%Q%C%1!<%8$,%5%]!<%H$9$k%(%s%8%s$O(B
+%   (u){\pTeX}$B!"(B{\XeTeX}$B!"(B{\LuaTeX}$B$G$"$k!#(B
+%   $B!V0BA4%b!<%I!W$H$O!"$3$l$i$N%(%s%8%s$rI,MW$H$9$k0lIt$N5!G=(B
+%   \footnote{$B0BA4%b!<%I$G$O!"6/@)E*$K%0%k!<%W%k%S$K at Z$jBX$o$k!#(B
+%     $B$^$?!"?FJ8;z!&%k%S$NN>J}$N6QEy3d$jIU$1!"$*$h$S!"(B
+%     $B>.=q$-J8;z<+F0JQ49$,L58z$K$J$k!#(B}%
+%   $B$rL58z2=$7$?%b!<%I$G$"$k!#(B
+%   $B$D$^$j!"0BA4%b!<%I$K at Z$jBX$($k$3$H$G!"!H%5%]!<%HBP>]!I$G$J$$(B
+%   $B%(%s%8%s!J(B{\pdfTeX}$BEy!K$G$bK\%Q%C%1!<%8$N0lIt$N5!G=$,(B
+%   $B;H$($k2DG=@-$,$"$k!#(B
+% \item $B;HMQCf$N%(%s%8%s$,(B{\pdfTeX}$B$G$"$k>l9g!"4{Dj$G0BA4%b!<%I(B
+%   $B$,M-8z$K$J$k!#(B
+% \end{itemize}
+%
 % \item |\rubysizeratio{|\jmeta{$B<B?t(B}|}|
 %
 % $B%k%S%5%$%:$N?FJ8;z%5%$%:$KBP$9$k3d9g!#(B
@@ -630,7 +674,7 @@
 % \end{macro}
 %
 % \begin{macro}{\pxrr at warn@must at group}
-% $B2$J8%k%S!"$"$k$$$ON>B&%k%S$G%0%k!<%W%k%S0J30$N;XDj$,9T$o$l$?>l9g!#(B
+% $B2$J8%k%S$G%0%k!<%W%k%S0J30$N;XDj$,9T$o$l$?>l9g!#(B
 % $B6/@)E*$K%0%k!<%W%k%S$KJQ99$5$l$k!#(B
 %    \begin{macrocode}
 \def\pxrr at warn@must at group{%
@@ -639,6 +683,16 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\pxrr at warn@bad at jukugo}
+% $BN>B&%k%S$G=O8l%k%S$N;XDj$,9T$o$l$?>l9g!#(B
+% $B6/@)E*$KA*BrE*%b%N%k%S!J(B|M|$B!K$KJQ99$5$l$k!#(B
+%    \begin{macrocode}
+\def\pxrr at warn@bad at jukugo{%
+  \pxrr at warn{Jukugo ruby is not allowed here}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\pxrr at fatal@bad at intr}
 % $B%4!<%9%H=hM}$,M-8z$G?JF~M-$j$r at _Dj$7$?>l9g!#(B
 % $B!JCWL?E*%(%i!<!K!#(B
@@ -682,14 +736,26 @@
 %    \begin{macrocode}
 \def\pxrr at fatal@bad at mono{%
   \pxrr at fatal@error{%
-    Mono-ruby must have a single group%
+    Mono-ruby body must have a single group%
   }\pxrr at eh@fatal
 }
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\pxrr at fatal@bad at switching}
+% $BA*BrE*%k%S$N?FJ8;zNs$,(B2$B$D0J>e$N%0%k!<%W$r;}$D>l9g!#(B
+%    \begin{macrocode}
+\def\pxrr at fatal@bad at switching{%
+  \pxrr at fatal@error{%
+    The body of Switching-ruby (M/J) must\MessageBreak
+    have a single group%
+  }\pxrr at eh@fatal
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\pxrr at fatal@bad at movable}
-% $B2$J8%k%S$^$?$ON>B&%k%S!JI,$:%0%k!<%W%k%S$H$J$k!K$G(B
+% $B2$J8%k%S!JI,$:%0%k!<%W%k%S$H$J$k!K$G(B
 % $B%k%SJ8;zNs$,(B2$B$D0J>e$N%0%k!<%W$r;}$D>l9g!#(B
 %    \begin{macrocode}
 \def\pxrr at fatal@bad at movable{%
@@ -1130,6 +1196,91 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \subsection{$BJQ?t(B}
+%
+% \begin{macro}{\pxrr at body@list}
+% $B?FJ8;zNs$N$?$a$K;H$&%j%9%H!#(B
+%    \begin{macrocode}
+\let\pxrr at body@list\@undefined
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\pxrr at body@count}
+% |\pxrr at body@list| $B$ND9$5!#(B
+% $B at 0?tCM%^%/%m!#(B
+%    \begin{macrocode}
+\let\pxrr at body@count\@undefined
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\pxrr at ruby@list}
+% $B%k%SJ8;zNs$N$?$a$K;H$&%j%9%H!#(B
+%    \begin{macrocode}
+\let\pxrr at ruby@list\@undefined
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\pxrr at ruby@count}
+% |\pxrr at ruby@list| $B$ND9$5!#(B
+% $B at 0?tCM%^%/%m!#(B
+%    \begin{macrocode}
+\let\pxrr at ruby@count\@undefined
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\pxrr at sruby@list}
+% 2$B$DL\$N%k%SJ8;zNs$N$?$a$K;H$&%j%9%H!#(B
+%    \begin{macrocode}
+\let\pxrr at sruby@list\@undefined
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\pxrr at sruby@count}
+% |\pxrr at sruby@list| $B$ND9$5!#(B
+% $B at 0?tCM%^%/%m!#(B
+%    \begin{macrocode}
+\let\pxrr at sruby@count\@undefined
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\pxrr at whole@list}
+% $B?FJ8;z$H%k%S$N%j%9%H$r(Bzip$B$7$?%j%9%H!#(B
+%    \begin{macrocode}
+\let\pxrr at whole@list\@undefined
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\pxrr at bspace}
+% $B%k%S$,?FJ8;z$+$iA0B&$K$O$_$@$9D9$5!#(B
+% $B@#K!CM%^%/%m!#(B
+%    \begin{macrocode}
+\let\pxrr at bspace\@undefined
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\pxrr at aspace}
+% $B%k%S$,?FJ8;z$+$i8eB&$K$O$_$@$9D9$5!#(B
+% $B@#K!CM%^%/%m!#(B
+%    \begin{macrocode}
+\let\pxrr at aspace\@undefined
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\pxrr at natwd}
+% |\pxrr at evenspace@int| $B$N%Q%i%a%?!#(B
+% $B@#K!CM%^%/%m!#(B
+%    \begin{macrocode}
+\let\pxrr at natwd\@undefined
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\pxrr at all@input}
+% $BN>B&%k%S$N=hM}$G;H$o$l$k0l;~JQ?t!#(B
+%    \begin{macrocode}
+\let\pxrr at all@input\@undefined
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection{$BJd=u<jB3(B}
 %
 % \subsubsection{$B;(B?$JDj5A(B}
@@ -1179,6 +1330,14 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\pxrr at token}
+% |\futurelet| $BMQ$N0l;~JQ?t!#(B
+% \Note if-$B%H!<%/%s$J$I$N!H4m81!I$J%H!<%/%s$K$J$j$&$k$N$G;H$$2s$5$J$$!#(B
+%    \begin{macrocode}
+\let\pxrr at token\relax
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\pxrr at zero}
 % $B at 0?tDj?t$N%<%m!#(B
 % |\z@| $B$H0[$J$j!"!VC10LIU@#K!!W$N78?t$H$7$F;HMQ2DG=!#(B
@@ -1224,12 +1383,13 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\pxrr at ifnum}
-% |\pxrr at ifnum{|\jmeta{$B0z?t(B}|}|\jmeta{$B??(B}|}{|\jmeta{$B56(B}|}|\Means
-% |\ifnum|\jmeta{$B0z?t(B} $B$r9T$&%F%9%H!#(B
+% \begin{macro}{\pxrr at cond}
+% |\pxrr at cond\ifXXX...\fi{|\jmeta{$B??(B}|}{|\jmeta{$B56(B}|}|\Means
+% $B0lHL$N(B{\TeX}$B$N(Bif$BJ8(B |\ifXXX...| $B$r9T$&%F%9%H!#(B
+% \Note |\fi| $B$rIU$1$F$$$k$N$O!"(Bif-$BIT6Q9U$rHr$1$k$?$a!#(B
 %    \begin{macrocode}
-\def\pxrr at ifnum#1{%
-  \ifnum#1\expandafter\@firstoftwo
+\@gobbletwo\if\if \def\pxrr at cond#1\fi{%
+  #1\expandafter\@firstoftwo
   \else\expandafter\@secondoftwo
   \fi
 }
@@ -1297,11 +1457,12 @@
 % $B%^%/%mE83+$N%H%l!<%9$rL58z$K$7$?>uBV$G(B\jmeta{$B%F%-%9%H(B}$B$r<B9T$9$k!#(B
 %    \begin{macrocode}
 \def\pxrr at without@macro at trace#1{%
-  \chardef\pxrr at tracingmacros=\tracingmacros
+  \chardef\pxrr at tracingmacros@save=\tracingmacros
   \tracingmacros\z@
   #1%
-  \tracingmacros\pxrr at tracingmacros
+  \tracingmacros\pxrr at tracingmacros@save
 }
+\chardef\pxrr at tracingmacros@save=0
 %    \end{macrocode}
 % \end{macro}
 %
@@ -1382,9 +1543,9 @@
       \else
         \@tempdimb=\@tempcntb\@ne
       \fi}%
-    \xdef\pxrr at gtmpa{\the\@tempdimb}%
+    \xdef\pxrr at gtempa{\the\@tempdimb}%
   \endgroup
-  #1=\pxrr at gtmpa\relax
+  #1=\pxrr at gtempa\relax
 }
 %    \end{macrocode}
 % \end{macro}
@@ -1472,13 +1633,13 @@
   \pxrr at decompose@loopa#1\pxrr at end
 }
 \def\pxrr at decompose@loopa{%
-  \futurelet\pxrr at tempa\pxrr at decompose@loopb
+  \futurelet\pxrr at token\pxrr at decompose@loopb
 }
 \def\pxrr at decompose@loopb{%
-  \pxrr at ifx{\pxrr at tempa\pxrr at end}{%
+  \pxrr at ifx{\pxrr at token\pxrr at end}{%
     \pxrr at appto\pxrr at res{\pxrr at post}%
   }{%
-    \pxrr at setok{\pxrr at ifx{\pxrr at tempa\bgroup}}%
+    \pxrr at setok{\pxrr at ifx{\pxrr at token\bgroup}}%
     \pxrr at decompose@loopc
   }%
 }
@@ -1589,6 +1750,74 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\pxrr at tzip@list}
+% |\pxrr at tzip@list\CSa\CSb\CSc|\Means
+% |\CSa|$B!"(B|\CSb|$B!"(B|\CSc| $B$,0J2<$N$h$&$KE83+$5$l$k%^%/%m$H$9$k!'(B
+% \begin{quote}\small
+% |\CSa| = |\pxrr at pre{|\jmeta{X1}|}\pxrr at inter{|\jmeta{X2}|}|^^A
+% $\cdots$|\pxrr at inter{|\jmeta{Xn}|}\pxrr at post|\\
+% |\CSb| = |\pxrr at pre{|\jmeta{Y1}|}\pxrr at inter{|\jmeta{Y2}|}|^^A
+% $\cdots$|\pxrr at inter{|\jmeta{Yn}|}\pxrr at post|\\
+% |\CSc| = |\pxrr at pre{|\jmeta{Z1}|}\pxrr at inter{|\jmeta{Z2}|}|^^A
+% $\cdots$|\pxrr at inter{|\jmeta{Zn}|}\pxrr at post|
+% \end{quote}
+% $B$3$NL?Na$O(B |\pxrr at res| $B$r0J2<$NFbMF$KDj5A$9$k!#(B
+% \begin{quote}\small
+% |\pxrr at pre{|\jmeta{X1}|}{|\jmeta{Y1}|}{|\jmeta{Z1}|}|^^A
+% |\pxrr at inter{|\jmeta{X2}|}{|\jmeta{Y2}|}{|\jmeta{Z2}|}|^^A
+% $\cdots$\\
+% |\pxrr at inter{|\jmeta{Xn}|}{|\jmeta{Yn}|}{|\jmeta{Zn}|}|^^A
+% |\pxrr at post|
+% \end{quote}
+%    \begin{macrocode}
+\def\pxrr at tzip@list#1#2#3{%
+  \let\pxrr at res\@empty
+  \let\pxrr at post\relax
+  \let\pxrr at tempa#1\pxrr at appto\pxrr at tempa{{}}%
+  \let\pxrr at tempb#2\pxrr at appto\pxrr at tempb{{}}%
+  \let\pxrr at tempc#3\pxrr at appto\pxrr at tempc{{}}%
+  \pxrr at tzip@list at loopa
+}
+\def\pxrr at tzip@list at loopa{%
+  \expandafter\pxrr at tzip@list at loopb\pxrr at tempa\pxrr at end
+}
+\def\pxrr at tzip@list at loopb#1#2#3\pxrr at end{%
+  \pxrr at ifx{#1\relax}{%
+    \pxrr at tzip@list at exit
+  }{%
+    \pxrr at appto\pxrr at res{#1{#2}}%
+    \def\pxrr at tempa{#3}%
+    \expandafter\pxrr at tzip@list at loopc\pxrr at tempb\pxrr at end
+  }%
+}
+\def\pxrr at tzip@list at loopc#1#2#3\pxrr at end{%
+  \pxrr at ifx{#1\relax}{%
+    \pxrr at interror{tzip}%
+    \pxrr at appto\pxrr at res{{}}%
+    \pxrr at tzip@list at exit
+  }{%
+    \pxrr at appto\pxrr at res{{#2}}%
+    \def\pxrr at tempb{#3}%
+    \expandafter\pxrr at tzip@list at loopd\pxrr at tempc\pxrr at end
+  }%
+}
+\def\pxrr at tzip@list at loopd#1#2#3\pxrr at end{%
+  \pxrr at ifx{#1\relax}{%
+    \pxrr at interror{tzip}%
+    \pxrr at appto\pxrr at res{{}}%
+    \pxrr at tzip@list at exit
+  }{%
+    \pxrr at appto\pxrr at res{{#2}}%
+    \def\pxrr at tempc{#3}%
+    \pxrr at tzip@list at loopa
+  }%
+}
+\def\pxrr at tzip@list at exit{%
+  \pxrr at appto\pxrr at res{\pxrr at post}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\pxrr at concat@list}
 % |\pxrr at concat@list\CS|\Means
 % $B%j%9%H$NMWAG$rO"7k$9$k!#(B
@@ -1614,6 +1843,29 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\pxrr at unite@group}
+% |\pxrr at unite@group\CS|\Means
+% $B%j%9%H$NMWAG$rO"7k$7$F(B1$BMWAG$N%j%9%H$KAH$_D>$9!#(B
+% $B$9$J$o$A!"(B|\CS| $B$,(B
+% \begin{quote}\small
+% |\CS| = |\pxrr at pre{|\jmeta{X1}|}\pxrr at inter{|\jmeta{X2}|}|^^A
+% $\cdots$|\pxrr at inter{|\jmeta{Xn}|}\pxrr at post|
+% \end{quote}
+% $B$N;~$K!"(B|\CS| $B$r0J2<$NFbMF$GCV$-49$($k!#(B
+% \begin{quote}\small
+% |\pxrr at pre{|\jmeta{X1}\jmeta{X2}$\cdots$\jmeta{Xn}|}\pxrr at post|
+% \end{quote}
+%    \begin{macrocode}
+\def\pxrr at unite@group#1{%
+  \expandafter\pxrr at concat@list\expandafter{#1}%
+  \expandafter\pxrr at unite@group at a\pxrr at res\pxrr at end#1%
+}
+\def\pxrr at unite@group at a#1\pxrr at end#2{%
+  \def#2{\pxrr at pre{#1}\pxrr at post}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\pxrr at zip@single}
 % |\pxrr at zip@single\CSa\CSb|\Means
 % \begin{quote}\small
@@ -1665,6 +1917,8 @@
 %
 % $B$3$N>. at a$N%^%/%mFb$G;H$o$l$kJQ?t!#(B
 %    \begin{macrocode}
+\let\pxrr at x@tempa\@empty
+\let\pxrr at x@tempb\@empty
 \let\pxrr at x@gtempa\@empty
 \newif\ifpxrr at x@swa
 %    \end{macrocode}
@@ -1834,16 +2088,34 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\ifpxrr at in@tate}
+% \begin{macro}{\pxrr at if@in at tate}
+% |\pxrr at if@in at tate{|\jmeta{$B??(B}|}{|\jmeta{$B56(B}|}|\Means
 % $B=DAH$G$"$k$+!#(B
-% \Note {p\TeX} $B0J30$G$N=DAH$r%5%]!<%H$9$kM=Dj$O$J$$!#(B
 %    \begin{macrocode}
 \ifpxrr at in@ptex
-  \pxrr at csletcs{ifpxrr at in@tate}{iftdir}
+%    \end{macrocode}
+% {p\TeX}$B7O$N>l9g!"(B|\iftdir| $B%W%j%_%F%#%V$rMxMQ$9$k!#(B
+% \Note |\iftdir| $B$,L$Dj5A$N$H$-$K(Bif$B$,IT6Q9U$K$J$k$N$rKI$0!#(B
+%    \begin{macrocode}
+  \begingroup \catcode`\|=0
+    \gdef\pxrr at if@in at tate{%
+      \pxrr at cond|iftdir|fi
+    }
+  \endgroup
+\else\ifpxrr at in@luatexja
+%    \end{macrocode}
+% Lua\TeX-ja$BMxMQ$N>l9g!"(B|direction| $B%Q%i%a%?$rMxMQ$9$k!#(B
+%    \begin{macrocode}
+  \def\pxrr at if@in at tate{%
+    \pxrr at cond\ifnum\ltjgetparameter{direction}=\thr@@\fi
+  }
 \else
-  \pxrr at csletcs{ifpxrr at in@tate}{iffalse}
-\fi
 %    \end{macrocode}
+% $B$=$l0J30$O>o$K2#AH$H8+$J$9!#(B
+%    \begin{macrocode}
+  \let\pxrr at if@in at tate\@secondoftwo
+\fi\fi
+%    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\pxrr at get@jchar at token}
@@ -2311,7 +2583,7 @@
   \pxrr at csletcs{ifpxrr at aprotr}{ifpxrr at d@aprotr}%
   \let\pxrr at bintr@\pxrr at d@bintr
   \let\pxrr at aintr@\pxrr at d@aintr
-  \let\pxrr at athead@\pxrr at d@athead
+  \let\pxrr at athead\pxrr at d@athead
   \let\pxrr at mode\pxrr at d@mode
   \let\pxrr at side\pxrr at d@side
   \let\pxrr at evensp\pxrr at d@evensp
@@ -2331,6 +2603,12 @@
   \pxrr at mode@givenfalse
   \pxrr at athead@givenfalse
 %    \end{macrocode}
+% $BN>B&%k%S$N>l9g!"4pK\%b!<%I4{DjCM$,(B |M| $B$K8GDj$5$l$k!#(B
+%    \begin{macrocode}
+  \ifpxrr at truby
+    \let\pxrr at mode=M%
+  \fi
+%    \end{macrocode}
 % $BM-8B>uBV5!3#$r3+;O$5$;$k!#(B
 % $BF~NO$NKvHx$K(B |@| $B$r2C$($F$$$k!#(B
 % |\pxrr at end| $B$O%(%i!<;~$NC&=P$KMQ$$$k!#(B
@@ -2427,6 +2705,8 @@
 \def\pxrr at po@C at m{M}
 \def\pxrr at po@C at g{M}
 \def\pxrr at po@C at j{M}
+\def\pxrr at po@C at M{M}
+\def\pxrr at po@C at J{M}
 \def\pxrr at po@C at P{M}
 \def\pxrr at po@C at S{M}
 \def\pxrr at po@C at e{M}
@@ -2542,6 +2822,14 @@
   \let\pxrr at mode=j%
   \pxrr at mode@giventrue
 }
+\def\pxrr at po@PR at M{%
+  \let\pxrr at mode=M%
+  \pxrr at mode@giventrue
+}
+\def\pxrr at po@PR at J{%
+  \let\pxrr at mode=J%
+  \pxrr at mode@giventrue
+}
 \def\pxrr at po@PR at P{%
   \chardef\pxrr at side\z@
 }
@@ -2600,6 +2888,24 @@
 %
 % \subsection{$B%*%W%7%g%s at 09g@-8!::(B}
 %
+% \begin{macro}{\pxrr at mode@grand}
+% $B4pK\%b!<%I$N!HBgJ,N`!I!#(B
+% $B%b%N!J(B|m|$B!K!&=O8l!J(B|j|$B!K!&%0%k!<%W!J(B|g|$B!K$N2?$l$+!#(B
+% $B$D$^$j!HA*BrE*!I at _Dj$N(B |M|$B!&(B|J| $B$r(B |m|$B!&(B|j| $B$K4s$;$k!#(B
+% \Note $B40A4E83+2DG=$G$"$k$,!"!H at hF,40A4E83+2DG=!I$G$J$$$3$H$KCm0U!#(B
+%    \begin{macrocode}
+\def\pxrr at mode@grand{%
+  \if      m\pxrr at mode m%
+  \else\if M\pxrr at mode m%
+  \else\if j\pxrr at mode j%
+  \else\if J\pxrr at mode j%
+  \else\if g\pxrr at mode g%
+  \else ?%
+  \fi\fi\fi\fi\fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\pxrr at check@option}
 % |\pxrr at parse@option| $B$N7k2L$G$"$k%*%W%7%g%s at _DjCM$N at 09g@-$r8!::$7!"(B
 % $BI,MW$K1~$8$F!"CWL?E*%(%i!<$r=P$7$?$j!"7Y9p$r=P$7$FE, at Z$JCM$K(B
@@ -2644,15 +2950,15 @@
     \fi
   \fi
 %    \end{macrocode}
-% $BN>B&%k%S$G$O%b%N%k%S!J(B|m|$B!K!&=O8l%k%S!J(B|j|$B!K$O;XDjIT2D$J$N$G!"(B
+% $BN>B&%k%S$G$O=O8l%k%S!J(B|j|$B!K$O;XDjIT2D$J$N$G!"(B
 % $B%0%k!<%W%k%S$KJQ99$9$k!#(B
 % $B$3$N;~$KL@<(;XDj$G$"$k>l9g$O7Y9p$r=P$9!#(B
 %    \begin{macrocode}
-  \if g\pxrr at mode\else
+  \if \pxrr at mode@grand j%
     \ifnum\pxrr at side=\tw@
       \let\pxrr at mode=g\relax
       \ifpxrr at mode@given
-        \pxrr at warn@must at group
+        \pxrr at warn@bad at jukugo
       \fi
     \fi
   \fi
@@ -2663,9 +2969,9 @@
 %    \end{macrocode}
 % $B2#AH$_$G$OIT2D$J$N$GCfIU$-$KJQ99$9$k!#(B
 %    \begin{macrocode}
-    \ifpxrr at in@tate\else
+    \pxrr at if@in at tate{}{%else
       \chardef\pxrr at athead\z@
-    \fi
+    }%
 %    \end{macrocode}
 % $B%0%k!<%W%k%S$G$OIT2D$J$N$GCfIU$-$KJQ99$9$k!#(B
 %    \begin{macrocode}
@@ -2770,8 +3076,8 @@
   \pxrr at get@zwidth\pxrr at body@zw
   \begingroup
     \pxrr at use@ruby at font
-    \pxrr at get@zwidth\pxrr at gtempa
-    \global\let\pxrr at gtempa\pxrr at gtempa
+    \pxrr at get@zwidth\pxrr at ruby@zw
+    \global\let\pxrr at gtempa\pxrr at ruby@zw
   \endgroup
   \let\pxrr at ruby@zw\pxrr at gtempa
   \pxrr at get@iiskip\pxrr at iiskip
@@ -2779,11 +3085,11 @@
 %    \end{macrocode}
 % |\pxrr at htratio| $B$NCM$r at _Dj$9$k!#(B
 %    \begin{macrocode}
-  \ifpxrr at in@tate
+  \pxrr at if@in at tate{%
     \let\pxrr at htratio\pxrr at thtratio
-  \else
+  }{%
     \let\pxrr at htratio\pxrr at yhtratio
-  \fi
+  }%
 %    \end{macrocode}
 % |\pxrr at ruby@raise| $B$NCM$r7W;;$9$k!#(B
 %    \begin{macrocode}
@@ -2840,6 +3146,7 @@
 %
 % \begin{macro}{\pxrr at evenspace}
 % \begin{macro}{\pxrr at evenspace@int}
+% \begin{macro}{\pxrr at makebox@res}
 % |\pxrr at evenspace{|\jmeta{$B%Q%?!<%s(B}|}\CS{|\jmeta{$B%U%)%s%H(B}|}|^^A
 % |{|\jmeta{$BI}(B}|}{|\jmeta{$B%F%-%9%H(B}|}|\Means
 % \jmeta{$B%F%-%9%H(B}$B$r;XDj$N(B\jmeta{$BI}(B}$B$KBP$9$k(B
@@ -2949,9 +3256,11 @@
   \let\pxrr at sprop@y@#2%
   \let\pxrr at sprop@z@#3%
 }
+\let\pxrr at makebox@res\@undefined
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\pxrr at adjust@margin}
 % |\pxrr at adjust@margin|\Means
@@ -3008,6 +3317,9 @@
   \let\pxrr at inter@save\pxrr at inter
   \let\pxrr at post@save\pxrr at post
 }
+\let\pxrr at pre@save\@undefined
+\let\pxrr at inter@save\@undefined
+\let\pxrr at post@save\@undefined
 %    \end{macrocode}
 % \end{macro}
 %
@@ -3044,14 +3356,14 @@
   \expandafter\pxrr at transform@kana at loop@a#1\pxrr at end
 }
 \def\pxrr at transform@kana at loop@a{%
-  \futurelet\pxrr at tempa\pxrr at transform@kana at loop@b
+  \futurelet\pxrr at token\pxrr at transform@kana at loop@b
 }
 \def\pxrr at transform@kana at loop@b{%
-  \ifx\pxrr at tempa\pxrr at end
+  \ifx\pxrr at token\pxrr at end
     \let\pxrr at tempb\pxrr at transform@kana at end
-  \else\ifx\pxrr at tempa\bgroup
+  \else\ifx\pxrr at token\bgroup
     \let\pxrr at tempb\pxrr at transform@kana at loop@c
-  \else\ifx\pxrr at tempa\@sptoken
+  \else\ifx\pxrr at token\@sptoken
     \let\pxrr at tempb\pxrr at transform@kana at loop@d
   \else
     \let\pxrr at tempb\pxrr at transform@kana at loop@e
@@ -3129,6 +3441,14 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\pxrr at locate@temp}
+% |\pxrr at compose@*side at block@do| $B$G;H$o$l$k0l;~JQ?t!#(B
+% $B at 0?tDj?t!#(B
+%    \begin{macrocode}
+\let\pxrr at locate@temp\relax
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\pxrr at epsilon}
 % $B%k%SJ8;zNs$H?FJ8;zNs$N<+A3D9$N:9$,$3$NCM0J2<$N>l9g$O!"(B
 % $B:9$O$J$$$b$N$H$_$J$9!J1i;;8m:9BP:v!K!#(B
@@ -3247,6 +3567,10 @@
   \pxrr at compose@block at pre
 }
 \def\pxrr at compose@twoside at block@do#1#2#3#4{%
+%    \end{macrocode}
+% |\pxrr at boxa| $B$K?FJ8;z!"(B|\pxrr at boxr| $B$K>eB&%k%S!"(B
+% |\pxrr at boxb| $B$K2<B&%k%S$N=PNO$rJ];}$9$k!#(B
+%    \begin{macrocode}
   \setbox\pxrr at boxa\pxrr at hbox{#2}%
   \setbox\pxrr at boxr\pxrr at hbox{%
     \pxrr at use@ruby at font
@@ -3257,46 +3581,76 @@
     #4%
   }%
 %    \end{macrocode}
-% 3$B$D$N%\%C%/%9$N:GBg$NI}$r5a$a$k!#(B
-% $B$3$l$,A4BN$NI}$H$J$k!#(B
+% $B!V2?$l$+$N%k%S$,?FJ8;zNs$h$jD9$$$+!W$r8!::$9$k!#(B
 %    \begin{macrocode}
-  \@tempdima\wd\pxrr at boxa
-  \ifdim\@tempdima<\wd\pxrr at boxr
-    \@tempdima\wd\pxrr at boxr
-  \fi
-  \ifdim\@tempdima<\wd\pxrr at boxb
-    \@tempdima\wd\pxrr at boxb
-  \fi
-  \edef\pxrr at maxwd{\the\@tempdima}%
-  \advance\@tempdima-\pxrr at epsilon\relax
-  \edef\pxrr at maxwdx{\the\@tempdima}%
+  \@tempswafalse
+  \@tempdima\wd\pxrr at boxr
+  \advance\@tempdima-\wd\pxrr at boxa
+  \ifdim\pxrr at epsilon<\@tempdima \@tempswatrue \fi
+  \@tempdima\wd\pxrr at boxb
+  \advance\@tempdima-\wd\pxrr at boxa
+  \ifdim\pxrr at epsilon<\@tempdima \@tempswatrue \fi
 %    \end{macrocode}
-% $BA4BN$NI}$h$jC;$$%\%C%/%9$r6QEy3d$j$GAH$_D>$9!#(B
+% $B?FJ8;z$h$jD9$$%k%S$,B8:_$9$k>l9g!#(B
+% $BD9$$J}$N%k%SJ8;zNs$ND9$5$K9g$o$;$F!"?FJ8;zNs$H(B
+% $BB>J}$N%k%SJ8;zNs$rAH$_D>$9!#(B
+% $B!J<B:]$N=hM}$O(B |\pxrr at compose@twoside at block@sub| $B$G9T$&!#!K(B
 %    \begin{macrocode}
-  \ifdim\pxrr at maxwdx>\wd\pxrr at boxr
-    \pxrr at decompose{#3}%
-    \edef\pxrr at natwd{\the\wd\pxrr at boxr}%
-    \pxrr at evenspace@int{#1}\pxrr at boxr
-     \pxrr at use@ruby at font{\pxrr at maxwd}%
-    \pxrr at adjust@margin
-  \fi
-  \ifdim\pxrr at maxwdx>\wd\pxrr at boxb
-    \pxrr at decompose{#4}%
-    \edef\pxrr at natwd{\the\wd\pxrr at boxb}%
-    \pxrr at evenspace@int{#1}\pxrr at boxb
-     \pxrr at use@ruby at font{\pxrr at maxwd}%
-    \pxrr at adjust@margin
-  \fi
+  \if at tempswa
+    \pxrr at protrtrue
 %    \end{macrocode}
-% $B?FJ8;zNs$N%\%C%/%9$r:G8e$K=hM}$7$F!"$=$N(B |\pxrr@?space| $B$NCM$r(B
-% $B0J9_$N=hM}$GMQ$$$k!#(B
-% $B!J?FJ8;zNs$,C;$/$J$$>l9g$O(B |\pxrr@?space| $B$O%<%m!#!K(B
+% $B!V3HD%8*IU$-!W;XDj$N>l9g!"A0B&$NFM=P$rM^;_$9$k!#(B
 %    \begin{macrocode}
-  \ifdim\pxrr at maxwdx>\wd\pxrr at boxa
-    \pxrr at decompose{#2}%
-    \edef\pxrr at natwd{\the\wd\pxrr at boxa}%
-    \pxrr at evenspace@int{#1}\pxrr at boxa\relax{\pxrr at maxwd}%
+    \let\pxrr at locate@temp#1%
+    \ifnum\pxrr at athead>\@ne
+      \ifnum\pxrr at locate@temp=\pxrr at locate@inner
+        \let\pxrr at locate@temp\pxrr at locate@head
+      \fi
+    \fi
+%    \end{macrocode}
+% $B>eB&$H2<B&$N$I$A$i$N%k%S$,D9$$$+$K1~$8$F0z?t$rJQ$($F!"(B
+% |\pxrr at compose@twoside at block@sub| $B$r8F$S=P$9!#(B
+%    \begin{macrocode}
+    \ifdim\wd\pxrr at boxr<\wd\pxrr at boxb
+      \pxrr at compose@twoside at block@sub{#2}{#3}%
+       \pxrr at boxr\pxrr at boxb
+    \else
+      \pxrr at compose@twoside at block@sub{#2}{#4}%
+       \pxrr at boxb\pxrr at boxr
+    \fi
+%    \end{macrocode}
+% $B?FJ8;z$NJ}$,D9$$>l9g!#(B
+% $B?FJ8;zNs$ND9$5$K9g$o$;$F!"N>J}$N%k%S$r!JJRB&$N>l9g$HF1MM$N!K(B
+% $B6QEy3d$j$GAH$_D>$9!#(B
+%    \begin{macrocode}
   \else
+    \pxrr at protrfalse
+%    \end{macrocode}
+% $B8*IU$-%k%S$N>l9g$OAH$_D>$7$r9T$o$J$$!#(B
+%    \begin{macrocode}
+    \ifnum\pxrr at athead=\z@
+      \@tempdima\wd\pxrr at boxa
+      \advance\@tempdima-\wd\pxrr at boxr
+      \ifdim\pxrr at epsilon<\@tempdima
+        \pxrr at decompose{#3}%
+        \edef\pxrr at natwd{\the\wd\pxrr at boxr}%
+        \pxrr at evenspace@int{#1}\pxrr at boxr
+         \pxrr at use@ruby at font{\wd\pxrr at boxa}%
+        \pxrr at adjust@margin
+      \fi
+      \@tempdima\wd\pxrr at boxa
+      \advance\@tempdima-\wd\pxrr at boxb
+      \ifdim\pxrr at epsilon<\@tempdima
+        \pxrr at decompose{#4}%
+        \edef\pxrr at natwd{\the\wd\pxrr at boxb}%
+        \pxrr at evenspace@int{#1}\pxrr at boxb
+         \pxrr at use@ruby at font{\wd\pxrr at boxa}%
+        \pxrr at adjust@margin
+      \fi
+    \fi
+%    \end{macrocode}
+% |\pxrr@?space| $B$O%<%m$K at _Dj$9$k!#(B
+%    \begin{macrocode}
     \let\pxrr at bspace\pxrr at zeropt
     \let\pxrr at aspace\pxrr at zeropt
   \fi
@@ -3320,6 +3674,73 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\pxrr at body@wd}
+% |\pxrr at compose@twoside at block@sub| $B$NFbIt$GMQ$$$i$l$kJQ?t$G!"(B
+% $B!H?FJ8;zNs$N<B:]$ND9$5!I!J6QEy3d$j$GF~$C$?Cf4V$N6u$-$rF~$l$k$,(B
+% $BN>C<$N6u$-$rF~$l$J$$!K$rI=$9!#(B
+% $B@#K!CM%^%/%m!#(B
+%    \begin{macrocode}
+\let\pxrr at body@wd\relax
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\pxrr at compose@twoside at block@sub}
+% |\pxrr at compose@twoside at block@sub| $B$NFbIt$GMQ$$$i$l$k%^%/%m!#(B
+%    \begin{macrocode}
+\let\pxrr at restore@margin at values\relax
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\pxrr at compose@twoside at block@sub}
+% |\pxrr at compose@twoside at block@sub{|^^A
+% \jmeta{$B?FJ8;z(B}|}{|\jmeta{$BC;$$J}$N%k%SJ8;z(B}|}\CSa\CSb|\Means
+% $BN>B&%k%S$G?FJ8;zNs$h$jD9$$%k%SJ8;zNs$,B8:_$9$k>l9g$N(B
+% $BAH$_D>$7$N=hM}$r9T$&!#(B
+% $B$3$N%^%/%m$N8F=P;~!">eB&%k%S$N=PNO7k2L$,(B |\pxrr at boxr|$B!"(B
+% $B2<B&%k%S$N=PNO7k2L$,(B |\pxrr at boxb| $B$KF~$C$F$$$k$,!"(B
+% $B$3$N(B2$B$D$N%\%C%/%9$N$&$A!"C;$$%k%S$NJ}$,(B |\CSa|$B!"(B
+% $BD9$$%k%S$NJ}$,(B |\CSb| $B$H$7$FEO$5$l$F$$$k!#(B
+%    \begin{macrocode}
+\def\pxrr at compose@twoside at block@sub#1#2#3#4{%
+  \pxrr at decompose{#1}%
+  \edef\pxrr at natwd{\the\wd\pxrr at boxa}%
+  \pxrr at evenspace@int\pxrr at locate@temp\pxrr at boxa\relax{\wd#4}%
+  \@tempdima\wd#4%
+  \advance\@tempdima-\pxrr at bspace\relax
+  \advance\@tempdima-\pxrr at aspace\relax
+  \edef\pxrr at body@wd{\the\@tempdima}%
+  \advance\@tempdima-\wd#3%
+  \ifdim\pxrr at epsilon<\@tempdima
+    \edef\pxrr at restore@margin at values{%
+      \edef\noexpand\pxrr at bspace{\pxrr at bspace}%
+      \edef\noexpand\pxrr at aspace{\pxrr at aspace}%
+    }%
+    \pxrr at decompose{#2}%
+    \edef\pxrr at natwd{\the\wd#3}%
+    \pxrr at evenspace@int\pxrr at locate@temp#3%
+     \pxrr at use@ruby at font{\pxrr at body@wd}%
+    \pxrr at adjust@margin
+    \pxrr at restore@margin at values
+    \setbox#3\hbox{%
+      \kern\pxrr at bspace\relax
+      \box#3%
+    }%
+  \else
+    \ifnum\pxrr at locate@temp=\pxrr at locate@head
+      \@tempdima\z@
+    \else\ifnum\pxrr at locate@temp=\pxrr at locate@inner
+      \@tempdima.5\@tempdima
+    \fi\fi
+    \advance\@tempdima\pxrr at bspace\relax
+    \setbox#3\hbox{%
+      \kern\@tempdima
+      \box#3%
+    }%
+  \fi
+}
+%     \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\pxrr at compose@block at pre}
 % |\pxrr at compose@block at pre{|\jmeta{$B%Q%?!<%s(B}|}{|^^A
 %r \jmeta{$B?FJ8;z(B}|}{|\jmeta{$B%k%S(B1}|}{|\jmeta{$B%k%S(B2}|}|\Means
@@ -3330,7 +3751,7 @@
 %    \end{macrocode}
 % |f| $B;XDj;~$O>.=q$-2>L>$NJQ49$r;\$9!#(B
 %    \begin{macrocode}
-  \pxrr at ifnum{\pxrr at fullsize>\z@}{%
+  \pxrr at cond\ifnum\pxrr at fullsize>\z@\fi{%
     \pxrr at compose@block at pre@a
   }{%
     \pxrr at compose@block at pre@d
@@ -3355,7 +3776,7 @@
   \pxrr at compose@block at pre@d{#3}{#4}{#1}{#2}%
 }
 \def\pxrr at compose@block at pre@d{%
-  \pxrr at ifnum{\pxrr at evensp=\z@}{%
+  \pxrr at cond\ifnum\pxrr at evensp=\z@\fi{%
     \pxrr at compose@block at pre@e
   }{%
     \pxrr at compose@block at pre@f
@@ -3366,7 +3787,7 @@
   \pxrr at compose@block at pre@f{#1}{{#2}}%
 }
 \def\pxrr at compose@block at pre@f{%
-  \pxrr at ifnum{\pxrr at revensp=\z@}{%
+  \pxrr at cond\ifnum\pxrr at revensp=\z@\fi{%
     \pxrr at compose@block at pre@g
   }{%
     \pxrr at compose@block at do
@@ -3376,6 +3797,7 @@
 \def\pxrr at compose@block at pre@g#1#2#3#4{%
   \pxrr at compose@block at do{#1}{#2}{{#3}}{{#4}}%
 }
+\let\pxrr at compose@block at tempa\@undefined
 %    \end{macrocode}
 % \end{macro}
 %
@@ -3518,10 +3940,10 @@
 %    \begin{macrocode}
 \def\pxrr at check@kinsoku#1{%
   \let\pxrr at tempb#1%
-  \futurelet\pxrr at tempa\pxrr at check@kinsoku at a
+  \futurelet\pxrr at token\pxrr at check@kinsoku at a
 }
 \def\pxrr at check@kinsoku at a{%
-  \pxrr at check@char\pxrr at tempa
+  \pxrr at check@char\pxrr at token
 %    \end{macrocode}
 % $BOBJ8%k%S$N>l9g$O!"2$J8DL>oJ8;z$bOBJ8DL>oJ8;z$HF1$807$$$K$9$k!#(B
 %    \begin{macrocode}
@@ -3956,6 +4378,20 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\pxrr at mode@is at switching}
+% |\if\pxrr at mode@is at switching{|\jmeta{$B4pK\%b!<%I(B}|}| $B$N7A$N(B
+% if$BJ8$H$7$F;H$&!#(B
+% $B%b!<%I$,!HA*BrE*!I!J(B|M|$B!&(B|J|$B!K$G$"$k$+!#(B
+%    \begin{macrocode}
+\def\pxrr at mode@is at switching{%
+  \if      M\pxrr at mode T%
+  \else\if J\pxrr at mode T%
+  \else F%
+  \fi\fi T%
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\pxrr at ruby@proc}
 % |\pxrr at ruby@proc{|\jmeta{$B?FJ8;zNs(B}|}{|\jmeta{$B%k%SJ8;zNs(B}|}|\Means
 % $B$3$l$,<jB3$NK\BN$H$J$k!#(B
@@ -3976,6 +4412,7 @@
   \pxrr at decompbar{#2}%
   \let\pxrr at ruby@list\pxrr at res
   \edef\pxrr at ruby@count{\the\pxrr at cntr}%
+  \let\pxrr at sruby@list\relax
 %    \end{macrocode}
 % $B?FJ8;zF~NO$r%0%k!<%WNs$KJ,2r$9$k!#(B
 %    \begin{macrocode}
@@ -3982,13 +4419,23 @@
   \pxrr at decompbar{#1}%
   \let\pxrr at body@list\pxrr at res
   \edef\pxrr at body@count{\the\pxrr at cntr}%
-\ifpxrrDebug
-  \pxrr at debug@show at input
-\fi
+%    \end{macrocode}
+% $B0BA4%b!<%I$K4X$9$k=hM}$r9T$&!#(B
+%    \begin{macrocode}
   \ifpxrr at safe@mode
     \pxrr at setup@safe at mode
   \fi
 %    \end{macrocode}
+% $B%b!<%I$,!HA*BrE*!I$G$"$k>l9g!"!HIaDL$N!I%b!<%I(B
+% $B!J(B|m|$B!&(B|j|$B!&(B|g|$B!K$K5"Ce$5$;$k!#(B
+%    \begin{macrocode}
+  \if\pxrr at mode@is at switching
+    \pxrr at resolve@mode
+  \fi
+\ifpxrrDebug
+  \pxrr at debug@show at input
+\fi
+%    \end{macrocode}
 % $BF~NO8!::$r9T$$!"%Q%9$7$?>l9g$OAHHG=hM}$K?J$`!#(B
 %    \begin{macrocode}
   \pxrr at if@alive{%
@@ -4030,22 +4477,45 @@
 %    \begin{macrocode}
   \pxrr at parse@option\pxrr at option
 %    \end{macrocode}
-% $BN>B&%k%S$N>l9g!"F~NOJ8;zNs$r%0%k!<%WJ,2r$;$:$K!"$=$N$^$^$N0z?tNs$N(B
-% $B7A$G%^%/%m$K5-21$9$k!#(B
+% $BN>B&$N%0%k!<%W%k%S$G$O(B |pxrr at all@input| $B$rMxMQ$9$k$N$G!"(B
+% $BF~NOJ8;zNs$r at _Dj$9$k!#(B
 %    \begin{macrocode}
   \def\pxrr at all@input{{#1}{#2}{#3}}%
+%    \end{macrocode}
+% $BF~NOJ8;zNs$N%0%k!<%WJ,2r$r9T$&!#(B
+%    \begin{macrocode}
+  \pxrr at decompbar{#3}%
+  \let\pxrr at sruby@list\pxrr at res
+  \edef\pxrr at sruby@count{\the\pxrr at cntr}%
+  \pxrr at decompbar{#2}%
+  \let\pxrr at ruby@list\pxrr at res
+  \edef\pxrr at ruby@count{\the\pxrr at cntr}%
+  \pxrr at decompbar{#1}%
+  \let\pxrr at body@list\pxrr at res
+  \edef\pxrr at body@count{\the\pxrr at cntr}%
+%    \end{macrocode}
+% $B0BA4%b!<%I$K4X$9$k=hM}$r9T$&!#(B
+%    \begin{macrocode}
+  \ifpxrr at safe@mode
+    \pxrr at setup@safe at mode
+  \fi
+  \if\pxrr at mode@is at switching
+    \pxrr at resolve@mode
+  \fi
 \ifpxrrDebug
   \pxrr at debug@show at input
 \fi
-  \ifpxrr at safe@mode
-    \pxrr at setup@safe at mode
-  \fi
 %    \end{macrocode}
 % $BF~NO8!::$r9T$$!"%Q%9$7$?>l9g$OAHHG=hM}$K?J$`!#(B
 %    \begin{macrocode}
   \pxrr at if@alive{%
-    \pxrr at ruby@check at tg
-    \pxrr at if@alive{\pxrr at ruby@main at tg}%
+    \if g\pxrr at mode
+      \pxrr at ruby@check at tg
+      \pxrr at if@alive{\pxrr at ruby@main at tg}%
+    \else
+      \pxrr at ruby@check at tm
+      \pxrr at if@alive{\pxrr at ruby@main at tm}%
+    \fi
   }%
 %    \end{macrocode}
 % $B8e=hM}$r9T$&!#(B
@@ -4059,7 +4529,22 @@
 % $B0BA4%b!<%IMQ$N at _Dj!#(B
 %    \begin{macrocode}
 \def\pxrr at setup@safe at mode{%
-  \let\pxrr at mode=g%
+%    \end{macrocode}
+% $BC1=c%0%k!<%W%k%S$K6/@)E*$KJQ99$9$k!#(B
+% $B$3$l$K1~$8$F!"?FJ8;zNs$H%k%SJ8;zNs$N%0%k!<%W$r(B1$B$D$K=8 at .$9$k!#(B
+%    \begin{macrocode}
+  \let\pxrr at mode=g\relax
+  \pxrr at unite@group\pxrr at body@list
+  \def\pxrr at body@count{1}%
+  \pxrr at unite@group\pxrr at ruby@list
+  \def\pxrr at ruby@count{1}%
+  \ifx\pxrr at sruby@list\relax\else
+    \pxrr at unite@group\pxrr at sruby@list
+    \def\pxrr at sruby@count{1}%
+  \fi
+%    \end{macrocode}
+% $B!HJ8;zC10L$N%9%-%c%s!I$,I,MW$J5!G=$rL58z$K$9$k!#(B
+%    \begin{macrocode}
   \chardef\pxrr at evensp\z@
   \chardef\pxrr at revensp\z@
   \chardef\pxrr at fullsize\z@
@@ -4067,6 +4552,47 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\pxrr at resolve@mode}
+% $B4pK\%b!<%I$,!HA*BrE*!I!J(B|M|$B!&(B|J|$B!K$G$"$k>l9g$K!">u67$K1~$8$F(B
+% $BE, at Z$JDL>o$N%b!<%I$K at Z$jBX$($k!#(B
+%    \begin{macrocode}
+\def\pxrr at resolve@mode{%
+  \ifnum\pxrr at body@count=\@ne
+%    \end{macrocode}
+% $B%k%S%0%k!<%W$,(B1$B$D$G?FJ8;z$,J#?t$"$k>l9g$K$O%0%k!<%W%k%S$rA*Br$7!"(B
+%    \begin{macrocode}
+    \ifnum\pxrr at ruby@count=\@ne
+      \let\pxrr at pre\pxrr at decompose
+      \let\pxrr at post\relax
+      \pxrr at body@list
+      \ifnum\pxrr at cntr=\@ne\else
+        \let\pxrr at mode=g%
+      \fi
+    \fi
+%    \end{macrocode}
+% $B$=$l0J30$O%b%N%k%S!&=O8l%k%S$rA*Br$9$k!#(B
+%    \begin{macrocode}
+    \if M\pxrr at mode \let\pxrr at mode=m\fi
+    \if J\pxrr at mode \let\pxrr at mode=j\fi
+\ifpxrrDebug
+  \pxrr at debug@show at resolve@mode
+\fi
+%    \end{macrocode}
+% |\pxrr at check@option| $B$G9T$C$F$$$kD4 at 0$r$d$jD>$9!#(B
+%    \begin{macrocode}
+    \if g\pxrr at mode
+      \chardef\pxrr at athead\z@
+    \fi
+    \if g\pxrr at mode\else
+      \chardef\pxrr at evensp\@ne
+    \fi
+  \else
+    \pxrr at fatal@bad at switching
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsubsection{$BF~NO8!::(B}
 %
 % $B%0%k!<%W!&J8;z$N8D?t$N8!::$r9T$&<jB3!#(B
@@ -4121,15 +4647,53 @@
 % \end{macro}
 %
 % \begin{macro}{\pxrr at ruby@check at tg}
-% $BN>B&%k%S$N>l9g!"$3$3$G8!::$9$kFbMF$O$J$$!#(B
-% $B!JN>B&%k%S$NF~NOJ8;zNs$O%0%k!<%WJ,3d$5$l$:!">o$KC10l%0%k!<%W$H(B
-% $B$7$F07$o$l$k!#!K(B
+% $BN>B&$N%0%k!<%W%k%S$N>l9g!#(B
+% $B%k%S$,(B2$B$D$"$k$3$H$r=|$-!"JRB&$N>l9g$HF1$8!#(B
 %    \begin{macrocode}
 \def\pxrr at ruby@check at tg{%
+  \ifnum\pxrr at body@count=\pxrr at ruby@count\relax\else
+    \pxrr at fatal@bad at length\pxrr at body@count\pxrr at ruby@count
+  \fi
+  \ifnum\pxrr at body@count=\pxrr at sruby@count\relax\else
+    \pxrr at fatal@bad at length\pxrr at body@count\pxrr at sruby@count
+  \fi
+  \pxrr at if@alive{%
+    \ifnum\pxrr at body@count=\@ne\else
+      \ifpxrr at abody
+        \pxrr at fatal@bad at movable
+      \else\ifnum\pxrr at extra=\z@
+        \pxrr at fatal@na at movable
+      \fi\fi
+    \fi
+  }%
 }
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\pxrr at ruby@check at tm}
+% $BN>B&$N%b%N%k%S$N>l9g!#(B
+% $B%k%S$,(B2$B$D$"$k$3$H$r=|$-!"JRB&$N>l9g$HF1$8!#(B
+%    \begin{macrocode}
+\def\pxrr at ruby@check at tm{%
+  \ifnum\pxrr at body@count=\@ne
+    \let\pxrr at pre\pxrr at decompose
+    \let\pxrr at post\relax
+    \pxrr at body@list
+    \let\pxrr at body@list\pxrr at res
+    \edef\pxrr at body@count{\the\pxrr at cntr}%
+    \ifnum\pxrr at body@count=\pxrr at ruby@count\relax\else
+      \pxrr at fatal@bad at length\pxrr at body@count\pxrr at ruby@count
+    \fi
+    \ifnum\pxrr at body@count=\pxrr at sruby@count\relax\else
+      \pxrr at fatal@bad at length\pxrr at body@count\pxrr at sruby@count
+    \fi
+  \else
+    \pxrr at fatal@bad at mono
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsubsection{$B%k%SAHHG=hM}(B}
 %
 % \begin{macro}{\ifpxrr at par@head}
@@ -4359,8 +4923,67 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\pxrr at ruby@main at tm}
+% $BN>B&$N%b%N%k%S$N>l9g!#(B
+%    \begin{macrocode}
+\def\pxrr at ruby@main at tm{%
+  \pxrr at tzip@list\pxrr at body@list\pxrr at ruby@list\pxrr at sruby@list
+  \let\pxrr at whole@list\pxrr at res
+  \pxrr at check@par at head
+  \pxrr at any@protrfalse
+\ifpxrrDebug
+\pxrr at debug@show at recomp
+\fi
+  \let\pxrr at locate@head@\pxrr at locate@inner
+  \let\pxrr at locate@end@\pxrr at locate@inner
+  \let\pxrr at locate@sing@\pxrr at locate@inner
+  \ifpxrr at aprotr\else
+    \let\pxrr at locate@end@\pxrr at locate@end
+    \let\pxrr at locate@sing@\pxrr at locate@end
+  \fi
+  \ifpxrr at bprotr\else
+    \let\pxrr at locate@head@\pxrr at locate@head
+    \let\pxrr at locate@sing@\pxrr at locate@head
+  \fi
+  \def\pxrr at pre##1##2##3{%
+    \pxrr at if@last{%
+      \pxrr at compose@twoside at block\pxrr at locate@sing@
+       {##1}{##2}{##3}%
+      \pxrr at intrude@head
+      \unhbox\pxrr at boxr
+      \pxrr at intrude@end
+      \pxrr at takeout@any at protr
+    }{%
+      \pxrr at compose@twoside at block\pxrr at locate@head@
+       {##1}{##2}{##3}%
+      \pxrr at intrude@head
+      \unhbox\pxrr at boxr
+    }%
+  }%
+  \def\pxrr at inter##1##2##3{%
+    \pxrr at if@last{%
+      \pxrr at compose@twoside at block\pxrr at locate@end@
+       {##1}{##2}{##3}%
+      \pxrr at inter@mono
+      \unhbox\pxrr at boxr
+      \pxrr at intrude@end
+      \pxrr at takeout@any at protr
+    }{%
+      \pxrr at compose@twoside at block\pxrr at locate@inner
+       {##1}{##2}{##3}%
+      \pxrr at inter@mono
+      \unhbox\pxrr at boxr
+    }%
+  }%
+  \let\pxrr at post\@empty
+  \setbox\pxrr at boxr\pxrr at hbox{\pxrr at whole@list}%
+  \unhbox\pxrr at boxr
+}
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}{\pxrr at ruby@main at tg}
-% $BN>B&%k%S!JI,$:C1=c%0%k!<%W%k%S$G$"$k!K$N>l9g!#(B
+% $BN>B&$NC1=c%0%k!<%W%k%S$N>l9g!#(B
 %    \begin{macrocode}
 \def\pxrr at ruby@main at tg{%
   \pxrr at check@par at head
@@ -4381,6 +5004,13 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\pxrr at ruby@main at mg}
+% $BL$<BAu!J8F=P$b$J$$!K!#(B
+%    \begin{macrocode}
+\let\pxrr at ruby@main at mg\@undefined
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsubsection{$BA0=hM}(B}
 %
 % $B%4!<%9%H=hM}$9$k!#$=$N$?$a!"E83+ITG=L?Na$,!D!#(B
@@ -4440,6 +5070,9 @@
 % $B!J%0%k!<%WFb$G(B |\usefont{T1}{lmr}{m}{n}| $B$r8F$s$G$*$/$H!"(B
 % $BBg0hE*$K(B |\T1/lmr/m/n/2.5| $B$,Dj5A$5$l$k!#!K(B
 %    \begin{macrocode}
+\chardef\pxrr at aghostchar=23 % compwordmark
+\let\pxrr at aghost\relax
+\let\pxrr at aghostfont\relax
 \def\pxrr at setup@aghost{%
   \global\let\pxrr at setup@aghost\relax
   \IfFileExists{t1lmr.fd}{%
@@ -4447,7 +5080,6 @@
       \fontsize{2.5}{0}\usefont{T1}{lmr}{m}{n}%
     \endgroup
     \global\pxrr at letcs\pxrr at aghostfont{T1/lmr/m/n/2.5}%
-    \global\chardef\pxrr at aghostchar=23 % compwordmark
     \gdef\pxrr at aghost{{\pxrr at aghostfont\pxrr at aghostchar}}%
     \global\xspcode\pxrr at aghostchar=3 %
   }{%else
@@ -4588,6 +5220,10 @@
     ----
   }%
 }
+\def\pxrr at debug@show at resolve@mode{%
+  \typeout{----\pxrr at pkgname\space resolve-mode:
+    \meaning\pxrr at mode}%
+}
 %    \end{macrocode}
 %
 % \Finale

Modified: trunk/Master/texmf-dist/tex/platex/pxrubrica/pxrubrica.sty
===================================================================
--- trunk/Master/texmf-dist/tex/platex/pxrubrica/pxrubrica.sty	2017-04-20 21:09:43 UTC (rev 43942)
+++ trunk/Master/texmf-dist/tex/platex/pxrubrica/pxrubrica.sty	2017-04-20 21:10:01 UTC (rev 43943)
@@ -22,7 +22,7 @@
 %% in the same archive or directory.)
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{pxrubrica}
-  [2017/04/10 v1.1 PX Japanese-style ruby]
+  [2017/04/20 v1.2 PX Japanese-style ruby]
 \RequirePackage{keyval}
 \def\pxrr at pkgname{pxrubrica}
 \def\pxrr at error{%
@@ -58,6 +58,9 @@
 \def\pxrr at warn@must at group{%
   \pxrr at warn{Only group ruby is allowed here}%
 }
+\def\pxrr at warn@bad at jukugo{%
+  \pxrr at warn{Jukugo ruby is not allowed here}%
+}
 \def\pxrr at fatal@bad at intr{%
   \pxrr at fatal@error{%
     Intrusion disallowed when ghost is enabled%
@@ -76,9 +79,15 @@
 }
 \def\pxrr at fatal@bad at mono{%
   \pxrr at fatal@error{%
-    Mono-ruby must have a single group%
+    Mono-ruby body must have a single group%
   }\pxrr at eh@fatal
 }
+\def\pxrr at fatal@bad at switching{%
+  \pxrr at fatal@error{%
+    The body of Switching-ruby (M/J) must\MessageBreak
+    have a single group%
+  }\pxrr at eh@fatal
+}
 \def\pxrr at fatal@bad at movable{%
   \pxrr at fatal@error{%
     Novable group ruby is not allowed here%
@@ -150,6 +159,17 @@
 \chardef\pxrr at evensp=1
 \chardef\pxrr at revensp=1
 \chardef\pxrr at fullsize=1
+\let\pxrr at body@list\@undefined
+\let\pxrr at body@count\@undefined
+\let\pxrr at ruby@list\@undefined
+\let\pxrr at ruby@count\@undefined
+\let\pxrr at sruby@list\@undefined
+\let\pxrr at sruby@count\@undefined
+\let\pxrr at whole@list\@undefined
+\let\pxrr at bspace\@undefined
+\let\pxrr at aspace\@undefined
+\let\pxrr at natwd\@undefined
+\let\pxrr at all@input\@undefined
 \newif\ifpxrr at ok
 \newcount\pxrr at cnta
 \newcount\pxrr at cntr
@@ -157,6 +177,7 @@
 \newbox\pxrr at boxa
 \newbox\pxrr at boxb
 \newbox\pxrr at boxr
+\let\pxrr at token\relax
 \chardef\pxrr at zero=0
 \def\pxrr at zeropt{0pt}
 \def\pxrr at hfilx#1{%
@@ -168,8 +189,8 @@
   \else\expandafter\@secondoftwo
   \fi
 }
-\def\pxrr at ifnum#1{%
-  \ifnum#1\expandafter\@firstoftwo
+\@gobbletwo\if\if \def\pxrr at cond#1\fi{%
+  #1\expandafter\@firstoftwo
   \else\expandafter\@secondoftwo
   \fi
 }
@@ -192,11 +213,12 @@
 \def\pxrr at nil{\noexpand\pxrr at nil}
 \def\pxrr at end{\noexpand\pxrr at end}
 \def\pxrr at without@macro at trace#1{%
-  \chardef\pxrr at tracingmacros=\tracingmacros
+  \chardef\pxrr at tracingmacros@save=\tracingmacros
   \tracingmacros\z@
   #1%
-  \tracingmacros\pxrr at tracingmacros
+  \tracingmacros\pxrr at tracingmacros@save
 }
+\chardef\pxrr at tracingmacros@save=0
 \def\pxrr at hbox#1{%
   \hbox{%
     \color at begingroup
@@ -252,9 +274,9 @@
       \else
         \@tempdimb=\@tempcntb\@ne
       \fi}%
-    \xdef\pxrr at gtmpa{\the\@tempdimb}%
+    \xdef\pxrr at gtempa{\the\@tempdimb}%
   \endgroup
-  #1=\pxrr at gtmpa\relax
+  #1=\pxrr at gtempa\relax
 }
 \def\pxrr at interpolate#1#2#3#4#5{%
   \edef\pxrr at tempa{#1}%
@@ -294,13 +316,13 @@
   \pxrr at decompose@loopa#1\pxrr at end
 }
 \def\pxrr at decompose@loopa{%
-  \futurelet\pxrr at tempa\pxrr at decompose@loopb
+  \futurelet\pxrr at token\pxrr at decompose@loopb
 }
 \def\pxrr at decompose@loopb{%
-  \pxrr at ifx{\pxrr at tempa\pxrr at end}{%
+  \pxrr at ifx{\pxrr at token\pxrr at end}{%
     \pxrr at appto\pxrr at res{\pxrr at post}%
   }{%
-    \pxrr at setok{\pxrr at ifx{\pxrr at tempa\bgroup}}%
+    \pxrr at setok{\pxrr at ifx{\pxrr at token\bgroup}}%
     \pxrr at decompose@loopc
   }%
 }
@@ -376,6 +398,51 @@
 \def\pxrr at zip@list at exit{%
   \pxrr at appto\pxrr at res{\pxrr at post}%
 }
+\def\pxrr at tzip@list#1#2#3{%
+  \let\pxrr at res\@empty
+  \let\pxrr at post\relax
+  \let\pxrr at tempa#1\pxrr at appto\pxrr at tempa{{}}%
+  \let\pxrr at tempb#2\pxrr at appto\pxrr at tempb{{}}%
+  \let\pxrr at tempc#3\pxrr at appto\pxrr at tempc{{}}%
+  \pxrr at tzip@list at loopa
+}
+\def\pxrr at tzip@list at loopa{%
+  \expandafter\pxrr at tzip@list at loopb\pxrr at tempa\pxrr at end
+}
+\def\pxrr at tzip@list at loopb#1#2#3\pxrr at end{%
+  \pxrr at ifx{#1\relax}{%
+    \pxrr at tzip@list at exit
+  }{%
+    \pxrr at appto\pxrr at res{#1{#2}}%
+    \def\pxrr at tempa{#3}%
+    \expandafter\pxrr at tzip@list at loopc\pxrr at tempb\pxrr at end
+  }%
+}
+\def\pxrr at tzip@list at loopc#1#2#3\pxrr at end{%
+  \pxrr at ifx{#1\relax}{%
+    \pxrr at interror{tzip}%
+    \pxrr at appto\pxrr at res{{}}%
+    \pxrr at tzip@list at exit
+  }{%
+    \pxrr at appto\pxrr at res{{#2}}%
+    \def\pxrr at tempb{#3}%
+    \expandafter\pxrr at tzip@list at loopd\pxrr at tempc\pxrr at end
+  }%
+}
+\def\pxrr at tzip@list at loopd#1#2#3\pxrr at end{%
+  \pxrr at ifx{#1\relax}{%
+    \pxrr at interror{tzip}%
+    \pxrr at appto\pxrr at res{{}}%
+    \pxrr at tzip@list at exit
+  }{%
+    \pxrr at appto\pxrr at res{{#2}}%
+    \def\pxrr at tempc{#3}%
+    \pxrr at tzip@list at loopa
+  }%
+}
+\def\pxrr at tzip@list at exit{%
+  \pxrr at appto\pxrr at res{\pxrr at post}%
+}
 \def\pxrr at concat@list#1{%
   \let\pxrr at res\@empty
   \def\pxrr at pre##1{%
@@ -385,6 +452,13 @@
   \let\pxrr at post\relax
   #1%
 }
+\def\pxrr at unite@group#1{%
+  \expandafter\pxrr at concat@list\expandafter{#1}%
+  \expandafter\pxrr at unite@group at a\pxrr at res\pxrr at end#1%
+}
+\def\pxrr at unite@group at a#1\pxrr at end#2{%
+  \def#2{\pxrr at pre{#1}\pxrr at post}%
+}
 \def\pxrr at zip@single#1#2{%
   \expandafter\pxrr at zip@single at a\expandafter#1#2\pxrr at end
 }
@@ -406,6 +480,8 @@
 \def\pxrr at tzip@single at c#1\pxrr at end#2\pxrr at end#3\pxrr at end{%
   \def\pxrr at res{\pxrr at pre{#1}{#2}{#3}\pxrr at post}%
 }
+\let\pxrr at x@tempa\@empty
+\let\pxrr at x@tempb\@empty
 \let\pxrr at x@gtempa\@empty
 \newif\ifpxrr at x@swa
 \def\pxrr at ifprimitive#1{%
@@ -500,10 +576,18 @@
   \let\pxrr at jchardef\chardef
 \fi
 \ifpxrr at in@ptex
-  \pxrr at csletcs{ifpxrr at in@tate}{iftdir}
+  \begingroup \catcode`\|=0
+    \gdef\pxrr at if@in at tate{%
+      \pxrr at cond|iftdir|fi
+    }
+  \endgroup
+\else\ifpxrr at in@luatexja
+  \def\pxrr at if@in at tate{%
+    \pxrr at cond\ifnum\ltjgetparameter{direction}=\thr@@\fi
+  }
 \else
-  \pxrr at csletcs{ifpxrr at in@tate}{iffalse}
-\fi
+  \let\pxrr at if@in at tate\@secondoftwo
+\fi\fi
 \ifpxrr at in@ptex
   \def\pxrr at get@jchar at token#1#2{%
     \begingroup
@@ -739,7 +823,7 @@
   \pxrr at csletcs{ifpxrr at aprotr}{ifpxrr at d@aprotr}%
   \let\pxrr at bintr@\pxrr at d@bintr
   \let\pxrr at aintr@\pxrr at d@aintr
-  \let\pxrr at athead@\pxrr at d@athead
+  \let\pxrr at athead\pxrr at d@athead
   \let\pxrr at mode\pxrr at d@mode
   \let\pxrr at side\pxrr at d@side
   \let\pxrr at evensp\pxrr at d@evensp
@@ -752,6 +836,9 @@
   \pxrr at afintrfalse
   \pxrr at mode@givenfalse
   \pxrr at athead@givenfalse
+  \ifpxrr at truby
+    \let\pxrr at mode=M%
+  \fi
   \def\pxrr at po@FS{bi}%
   \expandafter\pxrr at parse@option at loop\pxrr at tempa @\pxrr at end
 }
@@ -811,6 +898,8 @@
 \def\pxrr at po@C at m{M}
 \def\pxrr at po@C at g{M}
 \def\pxrr at po@C at j{M}
+\def\pxrr at po@C at M{M}
+\def\pxrr at po@C at J{M}
 \def\pxrr at po@C at P{M}
 \def\pxrr at po@C at S{M}
 \def\pxrr at po@C at e{M}
@@ -922,6 +1011,14 @@
   \let\pxrr at mode=j%
   \pxrr at mode@giventrue
 }
+\def\pxrr at po@PR at M{%
+  \let\pxrr at mode=M%
+  \pxrr at mode@giventrue
+}
+\def\pxrr at po@PR at J{%
+  \let\pxrr at mode=J%
+  \pxrr at mode@giventrue
+}
 \def\pxrr at po@PR at P{%
   \chardef\pxrr at side\z@
 }
@@ -971,6 +1068,15 @@
 \def\pxrr at po@TR at mi@A{fi}
 \def\pxrr at po@TR at as@A{fi}
 \def\pxrr at po@TR at ai@A{fi}
+\def\pxrr at mode@grand{%
+  \if      m\pxrr at mode m%
+  \else\if M\pxrr at mode m%
+  \else\if j\pxrr at mode j%
+  \else\if J\pxrr at mode j%
+  \else\if g\pxrr at mode g%
+  \else ?%
+  \fi\fi\fi\fi\fi
+}
 \def\pxrr at check@option{%
   \ifpxrr at bprotr\else
     \ifpxrr at aprotr\else
@@ -998,18 +1104,18 @@
       \fi
     \fi
   \fi
-  \if g\pxrr at mode\else
+  \if \pxrr at mode@grand j%
     \ifnum\pxrr at side=\tw@
       \let\pxrr at mode=g\relax
       \ifpxrr at mode@given
-        \pxrr at warn@must at group
+        \pxrr at warn@bad at jukugo
       \fi
     \fi
   \fi
   \ifnum\pxrr at athead>\z@
-    \ifpxrr at in@tate\else
+    \pxrr at if@in at tate{}{%else
       \chardef\pxrr at athead\z@
-    \fi
+    }%
     \if g\pxrr at mode
       \chardef\pxrr at athead\z@
     \fi
@@ -1041,17 +1147,17 @@
   \pxrr at get@zwidth\pxrr at body@zw
   \begingroup
     \pxrr at use@ruby at font
-    \pxrr at get@zwidth\pxrr at gtempa
-    \global\let\pxrr at gtempa\pxrr at gtempa
+    \pxrr at get@zwidth\pxrr at ruby@zw
+    \global\let\pxrr at gtempa\pxrr at ruby@zw
   \endgroup
   \let\pxrr at ruby@zw\pxrr at gtempa
   \pxrr at get@iiskip\pxrr at iiskip
   \pxrr at get@iaiskip\pxrr at iaiskip
-  \ifpxrr at in@tate
+  \pxrr at if@in at tate{%
     \let\pxrr at htratio\pxrr at thtratio
-  \else
+  }{%
     \let\pxrr at htratio\pxrr at yhtratio
-  \fi
+  }%
   \@tempdima\pxrr at body@zw\relax
   \@tempdima\pxrr at htratio\@tempdima
   \@tempdimb\pxrr at ruby@zw\relax
@@ -1137,6 +1243,7 @@
   \let\pxrr at sprop@y@#2%
   \let\pxrr at sprop@z@#3%
 }
+\let\pxrr at makebox@res\@undefined
 \def\pxrr at adjust@margin{%
   \pxrr at save@listproc
   \@tempdima\pxrr at body@zw\relax
@@ -1170,6 +1277,9 @@
   \let\pxrr at inter@save\pxrr at inter
   \let\pxrr at post@save\pxrr at post
 }
+\let\pxrr at pre@save\@undefined
+\let\pxrr at inter@save\@undefined
+\let\pxrr at post@save\@undefined
 \def\pxrr at restore@listproc{%
   \let\pxrr at pre\pxrr at pre@save
   \let\pxrr at inter\pxrr at inter@save
@@ -1184,14 +1294,14 @@
   \expandafter\pxrr at transform@kana at loop@a#1\pxrr at end
 }
 \def\pxrr at transform@kana at loop@a{%
-  \futurelet\pxrr at tempa\pxrr at transform@kana at loop@b
+  \futurelet\pxrr at token\pxrr at transform@kana at loop@b
 }
 \def\pxrr at transform@kana at loop@b{%
-  \ifx\pxrr at tempa\pxrr at end
+  \ifx\pxrr at token\pxrr at end
     \let\pxrr at tempb\pxrr at transform@kana at end
-  \else\ifx\pxrr at tempa\bgroup
+  \else\ifx\pxrr at token\bgroup
     \let\pxrr at tempb\pxrr at transform@kana at loop@c
-  \else\ifx\pxrr at tempa\@sptoken
+  \else\ifx\pxrr at token\@sptoken
     \let\pxrr at tempb\pxrr at transform@kana at loop@d
   \else
     \let\pxrr at tempb\pxrr at transform@kana at loop@e
@@ -1250,6 +1360,7 @@
 }
 \newif\ifpxrr at protr
 \newif\ifpxrr at any@protr
+\let\pxrr at locate@temp\relax
 \def\pxrr at epsilon{0.01pt}
 \def\pxrr at compose@block#1#2#3{%
   \let\pxrr at compose@block at do\pxrr at compose@oneside at block@do
@@ -1323,35 +1434,50 @@
     \pxrr at use@ruby at font
     #4%
   }%
-  \@tempdima\wd\pxrr at boxa
-  \ifdim\@tempdima<\wd\pxrr at boxr
-    \@tempdima\wd\pxrr at boxr
-  \fi
-  \ifdim\@tempdima<\wd\pxrr at boxb
-    \@tempdima\wd\pxrr at boxb
-  \fi
-  \edef\pxrr at maxwd{\the\@tempdima}%
-  \advance\@tempdima-\pxrr at epsilon\relax
-  \edef\pxrr at maxwdx{\the\@tempdima}%
-  \ifdim\pxrr at maxwdx>\wd\pxrr at boxr
-    \pxrr at decompose{#3}%
-    \edef\pxrr at natwd{\the\wd\pxrr at boxr}%
-    \pxrr at evenspace@int{#1}\pxrr at boxr
-     \pxrr at use@ruby at font{\pxrr at maxwd}%
-    \pxrr at adjust@margin
-  \fi
-  \ifdim\pxrr at maxwdx>\wd\pxrr at boxb
-    \pxrr at decompose{#4}%
-    \edef\pxrr at natwd{\the\wd\pxrr at boxb}%
-    \pxrr at evenspace@int{#1}\pxrr at boxb
-     \pxrr at use@ruby at font{\pxrr at maxwd}%
-    \pxrr at adjust@margin
-  \fi
-  \ifdim\pxrr at maxwdx>\wd\pxrr at boxa
-    \pxrr at decompose{#2}%
-    \edef\pxrr at natwd{\the\wd\pxrr at boxa}%
-    \pxrr at evenspace@int{#1}\pxrr at boxa\relax{\pxrr at maxwd}%
+  \@tempswafalse
+  \@tempdima\wd\pxrr at boxr
+  \advance\@tempdima-\wd\pxrr at boxa
+  \ifdim\pxrr at epsilon<\@tempdima \@tempswatrue \fi
+  \@tempdima\wd\pxrr at boxb
+  \advance\@tempdima-\wd\pxrr at boxa
+  \ifdim\pxrr at epsilon<\@tempdima \@tempswatrue \fi
+  \if at tempswa
+    \pxrr at protrtrue
+    \let\pxrr at locate@temp#1%
+    \ifnum\pxrr at athead>\@ne
+      \ifnum\pxrr at locate@temp=\pxrr at locate@inner
+        \let\pxrr at locate@temp\pxrr at locate@head
+      \fi
+    \fi
+    \ifdim\wd\pxrr at boxr<\wd\pxrr at boxb
+      \pxrr at compose@twoside at block@sub{#2}{#3}%
+       \pxrr at boxr\pxrr at boxb
+    \else
+      \pxrr at compose@twoside at block@sub{#2}{#4}%
+       \pxrr at boxb\pxrr at boxr
+    \fi
   \else
+    \pxrr at protrfalse
+    \ifnum\pxrr at athead=\z@
+      \@tempdima\wd\pxrr at boxa
+      \advance\@tempdima-\wd\pxrr at boxr
+      \ifdim\pxrr at epsilon<\@tempdima
+        \pxrr at decompose{#3}%
+        \edef\pxrr at natwd{\the\wd\pxrr at boxr}%
+        \pxrr at evenspace@int{#1}\pxrr at boxr
+         \pxrr at use@ruby at font{\wd\pxrr at boxa}%
+        \pxrr at adjust@margin
+      \fi
+      \@tempdima\wd\pxrr at boxa
+      \advance\@tempdima-\wd\pxrr at boxb
+      \ifdim\pxrr at epsilon<\@tempdima
+        \pxrr at decompose{#4}%
+        \edef\pxrr at natwd{\the\wd\pxrr at boxb}%
+        \pxrr at evenspace@int{#1}\pxrr at boxb
+         \pxrr at use@ruby at font{\wd\pxrr at boxa}%
+        \pxrr at adjust@margin
+      \fi
+    \fi
     \let\pxrr at bspace\pxrr at zeropt
     \let\pxrr at aspace\pxrr at zeropt
   \fi
@@ -1369,8 +1495,47 @@
     \box\pxrr at boxa
   }%
 }
+\let\pxrr at body@wd\relax
+\let\pxrr at restore@margin at values\relax
+\def\pxrr at compose@twoside at block@sub#1#2#3#4{%
+  \pxrr at decompose{#1}%
+  \edef\pxrr at natwd{\the\wd\pxrr at boxa}%
+  \pxrr at evenspace@int\pxrr at locate@temp\pxrr at boxa\relax{\wd#4}%
+  \@tempdima\wd#4%
+  \advance\@tempdima-\pxrr at bspace\relax
+  \advance\@tempdima-\pxrr at aspace\relax
+  \edef\pxrr at body@wd{\the\@tempdima}%
+  \advance\@tempdima-\wd#3%
+  \ifdim\pxrr at epsilon<\@tempdima
+    \edef\pxrr at restore@margin at values{%
+      \edef\noexpand\pxrr at bspace{\pxrr at bspace}%
+      \edef\noexpand\pxrr at aspace{\pxrr at aspace}%
+    }%
+    \pxrr at decompose{#2}%
+    \edef\pxrr at natwd{\the\wd#3}%
+    \pxrr at evenspace@int\pxrr at locate@temp#3%
+     \pxrr at use@ruby at font{\pxrr at body@wd}%
+    \pxrr at adjust@margin
+    \pxrr at restore@margin at values
+    \setbox#3\hbox{%
+      \kern\pxrr at bspace\relax
+      \box#3%
+    }%
+  \else
+    \ifnum\pxrr at locate@temp=\pxrr at locate@head
+      \@tempdima\z@
+    \else\ifnum\pxrr at locate@temp=\pxrr at locate@inner
+      \@tempdima.5\@tempdima
+    \fi\fi
+    \advance\@tempdima\pxrr at bspace\relax
+    \setbox#3\hbox{%
+      \kern\@tempdima
+      \box#3%
+    }%
+  \fi
+}
 \def\pxrr at compose@block at pre{%
-  \pxrr at ifnum{\pxrr at fullsize>\z@}{%
+  \pxrr at cond\ifnum\pxrr at fullsize>\z@\fi{%
     \pxrr at compose@block at pre@a
   }{%
     \pxrr at compose@block at pre@d
@@ -1392,7 +1557,7 @@
   \pxrr at compose@block at pre@d{#3}{#4}{#1}{#2}%
 }
 \def\pxrr at compose@block at pre@d{%
-  \pxrr at ifnum{\pxrr at evensp=\z@}{%
+  \pxrr at cond\ifnum\pxrr at evensp=\z@\fi{%
     \pxrr at compose@block at pre@e
   }{%
     \pxrr at compose@block at pre@f
@@ -1402,7 +1567,7 @@
   \pxrr at compose@block at pre@f{#1}{{#2}}%
 }
 \def\pxrr at compose@block at pre@f{%
-  \pxrr at ifnum{\pxrr at revensp=\z@}{%
+  \pxrr at cond\ifnum\pxrr at revensp=\z@\fi{%
     \pxrr at compose@block at pre@g
   }{%
     \pxrr at compose@block at do
@@ -1411,6 +1576,7 @@
 \def\pxrr at compose@block at pre@g#1#2#3#4{%
   \pxrr at compose@block at do{#1}{#2}{{#3}}{{#4}}%
 }
+\let\pxrr at compose@block at tempa\@undefined
 \def\pxrr at add@protect#1{%
   \expandafter\pxrr at add@protect at a
     \csname\expandafter\@gobble\string#1\space\endcsname#1%
@@ -1454,10 +1620,10 @@
 }
 \def\pxrr at check@kinsoku#1{%
   \let\pxrr at tempb#1%
-  \futurelet\pxrr at tempa\pxrr at check@kinsoku at a
+  \futurelet\pxrr at token\pxrr at check@kinsoku at a
 }
 \def\pxrr at check@kinsoku at a{%
-  \pxrr at check@char\pxrr at tempa
+  \pxrr at check@char\pxrr at token
   \ifpxrr at abody\else
     \ifnum\pxrr at cntr=\@ne
       \pxrr at cntr\tw@
@@ -1662,6 +1828,12 @@
     \expandafter\pxrr at do@scan
   \fi
 }
+\def\pxrr at mode@is at switching{%
+  \if      M\pxrr at mode T%
+  \else\if J\pxrr at mode T%
+  \else F%
+  \fi\fi T%
+}
 \def\pxrr at ruby@proc#1#2{%
   \pxrr at prepare@fallback{#1}%
   \pxrr at assign@fsize
@@ -1669,15 +1841,19 @@
   \pxrr at decompbar{#2}%
   \let\pxrr at ruby@list\pxrr at res
   \edef\pxrr at ruby@count{\the\pxrr at cntr}%
+  \let\pxrr at sruby@list\relax
   \pxrr at decompbar{#1}%
   \let\pxrr at body@list\pxrr at res
   \edef\pxrr at body@count{\the\pxrr at cntr}%
+  \ifpxrr at safe@mode
+    \pxrr at setup@safe at mode
+  \fi
+  \if\pxrr at mode@is at switching
+    \pxrr at resolve@mode
+  \fi
 \ifpxrrDebug
   \pxrr at debug@show at input
 \fi
-  \ifpxrr at safe@mode
-    \pxrr at setup@safe at mode
-  \fi
   \pxrr at if@alive{%
     \if g\pxrr at mode
       \pxrr at ruby@check at g
@@ -1700,24 +1876,74 @@
   \pxrr at assign@fsize
   \pxrr at parse@option\pxrr at option
   \def\pxrr at all@input{{#1}{#2}{#3}}%
+  \pxrr at decompbar{#3}%
+  \let\pxrr at sruby@list\pxrr at res
+  \edef\pxrr at sruby@count{\the\pxrr at cntr}%
+  \pxrr at decompbar{#2}%
+  \let\pxrr at ruby@list\pxrr at res
+  \edef\pxrr at ruby@count{\the\pxrr at cntr}%
+  \pxrr at decompbar{#1}%
+  \let\pxrr at body@list\pxrr at res
+  \edef\pxrr at body@count{\the\pxrr at cntr}%
+  \ifpxrr at safe@mode
+    \pxrr at setup@safe at mode
+  \fi
+  \if\pxrr at mode@is at switching
+    \pxrr at resolve@mode
+  \fi
 \ifpxrrDebug
   \pxrr at debug@show at input
 \fi
-  \ifpxrr at safe@mode
-    \pxrr at setup@safe at mode
-  \fi
   \pxrr at if@alive{%
-    \pxrr at ruby@check at tg
-    \pxrr at if@alive{\pxrr at ruby@main at tg}%
+    \if g\pxrr at mode
+      \pxrr at ruby@check at tg
+      \pxrr at if@alive{\pxrr at ruby@main at tg}%
+    \else
+      \pxrr at ruby@check at tm
+      \pxrr at if@alive{\pxrr at ruby@main at tm}%
+    \fi
   }%
   \pxrr at ruby@exit
 }
 \def\pxrr at setup@safe at mode{%
-  \let\pxrr at mode=g%
+  \let\pxrr at mode=g\relax
+  \pxrr at unite@group\pxrr at body@list
+  \def\pxrr at body@count{1}%
+  \pxrr at unite@group\pxrr at ruby@list
+  \def\pxrr at ruby@count{1}%
+  \ifx\pxrr at sruby@list\relax\else
+    \pxrr at unite@group\pxrr at sruby@list
+    \def\pxrr at sruby@count{1}%
+  \fi
   \chardef\pxrr at evensp\z@
   \chardef\pxrr at revensp\z@
   \chardef\pxrr at fullsize\z@
 }
+\def\pxrr at resolve@mode{%
+  \ifnum\pxrr at body@count=\@ne
+    \ifnum\pxrr at ruby@count=\@ne
+      \let\pxrr at pre\pxrr at decompose
+      \let\pxrr at post\relax
+      \pxrr at body@list
+      \ifnum\pxrr at cntr=\@ne\else
+        \let\pxrr at mode=g%
+      \fi
+    \fi
+    \if M\pxrr at mode \let\pxrr at mode=m\fi
+    \if J\pxrr at mode \let\pxrr at mode=j\fi
+\ifpxrrDebug
+  \pxrr at debug@show at resolve@mode
+\fi
+    \if g\pxrr at mode
+      \chardef\pxrr at athead\z@
+    \fi
+    \if g\pxrr at mode\else
+      \chardef\pxrr at evensp\@ne
+    \fi
+  \else
+    \pxrr at fatal@bad at switching
+  \fi
+}
 \def\pxrr at ruby@check at g{%
   \ifnum\pxrr at body@count=\pxrr at ruby@count\relax
     \ifnum\pxrr at body@count=\@ne\else
@@ -1746,7 +1972,39 @@
   \fi
 }
 \def\pxrr at ruby@check at tg{%
+  \ifnum\pxrr at body@count=\pxrr at ruby@count\relax\else
+    \pxrr at fatal@bad at length\pxrr at body@count\pxrr at ruby@count
+  \fi
+  \ifnum\pxrr at body@count=\pxrr at sruby@count\relax\else
+    \pxrr at fatal@bad at length\pxrr at body@count\pxrr at sruby@count
+  \fi
+  \pxrr at if@alive{%
+    \ifnum\pxrr at body@count=\@ne\else
+      \ifpxrr at abody
+        \pxrr at fatal@bad at movable
+      \else\ifnum\pxrr at extra=\z@
+        \pxrr at fatal@na at movable
+      \fi\fi
+    \fi
+  }%
 }
+\def\pxrr at ruby@check at tm{%
+  \ifnum\pxrr at body@count=\@ne
+    \let\pxrr at pre\pxrr at decompose
+    \let\pxrr at post\relax
+    \pxrr at body@list
+    \let\pxrr at body@list\pxrr at res
+    \edef\pxrr at body@count{\the\pxrr at cntr}%
+    \ifnum\pxrr at body@count=\pxrr at ruby@count\relax\else
+      \pxrr at fatal@bad at length\pxrr at body@count\pxrr at ruby@count
+    \fi
+    \ifnum\pxrr at body@count=\pxrr at sruby@count\relax\else
+      \pxrr at fatal@bad at length\pxrr at body@count\pxrr at sruby@count
+    \fi
+  \else
+    \pxrr at fatal@bad at mono
+  \fi
+}
 \newif\ifpxrr at par@head
 \def\pxrr at check@par at head{%
   \ifvmode
@@ -1884,6 +2142,59 @@
   \let\pxrr at post\@empty
   \pxrr at whole@list
 }
+\def\pxrr at ruby@main at tm{%
+  \pxrr at tzip@list\pxrr at body@list\pxrr at ruby@list\pxrr at sruby@list
+  \let\pxrr at whole@list\pxrr at res
+  \pxrr at check@par at head
+  \pxrr at any@protrfalse
+\ifpxrrDebug
+\pxrr at debug@show at recomp
+\fi
+  \let\pxrr at locate@head@\pxrr at locate@inner
+  \let\pxrr at locate@end@\pxrr at locate@inner
+  \let\pxrr at locate@sing@\pxrr at locate@inner
+  \ifpxrr at aprotr\else
+    \let\pxrr at locate@end@\pxrr at locate@end
+    \let\pxrr at locate@sing@\pxrr at locate@end
+  \fi
+  \ifpxrr at bprotr\else
+    \let\pxrr at locate@head@\pxrr at locate@head
+    \let\pxrr at locate@sing@\pxrr at locate@head
+  \fi
+  \def\pxrr at pre##1##2##3{%
+    \pxrr at if@last{%
+      \pxrr at compose@twoside at block\pxrr at locate@sing@
+       {##1}{##2}{##3}%
+      \pxrr at intrude@head
+      \unhbox\pxrr at boxr
+      \pxrr at intrude@end
+      \pxrr at takeout@any at protr
+    }{%
+      \pxrr at compose@twoside at block\pxrr at locate@head@
+       {##1}{##2}{##3}%
+      \pxrr at intrude@head
+      \unhbox\pxrr at boxr
+    }%
+  }%
+  \def\pxrr at inter##1##2##3{%
+    \pxrr at if@last{%
+      \pxrr at compose@twoside at block\pxrr at locate@end@
+       {##1}{##2}{##3}%
+      \pxrr at inter@mono
+      \unhbox\pxrr at boxr
+      \pxrr at intrude@end
+      \pxrr at takeout@any at protr
+    }{%
+      \pxrr at compose@twoside at block\pxrr at locate@inner
+       {##1}{##2}{##3}%
+      \pxrr at inter@mono
+      \unhbox\pxrr at boxr
+    }%
+  }%
+  \let\pxrr at post\@empty
+  \setbox\pxrr at boxr\pxrr at hbox{\pxrr at whole@list}%
+  \unhbox\pxrr at boxr
+}
 \def\pxrr at ruby@main at tg{%
   \pxrr at check@par at head
   \pxrr at put@head at penalty
@@ -1900,6 +2211,7 @@
   \unhbox\pxrr at boxr
   \pxrr at intrude@end
 }
+\let\pxrr at ruby@main at mg\@undefined
 \newif\ifpxrr at ghost
 \pxrr at jchardef\pxrr at zspace=\pxrr at jc{2121:3000}
 \def\pxrr at jprologue{%
@@ -1914,6 +2226,9 @@
       \kern-\wd\pxrr at boxa
     \fi
 }
+\chardef\pxrr at aghostchar=23 % compwordmark
+\let\pxrr at aghost\relax
+\let\pxrr at aghostfont\relax
 \def\pxrr at setup@aghost{%
   \global\let\pxrr at setup@aghost\relax
   \IfFileExists{t1lmr.fd}{%
@@ -1921,7 +2236,6 @@
       \fontsize{2.5}{0}\usefont{T1}{lmr}{m}{n}%
     \endgroup
     \global\pxrr at letcs\pxrr at aghostfont{T1/lmr/m/n/2.5}%
-    \global\chardef\pxrr at aghostchar=23 % compwordmark
     \gdef\pxrr at aghost{{\pxrr at aghostfont\pxrr at aghostchar}}%
     \global\xspcode\pxrr at aghostchar=3 %
   }{%else
@@ -2021,6 +2335,10 @@
     ----
   }%
 }
+\def\pxrr at debug@show at resolve@mode{%
+  \typeout{----\pxrr at pkgname\space resolve-mode:
+    \meaning\pxrr at mode}%
+}
 \endinput
 %%
 %% End of file `pxrubrica.sty'.



More information about the tex-live-commits mailing list