From: Hironori Kitagawa Date: Sat, 26 Jul 2014 11:02:18 +0000 (+0900) Subject: Started to write lltjext.sty (↔ plext.sty); tabular/array, minipage, \parbox, \pbox. X-Git-Tag: 20150420.0~160 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d112be0c19048de5c0b9e0167319db8aa6423bb7;p=luatex-ja%2Fluatexja.git Started to write lltjext.sty (↔ plext.sty); tabular/array, minipage, \parbox, \pbox. --- diff --git a/src/lltjext.sty b/src/lltjext.sty new file mode 100644 index 0000000..75e0261 --- /dev/null +++ b/src/lltjext.sty @@ -0,0 +1,631 @@ +% +% lltjext.sty: derived from plext.sty in pLaTeX. +% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{lltjext} + [2014/07/26 v1.2-ltj-1 ...] + +\newif\if@rotsw +\def\array{\let\@acol\@arrayacol \let\@classz\@arrayclassz + \let\@classiv\@arrayclassiv + \let\\\@arraycr\let\@halignto\@empty\X@tabarray} +\def\tabular{\let\@halignto\@empty\X@tabular} +\@namedef{tabular*}{\@ifnextchar<%> + {\@stabular}{\@stabular}} +\def\X@tabarray{\@ifnextchar<%> + {\p@tabarray}{\p@tabarray}} +\def\X@tabular{\@ifnextchar<%> + {\p@tabular}{\p@tabular}} +\def\@stabular<#1>#2{\def\@halignto{to#2}\p@tabular<#1>} +\def\p@tabular<#1>{\leavevmode \hbox \bgroup $\let\@acol\@tabacol + \let\@classz\@tabclassz + \let\@classiv\@tabclassiv \let\\\@tabularcr\p@tabarray<#1>} +\def\p@tabarray<#1>{\m@th\@ifnextchar[%] + {\p@array<#1>}{\p@array<#1>[c]}} + +\def\p@array<#1>[#2]#3{% + \let\box@dir\relax + \if #1z\relax + \ifnum\ltjgetparameter{direction}=3 \relax + \let\box@dir\utod\@tempcnta=\zstrutbox + \fi + \else + \if #1y\relax + \let\box@dir\yoko\@tempcnta=\strutbox + \else\if #1t\relax + \let\box@dir\tate\@tempcnta=\tstrutbox + \else\if #1d\relax + \let\box@dir\dtou\@tempcnta=\dstrutbox + \else\if #1u\relax + \let\box@dir\utod\@tempcnta=\zstrutbox + \fi\fi\fi\fi + \fi + \ifx\box@dir\relax + \ifcase\ltjgetparameter{direction} + \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 + \else \let\box@dir\utod\@tempcnta=\zstrutbox% utod + \fi + \fi + \setbox\@arstrutbox\hbox{% + \box@dir + \vrule\@height\arraystretch\ltjgetht\@tempcnta + \@depth\arraystretch\ltjgetdp\@tempcnta \@width\z@}% + \fork@array@option<#1>[#2]% + \@mkpream{#3}\edef\@preamble{\ialign \noexpand\@halignto + \bgroup \tabskip\z@skip \@arstrut \@preamble \tabskip\z@skip \cr}% + \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox + \let\tabularnewline\\% + \@begin@alignbox\bgroup\box@dir\adjustbaseline + \let\par\@empty + \let\@sharp##\let\protect\relax + \lineskip\z@skip\baselineskip\z@skip\@preamble} +\def\endarray{\crcr\egroup\egroup\@end@alignbox} +\def\endtabular{\crcr\egroup\egroup\@end@alignbox$\egroup} +\expandafter \let \csname endtabular*\endcsname = \endtabular +\def\fork@array@option<#1>[#2]{% +\ifnum\ltjgetparameter{direction}=4 % yoko + \ifx\box@dir\yoko + \if #2t\relax + \let\@begin@alignbox\vtop + \let\@end@alignbox\relax + \else\if #2b\relax + \let\@begin@alignbox\vbox + \let\@end@alignbox\relax + \else + \let\@begin@alignbox\vcenter + \let\@end@alignbox\relax + \fi\fi + \else + \if #2t\relax + \def\@begin@alignbox{\vtop\bgroup\kern\z@\vbox}% + \def\@end@alignbox{\egroup}% + \else\if #2b\relax + \let\@begin@alignbox\vbox + \let\@end@alignbox\relax + \else + \let\@begin@alignbox\vcenter + \let\@end@alignbox\relax + \fi\fi + \fi +\else\ifnum\ltjgetparameter{direction}=1 % dtou + \ifx\box@dir\yoko + \if #2t\relax + \def\@begin@alignbox{\vtop\bgroup\kern\z@\vbox}% + \def\@end@alignbox{\egroup}% + \else\if #2b\relax + \let\@begin@alignbox\vbox + \let\@end@alignbox\relax + \else + \let\@begin@alignbox\vcenter + \let\@end@alignbox\relax + \fi\fi + \else\ifx\box@dir\dtou + \if #2t\relax + \let\@begin@alignbox\vtop + \let\@end@alignbox\relax + \else\if #2b\relax + \let\@begin@alignbox\vbox + \let\@end@alignbox\relax + \else + \let\@begin@alignbox\vcenter + \let\@end@alignbox\relax + \fi\fi + \else % 180 度回転→vtop, vbox を入れ替える + \if #2t\relax + \let\@begin@alignbox\vbox %%% !!! + \let\@end@alignbox\relax + \else\if #2b\relax + \let\@begin@alignbox\vtop %%% !!! + \let\@end@alignbox\relax + \else + \let\@begin@alignbox\vcenter + \let\@end@alignbox\relax + \fi\fi + \fi\fi +\else % tate, utod + \ifx\box@dir\yoko + \if #2t\relax + \def\@begin@alignbox{\vtop\bgroup\kern\z@\vbox}% + \def\@end@alignbox{\egroup}% + \else\if #2b\relax + \def\@begin@alignbox{\vbox\bgroup\vbox}% + \def\@end@alignbox{\kern\z@\egroup}% + \else + \let\@begin@alignbox\vcenter + \let\@end@alignbox\relax + \fi\fi + \else\ifx\box@dir\dtou % 180 度回転→vtop, vbox を入れ替える + \if #2t\relax + \let\@begin@alignbox\vbox %%% !!! + \let\@end@alignbox\relax + \else\if #2b\relax + \let\@begin@alignbox\vtop %%% !!! + \let\@end@alignbox\relax + \else + \let\@begin@alignbox\vcenter + \let\@end@alignbox\relax + \fi\fi + \else + \if #2t\relax + \let\@begin@alignbox\vtop + \let\@end@alignbox\relax + \else\if #2b\relax + \let\@begin@alignbox\vbox + \let\@end@alignbox\relax + \else + \let\@begin@alignbox\vcenter + \let\@end@alignbox\relax + \fi\fi + \fi\fi +\fi\fi% +} +\newbox\@floatbox +\newdimen\floatwidth +\newdimen\floatheight +\newdimen\floatruletick \floatruletick=0.4pt +\newdimen\captionfloatsep \captionfloatsep=10pt +\def\caption@dir{Z} +\let\captiondir\relax +\newdimen\captionwidth \captionwidth\z@ +\def\caption@posa{Z} +\def\caption@posb{Z} +\newbox\@captionbox +\def\captionfontsetup{\normalfont\normalsize} +\def\layoutfloat{\@ifnextchar(%) + {\X@layoutfloat}{\X@layoutfloat(-5\p@,-5\p@)}} +\def\X@layoutfloat(#1,#2){\@ifnextchar[%] + {\@layoutfloat(#1,#2)}{\@layoutfloat(#1,#2)[c]}} +\long\def\@layoutfloat(#1,#2)[#3]#4{% + \setbox\z@\hbox{#4}% + \floatwidth=#1 \floatheight=#2 \edef\float@pos{#3}% + \ifdim\floatwidth<\z@ + \floatwidth\wd\z@\floatruletick\z@ + \fi + \ifdim\floatheight<\z@ + \floatheight\ht\z@\advance\floatheight\dp\z@\relax + \floatruletick\z@ + \fi + \setbox\@floatbox\vbox to\floatheight{\offinterlineskip + \hrule width\floatwidth height\floatruletick depth\z@ + \vss\hbox to\floatwidth{% + \vrule width\floatruletick height\floatheight depth\z@ + \hss\vbox to\floatheight{\hsize\floatwidth\vss#4\vss}\hss + \vrule width\floatruletick height\floatheight depth\z@ + }\hrule width\floatwidth height\floatruletick depth\z@}} +\def\DeclareLayoutCaption#1<#2>(#3)[#4#5]{% + \expandafter + \ifx\csname #1@layoutcaption\endcsname\relax \else + \@latex@info{Redeclaring capiton layout setting of '#1'}% + \fi + \expandafter + \gdef\csname #1@layoutcaption\endcsname{% + \if Z\caption@dir\def\caption@dir{#2}\fi + \ifdim\captionwidth=\z@ \captionwidth=#3\relax\fi + \if Z\caption@posa\def\caption@posa{#4}\fi + \if Z\caption@posb\def\caption@posb{#5}\fi}} +\@onlypreamble\DeclareLayoutCaption +\DeclareLayoutCaption{figure}(.8\linewidth)[cd] +\DeclareLayoutCaption{table}(.8\linewidth)[cu] +\def\layoutcaption{\def\caption@dir{Z}\captionwidth\z@ + \def\caption@posa{Z}\def\caption@posb{Z}% + \@ifnextchar<\X@layoutcaption{% + \@ifnextchar(\@ilayoutcaption{% + \@ifnextchar[\@iilayoutcaption\relax}}} +\def\X@layoutcaption<#1>{\def\caption@dir{#1}% + \@ifnextchar(\@ilayoutcaption{% + \@ifnextchar[\@iilayoutcaption\relax}} +\def\@ilayoutcaption(#1){\setlength\captionwidth{#1}% + \@ifnextchar[{\@iilayoutcaption}{\relax}} +\def\@iilayoutcaption[#1#2]{% + \def\caption@posa{#1}\def\caption@posb{#2}} +\def\pcaption{\refstepcounter\@captype \@dblarg{\@pcaption\@captype}} +\long\def\@pcaption#1[#2]#3{% + \addcontentsline{\csname ext@#1\endcsname}{#1}{% + \protect\numberline{\csname the#1\endcsname}{\ignorespaces#2}}% + \ifvoid\@floatbox + \latex@error{Use with `\protect\layoutfloat'.}\@eha + \fi + \make@pcaptionbox{#3}% + \@pboxswfalse + \setbox\@tempboxa\vbox{\hbox to\hsize{\if l\float@pos\else\hss\fi + \if l\caption@posb\box\@captionbox\kern\captionfloatsep\fi + \if t\caption@posa\vtop + \else\if b\caption@posa\vbox + \else\ifmmode\vcenter \else\@pboxswtrue $\vcenter \fi\fi\fi + {\if u\caption@posb\box\@captionbox\kern\captionfloatsep\fi + \unvbox\@floatbox + \if d\caption@posb\kern\captionfloatsep\box\@captionbox\fi}% + \if r\caption@posb\kern\captionfloatsep\box\@captionbox\fi + \if@pboxsw \m@th$\fi \if r\float@pos\else\hss\fi}}% + \par\vskip.25\baselineskip + \box\@tempboxa} +\def\make@pcaptionbox#1{% + \expandafter + \ifx\csname\@captype @layoutcaption\endcsname\relax + \@latex@warning{Default caption layout of `\@captype' unknown.}% + \def\caption@dir{Z}\captionwidth\z@ + \def\caption@posa{Z}\def\caption@posb{Z}% + \else + \csname \@captype @layoutcaption\endcsname + \fi + \@tempswafalse + % tempswa\hline 基本組の組方向とキャプションの組方向が直交するか? + \if y\caption@dir \let\captiondir\yoko + \ifodd\ltjgetparameter{direction}\@tempswatrue\fi + \else\if z\caption@dir \let\captiondir\relax + \ifnum\ltjgetparameter{direction}=3 \let\captiondir\utod\fi + \else\if d\caption@dir \let\captiondir\dtou + \ifeven\ltjgetparameter{direction}\@tempswatrue\fi + \else\if u\caption@dir \let\captiondir\utod + \ifeven\ltjgetparameter{direction}\@tempswatrue\fi + \else\let\captiondir\tate + \ifeven\ltjgetparameter{direction}\@tempswatrue\fi + \fi\fi\fi\fi% t -> tate + \setbox0\hbox{\hbox{\captiondir + \captionfontsetup\parindent\z@\inhibitglue + \csname fnum@\@captype\endcsname\char\euc"A1A1\relax#1}}% + \if@tempswa \@tempdima\ltjgetht0 \else\@tempdima\ltjgetwd0 \fi + \ifdim\@tempdima>\captionwidth \@tempdima\captionwidth \fi + \@pboxswfalse + \setbox0\hbox{% + \if u\caption@posb\vbox + \else\if d\caption@posb\vbox + \else\if t\caption@posa\vtop + \else\if b\caption@posa\vbox + \else\ifmmode\vcenter\else\@pboxswtrue $\vcenter\fi + \fi\fi\fi\fi + {\hsize\@tempdima\kern\z@ + \vbox{\captiondir\hsize\@tempdima + \captionfontsetup\parindent\z@\inhibitglue + \csname fnum@\@captype\endcsname\char\euc"A1A1\relax#1}\kern\z@ + }\if@pboxsw \m@th$\fi}% + \let\to@captionboxwidth\relax + \if l\caption@posb \else\if r\caption@posb\else + \def\to@captionboxwidth{to\floatwidth}\fi\fi + \setbox\@captionbox\hbox\to@captionboxwidth{% + \if t\caption@posa\else\hss\fi + \unhbox0\relax + \if b\caption@posa\else\hss\fi}} +\def\minipage{\@ifnextchar<%> + {\X@minipage}{\X@minipage}} +\def\X@minipage<#1>{\@ifnextchar[%] + {\@iminipage<#1>}{\@iiiminipage<#1>{c}\@empty[s]}} +\def\@iminipage<#1>[#2]{\@ifnextchar[%] + {\@iiminipage<#1>{#2}}{\@iiiminipage<#1>{#2}\@empty[s]}} +\def\@iiminipage<#1>#2[#3]{\@ifnextchar[%] + {\@iiiminipage<#1>{#2}{#3}}{\@iiiminipage<#1>{#2}{#3}[#2]}} +\def\@iiiminipage<#1>#2#3[#4]#5{% + \leavevmode\bgroup + \setlength\@tempdima{#5}% + \def\@mpargs{<#1>{#2}{#3}[#4]{#5}}% + \let\box@dir\relax + \if #1z\relax + \ifnum\ltjgetparameter{direction}=3\relax + \let\box@dir\utod + \fi + \else + \if #1y\relax \let\box@dir\yoko + \else\if #1t\relax\let\box@dir\tate + \else\if #1d\relax\let\box@dir\dtou + \else\if #1u\relax\let\box@dir\utod + \fi\fi\fi\fi + \fi + \ifx\box@dir\relax + \ifcase\ltjgetparameter{direction}\relax + \or \let\box@dir\dtou + \or\or\let\box@dir\tate + \or \let\box@dir\yoko + \else \let\box@dir\utod + \fi + \fi + \setbox\@tempboxa\vbox\bgroup\box@dir + \adjustbaseline + \color@begingroup + \hsize\@tempdima + \textwidth\hsize \columnwidth\hsize + \@parboxrestore + \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}% + \c@mpfootnote\z@ + \let\@footnotetext\@mpfootnotetext + \let\@listdepth\@mplistdepth \@mplistdepth\z@ + \@minipagerestore + \global\@minipagetrue %% \global added 24 May 89 + \everypar{\global\@minipagefalse\everypar{}}} +\def\endminipage{% + \par + \unskip + \ifvoid\@mpfootins\else + \vskip\skip\@mpfootins + \normalcolor + \footnoterule + \unvbox\@mpfootins + \fi + \global\@minipagefalse %% added 24 May 89 + \color@endgroup + \egroup + \expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}\egroup} +\def\parbox{\@ifnextchar<%> + {\X@parbox}{\X@parbox}} +\def\X@parbox<#1>{\@ifnextchar[%] + {\@iparbox<#1>}{\@iiiparbox<#1>{c}\@empty[s]}} +\def\@iparbox<#1>[#2]{\@ifnextchar[%] + {\@iiparbox<#1>{#2}}{\@iiiparbox<#1>{#2}\@empty[s]}} +\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 + \setlength\@tempdima{#5}% + \fork@parbox@option<#1>[#2]% + \@begin@tempboxa\vbox{\box@dir + \hsize\@tempdima\@parboxrestore\adjustbaseline#6\endgraf}% + \ifx\@empty#3\relax\else + \setlength\@tempdimb{#3}% + \def\@parboxto{to\@tempdimb}% + \fi + \@begin@parbox\@parboxto{\box@dir\adjustbaseline + \let\hss\vss\let\unhbox\unvbox + \csname bm@#4\endcsname}\@end@parbox + \@end@tempboxa\egroup} +\def\fork@parbox@option<#1>[#2]{% + \let\box@dir\relax + \if #1z\relax + \ifnum\ltjgetparameter{direction}=3\relax + \let\box@dir\utod + \fi + \else + \if #1y\relax \let\box@dir\yoko + \else\if #1t\relax\let\box@dir\tate + \else\if #1d\relax\let\box@dir\dtou + \else\if #1u\relax\let\box@dir\utod + \fi\fi\fi\fi + \fi + \ifx\box@dir\relax + \ifcase\ltjgetparameter{direction}\relax + \or \let\box@dir\dtou + \or\or\let\box@dir\tate + \or \let\box@dir\yoko + \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 + \let\@begin@parbox\vtop + \let\@end@parbox\relax + \else\if #2b\relax + \let\@begin@parbox\vbox + \let\@end@parbox\relax + \else + \def\@begin@parbox{$\vcenter}% + \def\@end@parbox{\m@th$}% + \fi\fi + \else + \if #2t\relax + \def\@begin@parbox{\vtop\bgroup\kern\z@\vbox}% + \def\@end@parbox{\egroup}% + \else\if #2b\relax + \let\@begin@parbox\vbox + \let\@end@parbox\relax + \else + \def\@begin@parbox{$\vcenter}% + \def\@end@parbox{\m@th$}% + \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} + \else\if #2b\relax + \let\@begin@parbox\vbox + \let\@end@parbox\relax + \else + \def\@begin@parbox{$\vcenter}% + \def\@end@parbox{\m@th$}% + \fi\fi + \else\ifx\box@dir\dtou + \if #2t\relax + \let\@begin@parbox\vtop + \let\@end@parbox\relax + \else\if #2b\relax + \let\@begin@parbox\vbox + \let\@end@parbox\relax + \else + \def\@begin@parbox{$\vcenter}% + \def\@end@parbox{\m@th$}% + \fi\fi + \else % 180 度回転→vtop, vbox を入れ替える + \if #2t\relax + \let\@begin@parbox\vbox %%% !!! + \let\@end@parbox\relax + \else\if #2b\relax + \let\@begin@parbox\vtop %%% !!! + \let\@end@parbox\relax + \else + \def\@begin@parbox{$\vcenter}% + \def\@end@parbox{\m@th$}% + \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}% + \else\if #2b\relax + \def\@begin@parbox{\vbox\bgroup\vbox}% + \def\@end@parbox{\kern\z@\egroup}% + \else + \def\@begin@parbox{$\vcenter}% + \def\@end@parbox{\m@th$}% + \fi\fi + \else\ifx\box@dir\dtou % 180 度回転→vtop, vbox を入れ替える + \if #2t\relax + \let\@begin@parbox\vbox %%% !!! + \let\@end@parbox\relax + \else\if #2b\relax + \let\@begin@parbox\vtop %%% !!! + \let\@end@parbox\relax + \else + \def\@begin@parbox{$\vcenter}% + \def\@end@parbox{\m@th$}% + \fi\fi + \else + \if #2t\relax + \let\@begin@parbox\vtop + \let\@end@parbox\relax + \else\if #2b\relax + \let\@begin@parbox\vbox + \let\@end@parbox\relax + \else + \def\@begin@parbox{$\vcenter}% + \def\@end@parbox{\m@th$}% + \fi\fi + \fi\fi +\fi\fi% +} +\def\pbox{\leavevmode\@ifnextchar<{\X@makePbox}{\X@makePbox}} +\def\X@makePbox<#1>{% + \@ifnextchar[{\@imakePbox<#1>}{\@imakePbox<#1>[-5\p@]}} +\def\@imakePbox<#1>[#2]{\@ifnextchar[%] + {\@iimakePbox<#1>{#2}}{\@iimakePbox<#1>{#2}[c]}} +\def\@iimakePbox<#1>#2[#3]#4{% + \bgroup\let\box@dir\relax + \if #1z\relax + \ifnum\ltjgetparameter{direction}=3 \relax + \let\box@dir\utod + \fi + \else + \if #1y\relax \let\box@dir\yoko + \else\if #1t\relax\let\box@dir\tate + \else\if #1d\relax\let\box@dir\dtou + \else\if #1u\relax\let\box@dir\utod + \fi\fi\fi\fi + \fi + \ifx\box@dir\relax + \ifcase\ltjgetparameter{direction} + \or \let\box@dir\dtou + \or\or\let\box@dir\tate + \or \let\box@dir\yoko + \else \let\box@dir\utod + \fi + \fi + \ifdim #2 <\z@ \hbox{\box@dir#4}\else + \hbox to#2{\box@dir + \if #3l\relax\else\hss\fi + #4\relax + \if #3r\relax\else\hss\fi}\fi\egroup} +\def\picture{\@ifnextchar<%> + {\X@picture}{\X@picture}} +\def\X@picture<#1>(#2,#3){\@ifnextchar(%) + {\@@picture<#1>(#2,#3)}{\@@picture<#1>(#2,#3)(0,0)}} +\newdimen\save@ybaselineshift +\newdimen\save@tbaselineshift +\newdimen\@picwd +\def\@@picture<#1>(#2,#3)(#4,#5){% + \save@ybaselineshift\ybaselineshift + \save@tbaselineshift\tbaselineshift + \iftdir + \if#1y\let\box@dir\yoko + \@picwd=#3\unitlength \@picht=#2\unitlength + \@tempdima=#5\unitlength \@tempdimb=#4\unitlength + \else\let\box@dir\tate + \@picwd=#2\unitlength \@picht=#3\unitlength + \@tempdima=#4\unitlength \@tempdimb=#5\unitlength + \fi + \else + \if#1t\let\box@dir\tate + \@picwd=#3\unitlength \@picht=#2\unitlength + \@tempdima=#5\unitlength \@tempdimb=#4\unitlength + \else\let\box@dir\yoko + \@picwd=#2\unitlength \@picht=#3\unitlength + \@tempdima=#4\unitlength \@tempdimb=#5\unitlength + \fi + \fi + \setbox\@picbox\hbox to\@picwd\bgroup\box@dir + \hskip-\@tempdima\lower\@tempdimb\hbox\bgroup + \ybaselineshift\z@ \tbaselineshift\z@ + \ignorespaces} +\def\endpicture{% + \egroup\hss\egroup + \ht\@picbox\@picht \wd\@picbox\@picwd \dp\@picbox\z@ + \mbox{\box\@picbox}% + \ybaselineshift\save@ybaselineshift + \tbaselineshift\save@tbaselineshift} +\let\org@put\put +\def\put{\ybaselineshift\z@\tbaselineshift\z@\org@put} +\let\org@line\line +\def\line{\ybaselineshift\z@\tbaselineshift\z@\org@line} +\let\org@vector\vector +\def\vector{\ybaselineshift\z@\tbaselineshift\z@\org@vector} +\let\org@dashbox\dashbox +\def\dashbox{\ybaselineshift\z@\tbaselineshift\z@\org@dashbox} +\let\org@oval\oval +\def\oval{\ybaselineshift\z@\tbaselineshift\z@\org@oval} +\let\org@circle\circle +\def\circle{\ybaselineshift\z@\tbaselineshift\z@\org@circle} +\newif\ifnot@advanceline +\newskip\rensujiskip +\rensujiskip=0.25\chs plus.25\zw minus.25\zw +\DeclareRobustCommand\rensuji{% + \@ifstar{\not@advancelinetrue\@rensuji}{\@rensuji}} +\def\@rensuji{\@ifnextchar[{\@@rensuji}{\@@rensuji[c]}} +\def\@@rensuji[#1]#2{\ifydir\hbox{#2}\else + \hskip\rensujiskip + \ifvmode\leavevmode\fi + \ifnot@advanceline\not@advancelinefalse\else + \setbox\z@\hbox{\yoko#2}% + \@tempdima\ht\z@ \advance\@tempdima\dp\z@ + \if #1c\relax\vrule\@width\z@ \@height.5\@tempdima \@depth.5\@tempdima + \else\if #1r\relax\vrule\@width\z@\@height\z@ \@depth\@tempdima + \else\vrule\@width\z@ \@height\@tempdima \@depth\z@ + \fi\fi + \fi + \if #1c\relax\hbox to1zw{\yoko\hss#2\hss}% + \else\if #1r\relax\vbox{\hbox to1zw{\yoko\hss#2}}% + \else\vtop{\hbox to1zw{\yoko#2\hss}}% + \fi\fi + \hskip\rensujiskip +\fi} +\let\Rensuji\rensuji +\let\prensuji\rensuji +\def\Kanji#1{\expandafter\@Kanji\csname c@#1\endcsname} +\def\@Kanji#1{\expandafter\kansuji\number #1} +\def\kanji{\iftdir\expandafter\kansuji\fi} +\def\boutenchar{\char\euc"A1A2} +\def\bou#1{\ifvmode\leavevmode\fi\@bou#1\end} +\def\@bou#1{% + \ifx#1\end \let\next=\relax + \else + \iftdir\if@rotsw + \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen + \vss\moveleft-0.2zw\hbox{\boutenchar}\nointerlineskip + \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax + \else + \hbox to\z@{\vbox to\z@{\boxmaxdepth\maxdimen + \vss\moveleft0.2zw\hbox{\yoko\boutenchar}\nointerlineskip + \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax + \fi\else + \hbox to\z@{\vbox to\z@{% + \vss\moveleft-0.2zw\hbox{\yoko\boutenchar}\nointerlineskip + \hbox{\char\euc"A1A1}}\hss}\nobreak#1\relax + \fi + \let\next=\@bou + \fi\next} +\def\kasen#1{% + \ifydir\underline{#1}% + \else\if@rotsw\underline{#1}\else + \setbox\z@\hbox{#1}\leavevmode\raise.7zw + \hbox to\z@{\vrule\@width\wd\z@ \@depth\z@ \@height.4\p@\hss}% + \box\z@ + \fi\fi} +\def\@eqnnum{{\reset@font\rmfamily \normalcolor + \iftdir\raise.25zh\hbox{\yoko(\theequation)}% + \else (\theequation)\fi}} +\def\@thecounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}} +\def\@thmcounter#1{\noexpand\rensuji{\noexpand\arabic{#1}}} +\endinput +%% +%% End of file `plext.sty'. diff --git a/src/ltj-direction.lua b/src/ltj-direction.lua index 9b2b6ab..4f9da1b 100644 --- a/src/ltj-direction.lua +++ b/src/ltj-direction.lua @@ -278,14 +278,17 @@ end -- dir_node に包む方法を書いたテーブル local dir_node_aux do + local floor = math.floor local get_h =function (w,h,d) return h end local get_d =function (w,h,d) return d end local get_h_d =function (w,h,d) return h+d end local get_h_d_neg =function (w,h,d) return -h-d end local get_h_neg =function (w,h,d) return -h end local get_d_neg =function (w,h,d) return -d end - local get_w_half =function (w,h,d) return 0.5*w end - local get_w_neg_half =function (w,h,d) return -0.5*w end + local get_w_half =function (w,h,d) return floor(0.5*w) end + local get_w_neg_half =function (w,h,d) return floor(-0.5*w) end + local get_w_half_rem =function (w,h,d) return w-floor(0.5*w) end + local get_w_neg_half_rem =function (w,h,d) return -w-floor(-0.5*w) end local get_w_neg =function (w,h,d) return -w end local get_w =function (w,h,d) return w end local zero = function() return 0 end @@ -294,13 +297,13 @@ do [dir_tate] = { -- tate 中で組む width = get_h_d, height = get_w_half, - depth = get_w_half, + depth = get_w_half_rem, [id_hlist] = { { 'whatsit', sid_save }, { 'rotate', '0 1 -1 0' }, { 'kern', get_w_neg_half }, { 'box' , get_h }, - { 'kern', get_w_neg_half }, + { 'kern', get_w_neg_half_rem }, { 'whatsit', sid_restore }, }, [id_vlist] = { diff --git a/test/test54-lltjext.pdf b/test/test54-lltjext.pdf new file mode 100644 index 0000000..f8c25dd Binary files /dev/null and b/test/test54-lltjext.pdf differ diff --git a/test/test54-lltjext.tex b/test/test54-lltjext.tex new file mode 100644 index 0000000..96bbd3f --- /dev/null +++ b/test/test54-lltjext.tex @@ -0,0 +1,146 @@ +%#!luajitlatex +\ifdefined\directlua + \documentclass{ltjsarticle} + \usepackage{lltjext} +\else + \documentclass{jsarticle} + \usepackage{plext} + \usepackage{otf} +\fi +\pagestyle{empty} +\usepackage[T1]{fontenc} +\usepackage[a6paper,landscape,margin=10mm,top=5mm]{geometry} +\let\mcdefault\gtdefault +\let\rmdefault\sfdefault +\newdimen\WIDTH\WIDTH30\Cwd + +\def\AX{\adjustbaseline + \ifdefined\directlua\ltjsetparameter{autospacing=false, autoxspacing=false}% + \else\noautospacing\noautoxspacing\fi} +\def\TEST#1#2{\newpage +\hbox to 40\Cwd{\hss\vtop{\hsize=\WIDTH#1 +\normalsize +\section{組方向: \string#1,ボックス: #2} +\adjustbaseline +\paragraph{tabular}\ + +あいうxyz% +\begin{tabular}<#2>[t]{ll} +\hline +上(\texttt{t} opt),罫あり&T\\ +\hline +\end{tabular} +えおabc\hfil\penalty0\hfilneg あいうxyz% +\begin{tabular}<#2>[c]{l} +\hline +中央(\texttt{c} opt),罫あり\\ +\hline +\end{tabular} +えおabc\hfil\penalty0\hfilneg あいうxyz% +\begin{tabular}<#2>[b]{l} +\hline +下(\texttt{b} opt),罫あり\\ +\hline +\end{tabular} +えおabc\hfil\penalty0\hfilneg あいうxyz +\begin{tabular}<#2>[t]{l} +上(\texttt{t} opt),罫なし\\ +\end{tabular}えおabc\hfil\penalty0\hfilneg +あいうxyz% +\begin{tabular}<#2>[c]{l} +中央(\texttt{c} opt),罫なし\\ +\end{tabular}えおabc\hfil\penalty0\hfilneg +あいうxyz% +\begin{tabular}<#2>[b]{l} +下(\texttt{b} opt),罫なし\\ +\end{tabular}あいうxyz +}} + +\newpage +\hbox to 40\Cwd{\hss\vtop{\hsize=\WIDTH#1 +\AX + +\paragraph{minipage}\ + +あいうxyz% +\begin{minipage}<#2>[t]{10\Cwd} +そのため、 +仮に区単位でカテゴリコードを変更できるようにしても、SJIS版 +\end{minipage}あいうxyz% +\begin{minipage}<#2>[c]{10\Cwd} +そのため、 +仮に区単位でカテゴリコードを変更できるようにしても、SJIS版 +\end{minipage}\hfil\penalty0\hfilneg あいうxyz% +\begin{minipage}<#2>[b]{10\Cwd} +そのため、 +仮に区単位でカテゴリコードを変更できるようにしても、SJIS版 +\end{minipage}あいうxyz +}} + +\newpage +\hbox to 40\Cwd{\hss\vtop{\hsize=\WIDTH#1 +\subsection*{組方向: \string#1,ボックス: #2 後半} +\AX +\paragraph{parbox}\ + +あいうxyz\nobreak% +\parbox<#2>[t]{10\Cwd}{% +そのため、 +仮に区単位でカテゴリコードを変更できるようにしても、SJIS版}% +えおabc\hfil\penalty0\hfilneg あいうxyz\nobreak% +\parbox<#2>[c]{10\Cwd}{% +そのため、 +仮に区単位でカテゴリコードを変更できるようにしても、SJIS版}% +えおabc\hfil\penalty0\hfilneg あいうxyz\nobreak% +\parbox<#2>[b]{10\Cwd}{% +そのため、 +仮に区単位でカテゴリコードを変更できるようにしても、SJIS版}% +えおabc +}} + +\newpage +\hbox to 40\Cwd{\hss\vtop{\hsize=\WIDTH#1 + +\paragraph{pbox}\ + +\AX\noindent +あいうxyz\nobreak\pbox<#2>[20\Cwd][l]{% + 計算機科学(Computer Science)}えおabc\hfil\penalty0\hfilneg +あいうxyz\nobreak\pbox<#2>[20\Cwd][c]{% + 計算機科学(Computer Science)}えおabc\hfil\penalty0\hfilneg +あいうxyz\nobreak\pbox<#2>[20\Cwd][r]{% + 計算機科学(Computer Science)}えおabc + +}}} +\begin{document} + +%\tracingifs2\tracingonline2 +\TEST{\yoko}{y} +\TEST{\yoko}{t} +\TEST{\yoko}{z} +\TEST{\tate}{y} +\TEST{\tate}{t} +\TEST{\tate}{z} + +\ifdefined\directlua +\TEST{\yoko}{d} +\TEST{\yoko}{u} + +\TEST{\tate}{d} +\TEST{\tate}{u} + +\TEST{\dtou}{y} +\TEST{\dtou}{t} +\TEST{\dtou}{z} +\TEST{\dtou}{d} +\TEST{\dtou}{u} + +\TEST{\utod}{y} +\TEST{\utod}{t} +\TEST{\utod}{z} +\TEST{\utod}{d} +\TEST{\utod}{u} +\fi +\end{document} + + diff --git a/test/test54-res.pdf b/test/test54-res.pdf new file mode 100644 index 0000000..8d5ec5c Binary files /dev/null and b/test/test54-res.pdf differ diff --git a/test/test54.sh b/test/test54.sh new file mode 100755 index 0000000..a7cbd87 --- /dev/null +++ b/test/test54.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +platex -jobname test54-p test54-lltjext +dvipdfmx test54-p +luajitlatex -jobname test54-l test54-lltjext + +cat < test54-res.tex +\documentclass{article} +\pdfpageattr {/Group << /S /Transparency /I true /CS /DeviceRGB>>} +\pdfoptionpdfminorversion 7 +\usepackage[a6paper,landscape,margin=0mm]{geometry} +\usepackage{xcolor,graphicx} +\usepackage{transparent} + +\def\E#1{\newpage\leavevmode +\hbox to 0pt{\transparent{0.5}\textcolor{red}{% +\includegraphics[width=\textwidth,page=#1]{test54-p.pdf}}\hss}% +\hbox to 0pt{\transparent{0.5}\textcolor{blue}{% +\includegraphics[width=\textwidth,page=#1]{test54-l.pdf}}\hss}% +} + +\begin{document} +\parindent0pt + +\newcount\D +\D=1 +\loop\ifnum\D<25 + \E{\the\D}\advance\D1 + \repeat + +\end{document} +EOF + +pdflatex test54-res