\def\fileversion{2} \def\filedate{94/04/15} \def\docdate {94/04/15} % % \iffalse %% File: rotating.dtx Copyright (C) 1994 Sebastian Rahtz and Leonor Barroca % A package to provide a rotation environment, and % rotating floats and captions % % This package is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. % %<*driver> \documentclass{ltxdoc} \begin{document} \title{A style option for rotated objects in \LaTeX\thanks{This file has version number \fileversion, last revised \filedate.}} \author{Sebastian Rahtz \and Leonor Barroca} % \address{ArchaeoInformatica\\ % 12 Cygnet Street\\ % York Y02 1AG} % \netaddress{spqr@ftp.tex.ac.uk} % \author{Leonor Barroca} % \address{Department of Computer Science\\University of York\\ % Heslington\\York Y01 5DD} % \netaddress{lmb@minster.york.ac.uk} \date{\filedate} \maketitle \tableofcontents \listoffigures \listoftables \DocInput{rotating.dtx} \end{document} % % \fi % \CheckSum{342} % \begin{abstract} % This article documents a \LaTeX\ package, `rotating.sty', % which perform all the different sorts of % rotation one might like, including complete figures. % \end{abstract} % \section{History} % Sebastian Rahtz first wrote rotation macros in 1988, and has been fighting % with them since. The original trigonometry macros came from Jim Walker (Dept % Mathematics, University of South Carolina); we later borrowed % the trigonometry macros in psfig 1.8. % This set of macros is a complete overhaul of the practice % of rotated \LaTeX\ boxes destined for a PostScript driver. % % We finally decided to clean % these macros up and document them to bare-bones `doc' standard in % order to avoid doing some real work in January 1992. We must thank % Frank Mittelbach and Rainer Sch\"opf for promoting this style of literate % macro writing, and inspiring the rest of us to patch up our sorry % efforts. We apologize for the fact that we have not attempted to make % these macros compatible with `plain'. Life is just too short. % % A modification was supplied 9/2/92 by A. Mason to handle the \TeX % tures driver, chosen with the \verb|\rotdriver{TEXTURES}| option. % The `sidewaysfigure' environment was fixed on 17/3/92 after % suggestions by Rainer Sch\"opf. % % Version 1.7 (5.93) contains modifications (by David Carlisle, {\tt % carlisle@cs.man.ac.uk}) to avoid extra % spaces being generated in the output. Previous versions generated % spaces at the begining of the box if a \verb|%| was not used after the % \verb|\begin{rotate}|, also a space would be produced if a \TeX\ % counter was used instead of an explicit number for the rotation % argument. Similarly white space is now removed at the end of the box. % Also the \verb|\rotatedirection{|{\em direction}\verb|}| % command has been added. If the argument is anything other than {\tt % clockwise} (the default) then the {\tt rotate} and {\tt turn} % arguments will rotate anti-clockwise if given a positive argument. % % Version 1.8 replaces the fixed names for Figure and Table with the % \LaTeX standard\ \verb|\figurename| and \verb|\tablename|; % thanks to Johannes Braams for pointing out the need for this change. % We also belatedly record in the source the fact that the trigonometry % macros were written by Phil Taylor! % % Version 1.9 changed the sideways figure commands according to suggestions % from Donald Arseneau to not use their own numbering etc arrangement, but just % follow the normal figures and tables. % % Version 2.0 is a complete re-write, with most of the work now % being done by the \LaTeXe\ graphics package. % \section{Usage} % This style option provides three \LaTeX\ environments: % \begin{description} % \item[sideways] prints the contents turned through 90 degrees % counterclockwise % \item[turn] prints the contents turned through an arbitrary angle % \item[rotate] prints the contents turned through an arbitrary angle % but does {\em not} leave any space for the result % \end{description} % A full set of examples are given in the file |examples.tex| % Now we present the documented code. % \section{Setup} % \StopEventually{} % \begin{macrocode} %<*package> \ProvidesPackage{rotating}[\filedate\space\fileversion\space SPQR] \NeedsTeXFormat{LaTeX2e} \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{graphics}} \ProcessOptions \RequirePackage{graphics} \immediate\write\sixt@@n{Style option: rotating \fileversion\space <\filedate> (SPQR / LMB)} % \end{macrocode} % \section{Turning and rotation environments} % \begin{macro}{sideways} % Environment to turn the contents through 90 degrees. % \begin{macrocode} \def\sideways{% \Grot@setangle{90}% \setbox\z@\hbox\bgroup\ignorespaces} \def\endsideways{% \unskip\egroup \Grot@x\z@ \Grot@y\z@ \Grot@box } % \end{macrocode} % \end{macro} % \begin{macro}{turn} % Rotate the contents of the environment, leaving the appropriate space % \begin{macrocode} \def\turn#1{% \Grot@setangle{#1}% \setbox\z@\hbox\bgroup\ignorespaces} \def\endturn{% \unskip\egroup \Grot@x\z@ \Grot@y\z@ \Grot@box } % \end{macrocode} % \end{macro} % \begin{macro}{rotate} % Rotate the contents of the environment, leaving \emph{no space}. % \begin{macrocode} \def\rotate#1{% \Grot@setangle{#1}% \setbox\z@\hbox\bgroup\ignorespaces} \def\endrotate{% \unskip\egroup \Grot@x\z@ \Grot@y\z@ \wd0\z@\dp0\z@\ht0\z@ \Grot@box } % \end{macrocode} % \end{macro} % \begin{macro}{\turnbox} % A macro version of the `rotate' environment. % \begin{macrocode} \def\turnbox#1#2{% \Grot@setangle{#1}% \setbox\z@\hbox{{#2}}% \Grot@x\z@\Grot@y\z@ \wd0\z@\dp0\z@\ht0\z@ \Grot@box } % \end{macrocode} % \end{macro} % \section{Sideways figures and tables} % Now for the macros to provide a complete % environment for sideways figures and tables. % We define two environments \verb|sidewaysfigure| and % \verb|sidewaystable| that % fit in with the normal table and figure floats. These are `fixed' % environments that just do 90 degree rotation, but it would be easy % to parameterize this to do other rotations if needed (the mind % boggles\ldots) % % First a % generalised `rotfloat' environment. We have to take a copy of % \LaTeX's float macros, in order to change the assumed width of a % float being \verb|\columnwidth|. We want it to work on a width of % \verb|\textheight| so that when we rotate the float, it comes out % the right height. This is not actually very satisfactory, since what % we {\em really} want is for rotated floats to occupy the space they % actually {\em use}. The captions are a problem --- since they can % precede the figure or table, we cannot set them in a box of the % right width (ie the {\em height} of the forthcoming object), because % it has not happened yet. The result of these difficulties is that % rotated figures always end up as full page figures. % \begin{macrocode} \def\@rotfloat#1{\@ifnextchar[{\@xrotfloat{#1}}{% \edef\@tempa{\noexpand\@xrotfloat{#1}[\csname fps@#1\endcsname]}\@tempa}} \def\@xrotfloat#1[#2]{\ifhmode \@bsphack\@floatpenalty -\@Mii\else \@floatpenalty-\@Miii\fi\def\@captype{#1}\ifinner \@parmoderr\@floatpenalty\z@ \else\@next\@currbox\@freelist{\@tempcnta\csname ftype@#1\endcsname \multiply\@tempcnta\@xxxii\advance\@tempcnta\sixt@@n \@tfor \@tempa :=#2\do {\if\@tempa h\advance\@tempcnta \@ne\fi \if\@tempa t\advance\@tempcnta \tw@\fi \if\@tempa b\advance\@tempcnta 4\relax\fi \if\@tempa p\advance\@tempcnta 8\relax\fi }\global\count\@currbox\@tempcnta}\@fltovf\fi \global\setbox\@currbox\vbox\bgroup % \end{macrocode} % The only part changed is the setting of \verb|\hsize| within the % \verb|\vbox| to be \verb|\textheight| instead of \verb|\columnwidth|. % \begin{macrocode} \hsize\textheight \@parboxrestore } % \end{macrocode} % We copy the `\verb|\end@float|' macro and emend it to rotate the box we % produce in a float. The rotation is either clockwise or % anti-clockwise, depending on the macro \verb|\rotfloatpage|, % so that it can be adjusted for two-sided layout % (by hand at present). The macro must be set to L or R --- it % defaults to R. % \begin{macrocode} \def\page@L{L} \def\end@rotfloat{\par\vskip\z@\egroup% \ifnum\@floatpenalty <\z@ \global\setbox\@tempboxa\box\@currbox \message{Adding sideways figure on }% \global\setbox\@currbox\vbox to \wd\@tempboxa{% \ifx\rotfloatpage\page@L \message{left hand page }% \vfill\centerline{% \hbox to \ht\@tempboxa{\hfill \turnbox{90}{\box\@tempboxa}% }% }% \else \message{right hand page }% \centerline{% \hbox to \ht\@tempboxa{% \turnbox{-90}{\box\@tempboxa}% \hfill}% }\vfill \fi }% \@cons\@currlist\@currbox \ifdim \ht\@currbox >\textheight \@warning{Float larger than \string\textheight}% \ht\@currbox\textheight \fi \ifnum\@floatpenalty <-\@Mii \penalty -\@Miv \@tempdima\prevdepth \vbox{}% \prevdepth \@tempdima \penalty\@floatpenalty \else \vadjust{\penalty -\@Miv \vbox{}\penalty\@floatpenalty}\@esphack \fi\fi} % \end{macrocode} % The following definitions set up two environments, % \texttt{sidewaystable} and \texttt{sidewaysfigure}, which uses this % type of float. Naturally, users may need to change these to suit % their local style. Both contribute to the normal lists of figures % and tables. % \begin{macrocode} \def\sidewaysfigure{\let\make@caption\make@rcaption \@rotfloat{figure}} % \let\endsidewaysfigure\end@rotfloat % \def\sidewaystable{\let\make@caption\make@rcaption \@rotfloat{table}} \let\endsidewaystable\end@rotfloat % \end{macrocode} %We need to copy a standard %\verb|\@makecaption| to set the caption on a width of the {\em height} %of the float (ie the text height). This macro is normally defined in %\LaTeX\ style files, so style file writers who change that will also %need to redefine \verb|\r@caption|. % \begin{macrocode} \long\def\@makercaption#1#2{% \vskip 10\p@ \setbox\@tempboxa\hbox{#1: #2}% \ifdim \wd\@tempboxa >\vsize #1: #2\par \else \hbox to\vsize{\hfil\box\@tempboxa\hfil}% \fi}% % \end{macrocode} %\subsection{Rotated captions only} % Sometimes you may find that the rotation of complete figures does % not give quite the right result, since they always take up the whole % page. You may prefer to rotate the caption and the float contents % separately within a conventional figure. Here we offer a suggestion % for a \verb|\rotcaption| command, which inserts the caption rotated % by 90 degrees. It is essentially a copy of the normal captioning % code. % Styles which define the \verb|\@makecaption| command may also need % to define \verb|\@makerotcaption|. % \begin{macrocode} \def\rotcaption{\refstepcounter\@captype\@dblarg{\@rotcaption\@captype}} \long\def\@rotcaption#1[#2]#3{% \addcontentsline{\csname ext@#1\endcsname}{#1}{% \protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}% \par \begingroup \@parboxrestore \normalsize \@makerotcaption{\csname fnum@#1\endcsname}{#3}% \endgroup} \long\def\@makerotcaption#1#2{% \setbox\@tempboxa\hbox{#1: #2}% \ifdim \wd\@tempboxa > .8\vsize \rotatebox{90}{% \begin{minipage}{.8\textheight}#1 #2\end{minipage}% }\par \else% \rotatebox{90}{\box\@tempboxa}% \fi \hspace{12pt}% } % \end{macrocode} % % \Finale \endinput %