Debian Codegraph @

texmf-dist/source/latex/rotfloat/rotfloat.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (c) 1995-2004 Axel Sommerfeldt ([email protected])
4 %
5 % This file is part of the rotfloat package.
6 % ------------------------------------------
7 %
8 % It may be distributed and/or modified under the
9 % conditions of the LaTeX Project Public License, either version 1.2
10 % of this license or (at your option) any later version.
11 % The latest version of this license is in
12 % http://www.latex-project.org/lppl.txt
13 % and version 1.2 or later is part of all distributions of LaTeX
14 % version 1999/12/01 or later.
15 %
16 % \fi
17 % \CheckSum{215}
18 %
19 % \iffalse
20 %<*driver>
21 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
22 \documentclass{ltxdoc}
23 \setlength{\parindent}{0pt}
24 \setlength{\parskip}{\smallskipamount}
25 \begin{document}
26 \DocInput{rotfloat.dtx}
27 \end{document}
28 %</driver>
29 % \fi
30 %
31 % \newcommand*{\purerm}[1]{{\upshape\mdseries\rmfamily #1}}
32 % \newcommand*{\puresf}[1]{{\upshape\mdseries\sffamily #1}}
33 % \newcommand*{\purett}[1]{{\upshape\mdseries\ttfamily #1}}
34 %
35 % \changes{v1.0}{30 Mar 95}{First release}
36 % \changes{v1.1}{ 2 Feb 02}{Revised and adapted to new versions of float and rotating}
37 % \changes{v1.1a}{20 Feb 02}{Minor cosmetic changes}
38 % \changes{v1.2}{4 Jan 04}{Revised and support of [H] implemented}
39 %
40 % \GetFileInfo{rotfloat.sty}
41 % \def\fileversion{1.2}
42 % \def\filedate{2004/01/04}
43 % \title{The \puresf{rotfloat} package\thanks{This package has version number
44 % \fileversion, last revised \filedate.}}
45 % \author{Axel Sommerfeldt\\\texttt{[email protected]}}
46 % \date{2004/01/04}
47 % \maketitle
48 %
49 % \begin{abstract}
50 % The \textsf{float} package~\cite{float} provides commands to define new floats
51 % of various styles (|plain|, |boxed|, |ruled|, and userdefined ones);
52 % the \textsf{rotating} package~\cite{rotating} provides new environments (|sidewaysfigure|
53 % and |sidewaystable|) which are rotated by $90^\circ$ or $270^\circ$.
54 % But what about new rotated floats, e.g.\ a rotated ruled one?
55 % This package makes this possible; it builds a bridge between both packages
56 % and extend the commands from the \textsf{float} package to define rotated
57 % versions of the new floats, too.
58 % \end{abstract}
59 %
60 % \section{The user interface}
61 % To use this package just put the line
62 % \begin{quote}
63 % |\usepackage|\oarg{options}|{rotfloat}|
64 % \end{quote}
65 % into the preamble of your document. The options are exactly the same as
66 % for the \textsf{rotating} package, because all options will be passed to
67 % the \textsf{rotating} package.
68 % (The \textsf{rotfloat} package hasn't got any own options at all).
69 %
70 % \DescribeMacro{\newfloat}
71 % \DescribeMacro{\restylefloat}
72 % The commands |\newfloat| and |\restylefloat| from the \textsf{float} package
73 % (re)define the float type \meta{type} and now additionally a rotated one called
74 % \meta{\purett{sideways}type}:
75 % \begin{quote}
76 % |\newfloat|\marg{type}\marg{placement}\marg{ext}\oarg{within}\\
77 % |\restylefloat|\marg{type}
78 % \end{quote}
79 %
80 % \begin{minipage}[t]\textwidth
81 % E.g.\ the code
82 % \begin{quote}
83 % |\floatstyle{ruled}|\\
84 % |\floatname{program}{Program}|\\
85 % |\newfloat{program}{tbp}{lop}[section]|
86 % \end{quote}
87 % defines the new floating environments |program|, |program*|,
88 % |sidewaysprogram|, and |sidewaysprogram*|
89 % which behave equivalent to |figure|, |figure*|,
90 % |sidewaysfigure|, and |sidewaysfigure*|.
91 % (Note that |sidewaysfigure*| has been introduced to version $2.10$ of the \puresf{rotating}
92 % package, therefore you only get a |sidewaysprogram*| environment if you use this or a newer
93 % version of the \puresf{rotating} package.)
94 % \end{minipage}
95 %
96 % \begin{minipage}[t]\textwidth
97 % The code
98 % \begin{quote}\nopagebreak%
99 % |\floatstyle{boxed}|\\
100 % |\restylefloat{table}|
101 % \end{quote}
102 % will restyle the environments |table|, |table*|, |sidewaystable|, and |sidewaystable*|.
103 % \end{minipage}
104 %
105 % Please take a look at the \textsf{float} package for a complete description
106 % of these commands.
107 % Additionally an example file is provided with this package.
108 %
109 % \section{What has changed since version {1.0}?}
110 % Version $1.0$ of this package was a quick \& dirty hack. The
111 % version $1.1$ took it all more serious, it patched less code from
112 % the float package and especially it let the |[H]| code for the
113 % not-sideways floats intact. Furthermore it was adapted to the new
114 % version 1.3 of the float and 2.10 of the rotating package.
115 %
116 % This version $1.2$ is a further step in this direction. It was revised again
117 % to make it even more compatible to different versions of the float package.
118 % As an effect of this |[H]| for sideways floats is now fully supported
119 % (this could be desirable when used in cooperation with the \puresf{afterpage} package),
120 % furthermore a bug was fixed that caused problems if the \puresf{rotfloat}
121 % package was used together with the \puresf{color} package.
122 %
123 % \section{A final note}
124 % This package was tested with the versions $1.2$, $1.2c$, $1.2d$, $1.2e$, $1.3c$,
125 % and $1.3d$ of the \textsf{float} package and version $2.6$, $2.9$, $2.10$, $2.12$,
126 % and $2.13$ of the \textsf{rotating} package.
127 %
128 % You should \emph{not} use this package together with older versions of them!
129 % Future versions of these packages may make some trouble, but I hope they will not.
130 % If they do please don't hesitate to send me a bug report including a simple non-working
131 % example and the log file produced by \LaTeX.
132 %
133 % \section{Further reading}
134 %
135 % I recommend the following documents for further reading:
136 %
137 % \begin{itemize}
138 % \item
139 % The \TeX\ FAQ - Frequently asked questions about \TeX\ and \LaTeX :
140 % \begin{quote}\texttt{http://faq.tug.org/}\end{quote}
141 %
142 % \item
143 % A French FAQ can be found at
144 % \begin{quote}\texttt{http://www.grappa.univ-lille3.fr/FAQ-LaTeX/}\end{quote}
145 %
146 % \item
147 % A German FAQ can be fount at
148 % \begin{quote}\texttt{http://www.dante.de/faq/de-tex-faq/}\end{quote}
149 %
150 % \item
151 % \textsf{epslatex} from Keith Reckdahl contains many tips around
152 % graphics in \LaTeXe. You will find this document in the directory
153 % \begin{quote}\texttt{ftp://ftp.ctan.org/pub/tex/info/}\end{quote}
154 % as \texttt{epslatex.ps} and \texttt{epslatex.pdf}.
155 %
156 % There is also a french translation available at
157 % \begin{quote}\texttt{ftp://ftp.ctan.org/pub/tex/info/fepslatex.ps}\end{quote}
158 %
159 % \item
160 % \emph{``Gleitobjekte -- die richtige Schmierung''} from Axel Reichert
161 % is a German documentation about floating environments in general.
162 % You will find it here:
163 % \begin{quote}\texttt{ftp://ftp.ctan.org/pub/tex/info/german/gleitobjekte/}\end{quote}
164 % \end{itemize}
165 %
166 %
167 % \section{Thanks}
168 %
169 % I would like to thank Katja Melzner, Anselm Lingnau, Sebastian Rahtz,
170 % and \hbox{Wojciech} \hbox{Pietron}.
171 %
172 % \StopEventually{
173 % \begin{thebibliography}{9}
174 % \bibitem{float}
175 % Anselm Lingnau:
176 % \textsl{An Improved Environment for Floats},
177 % 2001/11/08
178 % \bibitem{rotating}
179 % Sebastian Rahtz and Leonor Barroca:
180 % \textsl{A style option for rotated objects in \LaTeX},
181 % 1997/09/26
182 % \end{thebibliography}
183 % }
184 % \setlength{\parskip}{0pt plus 1pt}
185 %
186 % \DoNotIndex{\@ifnextchar,\@ifundefined,\@namedef,\@nameuse}
187 % \DoNotIndex{\bgroup,\columnwidth,\csname,\def,\edef,\egroup,\else,\endcsname}
188 % \DoNotIndex{\empty,\expandafter,\fi,\global,\ifx,\let,\newcommand,\noexpand}
189 % \DoNotIndex{\renewcommand,\setbox,\textheight,\typeout,\undefined,\vbox}
190 % \DoNotIndex{\CurrentOption,\DeclareOption,\ExecuteOptions,\NeedsTeXFormat}
191 % \DoNotIndex{\PassOptionsToPackage,\ProcessOptions,\ProvidesPackage,\RequirePackage}
192 %
193 % \iffalse
194 %<*package>
195 % \fi
196 %
197 % \section{The code}
198 %
199 % \emph{Note:}
200 % If you really want to know what's exactly going on here, you have to study the
201 % code from the packages \textsf{float} and \textsf{rotating} first!
202 %
203 % \subsection{The identification part}
204 %
205 % \begin{macrocode}
206 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
207 \ProvidesPackage{rotfloat}[2004/01/04 v1.2 Combining float+rotating package (AS)]
208 % \end{macrocode}
209 %
210 % \subsection{The package loading part}
211 %
212 % Of course this package needs the \textsf{float} and the \textsf{rotating}
213 % package, so we load them both here.
214 % (The \textsf{rotfloat} package hasn't got any own options, so we just pass
215 % everything we get to the \textsf{rotating} package.)
216 % \changes{v1.1a}{19 Feb 02}{Use \cs{RequirePackageWithOptions} for rotating}
217 %
218 % \begin{macrocode}
219 \RequirePackage{float}[1994/06/20] % >= version 1.2
220 \RequirePackageWithOptions{rotating}%[1995/01/06] % >= version 2.6
221 % \end{macrocode}
222 %
223 % \subsection{Adaption of the float package}
224 % \changes{v1.0a}{1 Apr 95}{Blew \cs{float@end} up}
225 %
226 % We have different code for version $1.2$ and version $1.3$ of
227 % the \textsf{float} package. If |\@float@HH| is not defined we assume
228 % version $1.2$, otherwise version $1.3$.
229 % \changes{v1.1a}{19 Feb 02}{\cs{wlog} changed to \cs{PackageInfo}}
230 %
231 % \begin{macrocode}
232 \ifx\@float@HH\undefined
233 \PackageInfo{rotfloat}{float package v1.2 detected}
234 % \end{macrocode}
235 %
236 % First the code for version $1.2$ of the float package:
237 %
238 % \begin{macro}{\restylefloat}
239 % \changes{v1.0a}{1 Apr 95}{Extra |\bgroup| removed}
240 % \changes{v1.1}{1 Feb 02}{We define a *-sideways float as well}
241 %
242 % The new code for |\restylefloat| behaves like the old one, but it defines
243 % a sideways float as well.
244 % If |\@rotdblfloat| is defined we have loaded \textsf{rotating} version $2.10$
245 % or newer. In this case we can define a star form as well.
246 %
247 % \begin{macrocode}
248 \let\rotfloat@restyle\restylefloat
249 \renewcommand*\restylefloat[1]{%
250 \rotfloat@restyle{#1}%
251 \@namedef{sideways#1}{\rotfloat@float{#1}}%
252 \expandafter\let\csname endsideways#1\endcsname\float@end
253 \ifx\@rotdblfloat\@undefined
254 \else
255 \@namedef{sideways#1*}{\rotfloat@dblfloat{#1*}}%
256 \expandafter\let\csname endsideways#1*\endcsname\float@dblend
257 \fi}
258 % \end{macrocode}
259 % \end{macro}
260 %
261 % \begin{macro}{\rotfloat@float}
262 % \changes{v1.2}{29 Dec 03}{We use the original definitions via |\@namedef| now}
263 %
264 % What differs sideways floats from `normal' ones?
265 % \begin{enumerate}
266 % \item
267 % |\hsize|, |\textwidth|, and |\columnwidth| are set to |\textheight|.
268 % Usually this is done in |\@xrotfloat| (\puresf{rotating} package)
269 % but this time we have to do it for ourself because the \puresf{float}
270 % package handles floats differently:
271 %
272 % It collects its contents ($=$ |\@currbox|) first, so it can build up a new
273 % float contents (including the current one) later on.
274 % This step is neccessary because the \puresf{float} package will take care
275 % of the placement of the |\caption|. Furthermore it can add rules, boxes and
276 % so on here, whatever the actual float style wants to.
277 % (This is done in |\float@makebox|.)
278 %
279 % Note that we don't set |\hsize| here, because |\@xfloat| (part of \LaTeX)
280 % will set |\hsize| to |\columnwidth| anyway.
281 %
282 % \item
283 % We build up the float contents with |\rotfloat@makebox| (instead of
284 % |\float@makebox|) which rotates the contents additionally.
285 % \end{enumerate}
286 %
287 % \begin{macrocode}
288 \newcommand\rotfloat@float{%
289 \textwidth\textheight
290 \columnwidth\textheight
291 \let\rotfloat@@makebox\float@makebox
292 \let\float@makebox\rotfloat@makebox
293 \@nameuse}
294 % \end{macrocode}
295 % \end{macro}
296 %
297 % \begin{macro}{\rotfloat@dblfloat}
298 %
299 % For double column floats we use |\rotdblfloat@makebox| here.
300 %
301 % \begin{macrocode}
302 \newcommand\rotfloat@dblfloat{%
303 \textwidth\textheight
304 \columnwidth\textheight
305 \let\rotfloat@@makebox\float@makebox
306 \let\float@makebox\rotdblfloat@makebox
307 \@nameuse}
308 % \end{macrocode}
309 % \end{macro}
310 %
311 % \begin{macro}{\@HHfloat}
312 % \changes{v1.1}{1 Feb 02}{Leave H-code intact for normal floats}
313 % \changes{v1.2}{29 Dec 03}{Leave H-code intact for sideways floats, too}
314 %
315 % For sideways floats with a placement specifier |[H]| the original code
316 % of |\@HHfloat| from the \puresf{float} package is sufficient.
317 % But we have to take care that at the end of the float |\rotfloat@endH|
318 % will be called instead of |\float@endH| so we can handle them correctly
319 % later on.
320 %
321 % \begin{macrocode}
322 \let\rotfloat@HH\@HHfloat
323 \def\@HHfloat#1{%
324 \expandafter\let\csname endsideways#1\endcsname\rotfloat@endH
325 % \expandafter\let\csname endsideways#1*\endcsname\rotfloat@dblendH
326 \let\end@float\relax
327 \rotfloat@HH{#1}}
328 % \end{macrocode}
329 % \end{macro}
330 %
331 % \begin{macro}{\rotfloat@endH}
332 %
333 % The \puresf{float} package defines this command to close a floating
334 % environment with a |[H]| placement specifier:
335 % \begin{quote}
336 % |\newcommand\float@endH{%|\\
337 % | \egroup| (\emph{or} |\@endfloatbox|)\\
338 % | \vskip\intextsep|\\
339 % | \if@flstyle\float@makebox\egroup\else\box\@currbox\fi|\\
340 % | \vskip\intextsep\relax}|
341 % \end{quote}
342 %
343 % The |\egroup| (or |\@endfloatbox|) will close the |\@currbox| first.
344 % Afterwards the contents of the float will be typeset HERE, surrounded by
345 % some extra skip.
346 % If the float was defined with |\newfloat| or |\restylefloat|,
347 % |\float@makebox| will be used to build up the float contents.
348 % (An extra |\egroup| is needed to finish off the |\bgroup| that
349 % precedes the |\@nameuse| in the |\begin{|\meta{float}|}| commands.
350 % See the code documentation of the \puresf{float} package $v1.2$ for
351 % details.)
352 % Otherwise the vanilla |\@currbox| will be used.
353 %
354 % Here comes our version:
355 % If the float was defined with |\newfloat| or |\restylefloat|
356 % (that means |\if@flstyle| is true)
357 % we can use the original code from the \puresf{float} package
358 % because |\float@makebox| was replaced with |\rotfloat@makebox| anyway.
359 % (See our definition of |\rotfloat@float| for details.)
360 %
361 % But if this is not the case (that means |\if@flstyle| is false)
362 % we have to close the rotated float first.
363 % This is usually done with |\end@rotfloat| (which is part of the
364 % \puresf{rotating} package) but there is a caveat: |\end@rotfloat|
365 % uses |\end@float| which normally closes a floating environment.
366 % But we don't want to support floating here (well, that's why the user
367 % has specified the placement |[H]|), so we re-define |\end@float| to
368 % |\relax| which does simply nothing.
369 % (Note that this re-definition takes place in |\@HHfloat| because
370 % |\end@rotfloat| closes some environments first, so our re-definition
371 % would get lost if we would make it here.)
372 % Afterwards the original code from the \puresf{float} package
373 % ($=$ |\float@endH|) is sufficient again.
374 %
375 % \begin{macrocode}
376 \newcommand\rotfloat@endH{%
377 \if@flstyle
378 \else
379 % \let\end@float\relax
380 \end@rotfloat
381 \fi
382 \float@endH}
383 % \end{macrocode}
384 % \end{macro}
385 %
386 % \begin{macro}{\rotfloat@makebox}
387 %
388 % Finally: The typesetting of a (re-styled) rotated float.
389 %
390 % This is quite simple: We put the |\float@makebox| inside
391 % a rotated environment. For this purpose we use |\@rotfloat|
392 % and |\end@rotfloat| which usually begin and end a rotated floating
393 % environment; they are provided by the \puresf{rotating} package.
394 % But we have to keep the floating stuff outside, so
395 % we define |\@float| (which is used by |\@rotfloat|) and
396 % |\end@float| (which is used by |\end@rotfloat|) to do nothing.
397 %
398 % \begin{macrocode}
399 \newcommand\rotfloat@makebox{%
400 \vbox{%
401 \def\@float##1[##2]{}\let\end@float\relax
402 \@rotfloat{}[]%
403 \rotfloat@@makebox
404 \end@rotfloat}}
405 % \end{macrocode}
406 % \end{macro}
407 %
408 % \begin{macro}{\rotdblfloat@makebox}
409 %
410 % Well, this is quite the same as |\rotfloat@makebox| but we use the
411 % appropriate macros for the star-variants of floating environments here.
412 %
413 % \begin{macrocode}
414 \newcommand\rotdblfloat@makebox{%
415 \vbox{%
416 \def\@float##1[##2]{}\let\end@dblfloat\relax
417 \@rotdblfloat{}[]%
418 \rotfloat@@makebox
419 \end@rotdblfloat}}
420 % \end{macrocode}
421 % \end{macro}
422 %
423 % So far the code for the version $1.2$ of the float package.
424 %
425 % \begin{macrocode}
426 \else
427 % \end{macrocode}
428 %
429 % Now the code for the \puresf{float} package version $1.3$:
430 %
431 % It is mainly the same, so we only tell you the small differences compared to
432 % the code inside the branch for the \puresf{float} package version $1.2$ here.
433 %
434 % \begin{macrocode}
435 \PackageInfo{rotfloat}{float package v1.3 detected}
436 % \end{macrocode}
437 %
438 % \begin{macro}{\float@restyle}
439 % We have to extend |\float@restyle| instead of |\restylefloat| here,
440 % so |\restylefloat*| will still work.
441 % \begin{macrocode}
442 \let\rotfloat@restyle\float@restyle
443 \renewcommand*\float@restyle[1]{%
444 \rotfloat@restyle{#1}%
445 \@namedef{sideways#1}{\rotfloat@float{#1}}%
446 \expandafter\let\csname endsideways#1\endcsname\float@end
447 \ifx\@rotdblfloat\@undefined
448 \else
449 \@namedef{sideways#1*}{\rotfloat@dblfloat{#1*}}%
450 \expandafter\let\csname endsideways#1*\endcsname\float@dblend
451 \fi}
452 % \end{macrocode}
453 % \end{macro}
454 %
455 % \begin{macro}{\rotfloat@float}
456 % \begin{macro}{\rotfloat@dblfloat}
457 % These two don't have to be changed.
458 % \begin{macrocode}
459 \newcommand\rotfloat@float{%
460 \textwidth\textheight
461 \columnwidth\textheight
462 \let\rotfloat@@makebox\float@makebox
463 \let\float@makebox\rotfloat@makebox
464 \@nameuse}
465 \newcommand\rotfloat@dblfloat{%
466 \textwidth\textheight
467 \columnwidth\textheight
468 \let\rotfloat@@makebox\float@makebox
469 \let\float@makebox\rotdblfloat@makebox
470 \@nameuse}
471 % \end{macrocode}
472 % \end{macro}
473 % \end{macro}
474 %
475 % \begin{macro}{\@float@HH}
476 % We have to extend |\@float@HH| instead of |\@HHfloat| here.
477 % \begin{macrocode}
478 \let\rotfloat@HH\@float@HH
479 \def\@float@HH#1{%
480 \expandafter\let\csname endsideways#1\endcsname\rotfloat@endH
481 % \expandafter\let\csname endsideways#1*\endcsname\rotfloat@dblendH
482 \let\end@float\relax
483 \rotfloat@HH{#1}}
484 % \end{macrocode}
485 % \end{macro}
486 %
487 % \begin{macro}{\rotfloat@endH}
488 % This one hasn't to be changed.
489 % \begin{macrocode}
490 \newcommand\rotfloat@endH{%
491 \if@flstyle
492 \else
493 % \let\end@float\relax
494 \end@rotfloat
495 \fi
496 \float@endH}
497 % \end{macrocode}
498 % \end{macro}
499 %
500 % \begin{macro}{\rotfloat@makebox}
501 % \begin{macro}{\rotdblfloat@makebox}
502 % |\float@makebox| has a parameter here which will be set to |\columnwidth| or
503 % |\textwidth|. (In the \puresf{float} package $v1.2$ the |\columnwidth| was
504 % hard wired into |\float@makebox|.) So we have to pass this parameter through
505 % the original version of |\float@makebox| which we have saved to
506 % |\rotfloat@@makebox| within |\rotfloat@float|.)
507 % \begin{macrocode}
508 \newcommand*\rotfloat@makebox[1]{%
509 \vbox{%
510 \def\@float##1[##2]{}\let\end@float\relax
511 \@rotfloat{}[]%
512 \rotfloat@@makebox{#1}%
513 \end@rotfloat}}
514 \newcommand*\rotdblfloat@makebox[1]{%
515 \vbox{%
516 \def\@float##1[##2]{}\let\end@dblfloat\relax
517 \@rotdblfloat{}[]%
518 \rotfloat@@makebox{#1}%
519 \end@rotdblfloat}}
520 % \end{macrocode}
521 % \end{macro}
522 % \end{macro}
523 %
524 % That's all folks.
525 %
526 % \begin{macrocode}
527 \fi
528 % \end{macrocode}
529 %
530 % \iffalse
531 %</package>
532 % \fi
533 % \Finale
534 %
535 \endinput