X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=src%2Flltjext.sty;h=8238e7b77d2eee87c0ac2f012f03735fe33453e0;hb=4ab839e5f18b0f5e6d9b27a2b78cf51f4670815a;hp=7a445f5d7d527f6b7e6259e3c983e9155b6bb26b;hpb=ac5df029ce135ff6e847bb17448bda0238f529f1;p=luatex-ja%2Fluatexja.git diff --git a/src/lltjext.sty b/src/lltjext.sty index 7a445f5..8238e7b 100644 --- a/src/lltjext.sty +++ b/src/lltjext.sty @@ -3,9 +3,9 @@ % \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{lltjext}[2016/12/16 v1.2c-ltj-5 Macros for vertical writing] +\ProvidesPackage{lltjext}[2017/07/17 v1.2g-ltj-6 Macros for vertical writing] \RequirePackage{luatexja} - +\newcount\ltj@ext@dir {\catcode`\*=11 \global\let\ltj@lltjext@orig@tabularS=\tabular* }% @@ -15,19 +15,20 @@ %%% array and tabular \def\array{\let\@acol\@arrayacol \let\@classz\@arrayclassz \let\@classiv\@arrayclassiv - \let\\\@arraycr\let\@halignto\@empty\X@tabarray} + \let\\\@arraycr\let\@halignto\@empty + \ltj@ext@dir=\ltjgetparameter{direction}\relax\X@tabarray} \def\tabular{\let\@halignto\@empty\X@tabular} \@namedef{tabular*}{\@ifnextchar<%> - {\@stabular}{\@stabular}} + {\@stabular}{\@stabular}} \def\X@tabarray{\@ifnextchar<%> - {\p@tabarray}{\p@tabarray}} + {\p@tabarray}{\p@tabarray}} \def\X@tabular{\@ifnextchar<%> - {\p@tabular}{\p@tabular}} + {\p@tabular}{\p@tabular}} \def\@stabular<#1>#2{% \setlength\dimen@{#2}% \edef\@halignto{to\the\dimen@}\p@tabular<#1>} \def\p@tabular<#1>{\leavevmode \hbox \bgroup - \count@=\ltjgetparameter{direction}$\let\@acol\@tabacol + \ltj@ext@dir=\ltjgetparameter{direction}$\let\@acol\@tabacol \let\@classz\@tabclassz \let\@classiv\@tabclassiv \let\\\@tabularcr\p@tabarray<#1>} \def\p@tabarray<#1>{\m@th\@ifnextchar[%] @@ -36,12 +37,12 @@ \def\p@array<#1>[#2]#3{% \let\box@dir\relax \if #1z\relax - \ifnum\count@=3\relax + \ifnum\ltj@ext@dir=3\relax \let\box@dir\utod\@tempcnta=\zstrutbox \fi \else \if #1y\relax - \let\box@dir\yoko\@tempcnta=\strutbox + \let\box@dir\yoko\@tempcnta=\ystrutbox \else\if #1t\relax \let\box@dir\tate\@tempcnta=\tstrutbox \else\if #1d\relax @@ -51,10 +52,10 @@ \fi\fi\fi\fi \fi \ifx\box@dir\relax - \ifcase\count@ + \ifcase\ltj@ext@dir \or \let\box@dir\dtou\@tempcnta=\dstrutbox% dtou \or\or\let\box@dir\tate\@tempcnta=\tstrutbox% tate - \or \let\box@dir\yoko\@tempcnta=\strutbox% yoko + \or \let\box@dir\yoko\@tempcnta=\ystrutbox% yoko \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod \fi \fi @@ -65,7 +66,8 @@ \fork@array@option<#1>[#2]% \@mkpream{#3}\edef\@preamble{\ialign \noexpand\@halignto \bgroup\@arstrut \@preamble \tabskip\z@skip \cr}% - \let\tabularnewline\\% + \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox + \let\tabularnewline\\% \@begin@alignbox\bgroup\box@dir\adjustbaseline \let\par\@empty \let\@sharp##\let\protect\relax @@ -73,6 +75,39 @@ \def\endarray{\crcr\egroup\egroup\@end@alignbox} \def\endtabular{\endarray$\egroup} \expandafter \let \csname endtabular*\endcsname = \endtabular +% コミュニティ版では、アスキー版で不自然だった表組(array環境およびtabular環境)と +% 周囲の本文との揃え位置を修正し、以下のように設計しました。 +% \begin{itemize} +% \item 周囲の組方向が横組かつ組方向が||, ||指定の場合 +% \begin{itemize} +% \item |[t]|指定のとき\\一行目のベースラインが周囲のそれと一致(罫線の場合は和文ベースラインの位置) +% \item |[c]|指定のとき\\表組の中心が周囲の数式軸を通る(欧文ベースラインシフトの影響下) +% \item |[b]|指定のとき\\最終行のベースラインが周囲のそれと一致(罫線の場合は和文ベースラインの位置) +% \end{itemize} +% \item 周囲の組方向が横組かつ組方向が||指定の場合 +% \begin{itemize} +% \item |[t]|指定のとき\\表組の上端が周囲の和文ベースラインと一致 +% \item |[c]|指定のとき\\表組の中心が周囲の数式軸を通る(欧文ベースラインシフトの影響下) +% \item |[b]|指定のとき\\表組の下端が周囲の和文ベースラインと一致 +% \end{itemize} +% \item 周囲の組方向が縦組かつ組方向が||指定の場合 +% \begin{itemize} +% \item |[t]|指定のとき\\表組の上端が周囲の和文ベースラインと一致 +% \item |[c]|指定のとき\\表組の中心が周囲の数式軸を通る(欧文ベースラインシフトの影響下) +% \item |[b]|指定のとき\\表組の下端が周囲の和文ベースラインと一致 +% \end{itemize} +% \item 周囲の組方向が縦組かつ組方向が||指定の場合 +% \begin{itemize} +% \item |[t]|指定のとき\\一行目のベースラインが周囲のそれと一致(罫線の場合は和文ベースラインの位置) +% \item |[c]|指定のとき\\表組の中心が周囲の数式軸を通る(欧文ベースラインシフトの影響下) +% \item |[b]|指定のとき\\最終行のベースラインが周囲のそれと一致(罫線の場合は和文ベースラインの位置) +% \end{itemize} +% \item 周囲の組方向が縦組かつ組方向が||指定の場合 +% \begin{itemize} +% \item |[t]|指定のとき\\一行目の欧文ベースラインが周囲のそれと一致 +% \item |[c]|指定のとき\\表組の中心が周囲の数式軸を通る(欧文ベースラインシフトの影響下) +% \item |[b]|指定のとき\\最終行の欧文ベースラインが周囲のそれと一致 +% \end{itemize} \def\fork@array@option<#1>[#2]{% \ifnum\ltjgetparameter{direction}=4 % yoko \ifx\box@dir\yoko @@ -89,10 +124,10 @@ \else \if #2t\relax \def\@begin@alignbox{\vtop\bgroup\kern\z@\vbox}% - \def\@end@alignbox{\egroup}% + \let\@end@alignbox\egroup \else\if #2b\relax - \let\@begin@alignbox\vbox - \let\@end@alignbox\relax + \def\@begin@alignbox{\vbox\bgroup\vbox}% + \def\@end@alignbox{\kern\z@\egroup}% \else \let\@begin@alignbox\vcenter \let\@end@alignbox\relax @@ -102,10 +137,10 @@ \ifx\box@dir\yoko \if #2t\relax \def\@begin@alignbox{\vtop\bgroup\kern\z@\vbox}% - \def\@end@alignbox{\egroup}% + \let\@end@alignbox\egroup \else\if #2b\relax - \let\@begin@alignbox\vbox - \let\@end@alignbox\relax + \def\@begin@alignbox{\vbox\bgroup\vbox}% + \def\@end@alignbox{\kern\z@\egroup}% \else \let\@begin@alignbox\vcenter \let\@end@alignbox\relax @@ -137,7 +172,7 @@ \ifx\box@dir\yoko \if #2t\relax \def\@begin@alignbox{\vtop\bgroup\kern\z@\vbox}% - \def\@end@alignbox{\egroup}% + \let\@end@alignbox\egroup \else\if #2b\relax \def\@begin@alignbox{\vbox\bgroup\vbox}% \def\@end@alignbox{\kern\z@\egroup}% @@ -156,7 +191,7 @@ \let\@begin@alignbox\vcenter \let\@end@alignbox\relax \fi\fi - \else + \else\ifx\box@dir\tate \if #2t\relax \let\@begin@alignbox\vtop \let\@end@alignbox\relax @@ -167,7 +202,20 @@ \let\@begin@alignbox\vcenter \let\@end@alignbox\relax \fi\fi - \fi\fi + \else % utod + \if #2t\relax + \def\@begin@alignbox{\lower\dimexpr + \ltjgetparameter{talbaselineshift}-\ltjgetparameter{yalbaselineshift}\vtop} + \let\@end@alignbox\relax + \else\if #2b\relax + \def\@begin@alignbox{\lower\dimexpr + \ltjgetparameter{talbaselineshift}-\ltjgetparameter{yalbaselineshift}\vbox} + \let\@end@alignbox\relax + \else + \let\@begin@alignbox\vcenter + \let\@end@alignbox\relax + \fi\fi + \fi\fi\fi \fi\fi% } @@ -262,7 +310,7 @@ \csname \@captype @layoutcaption\endcsname \fi \@tempswafalse - % tempswa\hline 基本組の組方向とキャプションの組方向が直交するか? + % \@tempswa: 基本組の組方向とキャプションの組方向が直交するか? \if y\caption@dir \let\captiondir\yoko \ifodd\ltjgetparameter{direction}\relax\@tempswatrue\fi \else\if z\caption@dir \let\captiondir\relax @@ -358,7 +406,7 @@ \color@endgroup \egroup \expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}\egroup} -\def\parbox{\@ifnextchar<%> +\DeclareRobustCommand\parbox{\@ifnextchar<%> {\X@parbox}{\X@parbox}} \def\X@parbox<#1>{\@ifnextchar[%] {\@iparbox<#1>}{\@iiiparbox<#1>{c}\relax[s]}} @@ -367,19 +415,54 @@ \def\@iiparbox<#1>#2[#3]{\@ifnextchar[%]% {\@iiiparbox<#1>{#2}{#3}}{\@iiiparbox<#1>{#2}{#3}[#2]}} \long\def\@iiiparbox<#1>#2#3[#4]#5#6{% - \leavevmode\bgroup + \leavevmode \setlength\@tempdima{#5}% \fork@parbox@option<#1>[#2]% \@begin@tempboxa\vbox{\box@dir \hsize\@tempdima\@parboxrestore\adjustbaseline#6\@@par}% - \ifx\relax#3\relax\else + \ifx\relax#3\else \setlength\@tempdimb{#3}% \edef\@parboxto{to\the\@tempdimb}% \fi \@begin@parbox\@parboxto{\box@dir\adjustbaseline \let\hss\vss\let\unhbox\unvbox \csname bm@#4\endcsname}\@end@parbox - \@end@tempboxa\egroup} + \@end@tempboxa} +% コミュニティ版では、アスキー版で不自然だった|\parbox|の箱と +% 周囲の本文との揃え位置を修正し、以下のように設計しました。 +% \begin{itemize} +% \item 周囲の組方向が横組かつ組方向が||, ||指定の場合 +% \begin{itemize} +% \item |[t]|指定のとき\\一行目のベースラインが周囲のそれと一致 +% \item |[c]|指定のとき\\箱の中心が周囲の数式軸を通る(欧文ベースラインシフトの影響下) +% \item |[b]|指定のとき\\最終行のベースラインが周囲のそれと一致 +% \end{itemize} +% \item 周囲の組方向が横組かつ組方向が||指定の場合 +% \begin{itemize} +% \item |[t]|指定のとき\\箱の上端が周囲の和文文字の高さと一致 +% \item |[c]|指定のとき\\箱の中心が周囲の数式軸を通る(欧文ベースラインシフトの影響下) +% \item |[b]|指定のとき\\箱の下端が周囲の和文文字の深さと一致 +% \end{itemize} +% \item 周囲の組方向が縦組かつ組方向が||指定の場合 +% \begin{itemize} +% \item |[t]|指定のとき\\箱の上端が周囲の和文文字の高さと一致 +% \item |[c]|指定のとき\\箱の中心が周囲の数式軸を通る(欧文ベースラインシフトの影響下) +% \item |[b]|指定のとき\\箱の下端が周囲の和文文字の深さと一致 +% \end{itemize} +% \item 周囲の組方向が縦組かつ組方向が||指定の場合 +% \begin{itemize} +% \item |[t]|指定のとき\\一行目のベースラインが周囲のそれと一致 +% \item |[c]|指定のとき\\箱の中心が周囲の数式軸を通る(欧文ベースラインシフトの影響下) +% \item |[b]|指定のとき\\最終行のベースラインが周囲のそれと一致 +% \end{itemize} +% \item 周囲の組方向が縦組かつ組方向が||指定の場合 +% [TODO] 未定! +%^^A \begin{itemize} +%^^A \item |[t]|指定のとき\\箱の上端が周囲の和文ベースラインと一致 +%^^A \item |[c]|指定のとき\\箱の中心が周囲の数式軸を通る(欧文ベースラインシフトの影響下) +%^^A \item |[b]|指定のとき\\箱の下端が周囲の和文ベースラインと一致 +%^^A \end{itemize} +% \end{itemize} \def\fork@parbox@option<#1>[#2]{% \let\box@dir\relax \if #1z\relax @@ -401,7 +484,6 @@ \else \let\box@dir\utod \fi \fi -%%% now almost same as \fork@array@option \ifnum\ltjgetparameter{direction}=4 % yoko \ifx\box@dir\yoko \if #2t\relax @@ -411,32 +493,44 @@ \let\@begin@parbox\vbox \let\@end@parbox\relax \else - \def\@begin@parbox{$\vcenter}% - \def\@end@parbox{\m@th$}% + \ifmmode + \let\@begin@parbox\vcenter\let\@end@parbox\relax + \else + \def\@begin@parbox{\null$\vcenter}% + \def\@end@parbox{\m@th$\null}% + \fi \fi\fi \else \if #2t\relax - \def\@begin@parbox{\vtop\bgroup\kern\z@\vbox}% - \def\@end@parbox{\egroup}% + \def\@begin@parbox{\raise\cht\vtop\bgroup\kern\z@\vbox}% + \let\@end@parbox\egroup \else\if #2b\relax - \let\@begin@parbox\vbox - \let\@end@parbox\relax + \def\@begin@parbox{\lower\cdp\vbox\bgroup\vbox}% + \def\@end@parbox{\kern\z@\egroup}% \else - \def\@begin@parbox{$\vcenter}% - \def\@end@parbox{\m@th$}% + \ifmmode + \let\@begin@parbox\vcenter\let\@end@parbox\relax + \else + \def\@begin@parbox{\null$\vcenter}% + \def\@end@parbox{\m@th$\null}% + \fi \fi\fi \fi \else\ifnum\ltjgetparameter{direction}=1 % dtou \ifx\box@dir\yoko \if #2t\relax - \def\@begin@parbox{\vtop\bgroup\kern\z@\vbox} - \def\@end@parbox{\egroup} + \def\@begin@parbox{\raise\cht\vtop\bgroup\kern\z@\vbox}% + \let\@end@parbox\egroup \else\if #2b\relax - \let\@begin@parbox\vbox - \let\@end@parbox\relax + \def\@begin@parbox{\lower\cdp\vbox\bgroup\vbox}% + \def\@end@parbox{\kern\z@\egroup}% \else - \def\@begin@parbox{$\vcenter}% - \def\@end@parbox{\m@th$}% + \ifmmode + \let\@begin@parbox\vcenter\let\@end@parbox\relax + \else + \def\@begin@parbox{\null$\vcenter}% + \def\@end@parbox{\m@th$\null}% + \fi \fi\fi \else\ifx\box@dir\dtou \if #2t\relax @@ -446,8 +540,12 @@ \let\@begin@parbox\vbox \let\@end@parbox\relax \else - \def\@begin@parbox{$\vcenter}% - \def\@end@parbox{\m@th$}% + \ifmmode + \let\@begin@parbox\vcenter\let\@end@parbox\relax + \else + \def\@begin@parbox{\null$\vcenter}% + \def\@end@parbox{\m@th$\null}% + \fi \fi\fi \else % 180 度回転→vtop, vbox を入れ替える \if #2t\relax @@ -457,21 +555,44 @@ \let\@begin@parbox\vtop %%% !!! \let\@end@parbox\relax \else - \def\@begin@parbox{$\vcenter}% - \def\@end@parbox{\m@th$}% + \ifmmode + \let\@begin@parbox\vcenter\let\@end@parbox\relax + \else + \def\@begin@parbox{\null$\vcenter}% + \def\@end@parbox{\m@th$\null}% + \fi \fi\fi \fi\fi \else % tate, utod \ifx\box@dir\yoko \if #2t\relax - \def\@begin@parbox{\vtop\bgroup\kern\z@\vbox}% - \def\@end@parbox{\egroup}% + \def\@begin@parbox{\raise\cht\vtop\bgroup\kern\z@\vbox}% + \let\@end@parbox\egroup \else\if #2b\relax - \def\@begin@parbox{\vbox\bgroup\vbox}% + \def\@begin@parbox{\lower\cdp\vbox\bgroup\vbox}% \def\@end@parbox{\kern\z@\egroup}% \else - \def\@begin@parbox{$\vcenter}% - \def\@end@parbox{\m@th$}% + \ifmmode + \let\@begin@parbox\vcenter\let\@end@parbox\relax + \else + \def\@begin@parbox{\null$\vcenter}% + \def\@end@parbox{\m@th$\null}% + \fi + \fi\fi + \else\ifx\box@dir\tate + \if #2t\relax + \let\@begin@parbox\vtop + \let\@end@parbox\relax + \else\if #2b\relax + \let\@begin@parbox\vbox + \let\@end@parbox\relax + \else + \ifmmode + \let\@begin@parbox\vcenter\let\@end@parbox\relax + \else + \def\@begin@parbox{\null$\vcenter}% + \def\@end@parbox{\m@th$\null}% + \fi \fi\fi \else\ifx\box@dir\dtou % 180 度回転→vtop, vbox を入れ替える \if #2t\relax @@ -481,26 +602,34 @@ \let\@begin@parbox\vtop %%% !!! \let\@end@parbox\relax \else - \def\@begin@parbox{$\vcenter}% - \def\@end@parbox{\m@th$}% + \ifmmode + \let\@begin@parbox\vcenter\let\@end@parbox\relax + \else + \def\@begin@parbox{\null$\vcenter}% + \def\@end@parbox{\m@th$\null}% + \fi \fi\fi - \else + \else % \utod \if #2t\relax - \let\@begin@parbox\vtop - \let\@end@parbox\relax + \def\@begin@parbox{\raise\cht\vtop\bgroup\kern\z@\vtop}% + \let\@end@parbox\egroup \else\if #2b\relax - \let\@begin@parbox\vbox - \let\@end@parbox\relax + \def\@begin@parbox{\lower\cdp\vbox\bgroup\kern\z@\vbox}% + \let\@end@parbox\egroup \else - \def\@begin@parbox{$\vcenter}% - \def\@end@parbox{\m@th$}% + \ifmmode + \let\@begin@parbox\vcenter\let\@end@parbox\relax + \else + \def\@begin@parbox{\null$\vcenter}% + \def\@end@parbox{\m@th$\null}% + \fi \fi\fi - \fi\fi + \fi\fi\fi \fi\fi% } %%% pbox -\def\pbox{\leavevmode\@ifnextchar<{\X@makePbox}{\X@makePbox}} +\DeclareRobustCommand\pbox{\leavevmode\@ifnextchar<{\X@makePbox}{\X@makePbox}} \def\X@makePbox<#1>{% \@ifnextchar[{\@imakePbox<#1>}{\@imakePbox<#1>[-5\p@]}} \def\@imakePbox<#1>[#2]{\@ifnextchar[%] @@ -526,8 +655,9 @@ \else \let\box@dir\utod \fi \fi - \ifdim #2 <\z@ \hbox{\box@dir#4}\else - \hbox to#2{\box@dir + \setlength{\@tempdima}{#2}% + \ifdim\@tempdima<\z@ \hbox{\box@dir#4}\else + \hb@xt@\@tempdima{\box@dir \if #3l\relax\else\hss\fi #4\relax \if #3r\relax\else\hss\fi}\fi\egroup} @@ -697,24 +827,26 @@ \def\ltj@lltjext@patch@array{% \patchcmd{\@tabular}{\hbox\bgroup}{% - \hbox\bgroup\count@=\ltjgetparameter{direction}}{}{} + \hbox\bgroup\ltj@ext@dir=\ltjgetparameter{direction}}{}{} + \pretocmd{\array}% + {\ltj@ext@dir=\ltjgetparameter{direction}\relax}{}{} \def\@startpbox##1{\bgroup \box@dir\adjustbaseline%%% これを追加 - \hsize=##1\@arrayparboxrestore + \setlength\hsize{##1}\@arrayparboxrestore \everypar{% \vrule \@height \ltjgetht\@arstrutbox \@width \z@ \everypar{}}% } - \def\@tabarray{\@ifnextchar<\p@tabarray{\p@tabarray}} + \def\@tabarray{\@ifnextchar<\p@tabarray{\p@tabarray}} \def\p@array<##1>[##2]##3{% \let\box@dir\relax \if ##1z\relax - \ifnum\count@=3\relax + \ifnum\ltj@ext@dir=3\relax \let\box@dir\utod\@tempcnta=\zstrutbox \fi \else \if ##1y\relax - \let\box@dir\yoko\@tempcnta=\strutbox + \let\box@dir\yoko\@tempcnta=\ystrutbox \else\if ##1t\relax \let\box@dir\tate\@tempcnta=\tstrutbox \else\if ##1d\relax @@ -724,10 +856,10 @@ \fi\fi\fi\fi \fi \ifx\box@dir\relax - \ifcase\count@ - \or \let\box@dir\dtou\@tempcnta=\tabskip \z@\tabskip \z@\dstrutbox% dtou + \ifcase\ltj@ext@dir + \or \let\box@dir\dtou\@tempcnta=\dstrutbox% dtou \or\or\let\box@dir\tate\@tempcnta=\tstrutbox% tate - \or \let\box@dir\yoko\@tempcnta=\strutbox% yoko + \or \let\box@dir\yoko\@tempcnta=\ystrutbox% yoko \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod \fi \fi