]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/papers/matita/klufloa.sty
ported to kluwer style
[helm.git] / helm / papers / matita / klufloa.sty
diff --git a/helm/papers/matita/klufloa.sty b/helm/papers/matita/klufloa.sty
new file mode 100644 (file)
index 0000000..1fd176e
--- /dev/null
@@ -0,0 +1,732 @@
+%
+%
+%
+\ifcat a\noexpand @\let\next\relax\else \def\next{%
+\documentclass{kluwer}\usepackage{doc}\MakePercentIgnore}\fi\next
+\def\filedate{1998/03/13}
+%\changes{1997/07/10}{Fixes in @klu@caption: inserted [b] and moved
+%               kaprotate code from the else to after the fi.}
+\def\filename{klufloa.sty}
+%\DoNotIndex{\@M,\def,\c@secnumdepth,\baselineskip,\@pnumwidth,\else,\fi}
+%\DoNotIndex{\newcommand,\z@,\relax,\renewcommand,\ifnum,\csname,\endcsname}
+%\DoNotIndex{\baselineskip,\vskip,\hskip,\relax,\secdef,\gdef,\@cla,\@clb}
+%\DoNotIndex{\normalsize,\protect,\global,\setbox,\hbox,\vbox,\endinput}
+%\DoNotIndex{\egroup,\endgroup,\bgroup,\begingroup,\let}
+%\CodelineIndex
+%\newcommand{\Bs}{$\backslash$}
+%\parindent=0pt
+%\parskip=3pt
+%\hfuzz=10pt
+%\MakeShortVerb{\|}
+%\setlength{\marginparwidth}{0in}
+%\addtolength{\textwidth}{4pc}
+%\begin{document}
+%\begin{opening}
+%\title{\filename}
+%\date{\filedate}
+%\author{T. \surname{Hoekwater}}
+%\institute{Kluwer Academic Publishers, Dordrecht}
+%\begin{abstract}
+% This internal stylefile takes care of floats and the |kaprotate| macro's \\
+%
+%\noindent
+%{\bf Disclaimer:}  This stylefile is to be used by Kluwer Academic
+% Publishers in the contruction of full class files. Therefore, the
+% user interface is not very high-level, and is definately not meant
+% for normal usage. This stylefile is provided {\bf as is}, i.e. we
+% accept no responsibilities whatsoever. You are free to use this file
+% in any way you like, provided you do not make {\it any\/} changes.
+% If you {\it do\/} make changes, you have to rename the changed file.
+%\end{abstract}
+%\end{opening}
+%\tableofcontents
+%\newpage\section{Usage}
+% At this moment, there are three float environments done here:
+% |table|, |figure| (with their starred and sub... forms) and |algorithm|.
+%                                  
+%
+% In order to facilitate customization, the following commands are
+% exported:
+%
+% \def\pitem[#1]{\item[\ttfamily\string #1]\SpecialUsageIndex{#1}}
+%\begin{description}
+%\pitem[\tabwidth]  Allows setting the width of a table that has to be
+%centered, but does not contain a |tabular| or |TABULAR|. Also,
+%it might be handy for tables that contain more than one |tabular|.
+%(e.g. |\tabwidth{20pc}|)                                             
+%\pitem[\tabfont]  Font specification for the main text of tables.\\
+%           (default value |\footnotesize|)
+%\pitem[\tabcapfont]  Font specification for table captions.
+%               (default value |\footnotesize|)
+%\pitem[\figcapfont]  Font specification for caption of figures. There is no
+% definition for the font of the text of figures.
+%               (defaultvalue |\footnotesize|)
+%\pitem[\tableindent] Indentation for tables. 
+%               (default given by stylefile)
+% Tables and figures can be either indented over a specified width, or
+% centered. This can be done independent of each other, but both
+% always use the same indentation. i.e: You cannot
+% have figures indented 4 picas and tables 2 picas, but you can have
+% indented tables with centered figures.
+%\pitem[\figindent] Indentation for figures. From the note above for these
+%two commands it follows that if both are given, they have to set the same
+% value. If they don't, the last given value will prevail.
+%               (default given by stylefile)
+%\pitem[\figtabdot] The dot after the number. (default value |.|)         
+%\pitem[\captionskip] Vertical skip between caption and main body of float.
+%           (default value 6pt)
+%\pitem[\tabcapspace] Space between heading of caption and
+%text of caption. This is a vertical or horizontal skip, depending on
+%whether captions are split or not. Default value .5em.
+%\pitem[\splittabcaptions] Splits the table captions in two parts.
+%\pitem[\splitfigcaptions] Splits the figure captions in two parts.
+%\pitem[\splitcaptions] Combines both.
+%\pitem[\indentedcaptions] Ordinarily, captions are centered above or below
+%the float. This setting allows you to specify a specific indentation. 
+%\pitem[\captionindent] Value used for the previous option The default value
+%is 0pt (appears to make most sense).
+%\end{description}                  
+%
+%
+% 
+%\newpage\section{Implementation}
+%
+% The |klutab| is necesarry here, because we need the definitions 
+% of tabular \& co that set the correct widths. It also makes sure that
+% these two are nicely tied in to eachother (version control problems).
+%
+%    \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{klufloa}[\filedate ]
+\RequirePackage{klutab}[1997/05/30]
+%    \end{macrocode}
+%\subsection{Float parameters}
+% These are standard as in \LaTeXe.
+%    \begin{macrocode}
+\setcounter{topnumber}{2}
+\setcounter{bottomnumber}{1}
+\setcounter{totalnumber}{3}
+\setcounter{dbltopnumber}{2}
+%    \end{macrocode}
+% The parameters below try to ensure that there are not so many float
+% pages. (prevents empty white space). 
+%
+% In the old stylefiles, 
+% |\topfraction| was $.99$, but that was bit to much, resulting in
+% pages with a huge float and only two text lines. Now a float has
+% to be $>.85$|\textheight| before it will result in a float page.
+% (oversimplified, but this is the general idea). This leaves
+% space on the page for a few more textlines.
+%
+% |\bottomfraction| used to be $.3$,  but that is to small for almost 
+% any float this style generates; there are split captions and tabnotes
+% to account for, so the value has increased a bit.
+%    \begin{macrocode}
+\renewcommand{\topfraction}{.85}
+\renewcommand{\textfraction}{.01}
+\renewcommand{\bottomfraction}{.4}
+\renewcommand{\floatpagefraction}{.84}
+\renewcommand{\dblfloatpagefraction}{.84}
+\renewcommand{\dbltopfraction}{.7}
+%    \end{macrocode}
+%\newpage
+% \subsection{Helper macros}
+% |\figtabdot| serves the same purpose as |\sectiondot| elsewhere,
+% and the 
+% names of various strings.
+%    \begin{macrocode}
+\def\figtabdot{.}
+\def\tablename{Table}%
+\def\figurename{Figure}%
+\def\algorithmname{Algorithm}%
+%    \end{macrocode}
+% |\maxfloatwidth| is the allowed width of the table.\\
+% (If this is a rotated table or figure, it will use all of the
+% page. Of course, |\maxfloatwidth| then is |\textheight|.)\\
+% |\figtabbox| will contain the total float as a vbox.
+% |\floatindent| is the indentation skip for indented tables \& figures. 
+% The last defined value will overwrite the previous one.\\
+% |\@tabskip| is an aid in helping to decide indentation of rotated tables.\\
+% |\cap@type| is an aid in keeping track of caption types\\
+% |\captionskip| is the vertical skip between caption and main body.
+%    \begin{macrocode}
+\newdimen\maxfloatwidth
+\newbox\figtabbox
+\newdimen\floatindent
+\newdimen\@tabskip
+\gdef\cap@type{0}
+\newdimen\captionskip
+\setlength\captionskip{6pt}
+%    \end{macrocode}
+%
+%
+% |\@tabwidth| is
+% supposed to contain the width of the table. (the width of |\figtabbox| is
+% probably either |\textwidth| or zero.) |tabular| and |TABULAR| from 
+% |klutab.sty| set
+% this value automatically, but so should every |table|. If your table
+% does not contain a |tabular|, you can set this value yourself:
+% just say |\tabwidth{..}| somewhere in your table.  Your text will
+% be typeset inside a |\vbox| with width |\maxfloatwidth|.
+%    \begin{macrocode}
+\newdimen\@tabwidth
+\setlength\@tabwidth{\textwidth}
+\def\tabwidth#1{\global\setlength\@tabwidth{#1}}
+%    \end{macrocode}
+%
+% |\@getindent| calculates the value of |\maxfloatwidth|, 
+% It is called from figure and table. 
+%
+% For rotated floats, |\maxfloatwidth| == |\vsize|. The use
+% of |\vsize| here is probably 
+% better than |\textheight|, because it allows use of minipages and
+% |\vbox|es to get special effects (where |\textheight| $>$ |\vsize|).
+%
+% |\@floatcorrect| fixes indentation for rotated floats. This and\\
+% |\hbox@to@floatwidth| are just shortcuts. 
+%    \begin{macrocode}
+\def\@getmaxwidth{\maxfloatwidth=\hsize
+    \if@kaprotate \maxfloatwidth=\textheight \fi }
+\def\@floatcorrect{\if@kaprotate\else 
+  \advance\maxfloatwidth -\floatindent \fi }
+\def\hbox@to@floatwidth#1{\leavevmode
+        \hbox to \@tabwidth{#1}}
+%    \end{macrocode}
+%
+% |\@getindent| calculates the values for |\@tabskip| and
+% |\@floatindent|. The first check initializes |\@tabwidth| for
+% anything except tables. The macro\\ |\@centeredfloat| does the
+% hard work for centered floats, where |\floatindent| is not given
+% beforehand.
+%    \begin{macrocode}
+\def\@getindent{%
+   \ifnum\cap@type=2 \else 
+        \@tabwidth=\if@kaprotate \textheight \else \hsize \fi 
+        \if@figindent\advance \@tabwidth -\floatindent \fi\fi
+   \ifnum\cap@type=1
+     \if@figindent \@tabskip\floatindent
+       \else \@centeredfloat \fi
+   \else \ifnum\cap@type=2  
+            \if@tabindent \@tabskip\floatindent 
+               \else \@centeredfloat  \fi
+            \ifdim \@tabwidth > \maxfloatwidth
+                \@tabskip 0pt
+                \floatindent 0pt
+            \fi
+         \else
+            \@centeredfloat
+         \fi
+   \fi        
+}
+%    \end{macrocode}
+%
+% |\@centeredfloat|\\
+% Calculate |\@tabskip| for centering. In this macro, we know the
+% float will be centered. We calculate |\floatindent| ourselves from
+% |\maxfloatwidth|.
+% 
+% We need to maintain this indentation for rotated floats (so they
+%   will be vertically centered), but |\@tabskip| needs to be re-done.
+%
+%    \begin{macrocode}
+\def\@centeredfloat{%
+     \floatindent\maxfloatwidth
+     \advance\floatindent by -\@tabwidth
+     \divide\floatindent by 2
+     \@tabskip\floatindent
+     \if@kaprotate 
+       \@tabskip\hsize
+       \advance\@tabskip by -\ht\figtabbox
+       \advance\@tabskip by -\dp\figtabbox
+       \divide\@tabskip by 2
+     \fi
+}    
+%    \end{macrocode}
+%
+% \subsection{Table caption commands}
+% Here is the code for the captions.
+%
+%
+% |\indentedcaptions| is a user option that indents captions instead 
+% (over a default value of 0pt).  
+%    \begin{macrocode}
+\newif\if@centeredfigcaption 
+\newif\if@centeredtabcaption 
+\@centeredtabcaptiontrue
+\@centeredfigcaptiontrue
+\def\indentedtabcaptions{\global\@centeredtabcaptionfalse }
+\def\indentedfigcaptions{\global\@centeredfigcaptionfalse }
+\def\indentedcaptions{\global\@centeredtabcaptionfalse
+    \global\@centeredfigcaptionfalse}
+\newdimen\captionindent
+\setlength\captionindent{0pt}
+\newtoks\@floatcaption
+\def\tabcapspace{.5em}
+\def\tabcapfont{\footnotesize }
+\long\def\@maketabcaption#1#2{\global\@floatcaption={#2}%
+   \message{\tablename\space\thetable \if@kaprotate 
+     \space(rotated) \fi}}
+%    \end{macrocode}
+%
+% Captions are centered above the table by default.\footnote{
+% In real life, {\tt @klu@caption} would be called {\tt make@caption},
+% since these do the typesetting}. This code is called from |\endtable|. 
+%    \begin{macrocode}
+\def\@klu@caption{%
+  \setbox1=\hbox{\tabcapfont\fnum@table\hskip\tabcapspace
+    \the\@floatcaption}%
+  \noindent
+  \ifdim\wd1 >\@tabwidth
+     {\if@centeredtabcaption\centering\else \hskip \captionindent\fi 
+     \parbox[b]{\@tabwidth}{\tabcapfont\unhbox1}}%
+  \else
+     \hbox to \@tabwidth{%
+       \if@centeredtabcaption \hfil \else \hskip \captionindent\fi
+       \tabcapfont\fnum@table
+       \hskip\tabcapspace{\tabcapfont\the\@floatcaption}\hfil }% 
+  \fi 
+  \if@kaprotate \else \par \vskip -\baselineskip \fi
+  \par 
+}
+\def\@klu@figcaption{%
+  \setbox1=\hbox{\figcapfont\fnum@figure\hskip\tabcapspace
+            \the\@floatcaption}%
+  \noindent
+  \ifdim\wd1 >\@tabwidth
+     {\if@centeredfigcaption\centering\else \hskip \captionindent\fi 
+     \parbox{\@tabwidth}{\figcapfont\unhbox1}}%
+  \else
+     \hbox to \@tabwidth{%
+       \if@centeredfigcaption \hfil\else \hskip \captionindent\fi
+       \tabcapfont\fnum@figure
+       \hskip\tabcapspace{\figcapfont\the\@floatcaption}\hfil}%
+  \fi 
+  \par 
+}
+%    \end{macrocode}
+%
+% |\splitcaptions| is a user option to generate a caption in which the
+% `Table 1' is separated from the caption text. The resulting
+% definitions depend on being inside a
+% vbox when called.
+%    \begin{macrocode}
+\def\splitcaptions{\splittabcaptions\splitfigcaptions}
+\def\splittabcaptions{
+  \def\@klu@caption{%
+    \setbox1=\hbox{\tabcapfont\the\@floatcaption}%
+    \noindent
+    \ifdim\wd1 >\@tabwidth 
+     \hbox to \@tabwidth{\if@centeredtabcaption\hss\else 
+       \hskip\captionindent\fi
+     \tabcapfont\fnum@table\hss}\vskip \tabcapspace
+       \vskip 6pt
+     {\if@centeredtabcaption\centering\fi 
+       \hskip \captionindent
+          \parbox{\@tabwidth}{\tabcapfont\unhbox1}}%
+   \else
+     \hbox to \@tabwidth{%
+       \if@centeredtabcaption \hfil\else \hskip\captionindent\fi
+       \tabcapfont\fnum@table\strut\hfil }\vskip \tabcapspace
+      \hbox to \@tabwidth{%
+       \if@centeredtabcaption \hfil\else \hskip\captionindent \fi
+       \tabcapfont\the\@floatcaption \hfil }%
+       \if@kaprotate \else \par \vskip -\baselineskip \fi
+   \fi 
+   \par 
+}}
+\def\splitfigcaptions{\def\@klu@figcaption{%
+    \setbox1=\hbox{\figcapfont\the\@floatcaption}%
+    \noindent
+    \ifdim\wd1 >\@tabwidth 
+     \hbox to \@tabwidth{\if@centeredfigcaption\hfil\else 
+       \hskip\captionindent\fi
+            \figcapfont\fnum@figure\hfil}\vskip \tabcapspace
+       \vskip 6pt
+     {\if@centeredfigcaption\centering\fi \hskip \captionindent
+            \parbox{\@tabwidth}{\figcapfont\unhbox1}}%
+   \else
+     \hbox to \@tabwidth{%
+       \if@centeredfigcaption \hfil\else \hskip\captionindent\fi
+       \figcapfont\fnum@figure\strut\hfil }\vskip \tabcapspace
+      \hbox to \@tabwidth{%
+       \if@centeredfigcaption \hfil\else \hskip\captionindent\fi
+       \figcapfont\the\@floatcaption \hfil }%
+   \fi 
+   \par 
+}}%
+%    \end{macrocode}
+%\newpage
+%\subsection{Table}
+% Standard \LaTeX\ definitions first:
+%
+% |\newcounter| removed 7/6/96 to prevent errors when used as package.
+% (`counter |\c@table| already defined')
+%    \begin{macrocode}
+\@ifundefined{thetable}{\newcounter{table}}{}
+\def\thetable{\arabic{table}}
+\def\fps@table{tbp}
+\def\ftype@table{2}
+\def\ext@table{lot}
+\def\fnum@table{\tablename~\thetable\figtabdot}
+%    \end{macrocode}
+% Now the switch to control indentation.
+%
+%    \begin{macrocode}
+\newif\if@tabindent \@tabindentfalse
+\def\tableindent#1{%
+   \global\floatindent= #1\global\@tabindenttrue }
+%    \end{macrocode}
+% Default font for tables.
+% This could also be used to redefine the font
+% defaults like family and shape.
+%    \begin{macrocode}
+\def\tabfont{\footnotesize}
+%    \end{macrocode}
+% |\tabnotes| is intended to be used as `footnote' to a tabular
+% environment. |\@tabnotes| will be cleared before every table.
+%    \begin{macrocode}
+\def\@tabnotes{}
+\newcounter{tabnote}
+\def\tabnotemark{\ensuremath{^{\thetabnote}}}
+\def\thetabnote{\arabic{tabnote}}
+\def\tabnotesep{\par}
+\def\tabnote#1{\stepcounter{tabnote}%
+    \rlap{\tabnotemark }%
+    \begingroup
+    \let\tabnotesep\relax
+    \xdef\@tabnotes{\@tabnotes\tabnotesep \tabnotemark #1\par}%
+    \endgroup }
+\long\def\tabnotes#1{\gdef\@tabnotes{{\tabfont\noindent #1\par}}}
+%    \end{macrocode}
+% Now for the macro's that set the table itself. Just to recall: \\[6pt]
+%|\maxfloatwidth|== max. width of table\\
+%|\@tabskip|== horizontal offset\\
+%|\floatindent|==indent before table proper\\
+%|\@tabnotes|==macro containing tabnotes (in Tabfont)\\
+%|\figtabbox|==vbox containing table (minus caption \& tabnotes)
+%
+% Non-rotated version:\\
+% Check width of caption. If it is too wide to fit on one line, put it
+% in a |\parbox| with proper |\floatindent| before it.
+%
+%    \begin{macrocode}
+\def\@setnotrotatedtabbox{%
+  \setbox4=\hbox to \maxfloatwidth{\vbox{\hsize=\maxfloatwidth
+     \@klu@caption 
+     \vskip\captionskip \leavevmode
+     \unvbox\figtabbox\par
+     \noindent\parbox{\@tabwidth}{\tabfont\@tabnotes}\par}}% 
+      \if@fixedfloat\calc@fixedspace4\fi                  
+  \noindent\kern \floatindent\box4
+ }
+%    \end{macrocode}
+% Rotated version. We are inside a |\vbox| here, so we typeset 3
+% hboxes (and a |\vskip|).
+%
+% |\maxfloatwidth| is |\textheight| here, causing overfull boxes.
+%
+%    \begin{macrocode}
+\def\@setrotatedtabbox{\begingroup \hfuzz=\vsize   
+     \setbox2\hbox to \textheight{\hfil
+        \vbox to \hsize{\hsize=\vsize
+         \vfil
+         \hbox{\hbox@to@floatwidth{\vbox{\@klu@caption }}}
+         \vskip\captionskip 
+         \hbox{\hbox@to@floatwidth{\box\figtabbox\hss}}%        
+         \hbox{\hbox@to@floatwidth{\parbox{\@tabwidth}{\tabfont\@tabnotes}\hfil }}%
+         \vss                
+    }\hss}\rotl{2}\endgroup
+}
+%    \end{macrocode}
+% |\@makecaption| will be |\let| to |\@maketabcaption| in for the
+% duration of the table.
+%
+% This is quite simple code, apart from handling the optional argument
+% ourselves. |kaprotate| effectively kills Overfull and Underfull
+% hbox-es. I don't like that, but I also don't like the messages I
+% always get (Overfull hbox with width = |\textheight| $-$ |\textwidth|).
+%    \begin{macrocode}
+\def\table{\let\@makecaption\@maketabcaption
+    \global\@floatcaption={}%
+    \gdef\@tabnotes{}\setcounter{tabnote}{0}\gdef\cap@type{2}%
+    \@ifnextchar[{\t@blewithoptions}{\t@blewithoptions[tbp]}}
+\def\t@blewithoptions[#1]{%
+    \if H#1\@fixedtable \else \@float{table}[#1]\fi
+    \@getmaxwidth \if@tabindent \@floatcorrect \fi
+    \setbox\figtabbox\vbox\bgroup\tabfont
+    \if@kaprotate\hfuzz=\vsize\fi }%
+%    \end{macrocode}
+%
+% This |\hfuzz| is a bit more precise. At least ik will warn if the
+%    tabular itself is too large.
+%    \begin{macrocode}
+\def\endtable{\egroup \@getindent
+  \gdef\cap@type{0}\noindent
+  \hfuzz=\floatindent 
+    \if@kaprotate \@setrotatedtabbox 
+    \else \@setnotrotatedtabbox \fi 
+  \if@fixedfloat \vskip\intextsep \@fixedfloatfalse   
+  \else \end@float \fi 
+  \hfuzz =0.1pt }%
+%    \end{macrocode}
+%\subsection{Table starred} 
+% This code is basically identical to the code above.
+% Multicolumn `Here' floats in twocolumn layout don't work, for obvious
+%  reasons. If you need something like that, fake it with the
+%  twocolumn package.
+%    \begin{macrocode}
+\@namedef{table*}{\let\@makecaption\@maketabcaption
+    \global\@floatcaption={}%
+    \gdef\@tabnotes{}\setcounter{tabnote}{0}\gdef\cap@type{2}%
+    \@ifnextchar[{\dt@blewithoptions}{\dt@blewithoptions[tbp]}}
+\def\dt@blewithoptions[#1]{%
+    \if H#1\if@twocolumn \@dblfloat{table}[t]\else \@fixedtable\fi 
+    \else \@dblfloat{table}[#1]\fi
+    \@getmaxwidth \if@tabindent \@floatcorrect \fi
+    \setbox\figtabbox\vbox\bgroup\tabfont
+    \if@kaprotate \hfuzz=\vsize \fi }%
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\@namedef{endtable*}{\egroup  \@getindent
+    \gdef\cap@type{0}\noindent
+    \hfuzz=\floatindent
+    \if@kaprotate \@setrotatedtabbox
+    \else \@setnotrotatedtabbox \fi
+    \if@fixedfloat  \vskip\intextsep \@fixedfloatfalse   
+    \else \end@dblfloat \fi 
+    \hfuzz=0.1pt }%
+%    \end{macrocode}
+% \subsection{fixed point tables and figures}
+% The fixedtable option. If there is enough room on the page, the 
+% box is typeset right away. If there is not enough space, the page is
+% ended and the box is typeset at the top of the next page. This may
+% conflict with following `top' floats, but the exact location in
+% the text is maintained.
+%
+% Don't try to use |[H]| on rotated tables, and twocolumn will produce
+% overlapping text in the second column, also, these will not appear
+%    in a `list of tables' unless you specifically ask that.
+%    \begin{macrocode}
+\newif\if@fixedfloat
+\def\@fixedtable{\vskip\intextsep \@fixedfloattrue  
+    \def\caption{\@ifnextchar[{\f@xedcap{table}}%
+      {\f@xedcap{table}[]}}}
+\def\@fixedfigure{\vskip\intextsep \@fixedfloattrue
+    \def\caption{\@ifnextchar[{\f@xedcap{figure}}%
+      {\f@xedcap{figure}[]}}}
+\def\f@xedcap#1[#2]#3{\refstepcounter{#1}\def\@tempa{#2}%
+  \ifx\@tempa\empty
+  \else \addcontentsline{\csname ext@#1\endcsname}{#1}{#2}\fi
+    \message{#1\space\csname the#1\endcsname \space (fixed)}%
+    \global\@floatcaption={#3}}
+\def\calc@fixedspace#1{%                 
+       \@tempdima=\pagegoal    
+       \@tempdimb=\dp#1      
+       \advance\@tempdimb \ht#1      
+       \advance\@tempdima -\pagetotal
+       \advance\@tempdima -2\intextsep
+         \wlog{pageleft= \the\@tempdima, 
+           size= \the\@tempdimb }%
+       \ifdim\@tempdima>\@tempdimb \else \newpage \fi}    
+%    \end{macrocode}
+%
+%\newpage \subsection{Figure}
+% Now we are going to do this all over again for
+% figures. Documentation will only mark important differences.
+%
+% Parameters.
+%
+%    \begin{macrocode}
+\@ifundefined{thefigure}{\newcounter{figure}}{}
+\def\thefigure{\arabic{figure}}
+\def\fps@figure{tbp}
+\def\ftype@figure{1}
+\def\ext@figure{lof}
+\def\fnum@figure{\figurename~\thefigure\figtabdot}
+%    \end{macrocode}
+% Indentation, font and caption.
+%    \begin{macrocode}
+\newif\if@figindent   \@figindentfalse   
+\def\figindent#1{%
+  \global\floatindent #1
+  \global\@figindenttrue }
+\def\figcapfont{\footnotesize}
+\long\def\@makefigcaption#1#2{%
+  \message{\figurename\space\thefigure 
+      \if@kaprotate \space (rotated)\fi }%
+  \global\@floatcaption={#2}}
+%    \end{macrocode}
+% 
+% The |fixed| option. 
+% 
+%    \begin{macrocode}
+%    \end{macrocode}
+% The figure environment itself.
+%    \begin{macrocode}
+\def\figure{%
+   \gdef\cap@type{1}%
+   \let\@makecaption\@makefigcaption
+   \global\@floatcaption={}%
+   \@ifnextchar[{\f@gurewithoptions}{\f@gurewithoptions[tbp]}}%
+\def\f@gurewithoptions[#1]{%
+  \let\saved@centerline\centerline
+  \if H#1\@fixedfigure \else \@float{figure}[#1]\fi
+    \@getmaxwidth \if@figindent \@floatcorrect 
+        \def\centerline##1{##1}\fi
+  \setbox\figtabbox\vbox\bgroup }%
+\def\endfigure{\egroup   
+       \@getindent \gdef\cap@type{0}%
+       \hfuzz=\floatindent
+       \if@kaprotate \@setrotatedfigbox \pagebreak
+       \else \@setnotrotatedfigbox \fi 
+       \let\centerline\saved@centerline
+       \if@fixedfloat \vskip\intextsep \@fixedfloatfalse   
+       \else \end@float \fi 
+       \hfuzz=0.1pt }%
+%    \end{macrocode}
+% \subsection{figure starred}
+%    \begin{macrocode}
+\@namedef{figure*}{%
+    \def\cap@type{1}%
+    \let\@makecaption\@makefigcaption
+    \global\@floatcaption={}%
+    \@ifnextchar[{\df@gurewithoptions}{\df@gurewithoptions[ttp]}}
+\def\df@gurewithoptions[#1]{%
+  \let\saved@centerline\centerline
+  \if H#1 \@fixedfigure \else \@dblfloat{figure}[#1]\fi
+    \@getmaxwidth \if@figindent \@floatcorrect 
+        \def\centerline##1{##1}\fi
+     \setbox\figtabbox\vbox\bgroup }%
+\@namedef{endfigure*}{\egroup
+        \@getindent \gdef\cap@type{0}% 
+        \hfuzz=\floatindent
+        \if@kaprotate \@setrotatedfigbox
+        \else \@setnotrotatedfigbox \fi 
+         \let\centerline\saved@centerline
+        \if@fixedfloat \vskip\intextsep \@fixedfloatfalse
+        \else \end@dblfloat \fi
+        \hfuzz=0.1pt }%
+%    \end{macrocode}
+% Non-rotated version (in figures |\caption| is done last):
+%    \begin{macrocode}
+\def\@setnotrotatedfigbox{%
+  \setbox4=\hbox to \maxfloatwidth{\vbox{\hsize=\maxfloatwidth
+     \unvbox\figtabbox
+     \vskip\captionskip 
+     \@klu@figcaption }}% 
+      \if@fixedfloat\calc@fixedspace4 \fi                  
+  \noindent\kern \floatindent\box4 
+}
+%    \end{macrocode}
+% Rotated version: 
+%
+%    \begin{macrocode}
+\def\@setrotatedfigbox{%
+     \setbox2\vbox to \hsize{\hsize=\textheight
+         \leavevmode
+         \vrule width \textheight height 0pt depth 0pt\par
+         \vskip \@tabskip                                      
+         \hbox to \textheight{\hss\box\figtabbox\hss}%
+         \vskip\captionskip 
+         \hbox to \textheight{\vbox{\@klu@figcaption }}
+         \vss
+    }\rotl{2}}%
+%    \end{macrocode}
+%\newpage \subsection{Algorithm} 
+% This is a `standard' float. 
+%    \begin{macrocode}
+\newcounter{algorithm}
+\def\thealgorithm{\arabic{algorithm}}
+\def\fps@algorithm{tbp}
+\def\ftype@algorithm{4}
+\def\ext@algorithm{lof}
+\long\def\@makealgocaption#1#2{%
+     \hbox to \hsize{\parbox[t]{\hsize}{{\vskip 1ex \tabcapfont
+     #1\figtabdot~~#2}}}}
+\def\fnum@algorithm{\algorithmname\space \thealgorithm}
+\def\algorithm{\let\@makecaption\@makealgocaption
+                \@float{algorithm}\footnotesize\obeyspaces\obeylines}
+\let\endalgorithm\end@float
+%    \end{macrocode}
+%\subsection{subtable and subfigure}
+% These are the sub... environments. If you need comment on what
+% happens, please see |kluthm.sty|, definition of |subequation|.
+%    \begin{macrocode}
+\def\subtable{\@ifnextchar[{\@subtable}{\@subtable[alph]}}
+\def\@subtable[#1]{\refstepcounter{table}%
+  \def\@testoption{arabic}\def\@testparam{#1}%
+  \begingroup
+  \edef\old@table{\the\c@table}%
+  \edef\old@thetable{\thetable}%
+  \setcounter{table}{0}%
+  \ifx\@testoption\@testparam
+     \def\thetable{\old@thetable.\csname #1\endcsname{table}}%
+  \else
+     \def\thetable{\old@thetable\csname #1\endcsname{table}}%
+  \fi}
+\def\endsubtable{\setcounter{table}{\old@table}%
+  \endgroup \global\@ignoretrue}
+\def\subfigure{\@ifnextchar[{\@subfigure}{\@subfigure[alph]}}
+\def\@subfigure[#1]{\refstepcounter{figure}%
+  \def\@testoption{arabic}\def\@testparam{#1}%
+  \begingroup
+  \edef\old@figure{\the\c@figure}%
+  \edef\old@thefigure{\thefigure}%
+  \setcounter{figure}{0}%
+  \ifx\@testoption\@testparam
+     \def\thefigure{\old@thefigure.\csname #1\endcsname{figure}}%
+   \else
+     \def\thefigure{\old@thefigure\csname #1\endcsname{figure}}%
+   \fi}
+\def\endsubfigure{\setcounter{figure}{\old@figure}%
+  \endgroup \global\@ignoretrue}
+%    \end{macrocode}
+% \subsection{kaprotate}
+% This appears to be an afterthought now, but in fact it is a quite
+% handy command.  The environment is defined in this file, because
+% this reflects common usage, and this allows loading as a package
+% in e.g. |article|.
+%
+%    \begin{macrocode}
+
+\newif\if@kaprotate \@kaprotatefalse
+\def\kaprotate{\global\@kaprotatetrue}
+\def\endkaprotate{\global\@kaprotatefalse}
+
+%    \end{macrocode}
+%
+% \subsubsection{Rotation macros}
+% These are used in the |kaprotate| environment. Note that these
+% macros depend on PostScript output at this moment. Later,
+% I might include commands for (at least) Tpic.
+%
+% These are just a few macro's, so it isn't really worth including |graphicx|
+% at the moment.
+%
+% |\rotl| and |\rotr| rotate a given box over resp. 270 and 90 degrees
+% while typesetting that box. The new box has $wd_{new}=dp_1 + ht_1$ and
+% $ht_{new}=wd_1$, with $dp_{new} ==0$.
+%    \begin{macrocode} 
+\newdimen\rotdimen
+\def\rotstart#1{\special{ps: gsave currentpoint currentpoint translate
+    #1 neg exch neg exch translate}}
+\def\rotfinish{\special{ps: currentpoint grestore moveto}}
+\def\rotl#1{\rotdimen=\ht#1\advance\rotdimen by \dp#1
+    \hbox to \rotdimen{\vbox to\wd#1{\vskip \wd#1
+    \rotstart{270 rotate}\box #1\vss}\hss}\rotfinish}
+\def\rotr#1{\rotdimen=\ht #1\advance\rotdimen by \dp#1
+    \hbox to \rotdimen{\vbox to \wd#1{\vskip \wd#1
+    \rotstart{90 rotate}\box #1\vss}\hss}\rotfinish}
+\endinput
+%    \end{macrocode}
+%\newpage
+%\def\IndexParms{\hbadness=10000}
+%\PrintIndex
+%\end{document}
+% end of klufloa.sty
+
+
+
+
+