Imported Upstream version 1.15.1
[platform/upstream/krb5.git] / doc / pdf / tabulary.sty
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 2008 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           [2008/12/01 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   \expandafter\TY@tab\the\toks@
113   \crcr\omit
114   {\xdef\TY@save@row{}%
115      \loop
116     \advance\TY@count\m@ne
117     \ifnum\TY@count>\z@
118     \xdef\TY@save@row{\TY@save@row&\omit}%
119     \repeat}\TY@save@row
120   \endarray\global\setbox1=\lastbox\setbox0=\vbox{\unvbox1
121     \unskip\global\setbox1=\lastbox}\egroup
122   \dimen@\TY@linewidth
123   \divide\dimen@\TY@count
124   \ifdim\dimen@<\tymin
125     \TY@warn{tymin too large (\the\tymin), resetting to \the\dimen@}%
126     \tymin\dimen@
127   \fi
128   \setbox\tw@=\hbox{\unhbox\@ne
129     \loop
130 \@tempdima=\lastskip
131 \ifdim\@tempdima>\z@
132 Z   \message{ecs=\the\@tempdima^^J}%
133    \global\advance\TY@linewidth-\@tempdima
134 \fi
135     \unskip
136     \setbox\tw@=\lastbox
137     \ifhbox\tw@
138 Z     \message{Col \the\TY@count: Initial=\the\wd\tw@\space}%
139       \ifdim\wd\tw@>\tymax
140         \wd\tw@\tymax
141 Z       \message{> max\space}%
142 Z     \else
143 Z       \message{ \@spaces\space}%
144       \fi
145   \TY@width\dimen@
146 Z \message{\the\dimen@\space}%
147   \advance\dimen@\wd\tw@
148 Z \message{Final=\the\dimen@\space}%
149    \TY@width\xdef{\the\dimen@}%
150       \ifdim\dimen@<\tymin
151 Z        \message{< tymin}%
152          \global\advance\TY@linewidth-\dimen@
153          \expandafter\xdef\csname TY@F\the\TY@count\endcsname
154                                                         {\the\dimen@}%
155        \else
156       \expandafter\ifx\csname TY@F\the\TY@count\endcsname\z@
157 Z        \message{***}%
158          \global\advance\TY@linewidth-\dimen@
159          \expandafter\xdef\csname TY@F\the\TY@count\endcsname
160                                                         {\the\dimen@}%
161         \else
162 Z        \message{> tymin}%
163          \global\advance\TY@tablewidth\dimen@
164          \global\expandafter\let\csname TY@F\the\TY@count\endcsname
165                                                                \maxdimen
166        \fi\fi
167        \advance\TY@count\m@ne
168     \repeat}%
169     \TY@checkmin
170     \TY@checkmin
171     \TY@checkmin
172     \TY@checkmin
173     \TY@count\z@
174     \let\TY@box\TY@box@v
175   {\expandafter\TY@final\the\toks@\endTY@final}%
176   \count@\z@
177   \@tempswatrue
178   \@whilesw\if@tempswa\fi{%
179   \advance\count@\@ne
180   \expandafter\ifx\csname TY@SF\the\count@\endcsname\relax
181     \@tempswafalse
182   \else
183     \global\expandafter\let\csname TY@F\the\count@\expandafter\endcsname
184                    \csname TY@SF\the\count@\endcsname
185     \global\expandafter\let\csname TY@\the\count@\expandafter\endcsname
186                    \csname TY@S\the\count@\endcsname
187   \fi}%
188   \TY@linewidth\@ovxx
189   \TY@tablewidth\@ovyy
190     \ifnum0=`{\fi}}
191 \def\TY@checkmin{%
192   \let\TY@checkmin\relax
193 \ifdim\TY@tablewidth>\z@
194   \Gscale@div\TY@ratio\TY@linewidth\TY@tablewidth
195  \ifdim\TY@tablewidth <\TY@linewidth
196    \def\TY@ratio{1}%
197  \fi
198 \else
199   \TY@warn{No suitable columns!}%
200   \def\TY@ratio{1}%
201 \fi
202 \count@\z@
203 Z \message{^^JLine Width: \the\TY@linewidth,
204 Z             Natural Width: \the\TY@tablewidth,
205 Z             Ratio: \TY@ratio^^J}%
206 \@tempdima\z@
207 \loop
208 \ifnum\count@<\TY@count
209 \advance\count@\@ne
210   \ifdim\csname TY@F\the\count@\endcsname>\tymin
211     \dimen@\csname TY@\the\count@\endcsname
212     \dimen@\TY@ratio\dimen@
213     \ifdim\dimen@<\tymin
214 Z     \message{Column \the\count@\space ->}%
215       \global\expandafter\let\csname TY@F\the\count@\endcsname\tymin
216       \global\advance\TY@linewidth-\tymin
217       \global\advance\TY@tablewidth-\csname TY@\the\count@\endcsname
218       \let\TY@checkmin\TY@@checkmin
219     \else
220       \expandafter\xdef\csname TY@F\the\count@\endcsname{\the\dimen@}%
221       \advance\@tempdima\csname TY@F\the\count@\endcsname
222     \fi
223   \fi
224 Z \dimen@\csname TY@F\the\count@\endcsname\message{\the\dimen@, }%
225 \repeat
226 Z \message{^^JTotal:\the\@tempdima^^J}%
227 }
228 \let\TY@@checkmin\TY@checkmin
229 \newdimen\TY@linewidth
230 \def\tyformat{\everypar{{\nobreak\hskip\z@skip}}}
231 \newdimen\tymin
232 \tymin=10pt
233 \newdimen\tymax
234 \tymax=2\textwidth
235 \def\@testpach{\@chclass
236  \ifnum \@lastchclass=6 \@ne \@chnum \@ne \else
237   \ifnum \@lastchclass=7 5 \else
238    \ifnum \@lastchclass=8 \tw@ \else
239     \ifnum \@lastchclass=9 \thr@@
240    \else \z@
241    \ifnum \@lastchclass = 10 \else
242    \edef\@nextchar{\expandafter\string\@nextchar}%
243    \@chnum
244    \if \@nextchar c\z@ \else
245     \if \@nextchar l\@ne \else
246      \if \@nextchar r\tw@ \else
247    \if \@nextchar C7 \else
248     \if \@nextchar L8 \else
249      \if \@nextchar R9 \else
250      \if \@nextchar J10 \else
251    \z@ \@chclass
252    \if\@nextchar |\@ne \else
253     \if \@nextchar !6 \else
254      \if \@nextchar @7 \else
255       \if \@nextchar <8 \else
256        \if \@nextchar >9 \else
257   10
258   \@chnum
259   \if \@nextchar m\thr@@\else
260    \if \@nextchar p4 \else
261     \if \@nextchar b5 \else
262    \z@ \@chclass \z@ \@preamerr \z@ \fi \fi \fi \fi\fi \fi \fi\fi \fi
263      \fi  \fi  \fi  \fi  \fi  \fi \fi \fi \fi \fi \fi}
264 \def\TY@classz{%
265   \@classx
266   \@tempcnta\count@
267   \ifx\TY@box\TY@box@v
268     \global\advance\TY@count\@ne
269   \fi
270   \let\centering c%
271   \let\raggedright\noindent
272   \let\raggedleft\indent
273   \let\arraybackslash\relax
274   \prepnext@tok
275   \ifnum\@chnum<4
276     \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
277   \fi
278   \ifnum\@chnum=6
279     \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
280   \fi
281   \@addtopreamble{%
282     \ifcase\@chnum
283       \hfil \d@llarbegin\insert@column\d@llarend \hfil \or
284       \kern\z@
285        \d@llarbegin \insert@column \d@llarend \hfil \or
286       \hfil\kern\z@ \d@llarbegin \insert@column \d@llarend \or
287       $\vcenter\@startpbox{\@nextchar}\insert@column \@endpbox $\or
288       \vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or
289       \vbox \@startpbox{\@nextchar}\insert@column \@endpbox \or
290       \d@llarbegin \insert@column \d@llarend \or% dubious "s" case
291       \TY@box\centering\or
292       \TY@box\raggedright\or
293       \TY@box\raggedleft\or
294       \TY@box\relax
295     \fi}\prepnext@tok}
296 \def\TY@box#1{%
297   \ifx\centering#1%
298       \hfil \d@llarbegin\insert@column\d@llarend \hfil \else
299   \ifx\raggedright#1%
300         \kern\z@%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
301       \d@llarbegin \insert@column \d@llarend \hfil \else
302   \ifx\raggedleft#1%
303       \hfil\kern\z@ \d@llarbegin \insert@column \d@llarend \else
304   \ifx\relax#1%
305        \d@llarbegin \insert@column \d@llarend
306   \fi  \fi  \fi  \fi}
307 \def\TY@box@v#1{%
308       \vtop \@startpbox{\csname TY@F\the\TY@count\endcsname}%
309               #1\arraybackslash\tyformat
310                               \insert@column\@endpbox}
311 \newdimen\TY@tablewidth
312 \def\Gscale@div#1#2#3{%
313   \setlength\dimen@{#3}%
314   \ifdim\dimen@=\z@
315     \PackageError{graphics}{Division by 0}\@eha
316     \dimen@#2%
317   \fi
318   \edef\@tempd{\the\dimen@}%
319   \setlength\dimen@{#2}%
320   \count@65536\relax
321   \ifdim\dimen@<\z@
322     \dimen@-\dimen@
323     \count@-\count@
324   \fi
325   \loop
326     \ifdim\dimen@<8192\p@
327       \dimen@\tw@\dimen@
328       \divide\count@\tw@
329   \repeat
330   \dimen@ii=\@tempd\relax
331   \divide\dimen@ii\count@
332   \divide\dimen@\dimen@ii
333   \edef#1{\strip@pt\dimen@}}
334 \long\def\TY@get@body#1\end
335   {\toks@\expandafter{\the\toks@#1}\TY@find@end}
336 \def\TY@find@end#1{%
337   \def\@tempa{#1}%
338   \ifx\@tempa\TY@\def\@tempa{\end{#1}}\expandafter\@tempa
339   \else\toks@\expandafter
340     {\the\toks@\end{#1}}\expandafter\TY@get@body\fi}
341 \def\TY@warn{%
342   \PackageWarning{tabulary}}
343 \catcode`\Z=11
344 \AtBeginDocument{
345 \@ifpackageloaded{colortbl}{%
346 \expandafter\def\expandafter\@mkpream\expandafter#\expandafter1%
347   \expandafter{%
348     \expandafter\let\expandafter\CT@setup\expandafter\relax
349     \expandafter\let\expandafter\CT@color\expandafter\relax
350     \expandafter\let\expandafter\CT@do@color\expandafter\relax
351     \expandafter\let\expandafter\color\expandafter\relax
352     \expandafter\let\expandafter\CT@column@color\expandafter\relax
353     \expandafter\let\expandafter\CT@row@color\expandafter\relax
354     \@mkpream{#1}}
355 \let\TY@@mkpream\@mkpream
356 \def\TY@classz{%
357   \@classx
358   \@tempcnta\count@
359   \ifx\TY@box\TY@box@v
360     \global\advance\TY@count\@ne
361   \fi
362   \let\centering c%
363   \let\raggedright\noindent
364   \let\raggedleft\indent
365   \let\arraybackslash\relax
366   \prepnext@tok
367 \expandafter\CT@extract\the\toks\@tempcnta\columncolor!\@nil
368   \ifnum\@chnum<4
369     \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
370   \fi
371   \ifnum\@chnum=6
372     \global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
373   \fi
374   \@addtopreamble{%
375     \setbox\z@\hbox\bgroup\bgroup
376     \ifcase\@chnum
377       \hskip\stretch{.5}\kern\z@
378       \d@llarbegin\insert@column\d@llarend\hskip\stretch{.5}\or
379       \kern\z@%<<<<<<<<<<<<<<<<<<<<<<<<<<<
380        \d@llarbegin \insert@column \d@llarend \hfill \or
381       \hfill\kern\z@ \d@llarbegin \insert@column \d@llarend \or
382       $\vcenter\@startpbox{\@nextchar}\insert@column \@endpbox $\or
383       \vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or
384       \vbox \@startpbox{\@nextchar}\insert@column \@endpbox \or
385       \d@llarbegin \insert@column \d@llarend \or% dubious s case
386       \TY@box\centering\or
387       \TY@box\raggedright\or
388       \TY@box\raggedleft\or
389       \TY@box\relax
390     \fi
391  \egroup\egroup
392 \begingroup
393   \CT@setup
394   \CT@column@color
395   \CT@row@color
396   \CT@do@color
397 \endgroup
398         \@tempdima\ht\z@
399         \advance\@tempdima\minrowclearance
400         \vrule\@height\@tempdima\@width\z@
401 \unhbox\z@
402 }\prepnext@tok}%
403     \def\TY@arrayrule{%
404       \TY@subwidth\arrayrulewidth
405       \@addtopreamble{{\CT@arc@\vline}}}%
406     \def\TY@classvi{\ifcase \@lastchclass
407       \@acol \or
408       \TY@subwidth\doublerulesep
409       \ifx\CT@drsc@\relax
410         \@addtopreamble{\hskip\doublerulesep}%
411       \else
412         \@addtopreamble{{\CT@drsc@\vrule\@width\doublerulesep}}%
413       \fi\or
414       \@acol \or
415       \@classvii
416       \fi}%
417 }{%
418 \let\CT@start\relax
419 }
420 }
421 {\uccode`\*=`\ %
422 \uppercase{\gdef\TX@verb{%
423   \leavevmode\null\TX@vwarn
424   {\ifnum0=`}\fi\ttfamily\let\\\ignorespaces
425   \@ifstar{\let~*\TX@vb}{\TX@vb}}}}
426 \def\TX@vb#1{\def\@tempa##1#1{\toks@{##1}\edef\@tempa{\the\toks@}%
427     \expandafter\TX@v\meaning\@tempa\\ \\\ifnum0=`{\fi}}\@tempa!}
428 \def\TX@v#1!{\afterassignment\TX@vfirst\let\@tempa= }
429 \begingroup
430 \catcode`\*=\catcode`\#
431 \catcode`\#=12
432 \gdef\TX@vfirst{%
433   \if\@tempa#%
434     \def\@tempb{\TX@v@#}%
435   \else
436     \let\@tempb\TX@v@
437     \if\@tempa\space~\else\@tempa\fi
438   \fi
439   \@tempb}
440 \gdef\TX@v@*1 *2{%
441   \TX@v@hash*1##\relax\if*2\\\else~\expandafter\TX@v@\fi*2}
442 \gdef\TX@v@hash*1##*2{*1\ifx*2\relax\else#\expandafter\TX@v@hash\fi*2}
443 \endgroup
444 \def\TX@vwarn{%
445   \@warning{\noexpand\verb may be unreliable inside tabularx/y}%
446   \global\let\TX@vwarn\@empty}
447 \endinput
448 %%
449 %% End of file `tabulary.sty'.