2 %% This is file `tabulary.sty',
3 %% generated with the docstrip utility.
5 %% The original source files were:
7 %% tabulary.dtx (with options: `package')
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.
15 \NeedsTeXFormat{LaTeX2e}
16 \ProvidesPackage{tabulary}
17 [2007/10/02 v0.9 tabulary package (DPC)]
18 \RequirePackage{array}
20 \DeclareOption{debugshow}{\catcode`\Z=9\relax}
22 \def\arraybackslash{\let\\=\@arraycr}
24 \unskip\ifhmode\nobreak\fi\vrule\@width\z@\@height\z@\@depth\dp#1}
28 \let\endTY@final\endtabular
31 \edef\TY@{\@currenvir}%
37 \@whilesw\if@tempswa\fi{%
39 \expandafter\ifx\csname TY@F\the\count@\endcsname\relax
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
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
62 \let\TY@@mkpream\@mkpream
65 \if@firstamp \@firstampfalse \else
66 \global\advance\TY@count\@ne
67 \edef\@preamble{\@preamble &}\fi
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}%
78 \@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}%
80 \global\let\@mkpream\TY@@mkpream
83 \TY@subwidth\arrayrulewidth
84 \@addtopreamble \vline}
85 \def\TY@classvi{\ifcase \@lastchclass
87 \TY@subwidth\doublerulesep
88 \@addtopreamble{\hskip \doublerulesep}\or
93 \setbox\z@\hbox\bgroup
95 \let\equation$\let\endequation$%
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]}
104 \expandafter#1\csname TY@\the\TY@count\endcsname}
107 \advance\dimen@-#1\relax
108 \TY@width\xdef{\the\dimen@}%
109 \global\advance\TY@linewidth-#1\relax}
112 \let\TY@footnote\footnote%
113 \def\footnote{}% prevent footnotes from doing anything
114 \expandafter\TY@tab\the\toks@
116 {\xdef\TY@save@row{}%
118 \advance\TY@count\m@ne
120 \xdef\TY@save@row{\TY@save@row&\omit}%
122 \endarray\global\setbox1=\lastbox\setbox0=\vbox{\unvbox1
123 \unskip\global\setbox1=\lastbox}\egroup
125 \divide\dimen@\TY@count
127 \TY@warn{tymin too large (\the\tymin), resetting to \the\dimen@}%
130 \setbox\tw@=\hbox{\unhbox\@ne
134 Z \message{ecs=\the\@tempdima^^J}%
135 \global\advance\TY@linewidth-\@tempdima
140 Z \message{Col \the\TY@count: Initial=\the\wd\tw@\space}%
143 Z \message{> max\space}%
145 Z \message{ \@spaces\space}%
148 Z \message{\the\dimen@\space}%
149 \advance\dimen@\wd\tw@
150 Z \message{Final=\the\dimen@\space}%
151 \TY@width\xdef{\the\dimen@}%
154 \global\advance\TY@linewidth-\dimen@
155 \expandafter\xdef\csname TY@F\the\TY@count\endcsname
158 \expandafter\ifx\csname TY@F\the\TY@count\endcsname\z@
160 \global\advance\TY@linewidth-\dimen@
161 \expandafter\xdef\csname TY@F\the\TY@count\endcsname
165 \global\advance\TY@tablewidth\dimen@
166 \global\expandafter\let\csname TY@F\the\TY@count\endcsname
169 \advance\TY@count\m@ne
177 \let\footnote\TY@footnote % restore footnotes
178 {\expandafter\TY@final\the\toks@\endTY@final}%
181 \@whilesw\if@tempswa\fi{%
183 \expandafter\ifx\csname TY@SF\the\count@\endcsname\relax
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
195 \let\TY@checkmin\relax
196 \ifdim\TY@tablewidth>\z@
197 \Gscale@div\TY@ratio\TY@linewidth\TY@tablewidth
198 \ifdim\TY@tablewidth <\linewidth
202 \TY@warn{No suitable columns!}%
206 Z \message{^^JLine Width: \the\TY@linewidth,
207 Z Natural Width: \the\TY@tablewidth,
208 Z Ratio: \TY@ratio^^J}%
211 \ifnum\count@<\TY@count
213 \ifdim\csname TY@F\the\count@\endcsname>\tymin
214 \dimen@\csname TY@\the\count@\endcsname
215 \dimen@\TY@ratio\dimen@
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
223 \expandafter\xdef\csname TY@F\the\count@\endcsname{\the\dimen@}%
224 \advance\@tempdima\csname TY@F\the\count@\endcsname
227 Z \dimen@\csname TY@F\the\count@\endcsname\message{\the\dimen@, }%
229 Z \message{^^JTotal:\the\@tempdima^^J}%
231 \let\TY@@checkmin\TY@checkmin
232 \newdimen\TY@linewidth
233 \def\tyformat{\everypar{{\nobreak\hskip\z@skip}}}
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@@
244 \ifnum \@lastchclass = 10 \else
245 \edef\@nextchar{\expandafter\string\@nextchar}%
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
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
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}
271 \global\advance\TY@count\@ne
274 \let\raggedright\noindent
275 \let\raggedleft\indent
276 \let\arraybackslash\relax
279 \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
282 \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
286 \hfil \d@llarbegin\insert@column\d@llarend \hfil \or
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
295 \TY@box\raggedright\or
296 \TY@box\raggedleft\or
301 \hfil \d@llarbegin\insert@column\d@llarend \hfil \else
303 \kern\z@%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
304 \d@llarbegin \insert@column \d@llarend \hfil \else
306 \hfil\kern\z@ \d@llarbegin \insert@column \d@llarend \else
308 \d@llarbegin \insert@column \d@llarend
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}%
318 \PackageError{graphics}{Division by 0}\@eha
321 \edef\@tempd{\the\dimen@}%
322 \setlength\dimen@{#2}%
329 \ifdim\dimen@<8192\p@
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}
341 \ifx\@tempa\TY@\def\@tempa{\end{#1}}\expandafter\@tempa
342 \else\toks@\expandafter
343 {\the\toks@\end{#1}}\expandafter\TY@get@body\fi}
345 \PackageWarning{tabulary}}
348 \@ifpackageloaded{colortbl}{%
349 \expandafter\def\expandafter\@mkpream\expandafter#\expandafter1%
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
358 \let\TY@@mkpream\@mkpream
363 \global\advance\TY@count\@ne
366 \let\raggedright\noindent
367 \let\raggedleft\indent
368 \let\arraybackslash\relax
370 \expandafter\CT@extract\the\toks\@tempcnta\columncolor!\@nil
372 \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
375 \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
378 \setbox\z@\hbox\bgroup\bgroup
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
390 \TY@box\raggedright\or
391 \TY@box\raggedleft\or
402 \advance\@tempdima\minrowclearance
403 \vrule\@height\@tempdima\@width\z@
407 \TY@subwidth\arrayrulewidth
408 \@addtopreamble{{\CT@arc@\vline}}}%
409 \def\TY@classvi{\ifcase \@lastchclass
411 \TY@subwidth\doublerulesep
413 \@addtopreamble{\hskip\doublerulesep}%
415 \@addtopreamble{{\CT@drsc@\vrule\@width\doublerulesep}}%
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= }
433 \catcode`\*=\catcode`\#
437 \def\@tempb{\TX@v@#}%
440 \if\@tempa\space~\else\@tempa\fi
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}
448 \@warning{\noexpand\verb may be unreliable inside tabularx/y}%
449 \global\let\TX@vwarn\@empty}
452 %% End of file `tabulary.sty'.