File: rotfloat.dtx

package info (click to toggle)
tetex-src 2.0.2a-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 71,124 kB
  • ctags: 1,576
  • sloc: makefile: 1,764; sh: 1,181; perl: 925; lisp: 342; python: 251; sed: 138; ansic: 138; xml: 96; yacc: 52
file content (423 lines) | stat: -rw-r--r-- 14,980 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
% \iffalse meta-comment
%
% Copyright (c) 1995-2002 Axel Sommerfeldt (rotfloat@sommerfeldt.net)
%
% This file is part of the rotfloat package.
% ------------------------------------------
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% of this license or (at your option) any later version.
% The latest version of this license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.2 or later is part of all distributions of LaTeX 
% version 1999/12/01 or later.
%
% \fi
%
% \iffalse
%<*driver>
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\documentclass{ltxdoc}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\smallskipamount}
\begin{document}
  \DocInput{rotfloat.dtx}
\end{document}
%</driver>
% \fi
%
% \newcommand*{\purerm}[1]{{\upshape\mdseries\rmfamily #1}}
% \newcommand*{\puresf}[1]{{\upshape\mdseries\sffamily #1}}
% \newcommand*{\purett}[1]{{\upshape\mdseries\ttfamily #1}}
%
% \def\packageversion{1.1}
% \def\packagedate{2002/02/02}
% \changes{v1.0}{30 Mar 95}{First release}
% \changes{v1.1}{ 2 Feb 02}{Revised and adapted to new versions of float and rotating}
%
% \title{The \puresf{rotfloat} package\thanks{This package has version number
%        \packageversion, last revised \packagedate.}}
% \author{Axel Sommerfeldt\\\texttt{rotfloat@sommerfeldt.net}}
% \date{2002/02/02}
% \maketitle
%
% \begin{abstract}
% The \textsf{float} package~\cite{float} provides commands to define new floats
% of various styles (|plain|, |boxed|, |ruled|, and userdefined ones);
% the \textsf{rotating} package~\cite{rotating} provides new environments (|sidewaysfigure|
% and |sidewaystable|) which are rotated by $90^\circ$ or $270^\circ$.
% 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 \textsf{float} package to define rotated
% versions of the new floats, too.
% \end{abstract}
%
% \section{The user interface}
% To use this package just type
% \begin{quote}
%   |\usepackage|\oarg{options}|{rotfloat}|
% \end{quote}
% in the preamble of your document. The options are exactly the same as
% for the \textsf{rotating} package, because all options will be passed to
% the \textsf{rotating} package.
% (The \textsf{rotfloat} package hasn't got any own options at all).
%
% \DescribeMacro{\newfloat}
% \DescribeMacro{\restylefloat}
% The commands |\newfloat| and |\restylefloat| from the \textsf{float} package
% (re)define the float type \meta{type} and now additionally a rotated one called
% \meta{\purett{sideways}type}:
% \begin{quote}
%   |\newrotfloat|\marg{type}\marg{placement}\marg{ext}\oarg{within}\\
%   |\restylerotfloat|\marg{type}
% \end{quote}
%
% \begin{minipage}[t]\textwidth
% E.g.\ the code
% \begin{quote}
%   |\floatstyle{ruled}|\\
%   |\floatname{program}{Program}|\\
%   |\newfloat{program}{tbp}{lop}[section]|
% \end{quote}
% defines the new floating environments |program|, |program*|,
% |sidewaysprogram|, and |sidewaysprogram*|
% which behave equivalent to |figure|, |figure*|,
% |sidewaysfigure|, and |sidewaysfigure*|.
% (Note that |sidewaysfigure*| has been introduced to version $2.10$ of the \puresf{rotating}
% package, therefore you only get a |sidewaysprogram*| environment if you use this or a newer
% version of the \puresf{rotating} package.)
% \end{minipage}
%
% \begin{minipage}[t]\textwidth
% The code
% \begin{quote}\nopagebreak%
%   |\floatstyle{boxed}|\\
%   |\restylefloat{table}|
% \end{quote}
% will restyle the environments |table|, |table*|, |sidewaystable|, and |sidewaystable*|.
% \end{minipage}
%
% Please take a look at the \textsf{float} package for a complete description
% of these commands.
% Additionally an example file is provided with this package.
%
% \section{What has changed since version {1.0}?}
% Version $1.0$ of this package was a quick \& dirty but working hack. This version takes it all
% more serious, it tries to patch as less code from the float package as possible and
% especially it lets the |[H]| code for the not-sideways floats intact.
% (Version $1.0$ had just patched |[H]| to |[!ht]| to make thinks easier to handle.)
%
% Furthermore it was adapted to the new versions 1.3 of the float and
% 2.10 of the rotating package.
%
% \section{A final note}
% This package was tested with the versions $1.2$, $1.2c$, $1.2d$, $1.2e$, $1.3c$,
% and $1.3d$ of the \textsf{float} package and version $2.6$, $2.9$, $2.10$, $2.12$,
% and $2.13$ of the \textsf{rotating} package.
%
% You should \textbf{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.
% If they do please don't hesitate to send me a bug report including a simple non-working
% example and the logfile produced by TeX.
%
% \StopEventually{
%   \begin{thebibliography}{9}
%   \bibitem{float}
%   Anselm Lingnau:
%   \textsl{An Improved Environment for Floats},
%   1994/06/20
%   \bibitem{rotating}
%   Sebastian Rahtz and Leonor Barroca:
%   \textsl{A style option for rotated objects in \LaTeX},
%   1994/08/26
%   \end{thebibliography}
% }
% \setlength{\parskip}{0pt plus 1pt}
%
% \CheckSum{195}
% \DoNotIndex{\@ifnextchar,\@ifundefined,\@namedef,\@nameuse}
% \DoNotIndex{\bgroup,\columnwidth,\csname,\def,\edef,\egroup,\else,\endcsname}
% \DoNotIndex{\empty,\expandafter,\fi,\global,\ifx,\let,\newcommand,\noexpand}
% \DoNotIndex{\renewcommand,\setbox,\textheight,\typeout,\undefined,\vbox}
% \DoNotIndex{\CurrentOption,\DeclareOption,\ExecuteOptions,\NeedsTeXFormat}
% \DoNotIndex{\PassOptionsToPackage,\ProcessOptions,\ProvidesPackage,\RequirePackage}
%
% \iffalse
%<*package>
% \fi
%
% \section{The code}
%
% Note:
% If you really want to know what's exactly going on here, you have to study the
% code from the packages \textsf{float} and \textsf{rotating} first!
%
% \subsection{The identification part}
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{rotfloat}[2002/02/02 v1.1 rotfloat package (AS)]
\typeout{Package: rotfloat v1.1 <2002/02/02> (Axel Sommerfeldt)}
%    \end{macrocode}
%
% \subsection{The declaration and execution of options}
%
% The \textsf{rotfloat} package hasn't got any own options, so we just pass
% everything we get to the \textsf{rotating} package.
%
%    \begin{macrocode}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{rotating}}
\ProcessOptions
%    \end{macrocode}
%
% \subsection{The package loading part}
%
% Of course this package needs the \textsf{float} and the \textsf{rotating}
% package, so we load them both here.
%
%    \begin{macrocode}
\RequirePackage{float}[1994/06/20]      % >= version 1.2
\RequirePackage{rotating}%[1995/01/06]  % >= version 2.6
%    \end{macrocode}
%
% \subsection{Adaption of the float package}
% \changes{v1.0a}{1 Apr 95}{Blew {\tt\protect\bslash float@end} up}
%
% \begin{macro}{\rotfloat@xoftwo}
%
% If the float is a normal one, |\rotfloat@xoftwo| is defined to |\@firstoftwo|.
% If it is a sideways one, it will be (locally) defined to |\@secondoftwo|.
%
%    \begin{macrocode}
\let\rotfloat@xoftwo\@firstoftwo
%    \end{macrocode}
% \end{macro}
%
% From now on we have different code for version $1.2$ and version $1.3$ of
% the \textsf{float} package. If |\@float@HH| is not defined we assume
% version $1.2$, otherwise version $1.3$.
%
%    \begin{macrocode}
\ifx\@float@HH\undefined
  \wlog{rotfloat package: v1.2 of float detected}
%    \end{macrocode}
%
% First the code for version $1.2$ of the float package:
%
% \begin{macro}{\rotfloat@HH}
% \begin{macro}{\rotfloat@restyle}
%
% We save the old definitions of |\@HHfloat| and |\restylefloat|
% because we need them later on.
%
%    \begin{macrocode}
  \let\rotfloat@HH\@HHfloat
  \let\rotfloat@restyle\restylefloat
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@HHfloat}
% \changes{v1.1}{1 Feb 02}{Leave H-code intact for normal floats}
%
% We do not support the placement specifier |[H]| for sideways floats,
% therefore we have to patch it to |[!ht]| if it is a sideways one.
%
%    \begin{macrocode}
  \def\@HHfloat#1[H]{%
    \rotfloat@xoftwo{\rotfloat@HH{#1}[H]}{\@Hxfloat{#1}[!ht]}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\restylefloat}
% \changes{v1.0a}{1 Apr 95}{Senseless {\tt\protect\bslash bgroup} removed}
% \changes{v1.1}{1 Feb 02}{We define a *-sideways float as well}
%
% The new code for |\restylefloat| behaves like the old one, but it defines
% a sideways float as well. What differs sideways floats from the `normal' ones?
% \begin{enumerate}
% \item |\rotfloat@xoftwo| is defined to |\@secondoftwo|.
%   (|\rotfloat@xoftwo| will be used in |\@HHfloat|.)
% \item |\columnwidth| ist set to |\textheight| before calling |\@float|.
%   (|\@float| itself set |\hsize| to |\columnwidth|.)
% \item |\rotfloat@end| is used instead of |\float@end|.
% \end{enumerate}
%
% If |\@rotdblfloat| is defined we have included \textsf{rotating} version $2.10$
% or newer. In this case we can define a star form as well. Otherwise we define
% a star form, too, but this causes an error and will do the non-star form instead.
%
%    \begin{macrocode}
  \renewcommand*\restylefloat[1]{%
    \rotfloat@restyle{#1}%
    \@namedef{sideways#1}{%
      \let\rotfloat@xoftwo\@secondoftwo\columnwidth\textheight
      \@nameuse{fst@#1}\@float{#1}}%
    \expandafter\let\csname endsideways#1\endcsname\rotfloat@end
    \ifx\@rotdblfloat\undefined
      \@namedef{sideways#1*}{%
        \PackageError{rotfloat}{%
          You need rotating version 2.10 or newer to do this}{\@ehd}%
        \@nameuse{sideways#1}}%
      \expandafter\let\csname endsideways#1*\endcsname\rotfloat@end
    \else
      \@namedef{sideways#1*}{%
        \let\rotfloat@xoftwo\@secondoftwo\columnwidth\textheight
        \@nameuse{fst@#1}\@dblfloat{#1}}%
      \expandafter\let\csname endsideways#1*\endcsname\rotfloat@dblend
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rotfloat@end}
% \begin{macro}{\rotfloat@dblend}
% \changes{v1.0a}{1 Apr 95}{Senseless {\tt\protect\bslash egroup} removed}
%
% To understand the following code we first have to understand what is
% going on inside |\float@end|. Well, mainly it looks like this:
% \begin{quote}
% |\newcommand\float@end{%|\\
% |  \egroup|\\
% |  \global\setbox\@currbox\vbox\bgroup|\\
% |  \float@makebox\end@float\egroup}|
% \end{quote}
% The |\egroup| will finish the current definition of the float inside the
% vbox |\@currbox|.
% Afterwards the float is redefined to |\float@makebox| (which will build up a
% new float contents) plus |\end@float| (which will mainly finish the
% definition of the new float with |\egroup|). The |\egroup| finally closes
% the group which started at the beginning of the environment (see |\restylefloat|).
%
% These macros now do the same, but instead of using |\float@makebox| plus
% |\end@float| we set the new float contents to
% \begin{enumerate}
%   \item |\@rotfloat| (but without the contents of the |\@float| itself)
%   \item |\float@makebox| (which includes the contents of the float)
%   \item |\end@rotfloat| (which includes |\egroup|)
% \end{enumerate}
%
% Note that we do not need the final |\egroup| here, because we do not start
% our sideways environments with an extra |\bgroup|.
%
%    \begin{macrocode}
  \newcommand*\rotfloat@end{%
    \egroup%
    \global\setbox\@currbox\vbox\bgroup%
    \def\@float##1[##2]{}\let\@xfloat\@float\@rotfloat{}%
    \float@makebox\end@rotfloat}
  \newcommand*\rotfloat@dblend{%
    \egroup%
    \global\setbox\@currbox\vbox\bgroup%
    \def\@float##1[##2]{}\let\@xfloat\@float\@rotdblfloat{}%
    \float@makebox\end@rotdblfloat}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% So far the code for the version $1.2$ of the float package.
%
%    \begin{macrocode}
\else
%    \end{macrocode}
%
% Now the code for the float package version $1.3$:
%
%    \begin{macrocode}
  \wlog{rotfloat package: v1.3 of float detected}
%    \end{macrocode}
%
% \begin{macro}{\rotfloat@HH}
% \begin{macro}{\rotfloat@restyle}
%
% |\@HHfloat| has changed to |\float@HH| here.
% Furthermore we need to redefine |\float@restyle| instead of |\restylefloat|
% so |\restylefloat*| will still work.
%
%    \begin{macrocode}
  \let\rotfloat@HH\@float@HH
  \let\rotfloat@restyle\float@restyle
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@float@HH}
%
% |\@Hxfloat| has changed to |\float@Hx| here.
%
%    \begin{macrocode}
  \def\@float@HH#1[H]{%
    \rotfloat@xoftwo{\rotfloat@HH{#1}[H]}{\@float@Hx{#1}[!ht]}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\float@restyle}
%
% A |\@float@setevery{#1}| had to be added here.
%
%    \begin{macrocode}
  \renewcommand*\float@restyle[1]{%
    \rotfloat@restyle{#1}%
    \@namedef{sideways#1}{%
      \let\rotfloat@xoftwo\@secondoftwo\columnwidth\textheight
      \@nameuse{fst@#1}\@float@setevery{#1}\@float{#1}}%
    \expandafter\let\csname endsideways#1\endcsname\rotfloat@end
    \ifx\@rotdblfloat\undefined
      \@namedef{sideways#1*}{%
        \PackageError{rotfloat}{%
          You need rotating version 2.10 or newer to do this}{\@ehd}%
        \@nameuse{sideways#1}}%
      \expandafter\let\csname endsideways#1*\endcsname\rotfloat@end
    \else
      \@namedef{sideways#1*}{%
        \let\rotfloat@xoftwo\@secondoftwo\columnwidth\textheight
        \@nameuse{fst@#1}\@float@setevery{#1}\@dblfloat{#1}}%
      \expandafter\let\csname endsideways#1*\endcsname\rotfloat@dblend
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rotfloat@end}
% \begin{macro}{\rotfloat@dblend}
%
% Version $1.3$ of float has a revised code of |\float@end|,
% mainly two things have changed here:
% \begin{itemize}
% \item |\@endfloatbox| is called to finish the current float instead of |\egroup|.
%       Later on it is set to |\relax| so it don't get called within |\end@float| again.
% \item |\float@makebox| has a parameter now, which will be set to |\columnwidth| or
%       |\textwidth|.
%       (In float $1.2$ the |\columnwidth| was hard wired into |\float@makebox|.)
% \end{itemize}
%
% Note that the rotating package has is own code to handle the end of the float,
% so we call |\@endfloatbox| to finish the (empty) float, too, but we don't need
% to copy the trick of setting |\@endfloatbox| to |\relax| and we don't have to
% finish the |\vbox| ourself.
%
%    \begin{macrocode}
  \newcommand*\rotfloat@end{\@endfloatbox
    \global\setbox\@currbox\vbox\bgroup%
    \def\@float##1[##2]{}\let\@xfloat\@float\@rotfloat{}%
    \float@makebox\columnwidth\end@rotfloat}
  \newcommand*\rotfloat@dblend{\@endfloatbox
    \global\setbox\@currbox\vbox\bgroup%
    \def\@float##1[##2]{}\let\@xfloat\@float\@rotdblfloat{}%
    \float@makebox\textwidth\end@rotdblfloat}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% That's all folks.
%
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
% \iffalse
%</package>
% \fi
%
% \Finale
%
\endinput