The rotfloat package^{∗}

Harald Axel Sommerfeldt axel@hp1.ang-physik.uni-kiel.de

1995/03/30

Abstract The float package [1] provides commands to define new floats of various styles (plain, boxed, ruled, and userdefined ones ); the rotating package [2] provides new environments (sidewaysfigure and sidewaystable) which are rotated by 90^{∘} or 270^{∘}. But what about new rotated floats, e.g. a rotated ruled one? This package makes this possible; it builds a bridge between both packages and extend the commands from the float package to define rotated versions of the new floats, too.

1 The user interface

To use this package just type

     \usepackage[⟨options⟩]{rotfloat}

in the preamble of your document. The options are exactly the same as for the rotating package, in fact this package hasn’t got any own options at all.

\newfloat The commands \newfloat and \restylefloat from the float package (re)define \restylefloat the float type ⟨type⟩ and now additionally a rotated one called ⟨sidewaystype⟩:

\newrotfloat{⟨type⟩}{⟨placement⟩}{⟨ext⟩}[⟨within⟩]

     \restylerotfloat{⟨type⟩}

E.g. the code

     \floatstyle{ruled}
     \floatname{program}{Program}
     \newfloat{program}{tbp}{lop}[section]

defines the new floating environments program, program*, and sidewaysprogram which behave equivalent to figure, figure*, and sidewaysfigure. The code

     \floatstyle{boxed}
     \restylefloat{table}

will restyle the environments table, table*, and sidewaystable.

∗This package has version number 1.0, last revised 1995/03/30.

Please take a look at the float package for a complete description of these commands. Additionally an example file is provided with this package.

2 A final note

This package was written and tested with the version 1.2 of the float package and version 2.6 of the rotating package. You should not use this package together with older versions of them! Future versions of these packages may make some trouble, but I hope they will not.

3 The code

3.1 The identification part

 1 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
 2 \ProvidesPackage{rotfloat}[1995/03/30 v1.0 rotfloat package (AS)]
 3 \typeout{Package: rotfloat v1.0 <1995/03/30> (Axel Sommerfeldt)}

3.2 The declaration and execution of options

The rotfloat package hasn’t got any own options, so we just pass everything we get to the rotating package.

 4 \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{rotating}}
 5 \ProcessOptions

3.3 The package loading part

Of course this package needs the float and the rotating package, so we load them here.

 6 \RequirePackage{float}[1994/06/20]
 7 \RequirePackage{rotating}%[1995/01/06]

3.4 Adaption of the float package

\float@end First of all one improvement of the float package: \float@end now calls \end@float from the L^{A}TEX 2ε kernel. This code is more independent of what’s really going on in the L^{A}TEX 2ε macros \@float and \end@float than the original code of the float package is.

 8 \renewcommand*\float@end{%
 9 \egroup%
10 \global\setbox\@currbox\vbox\bgroup%
11 \float@makebox\end@float\egroup}

\@HHfloat \float@endH This patch has two functions: First of all, an error of the float package is fixed that causes floats with the placement specifier [H] to look differ from floats with other float placements. Additionaly this patch is required to make the sideways floats work with the placement [H].

12 \def\@HHfloat#1[H]{\@Hxfloat{#1}[!ht]}
13 \let\float@endH\undefined

3.5 The main code part

If you really want to know what’s exactly going on here, you have to study the code from the packages float and rotating first!

\rotfloat@restyle First, we save the old definition of \restylefloat because we need it later on.

14 \let\rotfloat@restyle\restylefloat

\restylefloat The new code for \restylefloat behaves quite like the old one, but it defines a sideways float as well. What differs sideways floats from the ‘normal’ ones?

  1. \columnwidth ist set to \textheight before calling \@float (\@float itself
     set \hsize to \columnwidth).
  2. \rotfloat@end is used instead of \float@end.

3. We define no *-form of the environment because a rotated float always fills the whole page.

15 \renewcommand*\restylefloat[1]{%
16 \rotfloat@restyle{#1}%
17 \@namedef{sideways#1}{%
18  \bgroup\@nameuse{fst@#1}\columnwidth\textheight\@float{#1}}%
19 \expandafter\let\csname endsideways#1\endcsname\rotfloat@end}

\rotfloat@end This macro does all the stuff that \float@end does and of course more: First of all, we finish the definition of \@currbox with \egroup. Then we set \@currbox to the new contents:

1. \@rotfloat (but without the contents of \@float)

2. \float@makebox (which includes the contents of \@float = \@currbox)

  3. \end@rotfloat (which includes \end@float)

Finally we finish the whole group (started in \@namedef{sideways#1} within

\restylefloat) with \egroup.
20 \newcommand*\rotfloat@end{%
21 \egroup%
22 \global\setbox\@currbox\vbox\bgroup%
23 \def\@float##1[##2]{}\let\@xfloat\@float\@rotfloat{}%
24 \float@makebox\end@rotfloat\egroup}

References

[1] Anselm Lingnau: An Improved Environment for Floats, 1994/06/20

[2] Sebastian Rahtz and Leonor Barroca: A style option for rotated objects in L^{A}TEX, 1994/08/26