summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/kluwer/klutab.sty
blob: edc4987c5b942ede9b5e4248bcacd39d80169261 (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
%
%<*other>
%
\ifcat a\noexpand @\let\next\relax\else \def\next{%
\documentclass{kluwer}\usepackage{doc}\MakePercentIgnore}\fi\next
\def\filedate{2000/04/29}
\def\filename{klutab.sty}
%\DoNotIndex{\@M,\def,\c@secnumdepth,\baselineskip,\@pnumwidth,\else,\fi}
%\DoNotIndex{\newcommand,\z@,\relax,\renewcommand,\ifnum,\csname,\endcsname}
%\DoNotIndex{\baselineskip,\vskip,\hskip,\relax,\secdef,\gdef,\@cla,\@clb}
%\DoNotIndex{\normalsize,\protect,\global,\setbox,\hbox,\vbox,\endinput}
%\DoNotIndex{\egroup,\endgroup,\bgroup,\begingroup,\let}
%\CodelineIndex 
%\changes{v??}{1997/02/12}{TH: Inserted definition of `array' to accomodate `hline'.}
%\changes{v??}{1999/12/07}{SK: some code delayed with AtBeginDocument: now (almost) compatible with array package'.}
%\newcommand{\Bs}{$\backslash$}
%\parindent=0pt
%\parskip=3pt
%\hfuzz=10pt
%\MakeShortVerb{\|}
%\setlength{\marginparwidth}{0in} 
%\addtolength{\textwidth}{4pc}
%\begin{document}
%\begin{opening}
%\title{\filename}
%\date{\filedate}
%\author{Kluwer Academic Publishers\surname{}}
%\institute{~}
%\begin{abstract}
% This internal stylefile takes care of tabulars.
%\end{abstract}                                 
%\end{opening}
%\tableofcontents
%\section{Usage}
%
% All of this is quite simple code. What happens
% is that some extra lines for use in tabulars are defined and
% included in the original definition of |tabular| and
% |tabular*|. These have a bit of extra vertical space which breaks
% the use of vertical rules in tabular's, which is why the old
% definitions are saved as |TABULAR| and |TABULAR*|. 
%
% There are some variations on |\cline|. I moved internal commands out of the
% definition of |tabular| so they could be used in |tabular*| easily. \\[6pt]
% |\rcline| == hbox 3pt to the left\\
% |\lcline| == hbox 3pt to the right\\
% |\lrcline| == both \\
% |\rlcline| == |\lrcline| (to provide symmetry)
%
% All of the environments  have
% been changed so that they also set the value of |\@tabwidth|, which
% is needed by |klufloa.sty|.
%
% |tabular*| has been adjusted to flush out the excess space over all
% columns instead of to the right of the last one. This is controlled
% by the value of |\stretchtabsep|, whose default value equals |\hfil|
%
%\newpage\section{Implementation}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{klutab}[\filedate ]
%    \end{macrocode}
% \subsection{Tabular}
% First some needed values. The `array' things may not belong here,
% but is also not save to put them somewhere else. After all, \LaTeX\
% seems to think this is correct. 
%    \begin{macrocode}
%</other>
%<*main>
\arraycolsep 6pt
\tabcolsep 6pt
\arrayrulewidth .4pt
\doublerulesep 2pt
%    \end{macrocode}
%
% Internal versions of the rules check whether first arg $>1$, and assign
% |\@tabklu@tmpa| accordingly. Next, execute |\@tabklu@tmpa| and
% unskip vertical width of rule. (All three are similar)
%    \begin{macrocode}
\def\@rcline[#1-#2]{%
  \noalign{%
       \global\@cla #1\relax
       \global\advance\@cla\m@ne
       \ifnum\@cla >0 
         \global\let\@tabklu@tmpa\@rclinea
       \else
         \global\let\@tabklu@tmpa\@rclineb
       \fi
       \global\@clb #2\relax
       \global\advance\@clb-\@cla }%
    \@tabklu@tmpa
    \noalign{\vskip-\arrayrulewidth}%
  }%
\def\@rclinea{%
    \multispan\@cla&\multispan\@clb 
    \hbox to 3pt{\hfil }%
    \unskip
    \leaders\hrule \@height \arrayrulewidth\hfill 
    \cr}%
\def\@rclineb{%
   \multispan\@clb 
   \hbox to 3pt{\hfil }%
   \unskip
   \leaders\hrule \@height \arrayrulewidth\hfill 
   \cr}%
\def\@lcline[#1-#2]{%
  \noalign{%
     \global\@cla #1\relax
     \global\advance\@cla\m@ne
     \ifnum\@cla >0
        \global\let\@tabklu@tmpa\@lclinea
     \else
        \global\let\@tabklu@tmpa\@lclineb
     \fi
     \global\@clb #2\relax
     \global\advance\@clb-\@cla
  }\@tabklu@tmpa
  \noalign{\vskip-\arrayrulewidth}%
}%
\def\@lclinea{%
     \multispan\@cla&\multispan\@clb
     \unskip
     \leaders\hrule \@height \arrayrulewidth\hfill
     \hbox to 3pt{\hfil }\cr}%
\def\@lclineb{%
     \multispan\@clb
     \unskip
     \leaders\hrule \@height \arrayrulewidth\hfill
     \hbox to 3pt{\hfil }\cr}%
\def\@lrcline[#1-#2]{%
   \noalign{%
     \global\@cla #1\relax
     \global\advance\@cla\m@ne
     \ifnum\@cla>0
        \global \let\@tabklu@tmpa\@lrclinea
     \else
        \global \let\@tabklu@tmpa\@lrclineb
     \fi
     \global \@clb #2\relax
     \global \advance\@clb-\@cla
     }%
     \@tabklu@tmpa
     \noalign{\vskip -\arrayrulewidth}%
  }%
\def\@lrclinea{%
     \multispan\@cla&\multispan\@clb 
     \hbox to 3pt{\hfil }%
     \unskip\leaders\hrule \@height \arrayrulewidth\hfill
     \hbox to 3pt{\hfil }%
     \cr}%
\def\@lrclineb{%
     \multispan\@clb 
     \hbox to 3pt{\hfil }%
     \unskip\leaders\hrule \@height \arrayrulewidth\hfill
     \hbox to 3pt{\hfil }%
     \cr}%
%    \end{macrocode}
% This is used for |tabular*|
%    \begin{macrocode}
\newlength\stretchtabsep
\setlength\stretchtabsep{0pt plus 1fil}
%    \end{macrocode}
% |\hline| has been redefined to provide some extra vertical
% space. Unforunately, we could not do the same for |\cline| and
% friend, because there can be more than one in one row. The old value
% of |\hline| is saved in |\savehline| in case you need it.
%
% |\arraystretch| is left to it's default value, but we did want extra
% spacing, so |\strut| is redefined (indirectly) to give some.
%
% And then, the entire tabular is saved in a |\hbox| so we can measure
% it up later. (See above for why we need to know this). There is a
% grouping level added to stop definitions from running away, but
% maybe this isn't needed. Not sure.
% We enclose all this in an |\AtBeginDocument| so that, if array.sty
% is loaded, the code will be executed on top of array.sty.
%    \begin{macrocode}
%
\AtBeginDocument{%
\let\savehline\hline
\def\tabular{\begingroup
   \def\hline{\noalign{\vskip3pt}\savehline\noalign{\vskip3pt}}%
   \def\rcline##1{\@rcline[##1]}%   
   \def\lcline##1{\@lcline[##1]}%   
   \def\lrcline##1{\@lrcline[##1]}%
   \let\rlcline=\lrcline   
    \setbox\strutbox\hbox{\vrule height.8\baselineskip
            depth.4\baselineskip width\z@}%
    \setbox0=\hbox\bgroup\def\@halignto{}\@tabular}%
%    \end{macrocode}
% |\endtabular| is quite straightforward.
%    \begin{macrocode}
\def\endtabular{\crcr\egroup\egroup $\egroup
  \egroup \tabwidth{\wd0}\unhbox0 \endgroup}%
%    \end{macrocode}     
% 
% Apparently we need to restore the definition of |\hline|
% inside of array's. This is just a quick hack that 'fixes' 
% the problem.
%    \begin{macrocode}
\let\klu@intarray\array     
\let\klu@intendarray\endarray     
\def\array{\begingroup \let\hline\savehline \klu@intarray }
\def\endarray{\klu@intendarray \endgroup}   
%    \end{macrocode}     
%
% |tabular*| follows the same rules, except for redefining
% |\@tabacol| to insert a |\hfil| value for |\tabskip| in the first
% preamble-entry (and all following, but these don't count), 
% thereby stretching out all intercolumn space instead
% of just the last (\LaTeX\ standard behaviour).  
%    \begin{macrocode}
\@ifundefined{newcolumntype}{% array.sty not loaded
\@namedef{tabular*}#1{%
   \begingroup 
   \let\savehline\hline
   \def\hline{\noalign{\vskip3pt}\savehline\noalign{\vskip3pt}}%
   \def\rcline##1{\@rcline[##1]}%   
   \def\lcline##1{\@lcline[##1]}%   
   \def\lrcline##1{\@lrcline[##1]}%   
   \let\rlcline=\lrcline   
     \setbox\strutbox\hbox{\vrule height.8\baselineskip
            depth.4\baselineskip width\z@}%
      \setbox0=\hbox\bgroup\def\@halignto{to #1}%
        \def\@tabacol{\edef\@preamble{\@preamble 
            \tabskip \stretchtabsep \hskip \tabcolsep}}\@tabular}%
}{% array.sty loaded:
\@namedef{tabular*}#1{%
   \begingroup 
   \let\savehline\hline
   \def\hline{\noalign{\vskip3pt}\savehline\noalign{\vskip3pt}}%
   \def\rcline##1{\@rcline[##1]}%   
   \def\lcline##1{\@lcline[##1]}%   
   \def\lrcline##1{\@lrcline[##1]}%   
   \let\rlcline=\lrcline
%   \def\@acol{\@addtopreamble{\hskip\col@sep plus 40pc}} % doesn't work
     \setbox\strutbox\hbox{\vrule height.8\baselineskip
            depth.4\baselineskip width\z@}%
      \setbox0=\hbox\bgroup
      \gdef\@halignto{to #1}%
        \@tabular}%
} % end array.sty loaded
\@namedef{endtabular*}{\endtabular}
%
%    \end{macrocode}
% \subsection{TABULAR}
% This is just ordinary \LaTeX\ tabular, apart from the |\hbox|. 
%    \begin{macrocode}
\def\TABULAR{%
     \let\savehline\hline %compatibility
     \let\rcline\cline \let\lcline\cline 
     \let\lrcline\cline \let\rlcline\cline 
     \setbox0=\hbox\bgroup\def\@halignto{}\@tabular}%
\def\endTABULAR{\crcr\egroup\egroup $\egroup
  \egroup \tabwidth{\wd0}\unhbox0 }%
\@namedef{TABULAR*}#1{%
     \let\savehline\hline %compatibility
     \let\rcline\cline \let\lcline\cline 
     \let\lrcline\cline \let\rlcline\cline 
     \setbox0=\hbox\bgroup\def\@halignto{to #1}\@tabular}%
\@namedef{endTABULAR*}{\endtabular}} % end of AtBeginDocument
%</main>
%<*other>
\endinput
%    \end{macrocode}
%\def\IndexParms{\hbadness=10000}
%\PrintIndex
%\end{document}
% end of klutab.sty
%</other>