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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
|
%%
%% This is file `tabularht.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tabularht.dtx (with options: `package')
%%
%% This is a generated file.
%%
%% Project: tabularht
%% Version: 2007/04/11 v2.5
%%
%% Copyright (C) 2005-2007 by
%% Heiko Oberdiek <heiko.oberdiek at googlemail.com>
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%% http://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status "maintained".
%%
%% This Current Maintainer of this work is Heiko Oberdiek.
%%
%% This work consists of the main source file tabularht.dtx
%% and the derived files
%% tabularht.sty, tabularht.pdf, tabularht.ins, tabularht.drv,
%% tabularht-example1.tex, tabularht-example2.tex.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tabularht}%
[2007/04/11 v2.5 Tabular with height specified (HO)]
\let\@toarrayheight\@empty
\let\tabH@array@init\@empty
\toks@={%
\begingroup
\long\def\x#1\vcenter\fi\fi\bgroup#2\@sharp#3#4\@nil{%
\endgroup
\gdef\@array[##1]##2{%
\tabH@array@init
#1%
\vcenter\fi\fi
\@toarrayheight
\bgroup
\let\@toarrayheight\@empty
#2\@sharp###3#4%
}%
}%
\expandafter\x\@array[#1]{#2}\@nil % hash-ok
}
\edef\tabH@patch@array{\the\toks@}
\def\tabH@patch@@array{%
\ifx\@array\@@array
\def\reserved@a{\let\@@array\@array}%
\else
\let\reserved@a\relax
\fi
\tabH@patch@array
\reserved@a
}
\tabH@patch@@array
\@ifpackageloaded{array}{}{%
\AtBeginDocument{%
\@ifpackageloaded{array}{%
\tabH@patch@@array
}{}%
}%
}
\def\tabH@setheight#1{%
\tabH@@setheight#1==\@nil
}
\def\tabH@@setheight#1=#2=#3\@nil{%
\ifx\\#2#3\\%
\setlength{\dimen@}{#1}%
\edef\@toarrayheight{to\the\dimen@}%
\else
\edef\tabH@temp{\zap@space#1 \@empty}%
\ifx\tabH@temp\tabH@to
\else
\ifx\tabH@temp\tabH@spread
\else
\PackageError{tabularht}{%
Unknown height specifier %
`\expandafter\strip@prefix\meaning\tabH@temp'%
}{%
The height dimension for tabular height can be prefixed%
\MessageBreak
with `to=' or `spread=', default is `to='.%
}%
\let\tabH@temp\tabH@to
\fi
\fi
\setlength{\dimen@}{#2}%
\edef\@toarrayheight{\tabH@temp\the\dimen@}%
\fi
}
\def\tabH@to{to}
\def\tabH@spread{spread}
\newenvironment{tabularht}[1]{%
\tabH@setheight{#1}%
\tabular
}{%
\endtabular
}
\newenvironment{tabularht*}[1]{%
\tabH@setheight{#1}%
\@nameuse{tabular*}%
}{%
\@nameuse{endtabular*}%
}
\newenvironment{tabularhtx}[1]{%
\tabH@setheight{#1}%
\tabularx
}{%
\endtabularx
}
\newenvironment{arrayht}[1]{%
\tabH@setheight{#1}%
\array
}{%
\endarray
}
\def\interrowspace{%
\noalign\bgroup
\tabH@interrowspace
}
\newcommand*{\tabH@interrowspace}[2][]{%
\tabH@vspace{#1}{#2}%
\egroup
}
\def\interrowfill{%
\noalign\bgroup
\tabH@interrowfill
}
\newcommand*{\tabH@interrowfill}[1][]{%
\tabH@vspace{#1}{\fill}%
\egroup
}
\def\tabH@vspace#1#2{%
\tabH@vspace@start{#1}%
\vspace{#2}%
\tabH@vspace@stop
}
\let\tabH@vspace@start\@gobble
\let\tabH@vspace@stop\@empty
\newcommand*{\interrowstart}{%
\noalign\bgroup
\tabH@interrowstart
}
\newcommand*{\tabH@interrowstart}[1][]{%
\tabH@vspace@start{#1}%
\egroup
}
\newcommand*{\interrowstop}{%
\noalign{\tabH@vspace@stop}%
}
\providecommand*{\tabH@driver}{}
\DeclareOption{vlines}{%
\let\tabH@temp\relax
}
\DeclareOption{pdftex}{}
\DeclareOption{dvips}{%
\def\tabH@driver{dvips}%
}
\ProcessOptions*\relax
\ifx\tabH@temp\relax
\else
\expandafter\endinput
\fi
\begingroup
\@ifundefined{eTeXversion}{%
\PackageError{tabularht}{%
Option `vlines' requires eTeX%
}{%
Use of eTeX is recommended for LaTeX, see ltnews16.%
}%
\endgroup
\endinput
}{}%
\endgroup
\begingroup
\let\@addtoreset\@gobbletwo
\newcounter{tabH@unique}%
\endgroup
\let\tabH@currenttab\@empty
\def\tabH@array@init{%
\ifx\@toarrayheight\@empty
% ignore vertical lines of nested tabular environments
\let\tabH@currenttab\@empty
\else
\stepcounter{tabH@unique}%
\edef\tabH@currenttab{\the\c@tabH@unique}%
\fi
}
\renewcommand*{\@arrayrule}{%
\@addtopreamble{%
\hskip -.5\arrayrulewidth
\ifx\tabH@currenttab\@empty
\else
\tabH@vrule{\tabH@currenttab}%
\fi
\begingroup
\expandafter\ifx\csname CT@arc@\endcsname\relax
\else
\expandafter\CT@arc@
\fi
\vline
\endgroup
\hskip -.5\arrayrulewidth
}%
}
\let\tabH@arrayrule\@arrayrule
\AtBeginDocument{%
\@ifpackageloaded{colortbl}{%
\let\@arrayrule\tabH@arrayrule
}{}%
}
\let\tabH@vrule\@gobble
\RequirePackage{ifpdf}
\ifpdf
\begingroup
\@ifundefined{pdfsavepos}{%
\PackageError{tabularht}{%
Your pdfTeX is too old%
}{%
\string\pdfsavepos\space is missing.%
}%
\endgroup
\csname fi\endcsname
\endinput
}{}%
\let\on@line\@empty
\PackageInfo{tabularht}{%
Using driver `pdftex' because of pdfTeX in PDF mode%
}%
\endgroup
\protected\def\tabH@vrule#1{%
\if@filesw
\pdfsavepos
\protected@write\@auxout{%
\let\tabH@lastxpos\relax
}{%
\tabH@aux@vrule{#1}{\tabH@lastxpos}%
}%
\fi
}%
\def\tabH@lastxpos{\the\pdflastxpos}%
\def\tabH@lastypos{\the\pdflastypos}%
% The .aux file contains three commands:
% \tabH@aux@vrule{tabular id}{x position}
% \tabH@aux@vstart{tabular id}{row id}{x position}{y position}
% \tabH@aux@vstop{y position}
%
\AtBeginDocument{%
% The .aux files are read the first time before
% \AtBeginDocument and later at \end{document}.
% \tabH@aux@done is a marker to distinguish
% between these two readings. Only in the first
% case we need the \tabH@aux@... commands.
\let\tabH@aux@done\@empty
\if@filesw
\immediate\write\@mainaux{%
\@percentchar\@percentchar BeginProlog: tabularht%
}%
% items in the aux file are executed,
% if tabularht is loaded
% and during the aux file read at \begin{document} only
\immediate\write\@mainaux{%
\detokenize{%
% the \tabH@aux@... commands are needed only if
% tabularht is loaded with driver pdftex.
\@ifundefined{tabH@aux@vrule}\@secondoftwo\@firstofone
{%
% disable commands except for the first .aux files reading
\@ifundefined{tabH@aux@done}\@gobble\@firstofone
}%
{%
\let\tabH@aux@vrule\@gobbletwo
\let\tabH@aux@vstart\@gobblefour
\let\tabH@aux@vstop\@gobble
}%
}%
}%
\immediate\write\@mainaux{%
\@percentchar\@percentchar EndProlog: tabularht%
}%
\fi
}%
% the x positions of vrules are stored in
% \tabH@<tabcount>list with distinct values
\protected\def\tabH@aux@vrule#1#2{%
\@ifundefined{tabH@#1list}{%
\expandafter\xdef\csname tabH@#1list\endcsname{%
\noexpand\do{#2}%
}%
}{%
\begingroup
\def\x{#2}%
\let\y\@undefined
\let\do\tabH@do@add
\expandafter\xdef\csname tabH@#1list\endcsname{%
\csname tabH@#1list\endcsname\@empty
\ifx\y\@undefined
\noexpand\do{\x}%
\fi
}%
\endgroup
}%
}%
\def\tabH@do@add#1{%
\ifx\y\@undefined
\ifnum#1<\x\space
\else
\expandafter\ifx\csname y\endcsname\relax\fi
\ifnum#1>\x\space
\noexpand\do{\x}%
\fi
\fi
\fi
\noexpand\do{#1}%
}%
\def\tabH@vspace@start#1{%
\if@filesw
\stepcounter{tabH@unique}%
\edef\tabH@currentrow{\the\c@tabH@unique}%
\pdfsavepos
\protected@write\@auxout{%
\let\tabH@lastxpos\relax
\let\tabH@lastypos\relax
}{%
\tabH@aux@vstart{\tabH@currenttab}{\tabH@currentrow}%
{\tabH@lastxpos}{\tabH@lastypos}%
}%
\fi
\begingroup
\edef\a{tabH@\tabH@currenttab row\tabH@currentrow}%
\expandafter\let\expandafter\x\csname\a x\endcsname
\ifx\x\relax
\else
\expandafter\let\expandafter\y\csname\a y\endcsname
\expandafter\let\expandafter\l
\csname tabH@\tabH@currenttab list\endcsname
\ifx\l\relax
\else
\def\f{#1}%
\ifx\f\@empty
\let\do\tabH@do@set
\else
\count@=\z@
\let\do\tabH@do@filter
\fi
\setbox\z@=\hbox{\l}%
\wd\z@=\z@
\dp\z@=\z@
\copy\z@
\fi
\fi
\endgroup
}%
\def\tabH@vspace@stop{%
\if@filesw
\pdfsavepos
\protected@write\@auxout{%
\let\tabH@lastypos\relax
}{%
\tabH@aux@vstop{\tabH@lastypos}%
}%
\fi
}%
\def\tabH@do@set#1{%
\hbox to \z@{%
\hskip \dimexpr #1sp - \x sp\relax
\vrule \@width\arrayrulewidth
\@depth\dimexpr \y sp\relax
\hss
}%
}%
\def\tabH@do@filter{%
\@tempswafalse
\advance\count@\@ne
\@for\e:=\f\do{%
\ifnum\e=\count@
\@tempswatrue
\fi
}%
\if@tempswa
\expandafter\tabH@do@set
\else
\expandafter\@gobble
\fi
}%
\protected\def\tabH@aux@vstart#1#2#3#4{%
\def\tabH@current@vstart{{#1}{#2}{#3}{#4}}%
}%
\protected\def\tabH@aux@vstop{%
\expandafter\tabH@aux@v\tabH@current@vstart
}%
\def\tabH@aux@v#1#2#3#4#5{%
\expandafter\gdef\csname tabH@#1row#2x\endcsname{#3}%
\expandafter\xdef\csname tabH@#1row#2y\endcsname{%
\the\numexpr #4 - #5\relax
}%
}%
\csname fi\endcsname
\endinput
\fi
\ifx\tabH@driver\@empty
\PackageError{tabularht}{%
Missing DVI driver, option `vlines' disabled%
}{%
Supported DVI drivers: dvips.%
}%
\expandafter\endinput
\fi
\def\tabH@driver@dvips{%
\def\tabH@literalps##1{\special{ps:SDict begin ##1 end}}%
\def\tabH@headerps##1{\special{! ##1}}%
}
\@onelevel@sanitize\tabH@driver
\@ifundefined{tabH@driver@\tabH@driver}{%
\PackageError{tabularht}{%
Unsupported driver `\tabH@driver'%
}{%
Supported DVI drivers: dvips.%
}%
\endinput
}{}
\begingroup
\let\on@line\@empty
\PackageInfo{tabularht}{%
Using driver `\tabH@driver'%
}%
\endgroup
\csname tabH@driver@\tabH@driver\endcsname
\protected\def\tabH@vrule#1#2\vrule#3\arrayrulewidth{%
#2% \fi or empty
% hack to get rid of maxdrift rounding of dvips,
% thus simulate a large motion
\kern1in\relax
\tabH@literalps{%
#1 tabH.vrule %
Resolution neg 0 translate%
}%
\vrule#3\arrayrulewidth
\tabH@literalps{Resolution 0 translate}%
\kern-1in\relax
}
\def\tabH@vspace@start#1{%
\begingroup
\let\y\@empty
\@for\x:=#1\do{%
\ifx\y\@empty
\edef\y{\x}%
\else
\edef\y{\y\space\x}%
\fi
}%
\tabH@literalps{\tabH@currenttab[\y]currentpoint exch pop}%
\endgroup
}
\def\tabH@vspace@stop{%
\tabH@literalps{%
currentpoint exch pop %
\number\dimexpr\arrayrulewidth\relax\space
tabH.vspace%
}%
}
\tabH@headerps{%
userdict begin%
/tabH.list 10 dict def%
/tabH.job [] def %
end%
/tabH.vrule{%
10 string cvs cvn dup tabH.list exch known{%
tabH.list exch dup [ exch tabH.list exch get %
currentpoint pop round exch true exch{%
% tabH.list key [ ... x true i
% tabH.list key [ ... false i
exch{%
% ... [ ... x i
2 copy lt{false}{%
2 copy eq{pop false}{exch true}ifelse%
}ifelse%
}{false}ifelse%
}forall %
pop%
]put%
}{%
tabH.list exch[currentpoint pop round]put%
}ifelse%
}bind def%
% <tab num> <cols array> <ytop> <ybottom> <rulewidth[sp]>
/tabH.vspace{%
userdict begin %
10 dict dup begin %
exch 65536 div Resolution mul 72.27 div %
% dvips uses a poor man's ceil function
% see dopage.c before "drawrule": (int)(... + 0.9999999)
0.9999999 add truncate%
/rulewidth exch def %
exch/ybottom exch def %
exch/ytop exch def %
exch/cols exch def %
exch/tabkey exch 10 string cvs cvn def %
end%
/tabH.job exch[exch userdict/tabH.job get aload pop]def %
end%
}bind def %
% Now we do the work at the end of the page.
% Unhappily "eop-hook" cannot be used, because "eop"
% executes "restore" before, so that all data are lost.
TeXDict begin%
/eop%
[%
{%
tabH.job{%
begin%
/colarray %
tabH.list tabkey known{tabH.list tabkey get}{[]}ifelse %
def %
cols length 0 eq not{%
/colarray[%
cols{1 sub %
dup 0 lt{pop}{%
dup colarray length ge{pop}{%
colarray exch get%
}ifelse%
}ifelse%
}forall%
]def%
}if %
colarray{%
% (rulewidth) == rulewidth == % debug
Resolution sub %
ytop rulewidth ytop ybottom sub v%
}forall %
end%
}forall%
% tabH.list{== ==}forall % debug
}bind aload pop %
TeXDict /eop get aload pop%
]cvx def %
end%
}
\endinput
%%
%% End of file `tabularht.sty'.
|