summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/shipunov/tex/sltables.sty
blob: b6238e867859adc55ab1c8ba4d14df3bae4f66cd (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
% Modified from the original LaTeX 2.09 sources by Alexey Shipunov, dactylorhiza@gmail.com

\ProvidesPackage{sltables}
	[2008/02/07 v1.2 S-Tables LaTeX package]

% Some modifications to LaTeX: aded LaTeX 2.09 counter
\newcount\mscount

%
% S-Tables Macro v1.0, ACS, TAMU (RANHELP@VENUS.TAMU.EDU)
%
% Help Text
%
\newhelp\stablestylehelp{You must choose a style between 0 and 3.}%
\newhelp\stablelinehelp{You should not use special hrules when stretching
a table.}%
\newhelp\stablesmultiplehelp{You have tried to place an S-Table inside another
S-Table. I would recommend not going on.}%
%
% Line Thicknesses (Values)
%
\newdimen\stablesthinline
\stablesthinline=0.4pt
\newdimen\stablesthickline
\stablesthickline=1pt
%
% Border and Internal Line Thicknesses
%
\newif\ifstablesborderthin
\stablesborderthinfalse
\newif\ifstablesinternalthin
\stablesinternalthintrue
\newif\ifstablesomit
\newif\ifstablemode
\newif\ifstablesright
\stablesrightfalse
%
% Save Registers
%
\newdimen\stablesbaselineskip
\newdimen\stableslineskip
\newdimen\stableslineskiplimit
%
% Counters
%
\newcount\stablesmode
\newcount\stableslines
\newcount\stablestemp
\stablestemp=3
\newcount\stablescount
\stablescount=0
\newcount\stableslinet
\stableslinet=0
%
% Table Style Selection
%
% 0 - Centered
% 1 - Left Justified
% 2 - Right Justified
% 3 - Not Justified
%
\newcount\stablestyle
\stablestyle=0
%
% Element Buffering Definitions
%
\def\stablesleft{\quad\hfil}%
\def\stablesright{\hfil\quad}%
%
% Vertical Bar Activation               <== changed!
%
{\catcode`\|=\active
\gdef\Start@Bar{%
\global\catcode`\|=\active
        \global\def|{\global\advance\stablesmode by 1&&&}%
        \global\def\|{\global\advance\stablesmode by 1&\omit\vrule width 0pt%
\hfil&&}}}%
%
%
% Strut Control
%
\newcount\stablestrutsize
\newbox\stablestrutbox
\setbox\stablestrutbox=\hbox{\vrule height10pt depth5pt width0pt}
\def\stablestrut{\relax\ifmmode%
                         \copy\stablestrutbox%
                       \else%
                         \unhcopy\stablestrutbox%
                       \fi}%
%
% Misc. Internal Stuff
%
\newdimen\stablesborderwidth
\newdimen\stablesinternalwidth
\newdimen\stablesdummy
\newcount\stablesdummyc
\newif\ifstablesin
\stablesinfalse
%
% Table Macros
%
\def\stable{\Start@Bar\stablestart%     <== changed!
  \stablemodetrue%
  \stablesadj%
  \halign%
  \stablesdef}%
\def\stableto#1{\Start@Bar\stablestart% <== changed!
  \stablemodefalse%
  \stablesadj%
  \halign to #1%
  \stablesdef}%
\def\stablesp#1{\Start@Bar\stablestart% <== changed!
  \stablemodefalse%
  \stablesadj%
  \halign spread #1%
  \stablesdef}%
\def\stablesadj{%
  \ifcase\stablestyle%
    \hbox to \hsize\bgroup\hss\vbox\bgroup%
  \or%
    \hbox to \hsize\bgroup\vbox\bgroup%
  \or%
    \hbox to \hsize\bgroup\hss\vbox\bgroup%
  \or%
    \hbox\bgroup\vbox\bgroup%
  \else%
    \errhelp=\stablestylehelp%
    \errmessage{Invalid style selected, using default}%
    \hbox to \hsize\bgroup\hss\vbox\bgroup%
  \fi}%
\def\stablesend{\egroup%
  \ifcase\stablestyle%
    \hss\egroup%
  \or%
    \hss\egroup%
  \or%
    \egroup%
  \or%
    \egroup%
  \else%
    \hss\egroup%
  \fi}%
