summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/oberdiek/tabularht.dtx
blob: c7b71b1c2272f41c72ff2a172b6dad43247c87e6 (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
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
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
% \iffalse meta-comment
% 
% Copyright (C) 2005, 2006, 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.
% 
% Distribution:
%    CTAN:macros/latex/contrib/oberdiek/tabularht.dtx
%    CTAN:macros/latex/contrib/oberdiek/tabularht.pdf
% 
% Unpacking:
%    (a) If tabularht.ins is present:
%           tex tabularht.ins
%    (b) Without tabularht.ins:
%           tex tabularht.dtx
%    (c) If you insist on using LaTeX
%           latex \let\install=y\input{tabularht.dtx}
%        (quote the arguments according to the demands of your shell)
% 
% Documentation:
%    (a) If tabularht.drv is present:
%           latex tabularht.drv
%    (b) Without tabularht.drv:
%           latex tabularht.dtx; ...
%    The class ltxdoc loads the configuration file ltxdoc.cfg
%    if available. Here you can specify further options, e.g.
%    use A4 as paper format:
%       \PassOptionsToClass{a4paper}{article}
% 
%    Programm calls to get the documentation (example):
%       pdflatex tabularht.dtx
%       makeindex -s gind.ist tabularht.idx
%       pdflatex tabularht.dtx
%       makeindex -s gind.ist tabularht.idx
%       pdflatex tabularht.dtx
% 
% Installation:
%    TDS:tex/latex/oberdiek/tabularht.sty
%    TDS:doc/latex/oberdiek/tabularht.pdf
%    TDS:doc/latex/oberdiek/tabularht-example1.tex
%    TDS:doc/latex/oberdiek/tabularht-example2.tex
%    TDS:source/latex/oberdiek/tabularht.dtx
%
%<*ignore>
\begingroup
  \catcode123=1 %
  \catcode125=2 %
  \def\x{LaTeX2e}%
\expandafter\endgroup
\ifcase 0\ifx\install y1\fi\expandafter
         \ifx\csname processbatchFile\endcsname\relax\else1\fi
         \ifx\fmtname\x\else 1\fi\relax
\else\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
\Msg{* Package: tabularht 2007/04/11 v2.5 Tabular with height specification (HO)}
\Msg{************************************************************************}

\keepsilent
\askforoverwritefalse

\let\MetaPrefix\relax
\preamble

This is a generated file.

Copyright (C) 2005, 2006, 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.

\endpreamble
\let\MetaPrefix\DoubleperCent

\generate{%
  \file{tabularht.ins}{\from{tabularht.dtx}{install}}%
  \file{tabularht.drv}{\from{tabularht.dtx}{driver}}%
  \usedir{tex/latex/oberdiek}%
  \file{tabularht.sty}{\from{tabularht.dtx}{package}}%
  \usedir{doc/latex/oberdiek}%
  \file{tabularht-example1.tex}{\from{tabularht.dtx}{example1}}%
  \file{tabularht-example2.tex}{\from{tabularht.dtx}{example2}}%
}

\catcode32=13\relax% active space
\let =\space%
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* file into a directory searched by TeX:}
\Msg{*}
\Msg{*     tabularht.sty}
\Msg{*}
\Msg{* And install the following script file:}
\Msg{*}
\Msg{*     }
\Msg{*}
\Msg{* To produce the documentation run the file `tabularht.drv'}
\Msg{* through LaTeX.}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}

\endbatchfile
%</install>
%<*ignore>
\fi
%</ignore>
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{tabularht.drv}%
  [2007/04/11 v2.5 Tabular with height specification (HO)]%
\documentclass{ltxdoc}
\usepackage{holtxdoc}[2008/08/11]
\begin{document}
  \DocInput{tabularht.dtx}%
\end{document}
%</driver>
% \fi
%
% \CheckSum{650}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \GetFileInfo{tabularht.drv}
%
% \title{The \xpackage{tabularht} package}
% \date{2007/04/11 v2.5}
% \author{Heiko Oberdiek\\\xemail{heiko.oberdiek at googlemail.com}}
%
% \maketitle
%
% \begin{abstract}
% This package defines some environments that adds
% a height specification to tabular and array.
% \end{abstract}
%
% \tableofcontents
%
% \section{Usage}
%
% \begin{quote}
%   |\usepackage{tabularht}|
% \end{quote}
% The package provides the following environments
% that extend the tabular/array environment by
% a height specification as first argument:
% \begin{itemize}
% \item |tabularht|, |tabularht*|
% \item |arrayht|
% \item |tabularhtx|
%       (if package \xpackage{tabularx} is loaded)
% \end{itemize}
% The height argument allows a length specification,
% package \xpackage{calc} is supported if used. This means,
% the tabular will have the specified height.
% You can also use the prefixes |to=| and |spread=|.
% |to=| is the default, |spread=| means, the natural
% height of the tabular box is changed by the length
% after |spread=|.
%
% Examples:
% \begin{quote}
% \begin{tabular}{@{}l@{ $\rightarrow$ }l@{}}
%   |\begin{tabularht}{1in}|
%   & height is 1in\\
%   |\begin{tabularht}{to=1in}|
%   & height is 1in\\
%   |\begin{tabularht}{spread=0pt}|
%   & natural height, same as |\begin{tabular}|\\
%   |\begin{tabularht}{spread=1in}|
%   & natural height increased by 1in
% \end{tabular}
% \end{quote}
%
% Hint:  See also package \xpackage{tabularkv}, it provides an interface,
%        where most parameters for the environments can be given
%        by key-value pairs.
%
% \begin{declcs}{interrowspace}\,|{|\dots|}|
% \end{declcs}
% Adds space between table rows. It is essentially
% the same as |\noalign{\vspace{...}}|.
% \begin{declcs}{interrowfill}
% \end{declcs}
% Short for |\interrowspace{\fill}|
% \begin{declcs}{interrowstart}\,\dots\,\cs{interrowstop}
% \end{declcs}
% Marker commands, useful for option \xoption{vlines}.
%
% \subsection{Option \xoption{vlines}}
%
% Warning: This stuff is experimental.
%
% \vspace{2ex}
% \noindent
% Vertical lines are interrupted, if space is inserted
% in \cs{noalign}, \cs{interrowspace}, \cs{addlinespace}
% (\xpackage{booktabs}),
% between double \cs{hline}s. This option tries to detect
% and add the vertical lines. The lines in a tabular
% with \xpackage{tabularht} support (environments of this package)
% are numbered from left to right. The gap that is
% controlled by \cs{interrowspace} or inbetween \cs{interrowstart}
% and \cs{interrowstop} is then filled with the detected
% vertical lines.
%
% If only a limited selection of the lines should be
% drawn, the commands know an optional argument with a
% list of line numbers, e.g.
% \begin{quote}
%\begin{verbatim}
%\begin{tabularht}{50mm}{|l|l|}
%  Hello & World\\
%  \interrowfill[1,3]
%  Foo & Bar
%\end{tabularht}
%\end{verbatim}
% \end{quote}
% There are three lines, but the middle line is not drawn
% in the gap between the first and second row.
% Zero can be used to suppress all lines:
% \begin{quote}
% |\interrowspace[0]{10mm}|
% \end{quote}
% The syntax of the commands with the optional argument
% with the line number list \meta{list}. \meta{list} is a comma
% separated list of numbers, \meta{height} means the
% height specification described above with the optional
% prefixes |to=| or |spread=|.
% \begin{quote}
%   \cs{interrowspace}\,|[|\meta{list}|]|\,|{|\meta{height}|}|\\
%   \cs{interrowfill}\,|[|\meta{list}|]|\\
%   \cs{interrowstart}\,|[|\meta{list}|]|\,\dots\,\cs{interrowstop}
% \end{quote}
%
% Option \xoption{vlines} is driver dependent and uses \eTeX\ features.
% \begin{description}
% \item[\xoption{pdftex}:] \pdfTeX\ in PDF mode.
%   Here the positions of the lines are written with the
%   help of the \cs{pdfsavepos} feature into the \xfile{.aux} file(s).
%   Therefore you need two LaTeX runs to get the lines.
% \item[\xoption{dvips}:]
%   Here, PostScript's currentpoint it used to get
%   the line positions. The lines are then drawn at the end
%   of the page. Thus one \LaTeX/dvips run is sufficient
%   for this option.
% \item[Other drivers:]\mbox{}
%   \begin{description}
%   \item[PostScript drivers:] probably possible, an end of page
%     hook would be nice.
%   \item[\VTeX:] with GeX (PostScript interpreter) probably possible.
%   \item[dvipdfm:] no idea. The big problem is, how to get the
%     current position?
%   \end{description}
% \end{description}
%
% \subsection{Limitations}
%
% \begin{itemize}
% \item
%   Vertical lines are interrupted by |\noalign{\vfill}|.
% \end{itemize}
%
% \subsection{Compatibility}
%
% \begin{itemize}
% \item
%   \xpackage{array}, \xpackage{delarray}, \xpackage{tabularx}
%   are supported.
% \item There can be problems with packages that
%   redefine \cs{@array} (or \cs{@@array}, \cs{@tabarray}) and
%   \cs{@arrayrule} (for option \xoption{vlines}).
% \item \xpackage{colortbl}: it should at least work, but there isn't
%   support for filling the gaps with color, neither
%   the rules nor the backgrounds.
% \end{itemize}
%
% \subsection{Examples}
%
% \subsubsection{Example 1}
%
%    \begin{macrocode}
%<*example1>
\documentclass{article}
\usepackage{tabularht}

\begin{document}
\fbox{%
  \begin{tabularht*}{1in}{4in}{@{}l@{\extracolsep{\fill}}r@{}}%
    upper left corner & upper right corner\\%
    \noalign{\vfill}%
    \multicolumn{2}{@{}c@{}}{bounding box}\\%
    \noalign{\vfill}%
    lower left corner & lower right corner\\%
  \end{tabularht*}%
}
\end{document}
%</example1>
%    \end{macrocode}
%
% \subsubsection{Example 2}
%
%    \begin{macrocode}
%<*example2>
\documentclass{article}
\usepackage{booktabs}
\usepackage[dvips,vlines]{tabularht}

\begin{document}

\begin{tabularht}{spread=0pt}{|l|l|}
  \hline
  First&Line\\%
  \hline
\interrowstart
  \addlinespace[10mm]%
\interrowstop
  \hline
  Second&Line\\%
\interrowstart
  \hline
  \hline
\interrowstop
  Third&Line\\%
  \hline
\interrowspace{10mm}
  \hline
  Fourth&Line\\%
  \hline
\end{tabularht}

\end{document}
%</example2>
%    \end{macrocode}
%
% \StopEventually{
% }
%
% \section{Implementation}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%    Package identification.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tabularht}%
  [2007/04/11 v2.5 Tabular with height specification (HO)]
%    \end{macrocode}
%
% \subsection{Environments}
%
%    \begin{macrocode}
\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}
%    \end{macrocode}
%    First argument is the height of the table,
%    then the orignal arguments for tabular follow.
%    \begin{macrocode}
\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}%
}
%    \end{macrocode}
%
% \subsection{Options}
%
%    \begin{macrocode}
\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
%    \end{macrocode}
%
% \subsection{Option vlines, driver independent stuff}
%
%    \begin{macrocode}
\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
%    \end{macrocode}
%
% \subsection{Driver pdftex}
%
%    \begin{macrocode}
\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
%    \end{macrocode}
%
% \subsection{DVI drivers}
%
%    \begin{macrocode}
\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%
}
%    \end{macrocode}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
% \section{Installation}
%
% \subsection{Download}
%
% \paragraph{Package.} This package is available on
% CTAN\footnote{\url{ftp://ftp.ctan.org/tex-archive/}}:
% \begin{description}
% \item[\CTAN{macros/latex/contrib/oberdiek/tabularht.dtx}] The source file.
% \item[\CTAN{macros/latex/contrib/oberdiek/tabularht.pdf}] Documentation.
% \end{description}
%
%
% \paragraph{Bundle.} All the packages of the bundle `oberdiek'
% are also available in a TDS compliant ZIP archive. There
% the packages are already unpacked and the documentation files
% are generated. The files and directories obey the TDS standard.
% \begin{description}
% \item[\CTAN{install/macros/latex/contrib/oberdiek.tds.zip}]
% \end{description}
% \emph{TDS} refers to the standard ``A Directory Structure
% for \TeX\ Files'' (\CTAN{tds/tds.pdf}). Directories
% with \xfile{texmf} in their name are usually organized this way.
%
% \subsection{Bundle installation}
%
% \paragraph{Unpacking.} Unpack the \xfile{oberdiek.tds.zip} in the
% TDS tree (also known as \xfile{texmf} tree) of your choice.
% Example (linux):
% \begin{quote}
%   |unzip oberdiek.tds.zip -d ~/texmf|
% \end{quote}
%
% \paragraph{Script installation.}
% Check the directory \xfile{TDS:scripts/oberdiek/} for
% scripts that need further installation steps.
% Package \xpackage{attachfile2} comes with the Perl script
% \xfile{pdfatfi.pl} that should be installed in such a way
% that it can be called as \texttt{pdfatfi}.
% Example (linux):
% \begin{quote}
%   |chmod +x scripts/oberdiek/pdfatfi.pl|\\
%   |cp scripts/oberdiek/pdfatfi.pl /usr/local/bin/|
% \end{quote}
%
% \subsection{Package installation}
%
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
% \docstrip\ archive. The files are extracted by running the
% \xfile{.dtx} through \plainTeX:
% \begin{quote}
%   \verb|tex tabularht.dtx|
% \end{quote}
%
% \paragraph{TDS.} Now the different files must be moved into
% the different directories in your installation TDS tree
% (also known as \xfile{texmf} tree):
% \begin{quote}
% \def\t{^^A
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
%   tabularht.sty & tex/latex/oberdiek/tabularht.sty\\
%   tabularht.pdf & doc/latex/oberdiek/tabularht.pdf\\
%   tabularht-example1.tex & doc/latex/oberdiek/tabularht-example1.tex\\
%   tabularht-example2.tex & doc/latex/oberdiek/tabularht-example2.tex\\
%   tabularht.dtx & source/latex/oberdiek/tabularht.dtx\\
% \end{tabular}^^A
% }^^A
% \sbox0{\t}^^A
% \ifdim\wd0>\linewidth
%   \begingroup
%     \advance\linewidth by\leftmargin
%     \advance\linewidth by\rightmargin
%   \edef\x{\endgroup
%     \def\noexpand\lw{\the\linewidth}^^A
%   }\x
%   \def\lwbox{^^A
%     \leavevmode
%     \hbox to \linewidth{^^A
%       \kern-\leftmargin\relax
%       \hss
%       \usebox0
%       \hss
%       \kern-\rightmargin\relax
%     }^^A
%   }^^A
%   \ifdim\wd0>\lw
%     \sbox0{\small\t}^^A
%     \ifdim\wd0>\linewidth
%       \ifdim\wd0>\lw
%         \sbox0{\footnotesize\t}^^A
%         \ifdim\wd0>\linewidth
%           \ifdim\wd0>\lw
%             \sbox0{\scriptsize\t}^^A
%             \ifdim\wd0>\linewidth
%               \ifdim\wd0>\lw
%                 \sbox0{\tiny\t}^^A
%                 \ifdim\wd0>\linewidth
%                   \lwbox
%                 \else
%                   \usebox0
%                 \fi
%               \else
%                 \lwbox
%               \fi
%             \else
%               \usebox0
%             \fi
%           \else
%             \lwbox
%           \fi
%         \else
%           \usebox0
%         \fi
%       \else
%         \lwbox
%       \fi
%     \else
%       \usebox0
%     \fi
%   \else
%     \lwbox
%   \fi
% \else
%   \usebox0
% \fi
% \end{quote}
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
% TDS installing feature, then some files can already be in the right
% place, see the documentation of \docstrip.
%
% \subsection{Refresh file name databases}
%
% If your \TeX~distribution
% (\teTeX, \mikTeX, \dots) relies on file name databases, you must refresh
% these. For example, \teTeX\ users run \verb|texhash| or
% \verb|mktexlsr|.
%
% \subsection{Some details for the interested}
%
% \paragraph{Attached source.}
%
% The PDF documentation on CTAN also includes the
% \xfile{.dtx} source file. It can be extracted by
% AcrobatReader 6 or higher. Another option is \textsf{pdftk},
% e.g. unpack the file into the current directory:
% \begin{quote}
%   \verb|pdftk tabularht.pdf unpack_files output .|
% \end{quote}
%
% \paragraph{Unpacking with \LaTeX.}
% The \xfile{.dtx} chooses its action depending on the format:
% \begin{description}
% \item[\plainTeX:] Run \docstrip\ and extract the files.
% \item[\LaTeX:] Generate the documentation.
% \end{description}
% If you insist on using \LaTeX\ for \docstrip\ (really,
% \docstrip\ does not need \LaTeX), then inform the autodetect routine
% about your intention:
% \begin{quote}
%   \verb|latex \let\install=y\input{tabularht.dtx}|
% \end{quote}
% Do not forget to quote the argument according to the demands
% of your shell.
%
% \paragraph{Generating the documentation.}
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
% the documentation. The process can be configured by the
% configuration file \xfile{ltxdoc.cfg}. For instance, put this
% line into this file, if you want to have A4 as paper format:
% \begin{quote}
%   \verb|\PassOptionsToClass{a4paper}{article}|
% \end{quote}
% An example follows how to generate the
% documentation with pdf\LaTeX:
% \begin{quote}
%\begin{verbatim}
%pdflatex tabularht.dtx
%makeindex -s gind.ist tabularht.idx
%pdflatex tabularht.dtx
%makeindex -s gind.ist tabularht.idx
%pdflatex tabularht.dtx
%\end{verbatim}
% \end{quote}
%
% \begin{History}
%   \begin{Version}{2005/09/22 v1.0}
%   \item
%     First public version.
%   \end{Version}
%   \begin{Version}{2005/10/16 v2.0}
%   \item
%     Height specification allows
%     |to=...| or |spread=...|, default is |to=|.
%   \item
%     Option \xoption{vlines} added,
%     drivers \xoption{pdftex} and \xoption{dvips}.
%   \item
%     \cs{interrowspace}, \cs{interrowfil}, and
%     \cs{interrowstart}\dots\cs{interrowstop} added.
%   \end{Version}
%   \begin{Version}{2005/10/18 v2.1}
%   \item
%     Fix for package \xpackage{colortbl}, but the colors
%     of \xpackage{colortbl} remain unsupported.
%   \end{Version}
%   \begin{Version}{2006/02/20 v2.2}
%   \item
%     Code is not changed.
%   \item
%     DTX framework.
%   \end{Version}
%   \begin{Version}{2006/12/22 v2.3}
%   \item
%     Documentation fix.
%   \item
%     Fix in code of option vlines.
%   \end{Version}
%   \begin{Version}{2007/03/21 v2.4}
%   \item
%     Fix: Counter |tabh@unique| must not be changed by \cs{include}.
%   \end{Version}
%   \begin{Version}{2007/04/11 v2.5}
%   \item
%     Line ends sanitized.
%   \end{Version}
% \end{History}
%
% \PrintIndex
%
% \Finale
\endinput