summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/platex-tools/plextarray.sty
blob: 6c34ee0e4f5d7feb44101cc1723b2228b22a38b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
%
% plextarray.sty
% written by Hironobu Yamashita (@aminophen)
%
% This package is part of the platex-tools bundle.
% https://github.com/aminophen/platex-tools
%
% This package `plextarray.sty' is based on:
%   * array.sty in latex-tools (2016/10/06 v2.4d)
%   * plext.sty in platex (2016/08/20 v1.2a)
% and lltjext.sty from LuaTeX-ja project.
%

\NeedsTeXFormat{pLaTeX2e}
\ProvidesPackage{plextarray}
  [2016/10/23 v1.0g Tabular extension package for plext and array]
\RequirePackage{plext}
\RequirePackage{array}

%% save definitions from array.sty
\def\array{\col@sep\arraycolsep
  \def\d@llarbegin{$}\let\d@llarend\d@llarbegin\def\@halignto{}%
  \@tabarray}
\def\tabular{\def\@halignto{}\@tabular}
\expandafter\def\csname tabular*\endcsname#1{%
       \setlength\dimen@{#1}%
       \edef\@halignto{to\the\dimen@}\@tabular}

%% patching internal code for array.sty and plext.sty
%
\def\@startpbox#1{\bgroup
  \box@dir\adjustbaseline %% added
  \hsize=#1\@arrayparboxrestore
   \everypar{%
      \vrule \@height \ht\@arstrutbox \@width \z@
      \everypar{}}%
   }
%
\def\@tabarray{\@ifnextchar<\p@tabarray{\p@tabarray<Z>}}
%
%% merged \@array (from array.sty) and \p@array (from plext.sty)
\def\p@array<#1>[#2]#3{%
  %%%%% new code for box direction
  \let\box@dir\relax
  \iftdir
    \if #1y\relax
      \let\box@dir\yoko
      \@tempcnta=\z@    % \(y)strutbox
    \else\if #1z\relax
      \@rotswtrue
      \let\box@dir\tate
      \@tempcnta=\tw@   % \zstrutbox
    \else
      \let\box@dir\tate
      \@tempcnta=\@ne   % \tstrutbox
    \fi\fi
  \else
    \if #1t\relax
      \let\box@dir\tate
      \@tempcnta=\@ne   % \tstrutbox
    \else
      \let\box@dir\yoko
      \@tempcnta=\z@    % \(y)strutbox
    \fi
  \fi
  %%%%% new code end
  \setbox \@arstrutbox \hbox{\box@dir %% add \box@dir
      % the behavior of \strutbox may be changed
      % (box resister -> conditional macro) in the future;
      % so, \strutbox should appear after \box@dir is applied.
      \@tempcntb=\ifcase\@tempcnta\strutbox
                 \or\tstrutbox\or\zstrutbox\or\@ctrerr\fi
      \@tempdima \ht \@tempcntb
      \advance \@tempdima by\extrarowheight
      \vrule \@height \arraystretch \@tempdima
             \@depth \arraystretch \dp \@tempcntb
             \@width \z@}%
  \fork@array@option<#1>[#2]%  %% merged from plext
  \begingroup
  \@mkpream{#3}%
  % following definition of \@preamble is from plext (\edef -> \xdef),
  % but it's not the same as the one in array; why?
  \xdef\@preamble{\ialign \noexpand \@halignto
                  \bgroup \tabskip \z@skip \@arstrut \@preamble
                          \tabskip \z@skip \cr}%
  \endgroup
  \@arrayleft
  \@begin@alignbox %% defined inside \fork@array@option
  \bgroup
  \box@dir\adjustbaseline
  \let\par\@empty
  \let\@sharp##\let\protect\relax
  \let\\\@arraycr\let\tabularnewline\\
  \lineskip\z@skip\baselineskip\z@skip\@preamble}
%
\def\endarray{\crcr \egroup \egroup \@end@alignbox \@arrayright \gdef\@preamble{}}
\def\endtabular{\endarray $\egroup\null}
\expandafter \let \csname endtabular*\endcsname = \endtabular
%
%% done

%% support for other packages
\@ifpackageloaded{colortbl}{% --- colortbl.sty 2012/06/21 v1.0b
  \PackageInfo{plextarray}{Package colortbl detected}%
  \def\endarray{\crcr \egroup \egroup \@end@alignbox \@arrayright \gdef\@preamble{}\CT@end}%
}{}
%% all done

\endinput