\def\stablestart{%
  \ifstablesin%
    \errhelp=\stablesmultiplehelp%
    \errmessage{An S-Table cannot be placed within an S-Table!}%
  \fi
  \global\stablesintrue%
  \global\advance\stablescount by 1%
  \message{<S-Tables Generating Table \number\stablescount}%
  \begingroup%
  \stablestrutsize=\ht\stablestrutbox%
  \advance\stablestrutsize by \dp\stablestrutbox%
  \ifstablesborderthin%
    \stablesborderwidth=\stablesthinline%
  \else%
    \stablesborderwidth=\stablesthickline%
  \fi%
  \ifstablesinternalthin%
    \stablesinternalwidth=\stablesthinline%
  \else%
    \stablesinternalwidth=\stablesthickline%
  \fi%
  \tabskip=0pt%
  \stablesbaselineskip=\baselineskip%
  \stableslineskip=\lineskip%
  \stableslineskiplimit=\lineskiplimit%
  \offinterlineskip%
  \def\borderrule{\vrule width \stablesborderwidth}%
  \def\internalrule{\vrule width \stablesinternalwidth}%
%
  \def\thinline{\noalign{\hrule height \stablesthinline}}%
  \def\thickline{\noalign{\hrule height \stablesthickline}}%
  \def\trule{\omit\leaders\hrule height \stablesthinline\hfill}%
  \def\ttrule{\omit\leaders\hrule height \stablesthickline\hfill}%
  \def\tttrule##1{\omit\leaders\hrule height ##1\hfill}%
  \def\stablesel{&\omit\global\stablesmode=0%
    \global\advance\stableslines by 1\borderrule\hfil\cr}%
  \def\el{\stablesel&}%
  \def\elt{\stablesel\thinline&}%
  \def\eltt{\stablesel\thickline&}%
  \def\elttt##1{\stablesel\noalign{\hrule height ##1}&}%
  \def\elspec{&\omit\hfil\borderrule\cr\omit\borderrule&%
              \ifstablemode%
              \else%
                \errhelp=\stablelinehelp%
                \errmessage{Special ruling will not display properly}%
              \fi}%
%
  \def\stmultispan##1{\mscount=##1 \loop\ifnum\mscount>3 \stspan\repeat}%
  \def\stspan{\span\omit \advance\mscount by -1}%
%
  \def\multicolumn##1{\omit\multiply\stablestemp by ##1%
     \stmultispan{\stablestemp}%
     \advance\stablesmode by ##1%
     \advance\stablesmode by -1%
     \stablestemp=3}%
  \def\multirow##1{\stablesdummyc=##1\parindent=0pt\setbox0\hbox\bgroup%
    \aftergroup\emultirow\let\temp=}
  \def\emultirow{\setbox1\vbox to\stablesdummyc\stablestrutsize%
    {\hsize\wd0\vfil\box0\vfil}%
    \ht1=\ht\stablestrutbox%
    \dp1=\dp\stablestrutbox%
    \box1}%
%
%  \def\stvcen##1{\vtop{\vfill\hbox{##1}\vfill}}% Currently does not work!
  \def\stpar##1{\vtop\bgroup\hsize ##1%
     \baselineskip=\stablesbaselineskip%
     \lineskip=\stableslineskip%
     \lineskiplimit=\stableslineskiplimit\bgroup\aftergroup\estpar\let\temp=}%
  \def\estpar{\vskip 6pt\egroup}%
  \def\stparrow##1##2{\stablesdummy=##2%
     \setbox0=\vtop to ##1\stablestrutsize\bgroup%
     \hsize\stablesdummy%
     \baselineskip=\stablesbaselineskip%
     \lineskip=\stableslineskip%
     \lineskiplimit=\stableslineskiplimit%
     \bgroup\vfil\aftergroup\estparrow%
     \let\temp=}%
  \def\estparrow{\vfil\egroup%
     \ht0=\ht\stablestrutbox%
     \dp0=\dp\stablestrutbox%
     \wd0=\stablesdummy%
     \box0}%
%
  \def\vt{\global\advance\stablesmode by 1&\omit\vrule width \stablesthinline%
          \hfil&&}%
  \def\vtt{\global\advance\stablesmode by 1&\omit\vrule width \stablesthickline%
          \hfil&&}%
  \def\vttt##1{\global\advance\stablesmode by 1&\omit\vrule width ##1%
          \hfil&&}%
  \def\vtr{\global\advance\stablesmode by 1&\omit\hfil\vrule width%
           \stablesthinline&&}%
  \def\vttr{\global\advance\stablesmode by 1&\omit\hfil\vrule width%
            \stablesthickline&&}%
  \def\vtttr##1{\global\advance\stablesmode by 1&\omit\hfil\vrule width ##1&&}%
  \stableslines=0%
  \stablesomitfalse}
%
\def\stablesdef{\bgroup\stablestrut\borderrule##\tabskip=0pt plus 1fil%
  &\stablesleft##\stablesright%
  &##\ifstablesright\hfill\fi\internalrule\ifstablesright\else\hfill\fi%
  \tabskip 0pt&&##\hfil\tabskip=0pt plus 1fil%
  &\stablesleft##\stablesright%
  &##\ifstablesright\hfill\fi\internalrule\ifstablesright\else\hfill\fi%
  \tabskip=0pt\cr%
  \ifstablesborderthin%
    \thinline%
  \else%
    \thickline%
  \fi&%
}%
\def\endstable{\advance\stableslines by 1\advance\stablesmode by 1% <== changed!
   \message{- Rows: \number\stableslines, Columns:  \number\stablesmode>}%
   \stablesel%
   \ifstablesborderthin%
     \thinline%
   \else%
     \thickline%
   \fi%
   \egroup\stablesend%
\endgroup%
\global\stablesinfalse%
\global\catcode`\|=12}%                 <== new!
\let\endstableto\endstable%             <== new!
\let\endstablesp\endstable%             <== new!
%