1%%
2%% This is file `floatflt.sty',
3%% generated with the docstrip utility.
4%%
5%% The original source files were:
6%%
7%% floatflt.dtx  (with options: `paketkod')
8%%
9%% Copyright (c) 1994-1998 by Mats Dahlgren <matsd@sssk.se>.
10%% All rights reserved.  See the file `floatflt.ins' for information
11%% on how you may (re-)distribute the `floatflt' package files.
12%% You are not allowed to make any changes to this file without
13%% explicit permission from the author.
14%%
15\NeedsTeXFormat{LaTeX2e}[1996/12/01]
16\ProvidesPackage{floatflt}[1997/07/16 v. 1.31]
17\newcounter{OptionTest}
18\setcounter{OptionTest}{0}
19\DeclareOption{rflt}{\setcounter{OptionTest}{1}}
20\DeclareOption{lflt}{\setcounter{OptionTest}{2}}
21\DeclareOption{vflt}{\setcounter{OptionTest}{0}}
22\DeclareOption*{\OptionNotUsed}
23\ProcessOptions
24\newbox\figbox
25\newbox\tabbox
26\newbox\pagebox
27\newcount\ffigcount
28\newcount\ftabcount
29\newcount\fftest
30\newcount\hangcount
31\newcount\nosuccesstryfig
32\newcount\nosuccesstrytab
33\newdimen\figgutter   \figgutter=1truepc
34\newdimen\tabgutter   \tabgutter=1truepc
35\newdimen\htdone      \htdone=0pt
36\newdimen\pageht
37\newdimen\startpageht
38\newdimen\tabbredd
39\newdimen\floatfltwidth
40\newdimen\fltitemwidth
41\newif\iftryingfig     \tryingfigfalse
42\newif\iftryingtab     \tryingtabfalse
43\newif\ifdoingfig      \doingfigfalse
44\newif\ifdoingtab      \doingtabfalse
45\newif\iffigprocessing \figprocessingfalse
46\newif\iftabprocessing \tabprocessingfalse
47\newif\ifpageafterfig  \pageafterfigfalse
48\newif\ifpageaftertab  \pageaftertabfalse
49\newif\ifoddpages
50\newif\ifoutput
51\newtoks\outputpretest
52\newenvironment{floatingfigure}[2][v]%
53{\@tfor \@tempa :=#1\do
54         {\if\@tempa r\global\oddpagestrue\fi
55          \if\@tempa l\global\oddpagesfalse\fi
56          \if\@tempa p%
57              \ifodd\c@page\global\oddpagestrue
58                \else\global\oddpagesfalse\fi
59          \fi
60          \if\@tempa v%
61             \ifnum\theOptionTest=0
62                 \ifodd\c@page\global\oddpagestrue
63                   \else\global\oddpagesfalse\fi
64             \else
65                  \ifodd\theOptionTest\global\oddpagestrue
66                    \else\global\oddpagesfalse\fi
67             \fi
68          \fi
69         }
70 \expandafter\ifx\csname oldoutput\endcsname\relax% ref. TeXbook Ex.7.7
71    \PackageError{floatflt}{The `floatflt' package is not initialized}
72     {Try to reinstall the `floatflt' package.\MessageBreak
73      Type `x' to quit or <Return> to try to go on.}\@@end\fi
74 \global\everypar={\tryfig\oldeverypar}% must be set globally!
75 \global\advance\ffigcount by 1
76 \iffigprocessing
77    {\count0=\ffigcount\advance\count0 by -1
78     \PackageWarningNoLine{floatflt}{Floating figures \the\count0\space%
79       \space and \the\ffigcount\space colliding}%
80    }%
81 \fi
82 \iftabprocessing \PackageWarningNoLine{floatflt}{Floating figure %
83   \the\ffigcount\space and floating table \the\ftabcount\space colliding}
84 \fi
85 \def\@captype{figure}
86 \global\setlength{\floatfltwidth}{#2}
87 \global\figprocessingtrue
88 \global\setbox\figbox=\vbox\bgroup% begin of figbox
89                               \hrule height 0pt width #2 depth 0pt%
90                               \hsize=#2%
91}
92{
93\egroup
94\figinsert\par%
95}
96\newenvironment{floatingtable}[2][v]%
97{\@tfor \@tempa :=#1\do
98         {\if\@tempa r\global\oddpagestrue\fi
99          \if\@tempa l\global\oddpagesfalse\fi
100          \if\@tempa p%
101              \ifodd\c@page\global\oddpagestrue
102                \else\global\oddpagesfalse\fi
103          \fi
104          \if\@tempa v%
105             \ifnum \theOptionTest=0
106                 \ifodd\c@page\global\oddpagestrue
107                   \else\global\oddpagesfalse\fi
108             \else
109                  \ifodd\theOptionTest\global\oddpagestrue
110                    \else\global\oddpagesfalse\fi
111             \fi
112          \fi
113         }
114\expandafter\ifx\csname oldoutput\endcsname\relax% ref. TeXbook Ex.7.7
115     \PackageError{floatflt}{The `floatflt' package is not initialized}
116     {Try to reinstall the `floatflt' package.\MessageBreak
117      Type `x' to quit or <Return> to try to go on.}\@@end\fi
118\global\setbox\tabbox=\vbox\bgroup\hrule height 0pt width 0pt depth 0pt%
119   \hsize=0pt\egroup
120 \global\everypar={\trytab\oldeverypar}
121 \global\advance\ftabcount by 1
122 \iftabprocessing
123    {\count0=\ftabcount\advance\count0 by -1
124     \PackageWarningNoLine{floatflt}{Floating tables \the\count0\space%
125            \space and \the\ftabcount \space colliding}%
126    }
127 \fi
128 \iftabprocessing \PackageWarningNoLine{floatflt}{Floating table %
129   \the\ffigcount\space and floating figure \the\ftabcount\space colliding}
130 \fi
131 \settowidth{\tabbredd}{#2}
132 \global\setlength{\floatfltwidth}{\tabbredd}
133 \def\@captype{table}
134 \global\tabprocessingtrue
135 \global\setbox\tabbox=\vbox\bgroup% begin of tabbox
136                              \hrule height 0pt width\tabbredd depth 0pt%
137                               \hsize=\tabbredd
138\noindent\ifnum\ftabcount >1\ifoddpages\else\hspace*{-12pt}\fi\fi%
139#2\vspace{0.2\baselineskip}%
140}
141{
142\egroup% end of \tabbox
143\tabinsert\par%
144}
145\AtBeginDocument{%
146\edef\oldoutput{\the\output}%
147\output={\the\outputpretest%
148           \ifoutput\oldoutput\fi}
149\outputpretest={\outputtrue}
150\edef\oldeverypar{\the\everypar}
151}
152\def\dofigtest{%
153   \ifnum\outputpenalty=-10005
154     \setbox\pagebox=\vbox{\unvbox255}%
155     \global\pageht=\ht\pagebox
156     \global\outputfalse
157     \unvbox\pagebox
158   \else
159     \global\outputtrue
160     \ifdoingfig
161         \global\pageafterfigtrue
162     \fi
163   \fi}%
164\def\dotabtest{%
165   \ifnum\outputpenalty=-10005
166     \setbox\pagebox=\vbox{\unvbox255}%
167     \global\pageht=\ht\pagebox
168     \global\outputfalse
169     \unvbox\pagebox
170   \else
171     \global\outputtrue
172     \ifdoingtab
173         \global\pageaftertabtrue
174     \fi
175   \fi}%
176\def\tryfig{%
177      \iftryingfig
178       {\everypar={\relax}\setbox0=\lastbox%
179       \parindent=\wd0 \parskip=0pt \par%
180       \penalty-10005 \leavevmode}%
181       \dimen0=\vsize%
182       \advance\dimen0 by -\pageht%
183       \advance\dimen0 by -2\baselineskip%
184       \ifdim\dimen0>\ht\figbox%
185         \dimen0=0.3\baselineskip
186         \vrule depth \dimen0 width 0pt
187         \vadjust{\kern -\dimen0%
188         \vtop to \dimen0{%
189             \baselineskip=\dimen0%
190             \vss \vbox to 1ex{%
191             \ifoddpages%
192               \hbox to \hsize{\hss\copy\figbox}%
193             \else% leftsetting
194               \hbox to \hsize{\copy\figbox\hss}%
195             \fi% \ifodd\count0
196             \vss}\null}}%
197       \global\tryingfigfalse%
198       \global\doingfigtrue
199       \global\startpageht=\pageht
200       \global\htdone=0pt
201       \dohangf
202       \ifnum\nosuccesstryfig>0%
203         \typeout{floatflt Message: Flt. fig. \the\ffigcount\space set on page
204             \the\count0, shifted \the\nosuccesstryfig\space par(s) forward.}%
205       \else
206         \typeout{Package floatflt Message: Floating figure \the\ffigcount
207              \space set on page \the\count0}%
208       \fi
209     \else
210       \global\advance\nosuccesstryfig by 1
211     \fi
212     \else%
213     \ifdoingfig
214       {\everypar={\relax}\setbox0=\lastbox
215       \parindent=\wd0 \parskip=0pt \par
216         \penalty-10005 \leavevmode}%
217    \global\htdone=\pageht
218    \global\advance\htdone by -\startpageht
219    \ifpageafterfig
220      \global\doingfigfalse
221    \else
222      \dimen0=\ht\figbox%
223      \advance\dimen0 by 0.5\baselineskip%
224      \ifdim\htdone<\dimen0%
225         \dohangf
226      \else
227         \global\doingfigfalse
228      \fi
229    \fi
230    \ifdoingfig\relax\else\global\figprocessingfalse\fi
231  \else
232    \global\outputpretest={\outputtrue}%
233  \fi
234\fi
235}
236\def\trytab{%
237      \iftryingtab%
238       {\everypar={\relax}\setbox0=\lastbox%
239       \parindent=\wd0 \parskip=0pt \par%
240       \penalty-10005 \leavevmode}%
241       \dimen0=\vsize%
242       \advance\dimen0 by -\pageht%
243       \advance\dimen0 by -2\baselineskip%
244       \ifdim\dimen0>\ht\tabbox%
245         \dimen0=0.3\baselineskip
246         \vrule depth \dimen0 width 0pt
247         \vadjust{\kern -\dimen0%
248         \vtop to \dimen0{%
249             \baselineskip=\dimen0%
250             \vss \vbox to 1ex{%
251              \ifoddpages%
252               \hbox to \hsize{\hss\copy\tabbox}%
253             \else% leftsetting
254               \hbox to \hsize{\copy\tabbox\hss}%
255             \fi% \ifodd\count0
256             \vss}\null}}%
257       \global\tryingtabfalse%
258       \global\doingtabtrue
259       \global\startpageht=\pageht
260       \global\htdone=0pt
261       \dohangt
262       \ifnum\nosuccesstrytab>0%
263         \typeout{floatflt Message: Flt. tab. \the\ftabcount\space set on page
264             \the\count0, shifted \the\nosuccesstrytab\space par(s) forward.}%
265       \else
266         \typeout{Package floatflt Message: Floating table \the\ftabcount\space
267                  set on page \the\count0}%
268       \fi
269     \else
270       \global\advance\nosuccesstrytab by 1
271     \fi
272     \else
273     \ifdoingtab
274       {\everypar={\relax}\setbox0=\lastbox
275       \parindent=\wd0 \parskip=0pt \par
276         \penalty-10005 \leavevmode}%
277    \global\htdone=\pageht
278    \global\advance\htdone by -\startpageht
279    \ifpageaftertab
280      \global\doingtabfalse
281    \else
282      \dimen0=\ht\tabbox%
283      \advance\dimen0 by 0.5\baselineskip%
284      \ifdim\htdone<\dimen0%
285         \dohangt
286      \else
287         \global\doingtabfalse
288      \fi
289    \fi
290    \ifdoingtab\relax\else\global\tabprocessingfalse\fi
291  \else
292    \global\outputpretest={\outputtrue}%
293  \fi
294\fi
295}
296\def\figinsert{%
297   \global\nosuccesstryfig=0%
298   \global\outputpretest={\dofigtest}%
299   \global\tryingfigtrue \global\doingfigfalse%
300   \global\pageafterfigfalse}%
301\def\tabinsert{%
302   \global\nosuccesstrytab=0%
303   \global\outputpretest={\dotabtest}%
304   \global\tryingtabtrue \global\doingtabfalse%
305   \global\pageaftertabfalse}%
306\def\dohangf{%
307   \dimen0=\ht\figbox%
308   \advance\dimen0 by -\htdone%
309   \advance\dimen0 by 1.49\baselineskip%
310   \hangcount=\dimen0%
311   \divide\hangcount by \baselineskip%
312   \dimen0=\wd\figbox%
313   \advance\dimen0 by \figgutter%
314   \ifoddpages%
315     \global\hangafter=-\hangcount% placing right
316     \global\hangindent=-\dimen0%
317   \else% \ifleftsetting
318     \global\hangafter=-\hangcount% placing left
319     \global\hangindent=\dimen0%
320   \fi
321}
322\def\dohangt{%
323   \dimen0=\ht\tabbox%
324   \advance\dimen0 by -\htdone%
325   \advance\dimen0 by 1.49\baselineskip%
326   \hangcount=\dimen0%
327   \divide\hangcount by \baselineskip%
328   \dimen0=\wd\tabbox%
329   \advance\dimen0 by \tabgutter%
330   \ifoddpages%
331     \global\hangafter=-\hangcount% placing right
332     \global\hangindent=-\dimen0%
333   \else% \ifleftsetting
334     \global\hangafter=-\hangcount% placing left
335     \global\hangindent=\dimen0%
336   \fi
337}
338\newcommand{\fltitem}[2][0pt]{\setlength{\fltitemwidth}{\linewidth}%
339  \addtolength{\fltitemwidth}{-\floatfltwidth}%
340  \addtolength{\fltitemwidth}{-0.5em}%
341  \item \parbox[t]{\fltitemwidth}{#2}\\[#1]}
342\newcommand{\fltditem}[3][0pt]{\setlength{\fltitemwidth}{\linewidth}%
343  \addtolength{\fltitemwidth}{-\floatfltwidth}%
344  \addtolength{\fltitemwidth}{-0.5em}%
345  \item[#2] \parbox[t]{\fltitemwidth}{#3}\\[#1]}
346\endinput
347%%
348%% End of file `floatflt.sty'.
349