%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lltjext}[2017/04/06 v1.2f-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*
}%
%%% 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<Z>}}
+ {\@stabular}{\@stabular<z>}}
\def\X@tabarray{\@ifnextchar<%>
- {\p@tabarray}{\p@tabarray<Z>}}
+ {\p@tabarray}{\p@tabarray<z>}}
\def\X@tabular{\@ifnextchar<%>
- {\p@tabular}{\p@tabular<Z>}}
+ {\p@tabular}{\p@tabular<z>}}
\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[%]
\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
\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=\ystrutbox% yoko
\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
% \item |[b]|指定のとき\\最終行のベースラインが周囲のそれと一致(罫線の場合は和文ベースラインの位置)
% \end{itemize}
% \item 周囲の組方向が縦組かつ組方向が|<z>|指定の場合
-% [TODO] 未定!
-%^^A \begin{itemize}
-%^^A \item |[t]|指定のとき\\表組の上端が周囲の和文ベースラインと一致
-%^^A \item |[c]|指定のとき\\表組の中心が周囲の数式軸を通る(欧文ベースラインシフトの影響下)
-%^^A \item |[b]|指定のとき\\表組の下端が周囲の和文ベースラインと一致
-%^^A \end{itemize}
+% \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
\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
\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%
}
\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
\let\@begin@parbox\vbox %%% !!!
\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
\ifmmode
\let\@begin@parbox\vcenter\let\@end@parbox\relax
\def\@end@parbox{\m@th$\null}%
\fi
\fi\fi
- \fi\fi
+ \fi\fi\fi
\fi\fi%
}
\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<Z>}}
+ \def\@tabarray{\@ifnextchar<\p@tabarray{\p@tabarray<z>}}
\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
\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=\ystrutbox% yoko