]> matita.cs.unibo.it Git - helm.git/blob - helm/papers/matita/klutab.sty
ocaml 3.09 transition
[helm.git] / helm / papers / matita / klutab.sty
1 %
2 %
3 \ifcat a\noexpand @\let\next\relax\else \def\next{%
4 \documentclass{kluwer}\usepackage{doc}\MakePercentIgnore}\fi\next
5 \def\filedate{1998/02/11}
6 \def\filename{klutab.sty}
7 %\DoNotIndex{\@M,\def,\c@secnumdepth,\baselineskip,\@pnumwidth,\else,\fi}
8 %\DoNotIndex{\newcommand,\z@,\relax,\renewcommand,\ifnum,\csname,\endcsname}
9 %\DoNotIndex{\baselineskip,\vskip,\hskip,\relax,\secdef,\gdef,\@cla,\@clb}
10 %\DoNotIndex{\normalsize,\protect,\global,\setbox,\hbox,\vbox,\endinput}
11 %\DoNotIndex{\egroup,\endgroup,\bgroup,\begingroup,\let}
12 %\CodelineIndex 
13 %\changes{1997/02/12}{TH: Inserted definition of `array' to accomodate `hline'.}
14 %\newcommand{\Bs}{$\backslash$}
15 %\parindent=0pt
16 %\parskip=3pt
17 %\hfuzz=10pt
18 %\MakeShortVerb{\|}
19 %\setlength{\marginparwidth}{0in} 
20 %\addtolength{\textwidth}{4pc}
21 %\begin{document}
22 %\begin{opening}
23 %\title{\filename}
24 %\date{\filedate}
25 %\author{Kluwer Academic Publishers\surname{}}
26 %\institute{~}
27 %\begin{abstract}
28 % This internal stylefile takes care of tabulars.
29 %\end{abstract}                                 
30 %\end{opening}
31 %\tableofcontents
32 %\section{Usage}
33 %
34 % All of this is quite simple code. What happens
35 % is that some extra lines for use in tabulars are defined and
36 % included in the original definition of |tabular| and
37 % |tabular*|. These have a bit of extra vertical space which breaks
38 % the use of vertical rules in tabular's, which is why the old
39 % definitions are saved as |TABULAR| and |TABULAR*|. 
40 %
41 % There are some variations on |\cline|. I moved internal commands out of the
42 % definition of |tabular| so they could be used in |tabular*| easily. \\[6pt]
43 % |\rcline| == hbox 3pt to the left\\
44 % |\lcline| == hbox 3pt to the right\\
45 % |\lrcline| == both \\
46 % |\rlcline| == |\lrcline| (to provide symmetry)
47 %
48 % All of the environments  have
49 % been changed so that they also set the value of |\@tabwidth|, which
50 % is needed by |klufloa.sty|.
51 %
52 % |tabular*| has been adjusted to flush out the excess space over all
53 % columns instead of to the right of the last one. This is controlled
54 % by the value of |\stretchtabsep|, whose default value equals |\hfil|
55 %
56 %\newpage\section{Implementation}
57 %    \begin{macrocode}
58 \NeedsTeXFormat{LaTeX2e}
59 \ProvidesPackage{klutab}[\filedate ]
60 %    \end{macrocode}
61 % \subsection{Tabular}
62 % First some needed values. The `array' things may not belong here,
63 % but is also not save to put them somewhere else. After all, \LaTeX\
64 % seems to think this is correct. 
65 %    \begin{macrocode}
66 \arraycolsep 6pt
67 \tabcolsep 6pt
68 \arrayrulewidth .4pt
69 \doublerulesep 2pt
70 %    \end{macrocode}
71 %
72 % Internal versions of the rules check whether first arg $>1$, and assign
73 % |\@tabklu@tmpa| accordingly. Next, execute |\@tabklu@tmpa| and
74 % unskip vertical width of rule. (All three are similar)
75 %    \begin{macrocode}
76 \def\@rcline[#1-#2]{%
77   \noalign{%
78        \global\@cla #1\relax
79        \global\advance\@cla\m@ne
80        \ifnum\@cla >0 
81          \global\let\@tabklu@tmpa\@rclinea
82        \else
83          \global\let\@tabklu@tmpa\@rclineb
84        \fi
85        \global\@clb #2\relax
86        \global\advance\@clb-\@cla }%
87     \@tabklu@tmpa
88     \noalign{\vskip-\arrayrulewidth}%
89   }%
90 \def\@rclinea{%
91     \multispan\@cla&\multispan\@clb 
92     \hbox to 3pt{\hfil }%
93     \unskip
94     \leaders\hrule \@height \arrayrulewidth\hfill 
95     \cr}%
96 \def\@rclineb{%
97    \multispan\@clb 
98    \hbox to 3pt{\hfil }%
99    \unskip
100    \leaders\hrule \@height \arrayrulewidth\hfill 
101    \cr}%
102 \def\@lcline[#1-#2]{%
103   \noalign{%
104      \global\@cla #1\relax
105      \global\advance\@cla\m@ne
106      \ifnum\@cla >0
107         \global\let\@tabklu@tmpa\@lclinea
108      \else
109         \global\let\@tabklu@tmpa\@lclineb
110      \fi
111      \global\@clb #2\relax
112      \global\advance\@clb-\@cla
113   }\@tabklu@tmpa
114   \noalign{\vskip-\arrayrulewidth}%
115 }%
116 \def\@lclinea{%
117      \multispan\@cla&\multispan\@clb
118      \unskip
119      \leaders\hrule \@height \arrayrulewidth\hfill
120      \hbox to 3pt{\hfil }\cr}%
121 \def\@lclineb{%
122      \multispan\@clb
123      \unskip
124      \leaders\hrule \@height \arrayrulewidth\hfill
125      \hbox to 3pt{\hfil }\cr}%
126 \def\@lrcline[#1-#2]{%
127    \noalign{%
128      \global\@cla #1\relax
129      \global\advance\@cla\m@ne
130      \ifnum\@cla>0
131         \global \let\@tabklu@tmpa\@lrclinea
132      \else
133         \global \let\@tabklu@tmpa\@lrclineb
134      \fi
135      \global \@clb #2\relax
136      \global \advance\@clb-\@cla
137      }%
138      \@tabklu@tmpa
139      \noalign{\vskip -\arrayrulewidth}%
140   }%
141 \def\@lrclinea{%
142      \multispan\@cla&\multispan\@clb 
143      \hbox to 3pt{\hfil }%
144      \unskip\leaders\hrule \@height \arrayrulewidth\hfill
145      \hbox to 3pt{\hfil }%
146      \cr}%
147 \def\@lrclineb{%
148      \multispan\@clb 
149      \hbox to 3pt{\hfil }%
150      \unskip\leaders\hrule \@height \arrayrulewidth\hfill
151      \hbox to 3pt{\hfil }%
152      \cr}%
153 %    \end{macrocode}
154 % This is used for |tabular*|
155 %    \begin{macrocode}
156 \newlength\stretchtabsep
157 \setlength\stretchtabsep{0pt plus 1fil}
158 %    \end{macrocode}
159 % |\hline| has been redefined to provide some extra vertical
160 % space. Unforunately, we could not do the same for |\cline| and
161 % friend, because there can be more than one in one row. The old value
162 % of |\hline| is saved in |\savehline| in case you need it.
163 %
164 % |\arraystretch| is left to it's default value, but we did want extra
165 % spacing, so |\strut| is redefined (indirectly) to give some.
166 %
167 % And then, the entire tabular is saved in a |\hbox| so we can measure
168 % it up later. (See above for why we need to know this). There is a
169 % grouping level added to stop definitions from running away, but
170 % maybe this isn't needed. Not sure.
171 %    \begin{macrocode}
172 \let\savehline\hline
173 \def\tabular{\begingroup
174    \def\hline{\noalign{\vskip3pt}\savehline\noalign{\vskip3pt}}%
175    \def\rcline##1{\@rcline[##1]}%   
176    \def\lcline##1{\@lcline[##1]}%   
177    \def\lrcline##1{\@lrcline[##1]}%
178    \let\rlcline=\lrcline   
179     \setbox\strutbox\hbox{\vrule height.8\baselineskip
180             depth.4\baselineskip width\z@}%
181     \setbox0=\hbox\bgroup\def\@halignto{}\@tabular}%
182 %    \end{macrocode}
183 % |\endtabular| is quite straightforward.
184 %    \begin{macrocode}
185 \def\endtabular{\crcr\egroup\egroup $\egroup
186   \egroup \tabwidth{\wd0}\unhbox0 \endgroup}%
187 %    \end{macrocode}     
188
189 % Apparently we need to restore the definition of |\hline|
190 % inside of array's. This is just a quick hack that 'fixes' 
191 % the problem.
192 %    \begin{macrocode}
193 \let\klu@intarray\array     
194 \let\klu@intendarray\endarray     
195 \def\array{\begingroup \let\hline\savehline \klu@intarray }
196 \def\endarray{\klu@intendarray \endgroup}   
197 %    \end{macrocode}     
198 %
199 % |tabular*| follows the same rules, except for redefining
200 % |\@tabacol| to insert a |\hfil| value for |\tabskip| in the first
201 % preamble-entry (and all following, but these don't count), 
202 % thereby stretching out all intercolumn space instead
203 % of just the last (\LaTeX\ standard behaviour).  
204 %    \begin{macrocode}
205 \@namedef{tabular*}#1{%
206    \begingroup 
207    \let\savehline\hline
208    \def\hline{\noalign{\vskip3pt}\savehline\noalign{\vskip3pt}}%
209    \def\rcline##1{\@rcline[##1]}%   
210    \def\lcline##1{\@lcline[##1]}%   
211    \def\lrcline##1{\@lrcline[##1]}%   
212    \let\rlcline=\lrcline   
213    \setbox\strutbox\hbox{\vrule height.8\baselineskip
214             depth.4\baselineskip width\z@}%
215     \setbox0=\hbox\bgroup\def\@halignto{to #1}%
216         \def\@tabacol{\edef\@preamble{\@preamble 
217             \tabskip \stretchtabsep \hskip \tabcolsep}}\@tabular}
218 \@namedef{endtabular*}{\endtabular}
219 %
220 %    \end{macrocode}
221 % \subsection{TABULAR}
222 % This is just ordinary \LaTeX\ tabular, apart from the |\hbox|. 
223 %    \begin{macrocode}
224 \def\TABULAR{%
225      \let\savehline\hline %compatibility
226      \let\rcline\cline \let\lcline\cline 
227      \let\lrcline\cline \let\rlcline\cline 
228      \setbox0=\hbox\bgroup\def\@halignto{}\@tabular}%
229 \def\endTABULAR{\crcr\egroup\egroup $\egroup
230   \egroup \tabwidth{\wd0}\unhbox0 }%
231 \@namedef{TABULAR*}#1{%
232      \let\savehline\hline %compatibility
233      \let\rcline\cline \let\lcline\cline 
234      \let\lrcline\cline \let\rlcline\cline 
235      \setbox0=\hbox\bgroup\def\@halignto{to #1}\@tabular}%
236 \@namedef{endTABULAR*}{\endtabular}
237 \endinput
238 %    \end{macrocode}
239 %\def\IndexParms{\hbadness=10000}
240 %\PrintIndex
241 %\end{document}
242 % end of klutab.sty