root / docs / build / latex / tabulary.sty @ 216bb34c
History | View | Annotate | Download (13.5 kB)
1 |
%% |
---|---|
2 |
%% This is file `tabulary.sty', |
3 |
%% generated with the docstrip utility. |
4 |
%% |
5 |
%% The original source files were: |
6 |
%% |
7 |
%% tabulary.dtx (with options: `package') |
8 |
%% DRAFT VERSION |
9 |
%% |
10 |
%% File `tabulary.dtx'. |
11 |
%% Copyright (C) 1995 1996 2003 David Carlisle |
12 |
%% This file may be distributed under the terms of the LPPL. |
13 |
%% See 00readme.txt for details. |
14 |
%% |
15 |
\NeedsTeXFormat{LaTeX2e} |
16 |
\ProvidesPackage{tabulary} |
17 |
[2007/10/02 v0.9 tabulary package (DPC)] |
18 |
\RequirePackage{array} |
19 |
\catcode`\Z=14 |
20 |
\DeclareOption{debugshow}{\catcode`\Z=9\relax} |
21 |
\ProcessOptions |
22 |
\def\arraybackslash{\let\\=\@arraycr} |
23 |
\def\@finalstrut#1{% |
24 |
\unskip\ifhmode\nobreak\fi\vrule\@width\z@\@height\z@\@depth\dp#1} |
25 |
\newcount\TY@count |
26 |
\def\tabulary{% |
27 |
\let\TY@final\tabular |
28 |
\let\endTY@final\endtabular |
29 |
\TY@tabular} |
30 |
\def\TY@tabular#1{% |
31 |
\edef\TY@{\@currenvir}% |
32 |
{\ifnum0=`}\fi |
33 |
\@ovxx\TY@linewidth |
34 |
\@ovyy\TY@tablewidth |
35 |
\count@\z@ |
36 |
\@tempswatrue |
37 |
\@whilesw\if@tempswa\fi{% |
38 |
\advance\count@\@ne |
39 |
\expandafter\ifx\csname TY@F\the\count@\endcsname\relax |
40 |
\@tempswafalse |
41 |
\else |
42 |
\expandafter\let\csname TY@SF\the\count@\expandafter\endcsname |
43 |
\csname TY@F\the\count@\endcsname |
44 |
\global\expandafter\let\csname TY@F\the\count@\endcsname\relax |
45 |
\expandafter\let\csname TY@S\the\count@\expandafter\endcsname |
46 |
\csname TY@\the\count@\endcsname |
47 |
\fi}% |
48 |
\global\TY@count\@ne |
49 |
\TY@width\xdef{0pt}% |
50 |
\global\TY@tablewidth\z@ |
51 |
\global\TY@linewidth#1\relax |
52 |
Z\message{^^J^^JTable^^J% |
53 |
Z Target Width: \the\TY@linewidth^^J% |
54 |
Z \string\tabcolsep: \the\tabcolsep\space |
55 |
Z \string\arrayrulewidth: \the\arrayrulewidth\space |
56 |
Z \string\doublerulesep: \the\doublerulesep^^J% |
57 |
Z \string\tymin: \the\tymin\space |
58 |
Z \string\tymax: \the\tymax^^J}% |
59 |
\let\@classz\TY@classz |
60 |
\let\verb\TX@verb |
61 |
\toks@{}\TY@get@body} |
62 |
\let\TY@@mkpream\@mkpream |
63 |
\def\TY@mkpream{% |
64 |
\def\@addamp{% |
65 |
\if@firstamp \@firstampfalse \else |
66 |
\global\advance\TY@count\@ne |
67 |
\edef\@preamble{\@preamble &}\fi |
68 |
\TY@width\xdef{0pt}}% |
69 |
\def\@acol{% |
70 |
\TY@subwidth\col@sep |
71 |
\@addtopreamble{\hskip\col@sep}}% |
72 |
\let\@arrayrule\TY@arrayrule |
73 |
\let\@classvi\TY@classvi |
74 |
\def\@classv{\save@decl |
75 |
\expandafter\NC@ecs\@nextchar\extracolsep{}\extracolsep\@@@ |
76 |
\sbox\z@{\d@llarbegin\@nextchar\d@llarend}% |
77 |
\TY@subwidth{\wd\z@}% |
78 |
\@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}% |
79 |
\prepnext@tok}% |
80 |
\global\let\@mkpream\TY@@mkpream |
81 |
\TY@@mkpream} |
82 |
\def\TY@arrayrule{% |
83 |
\TY@subwidth\arrayrulewidth |
84 |
\@addtopreamble \vline} |
85 |
\def\TY@classvi{\ifcase \@lastchclass |
86 |
\@acol \or |
87 |
\TY@subwidth\doublerulesep |
88 |
\@addtopreamble{\hskip \doublerulesep}\or |
89 |
\@acol \or |
90 |
\@classvii |
91 |
\fi} |
92 |
\def\TY@tab{% |
93 |
\setbox\z@\hbox\bgroup |
94 |
\let\[$\let\]$% |
95 |
\let\equation$\let\endequation$% |
96 |
\col@sep\tabcolsep |
97 |
\let\d@llarbegin\begingroup\let\d@llarend\endgroup |
98 |
\let\@mkpream\TY@mkpream |
99 |
\def\multicolumn##1##2##3{\multispan##1\relax}% |
100 |
\CT@start\TY@tabarray} |
101 |
\def\TY@tabarray{\@ifnextchar[{\TY@array}{\@array[t]}} |
102 |
\def\TY@array[#1]{\@array[t]} |
103 |
\def\TY@width#1{% |
104 |
\expandafter#1\csname TY@\the\TY@count\endcsname} |
105 |
\def\TY@subwidth#1{% |
106 |
\TY@width\dimen@ |
107 |
\advance\dimen@-#1\relax |
108 |
\TY@width\xdef{\the\dimen@}% |
109 |
\global\advance\TY@linewidth-#1\relax} |
110 |
\def\endtabulary{% |
111 |
\gdef\@halignto{}% |
112 |
\let\TY@footnote\footnote% |
113 |
\def\footnote{}% prevent footnotes from doing anything |
114 |
\expandafter\TY@tab\the\toks@ |
115 |
\crcr\omit |
116 |
{\xdef\TY@save@row{}% |
117 |
\loop |
118 |
\advance\TY@count\m@ne |
119 |
\ifnum\TY@count>\z@ |
120 |
\xdef\TY@save@row{\TY@save@row&\omit}% |
121 |
\repeat}\TY@save@row |
122 |
\endarray\global\setbox1=\lastbox\setbox0=\vbox{\unvbox1 |
123 |
\unskip\global\setbox1=\lastbox}\egroup |
124 |
\dimen@\TY@linewidth |
125 |
\divide\dimen@\TY@count |
126 |
\ifdim\dimen@<\tymin |
127 |
\TY@warn{tymin too large (\the\tymin), resetting to \the\dimen@}% |
128 |
\tymin\dimen@ |
129 |
\fi |
130 |
\setbox\tw@=\hbox{\unhbox\@ne |
131 |
\loop |
132 |
\@tempdima=\lastskip |
133 |
\ifdim\@tempdima>\z@ |
134 |
Z \message{ecs=\the\@tempdima^^J}% |
135 |
\global\advance\TY@linewidth-\@tempdima |
136 |
\fi |
137 |
\unskip |
138 |
\setbox\tw@=\lastbox |
139 |
\ifhbox\tw@ |
140 |
Z \message{Col \the\TY@count: Initial=\the\wd\tw@\space}% |
141 |
\ifdim\wd\tw@>\tymax |
142 |
\wd\tw@\tymax |
143 |
Z \message{> max\space}% |
144 |
Z \else |
145 |
Z \message{ \@spaces\space}% |
146 |
\fi |
147 |
\TY@width\dimen@ |
148 |
Z \message{\the\dimen@\space}% |
149 |
\advance\dimen@\wd\tw@ |
150 |
Z \message{Final=\the\dimen@\space}% |
151 |
\TY@width\xdef{\the\dimen@}% |
152 |
\ifdim\dimen@<\tymin |
153 |
Z \message{< tymin}% |
154 |
\global\advance\TY@linewidth-\dimen@ |
155 |
\expandafter\xdef\csname TY@F\the\TY@count\endcsname |
156 |
{\the\dimen@}% |
157 |
\else |
158 |
\expandafter\ifx\csname TY@F\the\TY@count\endcsname\z@ |
159 |
Z \message{***}% |
160 |
\global\advance\TY@linewidth-\dimen@ |
161 |
\expandafter\xdef\csname TY@F\the\TY@count\endcsname |
162 |
{\the\dimen@}% |
163 |
\else |
164 |
Z \message{> tymin}% |
165 |
\global\advance\TY@tablewidth\dimen@ |
166 |
\global\expandafter\let\csname TY@F\the\TY@count\endcsname |
167 |
\maxdimen |
168 |
\fi\fi |
169 |
\advance\TY@count\m@ne |
170 |
\repeat}% |
171 |
\TY@checkmin |
172 |
\TY@checkmin |
173 |
\TY@checkmin |
174 |
\TY@checkmin |
175 |
\TY@count\z@ |
176 |
\let\TY@box\TY@box@v |
177 |
\let\footnote\TY@footnote % restore footnotes |
178 |
{\expandafter\TY@final\the\toks@\endTY@final}% |
179 |
\count@\z@ |
180 |
\@tempswatrue |
181 |
\@whilesw\if@tempswa\fi{% |
182 |
\advance\count@\@ne |
183 |
\expandafter\ifx\csname TY@SF\the\count@\endcsname\relax |
184 |
\@tempswafalse |
185 |
\else |
186 |
\global\expandafter\let\csname TY@F\the\count@\expandafter\endcsname |
187 |
\csname TY@SF\the\count@\endcsname |
188 |
\global\expandafter\let\csname TY@\the\count@\expandafter\endcsname |
189 |
\csname TY@S\the\count@\endcsname |
190 |
\fi}% |
191 |
\TY@linewidth\@ovxx |
192 |
\TY@tablewidth\@ovyy |
193 |
\ifnum0=`{\fi}} |
194 |
\def\TY@checkmin{% |
195 |
\let\TY@checkmin\relax |
196 |
\ifdim\TY@tablewidth>\z@ |
197 |
\Gscale@div\TY@ratio\TY@linewidth\TY@tablewidth |
198 |
\ifdim\TY@tablewidth <\linewidth |
199 |
\def\TY@ratio{1}% |
200 |
\fi |
201 |
\else |
202 |
\TY@warn{No suitable columns!}% |
203 |
\def\TY@ratio{1}% |
204 |
\fi |
205 |
\count@\z@ |
206 |
Z \message{^^JLine Width: \the\TY@linewidth, |
207 |
Z Natural Width: \the\TY@tablewidth, |
208 |
Z Ratio: \TY@ratio^^J}% |
209 |
\@tempdima\z@ |
210 |
\loop |
211 |
\ifnum\count@<\TY@count |
212 |
\advance\count@\@ne |
213 |
\ifdim\csname TY@F\the\count@\endcsname>\tymin |
214 |
\dimen@\csname TY@\the\count@\endcsname |
215 |
\dimen@\TY@ratio\dimen@ |
216 |
\ifdim\dimen@<\tymin |
217 |
Z \message{Column \the\count@\space ->}% |
218 |
\global\expandafter\let\csname TY@F\the\count@\endcsname\tymin |
219 |
\global\advance\TY@linewidth-\tymin |
220 |
\global\advance\TY@tablewidth-\csname TY@\the\count@\endcsname |
221 |
\let\TY@checkmin\TY@@checkmin |
222 |
\else |
223 |
\expandafter\xdef\csname TY@F\the\count@\endcsname{\the\dimen@}% |
224 |
\advance\@tempdima\csname TY@F\the\count@\endcsname |
225 |
\fi |
226 |
\fi |
227 |
Z \dimen@\csname TY@F\the\count@\endcsname\message{\the\dimen@, }% |
228 |
\repeat |
229 |
Z \message{^^JTotal:\the\@tempdima^^J}% |
230 |
} |
231 |
\let\TY@@checkmin\TY@checkmin |
232 |
\newdimen\TY@linewidth |
233 |
\def\tyformat{\everypar{{\nobreak\hskip\z@skip}}} |
234 |
\newdimen\tymin |
235 |
\tymin=10pt |
236 |
\newdimen\tymax |
237 |
\tymax=2\textwidth |
238 |
\def\@testpach{\@chclass |
239 |
\ifnum \@lastchclass=6 \@ne \@chnum \@ne \else |
240 |
\ifnum \@lastchclass=7 5 \else |
241 |
\ifnum \@lastchclass=8 \tw@ \else |
242 |
\ifnum \@lastchclass=9 \thr@@ |
243 |
\else \z@ |
244 |
\ifnum \@lastchclass = 10 \else |
245 |
\edef\@nextchar{\expandafter\string\@nextchar}% |
246 |
\@chnum |
247 |
\if \@nextchar c\z@ \else |
248 |
\if \@nextchar l\@ne \else |
249 |
\if \@nextchar r\tw@ \else |
250 |
\if \@nextchar C7 \else |
251 |
\if \@nextchar L8 \else |
252 |
\if \@nextchar R9 \else |
253 |
\if \@nextchar J10 \else |
254 |
\z@ \@chclass |
255 |
\if\@nextchar |\@ne \else |
256 |
\if \@nextchar !6 \else |
257 |
\if \@nextchar @7 \else |
258 |
\if \@nextchar <8 \else |
259 |
\if \@nextchar >9 \else |
260 |
10 |
261 |
\@chnum |
262 |
\if \@nextchar m\thr@@\else |
263 |
\if \@nextchar p4 \else |
264 |
\if \@nextchar b5 \else |
265 |
\z@ \@chclass \z@ \@preamerr \z@ \fi \fi \fi \fi\fi \fi \fi\fi \fi |
266 |
\fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi} |
267 |
\def\TY@classz{% |
268 |
\@classx |
269 |
\@tempcnta\count@ |
270 |
\ifx\TY@box\TY@box@v |
271 |
\global\advance\TY@count\@ne |
272 |
\fi |
273 |
\let\centering c% |
274 |
\let\raggedright\noindent |
275 |
\let\raggedleft\indent |
276 |
\let\arraybackslash\relax |
277 |
\prepnext@tok |
278 |
\ifnum\@chnum<4 |
279 |
\global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@ |
280 |
\fi |
281 |
\ifnum\@chnum=6 |
282 |
\global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@ |
283 |
\fi |
284 |
\@addtopreamble{% |
285 |
\ifcase\@chnum |
286 |
\hfil \d@llarbegin\insert@column\d@llarend \hfil \or |
287 |
\kern\z@ |
288 |
\d@llarbegin \insert@column \d@llarend \hfil \or |
289 |
\hfil\kern\z@ \d@llarbegin \insert@column \d@llarend \or |
290 |
$\vcenter\@startpbox{\@nextchar}\insert@column \@endpbox $\or |
291 |
\vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or |
292 |
\vbox \@startpbox{\@nextchar}\insert@column \@endpbox \or |
293 |
\d@llarbegin \insert@column \d@llarend \or% dubious "s" case |
294 |
\TY@box\centering\or |
295 |
\TY@box\raggedright\or |
296 |
\TY@box\raggedleft\or |
297 |
\TY@box\relax |
298 |
\fi}\prepnext@tok} |
299 |
\def\TY@box#1{% |
300 |
\ifx\centering#1% |
301 |
\hfil \d@llarbegin\insert@column\d@llarend \hfil \else |
302 |
\ifx\raggedright#1% |
303 |
\kern\z@%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
304 |
\d@llarbegin \insert@column \d@llarend \hfil \else |
305 |
\ifx\raggedleft#1% |
306 |
\hfil\kern\z@ \d@llarbegin \insert@column \d@llarend \else |
307 |
\ifx\relax#1% |
308 |
\d@llarbegin \insert@column \d@llarend |
309 |
\fi \fi \fi \fi} |
310 |
\def\TY@box@v#1{% |
311 |
\vtop \@startpbox{\csname TY@F\the\TY@count\endcsname}% |
312 |
#1\arraybackslash\tyformat |
313 |
\insert@column\@endpbox} |
314 |
\newdimen\TY@tablewidth |
315 |
\def\Gscale@div#1#2#3{% |
316 |
\setlength\dimen@{#3}% |
317 |
\ifdim\dimen@=\z@ |
318 |
\PackageError{graphics}{Division by 0}\@eha |
319 |
\dimen@#2% |
320 |
\fi |
321 |
\edef\@tempd{\the\dimen@}% |
322 |
\setlength\dimen@{#2}% |
323 |
\count@65536\relax |
324 |
\ifdim\dimen@<\z@ |
325 |
\dimen@-\dimen@ |
326 |
\count@-\count@ |
327 |
\fi |
328 |
\loop |
329 |
\ifdim\dimen@<8192\p@ |
330 |
\dimen@\tw@\dimen@ |
331 |
\divide\count@\tw@ |
332 |
\repeat |
333 |
\dimen@ii=\@tempd\relax |
334 |
\divide\dimen@ii\count@ |
335 |
\divide\dimen@\dimen@ii |
336 |
\edef#1{\strip@pt\dimen@}} |
337 |
\long\def\TY@get@body#1\end |
338 |
{\toks@\expandafter{\the\toks@#1}\TY@find@end} |
339 |
\def\TY@find@end#1{% |
340 |
\def\@tempa{#1}% |
341 |
\ifx\@tempa\TY@\def\@tempa{\end{#1}}\expandafter\@tempa |
342 |
\else\toks@\expandafter |
343 |
{\the\toks@\end{#1}}\expandafter\TY@get@body\fi} |
344 |
\def\TY@warn{% |
345 |
\PackageWarning{tabulary}} |
346 |
\catcode`\Z=11 |
347 |
\AtBeginDocument{ |
348 |
\@ifpackageloaded{colortbl}{% |
349 |
\expandafter\def\expandafter\@mkpream\expandafter#\expandafter1% |
350 |
\expandafter{% |
351 |
\expandafter\let\expandafter\CT@setup\expandafter\relax |
352 |
\expandafter\let\expandafter\CT@color\expandafter\relax |
353 |
\expandafter\let\expandafter\CT@do@color\expandafter\relax |
354 |
\expandafter\let\expandafter\color\expandafter\relax |
355 |
\expandafter\let\expandafter\CT@column@color\expandafter\relax |
356 |
\expandafter\let\expandafter\CT@row@color\expandafter\relax |
357 |
\@mkpream{#1}} |
358 |
\let\TY@@mkpream\@mkpream |
359 |
\def\TY@classz{% |
360 |
\@classx |
361 |
\@tempcnta\count@ |
362 |
\ifx\TY@box\TY@box@v |
363 |
\global\advance\TY@count\@ne |
364 |
\fi |
365 |
\let\centering c% |
366 |
\let\raggedright\noindent |
367 |
\let\raggedleft\indent |
368 |
\let\arraybackslash\relax |
369 |
\prepnext@tok |
370 |
\expandafter\CT@extract\the\toks\@tempcnta\columncolor!\@nil |
371 |
\ifnum\@chnum<4 |
372 |
\global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@ |
373 |
\fi |
374 |
\ifnum\@chnum=6 |
375 |
\global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@ |
376 |
\fi |
377 |
\@addtopreamble{% |
378 |
\setbox\z@\hbox\bgroup\bgroup |
379 |
\ifcase\@chnum |
380 |
\hskip\stretch{.5}\kern\z@ |
381 |
\d@llarbegin\insert@column\d@llarend\hskip\stretch{.5}\or |
382 |
\kern\z@%<<<<<<<<<<<<<<<<<<<<<<<<<<< |
383 |
\d@llarbegin \insert@column \d@llarend \hfill \or |
384 |
\hfill\kern\z@ \d@llarbegin \insert@column \d@llarend \or |
385 |
$\vcenter\@startpbox{\@nextchar}\insert@column \@endpbox $\or |
386 |
\vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or |
387 |
\vbox \@startpbox{\@nextchar}\insert@column \@endpbox \or |
388 |
\d@llarbegin \insert@column \d@llarend \or% dubious s case |
389 |
\TY@box\centering\or |
390 |
\TY@box\raggedright\or |
391 |
\TY@box\raggedleft\or |
392 |
\TY@box\relax |
393 |
\fi |
394 |
\egroup\egroup |
395 |
\begingroup |
396 |
\CT@setup |
397 |
\CT@column@color |
398 |
\CT@row@color |
399 |
\CT@do@color |
400 |
\endgroup |
401 |
\@tempdima\ht\z@ |
402 |
\advance\@tempdima\minrowclearance |
403 |
\vrule\@height\@tempdima\@width\z@ |
404 |
\unhbox\z@ |
405 |
}\prepnext@tok}% |
406 |
\def\TY@arrayrule{% |
407 |
\TY@subwidth\arrayrulewidth |
408 |
\@addtopreamble{{\CT@arc@\vline}}}% |
409 |
\def\TY@classvi{\ifcase \@lastchclass |
410 |
\@acol \or |
411 |
\TY@subwidth\doublerulesep |
412 |
\ifx\CT@drsc@\relax |
413 |
\@addtopreamble{\hskip\doublerulesep}% |
414 |
\else |
415 |
\@addtopreamble{{\CT@drsc@\vrule\@width\doublerulesep}}% |
416 |
\fi\or |
417 |
\@acol \or |
418 |
\@classvii |
419 |
\fi}% |
420 |
}{% |
421 |
\let\CT@start\relax |
422 |
} |
423 |
} |
424 |
{\uccode`\*=`\ % |
425 |
\uppercase{\gdef\TX@verb{% |
426 |
\leavevmode\null\TX@vwarn |
427 |
{\ifnum0=`}\fi\ttfamily\let\\\ignorespaces |
428 |
\@ifstar{\let~*\TX@vb}{\TX@vb}}}} |
429 |
\def\TX@vb#1{\def\@tempa##1#1{\toks@{##1}\edef\@tempa{\the\toks@}% |
430 |
\expandafter\TX@v\meaning\@tempa\\ \\\ifnum0=`{\fi}}\@tempa!} |
431 |
\def\TX@v#1!{\afterassignment\TX@vfirst\let\@tempa= } |
432 |
\begingroup |
433 |
\catcode`\*=\catcode`\# |
434 |
\catcode`\#=12 |
435 |
\gdef\TX@vfirst{% |
436 |
\if\@tempa#% |
437 |
\def\@tempb{\TX@v@#}% |
438 |
\else |
439 |
\let\@tempb\TX@v@ |
440 |
\if\@tempa\space~\else\@tempa\fi |
441 |
\fi |
442 |
\@tempb} |
443 |
\gdef\TX@v@*1 *2{% |
444 |
\TX@v@hash*1##\relax\if*2\\\else~\expandafter\TX@v@\fi*2} |
445 |
\gdef\TX@v@hash*1##*2{*1\ifx*2\relax\else#\expandafter\TX@v@hash\fi*2} |
446 |
\endgroup |
447 |
\def\TX@vwarn{% |
448 |
\@warning{\noexpand\verb may be unreliable inside tabularx/y}% |
449 |
\global\let\TX@vwarn\@empty} |
450 |
\endinput |
451 |
%% |
452 |
%% End of file `tabulary.sty'. |