]> matita.cs.unibo.it Git - helm.git/blob - helm/papers/matita/klufloa.sty
ocaml 3.09 transition
[helm.git] / helm / papers / matita / klufloa.sty
1 %
2 %
3 %
4 \ifcat a\noexpand @\let\next\relax\else \def\next{%
5 \documentclass{kluwer}\usepackage{doc}\MakePercentIgnore}\fi\next
6 \def\filedate{1998/03/13}
7 %\changes{1997/07/10}{Fixes in @klu@caption: inserted [b] and moved
8 %               kaprotate code from the else to after the fi.}
9 \def\filename{klufloa.sty}
10 %\DoNotIndex{\@M,\def,\c@secnumdepth,\baselineskip,\@pnumwidth,\else,\fi}
11 %\DoNotIndex{\newcommand,\z@,\relax,\renewcommand,\ifnum,\csname,\endcsname}
12 %\DoNotIndex{\baselineskip,\vskip,\hskip,\relax,\secdef,\gdef,\@cla,\@clb}
13 %\DoNotIndex{\normalsize,\protect,\global,\setbox,\hbox,\vbox,\endinput}
14 %\DoNotIndex{\egroup,\endgroup,\bgroup,\begingroup,\let}
15 %\CodelineIndex
16 %\newcommand{\Bs}{$\backslash$}
17 %\parindent=0pt
18 %\parskip=3pt
19 %\hfuzz=10pt
20 %\MakeShortVerb{\|}
21 %\setlength{\marginparwidth}{0in}
22 %\addtolength{\textwidth}{4pc}
23 %\begin{document}
24 %\begin{opening}
25 %\title{\filename}
26 %\date{\filedate}
27 %\author{T. \surname{Hoekwater}}
28 %\institute{Kluwer Academic Publishers, Dordrecht}
29 %\begin{abstract}
30 % This internal stylefile takes care of floats and the |kaprotate| macro's \\
31 %
32 %\noindent
33 %{\bf Disclaimer:}  This stylefile is to be used by Kluwer Academic
34 % Publishers in the contruction of full class files. Therefore, the
35 % user interface is not very high-level, and is definately not meant
36 % for normal usage. This stylefile is provided {\bf as is}, i.e. we
37 % accept no responsibilities whatsoever. You are free to use this file
38 % in any way you like, provided you do not make {\it any\/} changes.
39 % If you {\it do\/} make changes, you have to rename the changed file.
40 %\end{abstract}
41 %\end{opening}
42 %\tableofcontents
43 %\newpage\section{Usage}
44 % At this moment, there are three float environments done here:
45 % |table|, |figure| (with their starred and sub... forms) and |algorithm|.
46 %                                  
47 %
48 % In order to facilitate customization, the following commands are
49 % exported:
50 %
51 % \def\pitem[#1]{\item[\ttfamily\string #1]\SpecialUsageIndex{#1}}
52 %\begin{description}
53 %\pitem[\tabwidth]  Allows setting the width of a table that has to be
54 %centered, but does not contain a |tabular| or |TABULAR|. Also,
55 %it might be handy for tables that contain more than one |tabular|.
56 %(e.g. |\tabwidth{20pc}|)                                             
57 %\pitem[\tabfont]  Font specification for the main text of tables.\\
58 %           (default value |\footnotesize|)
59 %\pitem[\tabcapfont]  Font specification for table captions.
60 %               (default value |\footnotesize|)
61 %\pitem[\figcapfont]  Font specification for caption of figures. There is no
62 % definition for the font of the text of figures.
63 %               (defaultvalue |\footnotesize|)
64 %\pitem[\tableindent] Indentation for tables. 
65 %               (default given by stylefile)
66 % Tables and figures can be either indented over a specified width, or
67 % centered. This can be done independent of each other, but both
68 % always use the same indentation. i.e: You cannot
69 % have figures indented 4 picas and tables 2 picas, but you can have
70 % indented tables with centered figures.
71 %\pitem[\figindent] Indentation for figures. From the note above for these
72 %two commands it follows that if both are given, they have to set the same
73 % value. If they don't, the last given value will prevail.
74 %               (default given by stylefile)
75 %\pitem[\figtabdot] The dot after the number. (default value |.|)         
76 %\pitem[\captionskip] Vertical skip between caption and main body of float.
77 %           (default value 6pt)
78 %\pitem[\tabcapspace] Space between heading of caption and
79 %text of caption. This is a vertical or horizontal skip, depending on
80 %whether captions are split or not. Default value .5em.
81 %\pitem[\splittabcaptions] Splits the table captions in two parts.
82 %\pitem[\splitfigcaptions] Splits the figure captions in two parts.
83 %\pitem[\splitcaptions] Combines both.
84 %\pitem[\indentedcaptions] Ordinarily, captions are centered above or below
85 %the float. This setting allows you to specify a specific indentation. 
86 %\pitem[\captionindent] Value used for the previous option The default value
87 %is 0pt (appears to make most sense).
88 %\end{description}                  
89 %
90 %
91
92 %\newpage\section{Implementation}
93 %
94 % The |klutab| is necesarry here, because we need the definitions 
95 % of tabular \& co that set the correct widths. It also makes sure that
96 % these two are nicely tied in to eachother (version control problems).
97 %
98 %    \begin{macrocode}
99 \NeedsTeXFormat{LaTeX2e}
100 \ProvidesPackage{klufloa}[\filedate ]
101 \RequirePackage{klutab}[1997/05/30]
102 %    \end{macrocode}
103 %\subsection{Float parameters}
104 % These are standard as in \LaTeXe.
105 %    \begin{macrocode}
106 \setcounter{topnumber}{2}
107 \setcounter{bottomnumber}{1}
108 \setcounter{totalnumber}{3}
109 \setcounter{dbltopnumber}{2}
110 %    \end{macrocode}
111 % The parameters below try to ensure that there are not so many float
112 % pages. (prevents empty white space). 
113 %
114 % In the old stylefiles, 
115 % |\topfraction| was $.99$, but that was bit to much, resulting in
116 % pages with a huge float and only two text lines. Now a float has
117 % to be $>.85$|\textheight| before it will result in a float page.
118 % (oversimplified, but this is the general idea). This leaves
119 % space on the page for a few more textlines.
120 %
121 % |\bottomfraction| used to be $.3$,  but that is to small for almost 
122 % any float this style generates; there are split captions and tabnotes
123 % to account for, so the value has increased a bit.
124 %    \begin{macrocode}
125 \renewcommand{\topfraction}{.85}
126 \renewcommand{\textfraction}{.01}
127 \renewcommand{\bottomfraction}{.4}
128 \renewcommand{\floatpagefraction}{.84}
129 \renewcommand{\dblfloatpagefraction}{.84}
130 \renewcommand{\dbltopfraction}{.7}
131 %    \end{macrocode}
132 %\newpage
133 % \subsection{Helper macros}
134 % |\figtabdot| serves the same purpose as |\sectiondot| elsewhere,
135 % and the 
136 % names of various strings.
137 %    \begin{macrocode}
138 \def\figtabdot{.}
139 \def\tablename{Table}%
140 \def\figurename{Figure}%
141 \def\algorithmname{Algorithm}%
142 %    \end{macrocode}
143 % |\maxfloatwidth| is the allowed width of the table.\\
144 % (If this is a rotated table or figure, it will use all of the
145 % page. Of course, |\maxfloatwidth| then is |\textheight|.)\\
146 % |\figtabbox| will contain the total float as a vbox.
147 % |\floatindent| is the indentation skip for indented tables \& figures. 
148 % The last defined value will overwrite the previous one.\\
149 % |\@tabskip| is an aid in helping to decide indentation of rotated tables.\\
150 % |\cap@type| is an aid in keeping track of caption types\\
151 % |\captionskip| is the vertical skip between caption and main body.
152 %    \begin{macrocode}
153 \newdimen\maxfloatwidth
154 \newbox\figtabbox
155 \newdimen\floatindent
156 \newdimen\@tabskip
157 \gdef\cap@type{0}
158 \newdimen\captionskip
159 \setlength\captionskip{6pt}
160 %    \end{macrocode}
161 %
162 %
163 % |\@tabwidth| is
164 % supposed to contain the width of the table. (the width of |\figtabbox| is
165 % probably either |\textwidth| or zero.) |tabular| and |TABULAR| from 
166 % |klutab.sty| set
167 % this value automatically, but so should every |table|. If your table
168 % does not contain a |tabular|, you can set this value yourself:
169 % just say |\tabwidth{..}| somewhere in your table.  Your text will
170 % be typeset inside a |\vbox| with width |\maxfloatwidth|.
171 %    \begin{macrocode}
172 \newdimen\@tabwidth
173 \setlength\@tabwidth{\textwidth}
174 \def\tabwidth#1{\global\setlength\@tabwidth{#1}}
175 %    \end{macrocode}
176 %
177 % |\@getindent| calculates the value of |\maxfloatwidth|, 
178 % It is called from figure and table. 
179 %
180 % For rotated floats, |\maxfloatwidth| == |\vsize|. The use
181 % of |\vsize| here is probably 
182 % better than |\textheight|, because it allows use of minipages and
183 % |\vbox|es to get special effects (where |\textheight| $>$ |\vsize|).
184 %
185 % |\@floatcorrect| fixes indentation for rotated floats. This and\\
186 % |\hbox@to@floatwidth| are just shortcuts. 
187 %    \begin{macrocode}
188 \def\@getmaxwidth{\maxfloatwidth=\hsize
189     \if@kaprotate \maxfloatwidth=\textheight \fi }
190 \def\@floatcorrect{\if@kaprotate\else 
191   \advance\maxfloatwidth -\floatindent \fi }
192 \def\hbox@to@floatwidth#1{\leavevmode
193         \hbox to \@tabwidth{#1}}
194 %    \end{macrocode}
195 %
196 % |\@getindent| calculates the values for |\@tabskip| and
197 % |\@floatindent|. The first check initializes |\@tabwidth| for
198 % anything except tables. The macro\\ |\@centeredfloat| does the
199 % hard work for centered floats, where |\floatindent| is not given
200 % beforehand.
201 %    \begin{macrocode}
202 \def\@getindent{%
203    \ifnum\cap@type=2 \else 
204         \@tabwidth=\if@kaprotate \textheight \else \hsize \fi 
205         \if@figindent\advance \@tabwidth -\floatindent \fi\fi
206    \ifnum\cap@type=1
207      \if@figindent \@tabskip\floatindent
208        \else \@centeredfloat \fi
209    \else \ifnum\cap@type=2  
210             \if@tabindent \@tabskip\floatindent 
211                \else \@centeredfloat  \fi
212             \ifdim \@tabwidth > \maxfloatwidth
213                 \@tabskip 0pt
214                 \floatindent 0pt
215             \fi
216          \else
217             \@centeredfloat
218          \fi
219    \fi        
220 }
221 %    \end{macrocode}
222 %
223 % |\@centeredfloat|\\
224 % Calculate |\@tabskip| for centering. In this macro, we know the
225 % float will be centered. We calculate |\floatindent| ourselves from
226 % |\maxfloatwidth|.
227
228 % We need to maintain this indentation for rotated floats (so they
229 %   will be vertically centered), but |\@tabskip| needs to be re-done.
230 %
231 %    \begin{macrocode}
232 \def\@centeredfloat{%
233      \floatindent\maxfloatwidth
234      \advance\floatindent by -\@tabwidth
235      \divide\floatindent by 2
236      \@tabskip\floatindent
237      \if@kaprotate 
238        \@tabskip\hsize
239        \advance\@tabskip by -\ht\figtabbox
240        \advance\@tabskip by -\dp\figtabbox
241        \divide\@tabskip by 2
242      \fi
243 }    
244 %    \end{macrocode}
245 %
246 % \subsection{Table caption commands}
247 % Here is the code for the captions.
248 %
249 %
250 % |\indentedcaptions| is a user option that indents captions instead 
251 % (over a default value of 0pt).  
252 %    \begin{macrocode}
253 \newif\if@centeredfigcaption 
254 \newif\if@centeredtabcaption 
255 \@centeredtabcaptiontrue
256 \@centeredfigcaptiontrue
257 \def\indentedtabcaptions{\global\@centeredtabcaptionfalse }
258 \def\indentedfigcaptions{\global\@centeredfigcaptionfalse }
259 \def\indentedcaptions{\global\@centeredtabcaptionfalse
260     \global\@centeredfigcaptionfalse}
261 \newdimen\captionindent
262 \setlength\captionindent{0pt}
263 \newtoks\@floatcaption
264 \def\tabcapspace{.5em}
265 \def\tabcapfont{\footnotesize }
266 \long\def\@maketabcaption#1#2{\global\@floatcaption={#2}%
267    \message{\tablename\space\thetable \if@kaprotate 
268      \space(rotated) \fi}}
269 %    \end{macrocode}
270 %
271 % Captions are centered above the table by default.\footnote{
272 % In real life, {\tt @klu@caption} would be called {\tt make@caption},
273 % since these do the typesetting}. This code is called from |\endtable|. 
274 %    \begin{macrocode}
275 \def\@klu@caption{%
276   \setbox1=\hbox{\tabcapfont\fnum@table\hskip\tabcapspace
277     \the\@floatcaption}%
278   \noindent
279   \ifdim\wd1 >\@tabwidth
280      {\if@centeredtabcaption\centering\else \hskip \captionindent\fi 
281      \parbox[b]{\@tabwidth}{\tabcapfont\unhbox1}}%
282   \else
283      \hbox to \@tabwidth{%
284        \if@centeredtabcaption \hfil \else \hskip \captionindent\fi
285        \tabcapfont\fnum@table
286        \hskip\tabcapspace{\tabcapfont\the\@floatcaption}\hfil }% 
287   \fi 
288   \if@kaprotate \else \par \vskip -\baselineskip \fi
289   \par 
290 }
291 \def\@klu@figcaption{%
292   \setbox1=\hbox{\figcapfont\fnum@figure\hskip\tabcapspace
293             \the\@floatcaption}%
294   \noindent
295   \ifdim\wd1 >\@tabwidth
296      {\if@centeredfigcaption\centering\else \hskip \captionindent\fi 
297      \parbox{\@tabwidth}{\figcapfont\unhbox1}}%
298   \else
299      \hbox to \@tabwidth{%
300        \if@centeredfigcaption \hfil\else \hskip \captionindent\fi
301        \tabcapfont\fnum@figure
302        \hskip\tabcapspace{\figcapfont\the\@floatcaption}\hfil}%
303   \fi 
304   \par 
305 }
306 %    \end{macrocode}
307 %
308 % |\splitcaptions| is a user option to generate a caption in which the
309 % `Table 1' is separated from the caption text. The resulting
310 % definitions depend on being inside a
311 % vbox when called.
312 %    \begin{macrocode}
313 \def\splitcaptions{\splittabcaptions\splitfigcaptions}
314 \def\splittabcaptions{
315   \def\@klu@caption{%
316     \setbox1=\hbox{\tabcapfont\the\@floatcaption}%
317     \noindent
318     \ifdim\wd1 >\@tabwidth 
319      \hbox to \@tabwidth{\if@centeredtabcaption\hss\else 
320        \hskip\captionindent\fi
321      \tabcapfont\fnum@table\hss}\vskip \tabcapspace
322        \vskip 6pt
323      {\if@centeredtabcaption\centering\fi 
324        \hskip \captionindent
325           \parbox{\@tabwidth}{\tabcapfont\unhbox1}}%
326    \else
327      \hbox to \@tabwidth{%
328        \if@centeredtabcaption \hfil\else \hskip\captionindent\fi
329        \tabcapfont\fnum@table\strut\hfil }\vskip \tabcapspace
330       \hbox to \@tabwidth{%
331        \if@centeredtabcaption \hfil\else \hskip\captionindent \fi
332        \tabcapfont\the\@floatcaption \hfil }%
333        \if@kaprotate \else \par \vskip -\baselineskip \fi
334    \fi 
335    \par 
336 }}
337 \def\splitfigcaptions{\def\@klu@figcaption{%
338     \setbox1=\hbox{\figcapfont\the\@floatcaption}%
339     \noindent
340     \ifdim\wd1 >\@tabwidth 
341      \hbox to \@tabwidth{\if@centeredfigcaption\hfil\else 
342        \hskip\captionindent\fi
343             \figcapfont\fnum@figure\hfil}\vskip \tabcapspace
344        \vskip 6pt
345      {\if@centeredfigcaption\centering\fi \hskip \captionindent
346             \parbox{\@tabwidth}{\figcapfont\unhbox1}}%
347    \else
348      \hbox to \@tabwidth{%
349        \if@centeredfigcaption \hfil\else \hskip\captionindent\fi
350        \figcapfont\fnum@figure\strut\hfil }\vskip \tabcapspace
351       \hbox to \@tabwidth{%
352        \if@centeredfigcaption \hfil\else \hskip\captionindent\fi
353        \figcapfont\the\@floatcaption \hfil }%
354    \fi 
355    \par 
356 }}%
357 %    \end{macrocode}
358 %\newpage
359 %\subsection{Table}
360 % Standard \LaTeX\ definitions first:
361 %
362 % |\newcounter| removed 7/6/96 to prevent errors when used as package.
363 % (`counter |\c@table| already defined')
364 %    \begin{macrocode}
365 \@ifundefined{thetable}{\newcounter{table}}{}
366 \def\thetable{\arabic{table}}
367 \def\fps@table{tbp}
368 \def\ftype@table{2}
369 \def\ext@table{lot}
370 \def\fnum@table{\tablename~\thetable\figtabdot}
371 %    \end{macrocode}
372 % Now the switch to control indentation.
373 %
374 %    \begin{macrocode}
375 \newif\if@tabindent \@tabindentfalse
376 \def\tableindent#1{%
377    \global\floatindent= #1\global\@tabindenttrue }
378 %    \end{macrocode}
379 % Default font for tables.
380 % This could also be used to redefine the font
381 % defaults like family and shape.
382 %    \begin{macrocode}
383 \def\tabfont{\footnotesize}
384 %    \end{macrocode}
385 % |\tabnotes| is intended to be used as `footnote' to a tabular
386 % environment. |\@tabnotes| will be cleared before every table.
387 %    \begin{macrocode}
388 \def\@tabnotes{}
389 \newcounter{tabnote}
390 \def\tabnotemark{\ensuremath{^{\thetabnote}}}
391 \def\thetabnote{\arabic{tabnote}}
392 \def\tabnotesep{\par}
393 \def\tabnote#1{\stepcounter{tabnote}%
394     \rlap{\tabnotemark }%
395     \begingroup
396     \let\tabnotesep\relax
397     \xdef\@tabnotes{\@tabnotes\tabnotesep \tabnotemark #1\par}%
398     \endgroup }
399 \long\def\tabnotes#1{\gdef\@tabnotes{{\tabfont\noindent #1\par}}}
400 %    \end{macrocode}
401 % Now for the macro's that set the table itself. Just to recall: \\[6pt]
402 %|\maxfloatwidth|== max. width of table\\
403 %|\@tabskip|== horizontal offset\\
404 %|\floatindent|==indent before table proper\\
405 %|\@tabnotes|==macro containing tabnotes (in Tabfont)\\
406 %|\figtabbox|==vbox containing table (minus caption \& tabnotes)
407 %
408 % Non-rotated version:\\
409 % Check width of caption. If it is too wide to fit on one line, put it
410 % in a |\parbox| with proper |\floatindent| before it.
411 %
412 %    \begin{macrocode}
413 \def\@setnotrotatedtabbox{%
414   \setbox4=\hbox to \maxfloatwidth{\vbox{\hsize=\maxfloatwidth
415      \@klu@caption 
416      \vskip\captionskip \leavevmode
417      \unvbox\figtabbox\par
418      \noindent\parbox{\@tabwidth}{\tabfont\@tabnotes}\par}}% 
419       \if@fixedfloat\calc@fixedspace4\fi                  
420   \noindent\kern \floatindent\box4
421  }
422 %    \end{macrocode}
423 % Rotated version. We are inside a |\vbox| here, so we typeset 3
424 % hboxes (and a |\vskip|).
425 %
426 % |\maxfloatwidth| is |\textheight| here, causing overfull boxes.
427 %
428 %    \begin{macrocode}
429 \def\@setrotatedtabbox{\begingroup \hfuzz=\vsize   
430      \setbox2\hbox to \textheight{\hfil
431         \vbox to \hsize{\hsize=\vsize
432          \vfil
433          \hbox{\hbox@to@floatwidth{\vbox{\@klu@caption }}}
434          \vskip\captionskip 
435          \hbox{\hbox@to@floatwidth{\box\figtabbox\hss}}%        
436          \hbox{\hbox@to@floatwidth{\parbox{\@tabwidth}{\tabfont\@tabnotes}\hfil }}%
437          \vss                
438     }\hss}\rotl{2}\endgroup
439 }
440 %    \end{macrocode}
441 % |\@makecaption| will be |\let| to |\@maketabcaption| in for the
442 % duration of the table.
443 %
444 % This is quite simple code, apart from handling the optional argument
445 % ourselves. |kaprotate| effectively kills Overfull and Underfull
446 % hbox-es. I don't like that, but I also don't like the messages I
447 % always get (Overfull hbox with width = |\textheight| $-$ |\textwidth|).
448 %    \begin{macrocode}
449 \def\table{\let\@makecaption\@maketabcaption
450     \global\@floatcaption={}%
451     \gdef\@tabnotes{}\setcounter{tabnote}{0}\gdef\cap@type{2}%
452     \@ifnextchar[{\t@blewithoptions}{\t@blewithoptions[tbp]}}
453 \def\t@blewithoptions[#1]{%
454     \if H#1\@fixedtable \else \@float{table}[#1]\fi
455     \@getmaxwidth \if@tabindent \@floatcorrect \fi
456     \setbox\figtabbox\vbox\bgroup\tabfont
457     \if@kaprotate\hfuzz=\vsize\fi }%
458 %    \end{macrocode}
459 %
460 % This |\hfuzz| is a bit more precise. At least ik will warn if the
461 %    tabular itself is too large.
462 %    \begin{macrocode}
463 \def\endtable{\egroup \@getindent
464   \gdef\cap@type{0}\noindent
465   \hfuzz=\floatindent 
466     \if@kaprotate \@setrotatedtabbox 
467     \else \@setnotrotatedtabbox \fi 
468   \if@fixedfloat \vskip\intextsep \@fixedfloatfalse   
469   \else \end@float \fi 
470   \hfuzz =0.1pt }%
471 %    \end{macrocode}
472 %\subsection{Table starred} 
473 % This code is basically identical to the code above.
474 % Multicolumn `Here' floats in twocolumn layout don't work, for obvious
475 %  reasons. If you need something like that, fake it with the
476 %  twocolumn package.
477 %    \begin{macrocode}
478 \@namedef{table*}{\let\@makecaption\@maketabcaption
479     \global\@floatcaption={}%
480     \gdef\@tabnotes{}\setcounter{tabnote}{0}\gdef\cap@type{2}%
481     \@ifnextchar[{\dt@blewithoptions}{\dt@blewithoptions[tbp]}}
482 \def\dt@blewithoptions[#1]{%
483     \if H#1\if@twocolumn \@dblfloat{table}[t]\else \@fixedtable\fi 
484     \else \@dblfloat{table}[#1]\fi
485     \@getmaxwidth \if@tabindent \@floatcorrect \fi
486     \setbox\figtabbox\vbox\bgroup\tabfont
487     \if@kaprotate \hfuzz=\vsize \fi }%
488 %    \end{macrocode}
489 %
490 %    \begin{macrocode}
491 \@namedef{endtable*}{\egroup  \@getindent
492     \gdef\cap@type{0}\noindent
493     \hfuzz=\floatindent
494     \if@kaprotate \@setrotatedtabbox
495     \else \@setnotrotatedtabbox \fi
496     \if@fixedfloat  \vskip\intextsep \@fixedfloatfalse   
497     \else \end@dblfloat \fi 
498     \hfuzz=0.1pt }%
499 %    \end{macrocode}
500 % \subsection{fixed point tables and figures}
501 % The fixedtable option. If there is enough room on the page, the 
502 % box is typeset right away. If there is not enough space, the page is
503 % ended and the box is typeset at the top of the next page. This may
504 % conflict with following `top' floats, but the exact location in
505 % the text is maintained.
506 %
507 % Don't try to use |[H]| on rotated tables, and twocolumn will produce
508 % overlapping text in the second column, also, these will not appear
509 %    in a `list of tables' unless you specifically ask that.
510 %    \begin{macrocode}
511 \newif\if@fixedfloat
512 \def\@fixedtable{\vskip\intextsep \@fixedfloattrue  
513     \def\caption{\@ifnextchar[{\f@xedcap{table}}%
514       {\f@xedcap{table}[]}}}
515 \def\@fixedfigure{\vskip\intextsep \@fixedfloattrue
516     \def\caption{\@ifnextchar[{\f@xedcap{figure}}%
517       {\f@xedcap{figure}[]}}}
518 \def\f@xedcap#1[#2]#3{\refstepcounter{#1}\def\@tempa{#2}%
519   \ifx\@tempa\empty
520   \else \addcontentsline{\csname ext@#1\endcsname}{#1}{#2}\fi
521     \message{#1\space\csname the#1\endcsname \space (fixed)}%
522     \global\@floatcaption={#3}}
523 \def\calc@fixedspace#1{%                 
524        \@tempdima=\pagegoal    
525        \@tempdimb=\dp#1      
526        \advance\@tempdimb \ht#1      
527        \advance\@tempdima -\pagetotal
528        \advance\@tempdima -2\intextsep
529          \wlog{pageleft= \the\@tempdima, 
530            size= \the\@tempdimb }%
531        \ifdim\@tempdima>\@tempdimb \else \newpage \fi}    
532 %    \end{macrocode}
533 %
534 %\newpage \subsection{Figure}
535 % Now we are going to do this all over again for
536 % figures. Documentation will only mark important differences.
537 %
538 % Parameters.
539 %
540 %    \begin{macrocode}
541 \@ifundefined{thefigure}{\newcounter{figure}}{}
542 \def\thefigure{\arabic{figure}}
543 \def\fps@figure{tbp}
544 \def\ftype@figure{1}
545 \def\ext@figure{lof}
546 \def\fnum@figure{\figurename~\thefigure\figtabdot}
547 %    \end{macrocode}
548 % Indentation, font and caption.
549 %    \begin{macrocode}
550 \newif\if@figindent   \@figindentfalse   
551 \def\figindent#1{%
552   \global\floatindent #1
553   \global\@figindenttrue }
554 \def\figcapfont{\footnotesize}
555 \long\def\@makefigcaption#1#2{%
556   \message{\figurename\space\thefigure 
557       \if@kaprotate \space (rotated)\fi }%
558   \global\@floatcaption={#2}}
559 %    \end{macrocode}
560
561 % The |fixed| option. 
562
563 %    \begin{macrocode}
564 %    \end{macrocode}
565 % The figure environment itself.
566 %    \begin{macrocode}
567 \def\figure{%
568    \gdef\cap@type{1}%
569    \let\@makecaption\@makefigcaption
570    \global\@floatcaption={}%
571    \@ifnextchar[{\f@gurewithoptions}{\f@gurewithoptions[tbp]}}%
572 \def\f@gurewithoptions[#1]{%
573   \let\saved@centerline\centerline
574   \if H#1\@fixedfigure \else \@float{figure}[#1]\fi
575     \@getmaxwidth \if@figindent \@floatcorrect 
576         \def\centerline##1{##1}\fi
577   \setbox\figtabbox\vbox\bgroup }%
578 \def\endfigure{\egroup   
579        \@getindent \gdef\cap@type{0}%
580        \hfuzz=\floatindent
581        \if@kaprotate \@setrotatedfigbox \pagebreak
582        \else \@setnotrotatedfigbox \fi 
583        \let\centerline\saved@centerline
584        \if@fixedfloat \vskip\intextsep \@fixedfloatfalse   
585        \else \end@float \fi 
586        \hfuzz=0.1pt }%
587 %    \end{macrocode}
588 % \subsection{figure starred}
589 %    \begin{macrocode}
590 \@namedef{figure*}{%
591     \def\cap@type{1}%
592     \let\@makecaption\@makefigcaption
593     \global\@floatcaption={}%
594     \@ifnextchar[{\df@gurewithoptions}{\df@gurewithoptions[ttp]}}
595 \def\df@gurewithoptions[#1]{%
596   \let\saved@centerline\centerline
597   \if H#1 \@fixedfigure \else \@dblfloat{figure}[#1]\fi
598     \@getmaxwidth \if@figindent \@floatcorrect 
599         \def\centerline##1{##1}\fi
600      \setbox\figtabbox\vbox\bgroup }%
601 \@namedef{endfigure*}{\egroup
602         \@getindent \gdef\cap@type{0}% 
603         \hfuzz=\floatindent
604         \if@kaprotate \@setrotatedfigbox
605         \else \@setnotrotatedfigbox \fi 
606          \let\centerline\saved@centerline
607         \if@fixedfloat \vskip\intextsep \@fixedfloatfalse
608         \else \end@dblfloat \fi
609         \hfuzz=0.1pt }%
610 %    \end{macrocode}
611 % Non-rotated version (in figures |\caption| is done last):
612 %    \begin{macrocode}
613 \def\@setnotrotatedfigbox{%
614   \setbox4=\hbox to \maxfloatwidth{\vbox{\hsize=\maxfloatwidth
615      \unvbox\figtabbox
616      \vskip\captionskip 
617      \@klu@figcaption }}% 
618       \if@fixedfloat\calc@fixedspace4 \fi                  
619   \noindent\kern \floatindent\box4 
620 }
621 %    \end{macrocode}
622 % Rotated version: 
623 %
624 %    \begin{macrocode}
625 \def\@setrotatedfigbox{%
626      \setbox2\vbox to \hsize{\hsize=\textheight
627          \leavevmode
628          \vrule width \textheight height 0pt depth 0pt\par
629          \vskip \@tabskip                                      
630          \hbox to \textheight{\hss\box\figtabbox\hss}%
631          \vskip\captionskip 
632          \hbox to \textheight{\vbox{\@klu@figcaption }}
633          \vss
634     }\rotl{2}}%
635 %    \end{macrocode}
636 %\newpage \subsection{Algorithm} 
637 % This is a `standard' float. 
638 %    \begin{macrocode}
639 \newcounter{algorithm}
640 \def\thealgorithm{\arabic{algorithm}}
641 \def\fps@algorithm{tbp}
642 \def\ftype@algorithm{4}
643 \def\ext@algorithm{lof}
644 \long\def\@makealgocaption#1#2{%
645      \hbox to \hsize{\parbox[t]{\hsize}{{\vskip 1ex \tabcapfont
646      #1\figtabdot~~#2}}}}
647 \def\fnum@algorithm{\algorithmname\space \thealgorithm}
648 \def\algorithm{\let\@makecaption\@makealgocaption
649                 \@float{algorithm}\footnotesize\obeyspaces\obeylines}
650 \let\endalgorithm\end@float
651 %    \end{macrocode}
652 %\subsection{subtable and subfigure}
653 % These are the sub... environments. If you need comment on what
654 % happens, please see |kluthm.sty|, definition of |subequation|.
655 %    \begin{macrocode}
656 \def\subtable{\@ifnextchar[{\@subtable}{\@subtable[alph]}}
657 \def\@subtable[#1]{\refstepcounter{table}%
658   \def\@testoption{arabic}\def\@testparam{#1}%
659   \begingroup
660   \edef\old@table{\the\c@table}%
661   \edef\old@thetable{\thetable}%
662   \setcounter{table}{0}%
663   \ifx\@testoption\@testparam
664      \def\thetable{\old@thetable.\csname #1\endcsname{table}}%
665   \else
666      \def\thetable{\old@thetable\csname #1\endcsname{table}}%
667   \fi}
668 \def\endsubtable{\setcounter{table}{\old@table}%
669   \endgroup \global\@ignoretrue}
670 \def\subfigure{\@ifnextchar[{\@subfigure}{\@subfigure[alph]}}
671 \def\@subfigure[#1]{\refstepcounter{figure}%
672   \def\@testoption{arabic}\def\@testparam{#1}%
673   \begingroup
674   \edef\old@figure{\the\c@figure}%
675   \edef\old@thefigure{\thefigure}%
676   \setcounter{figure}{0}%
677   \ifx\@testoption\@testparam
678      \def\thefigure{\old@thefigure.\csname #1\endcsname{figure}}%
679    \else
680      \def\thefigure{\old@thefigure\csname #1\endcsname{figure}}%
681    \fi}
682 \def\endsubfigure{\setcounter{figure}{\old@figure}%
683   \endgroup \global\@ignoretrue}
684 %    \end{macrocode}
685 % \subsection{kaprotate}
686 % This appears to be an afterthought now, but in fact it is a quite
687 % handy command.  The environment is defined in this file, because
688 % this reflects common usage, and this allows loading as a package
689 % in e.g. |article|.
690 %
691 %    \begin{macrocode}
692
693 \newif\if@kaprotate \@kaprotatefalse
694 \def\kaprotate{\global\@kaprotatetrue}
695 \def\endkaprotate{\global\@kaprotatefalse}
696
697 %    \end{macrocode}
698 %
699 % \subsubsection{Rotation macros}
700 % These are used in the |kaprotate| environment. Note that these
701 % macros depend on PostScript output at this moment. Later,
702 % I might include commands for (at least) Tpic.
703 %
704 % These are just a few macro's, so it isn't really worth including |graphicx|
705 % at the moment.
706 %
707 % |\rotl| and |\rotr| rotate a given box over resp. 270 and 90 degrees
708 % while typesetting that box. The new box has $wd_{new}=dp_1 + ht_1$ and
709 % $ht_{new}=wd_1$, with $dp_{new} ==0$.
710 %    \begin{macrocode} 
711 \newdimen\rotdimen
712 \def\rotstart#1{\special{ps: gsave currentpoint currentpoint translate
713     #1 neg exch neg exch translate}}
714 \def\rotfinish{\special{ps: currentpoint grestore moveto}}
715 \def\rotl#1{\rotdimen=\ht#1\advance\rotdimen by \dp#1
716     \hbox to \rotdimen{\vbox to\wd#1{\vskip \wd#1
717     \rotstart{270 rotate}\box #1\vss}\hss}\rotfinish}
718 \def\rotr#1{\rotdimen=\ht #1\advance\rotdimen by \dp#1
719     \hbox to \rotdimen{\vbox to \wd#1{\vskip \wd#1
720     \rotstart{90 rotate}\box #1\vss}\hss}\rotfinish}
721 \endinput
722 %    \end{macrocode}
723 %\newpage
724 %\def\IndexParms{\hbadness=10000}
725 %\PrintIndex
726 %\end{document}
727 % end of klufloa.sty
728
729
730
731
732