| 1 |
\documentclass[12pt,twocolumn]{article} |
| 2 |
\usepackage[a4paper]{geometry} |
| 3 |
\title{\texttt{rotpages.sty} --- Multiple page rotation in \LaTeX} |
| 4 |
\author{Sergio Callegari} |
| 5 |
\date{January 25th, 2002} |
| 6 |
|
| 7 |
\begin{document} |
| 8 |
\maketitle |
| 9 |
\thispagestyle{empty} |
| 10 |
|
| 11 |
\begin{abstract} |
| 12 |
This \LaTeX\ package permits to format documents where small sets of |
| 13 |
pages are rotated by 180 degrees and rearranged, so that they can be |
| 14 |
read by turning the printed copy upside-down. It was primarly meant |
| 15 |
for collecting exercises and solutions: the package permits to print |
| 16 |
the exercise text normally and the solution text upside-down in |
| 17 |
order to make it a bit harder for the students to unintentionally |
| 18 |
read the solutions before solving the exercises autonomously. Other |
| 19 |
uses are obviously possible. |
| 20 |
\end{abstract} |
| 21 |
|
| 22 |
|
| 23 |
\section{Introduction} |
| 24 |
%% |
| 25 |
The package \emph{rotpages.sty} is meant to be used when parts of a |
| 26 |
document should be made purposely difficult to read or obfuscated. An |
| 27 |
obvious way to make something difficult to read is to print it |
| 28 |
upside-down. This is well known by all those keen on puzzles and |
| 29 |
cross-words as in puzzle magazines the solutions are often printed |
| 30 |
``the wrong way'' to prevent the readers from spoiling the |
| 31 |
pleasure of the quiz by unintentionally reading the solutions. |
| 32 |
|
| 33 |
A similar situation emerges in collecting exercises and solutions as |
| 34 |
an aid for students training. The solutions must be there, so that the |
| 35 |
students can check their results and avoid getting stuck when they |
| 36 |
cannot answer some questions. At the same time the solutions should |
| 37 |
not be easily readable, otherwise the temptation to read them before |
| 38 |
attempting to solve a problem can be too strong. A typical format for |
| 39 |
exercise collections consists in putting all the exercises at the |
| 40 |
beginning and all the answers at the end. However, this makes people |
| 41 |
flap pages back and forth all the time. Having the solutions close to |
| 42 |
the relevant exercises and obfuscating them by page rotation can |
| 43 |
be an alternative practice. |
| 44 |
|
| 45 |
In \LaTeX, it is very easy to rotate small amounts of text. The package |
| 46 |
\texttt{graphics} is a valid aid in this sense. However, it is not easy |
| 47 |
to deal with large amounts of text. If the rotated material has to |
| 48 |
span many pages, it cannot be put in a \verb|\rotatebox| command. |
| 49 |
Furthermore, if many pages need to be rotated, it is not sufficient to |
| 50 |
flip them individually: they must also be rearranged so that they |
| 51 |
appear in the proper order when the printed copy of the document is |
| 52 |
read ``upside-down''. |
| 53 |
|
| 54 |
The package \texttt{rotpages.sty} permits to rotate a few pages, |
| 55 |
rearranging them consistently and preserving the normal \LaTeX\ |
| 56 |
algorithm for breaking the material into pages. |
| 57 |
|
| 58 |
|
| 59 |
\section{Usage} |
| 60 |
%% |
| 61 |
The package defines two basic commands: \verb|\rotboxpages| and |
| 62 |
\verb|\endrotboxpages|, which take no arguments. |
| 63 |
|
| 64 |
The command \verb|\rotboxpages| closes the current page and delimits |
| 65 |
the beginning of the text which should be typeset upside-down. The |
| 66 |
command \verb|\endrotboxpages| marks the end of the region which is |
| 67 |
typeset upside-down and makes sure that the rotated pages are flushed |
| 68 |
onto the \texttt{dvi} file. Then it opens a fresh page. The rotated |
| 69 |
material is by default printed surrounded by a frame (but this can be |
| 70 |
changed). Page headers and footers continue display the proper way. |
| 71 |
|
| 72 |
When used in two-column mode, the package correctly rotates the |
| 73 |
columns independently, rearranging them if necessary. The rotated |
| 74 |
columns get individually framed. Note that the package might not |
| 75 |
operate correctly with other packages that also alter the paging |
| 76 |
algorithms. |
| 77 |
|
| 78 |
The files in the \texttt{Examples} directory provide some usage |
| 79 |
examples. |
| 80 |
|
| 81 |
\subsection{Personalization} |
| 82 |
%% |
| 83 |
The behaviour of \texttt{rotpages.sty} can be largely |
| 84 |
personalized. Rotpages can frame the rotated pages, scale them, |
| 85 |
enhance them with notes (e.g. ``rotate the book to read this page |
| 86 |
properly'') and so on. All this is done by means of two ``hooks''. |
| 87 |
|
| 88 |
The first hook is set by renewing the command |
| 89 |
\verb|\rotboxAtRotationHook|. Whenever \LaTeX\ has finished preparing |
| 90 |
a page or a column and rotation is activated, \texttt{rotpages.sty} |
| 91 |
assures that the material is not directly shipped to the dvi file. On |
| 92 |
the contrary, the material is put into a box and this box is saved |
| 93 |
onto a stack. When the rotation mode is terminated, all the boxes |
| 94 |
saved onto the stack are shipped to the dvi file in inverse order. The |
| 95 |
stack mechanism is obviously necessary because the pages need to be |
| 96 |
rearranged while flipped upside down. The \verb|\rotboxAtRotationHook| |
| 97 |
is invoked on the pages/columns just before saving them onto the stack |
| 98 |
(i.e.\@ right after rotation). Hence the \verb|\rotboxAtRotationHook| |
| 99 |
takes a box as its argument and should return a box. In the simplest |
| 100 |
case the \verb|\rotboxAtRotationHook| command can just return its |
| 101 |
argument. In more complex scenarios it can put a frame around it and |
| 102 |
so on. |
| 103 |
|
| 104 |
The second hook is set by renewing the command |
| 105 |
\verb|\rotboxAtShippingHook|. The idea is the same as for the |
| 106 |
\verb|\rotboxAtRotationHook|, however this hook is invoked when taking |
| 107 |
the pages off the stack rather than while putting them onto the stack. |
| 108 |
|
| 109 |
In most cases the two hooks can be used indifferently. However there |
| 110 |
is a very subtle difference among the two. When putting the pages onto |
| 111 |
the stack one can easily keep trace of the relative number of the page |
| 112 |
among the lot that is being rotated, but cannot know the actual page |
| 113 |
number as this will be determined only at shipping time. On the |
| 114 |
contrary, when taking the pages out of the stack one can know the |
| 115 |
actual page number, because the shipping is effectively taking place. |
| 116 |
This differenc can be used to add numbering labels and |
| 117 |
rotated/non-rotated text to the pages being rotated as one of the |
| 118 |
files in the \texttt{Examples} directory shows. |
| 119 |
|
| 120 |
In any case, consider that \texttt{rotpages.sty} has no problems in |
| 121 |
dealing with labels and page-references and does so in the expected |
| 122 |
way, i.e.\@ using the ``actual'' page numbers. |
| 123 |
|
| 124 |
The default for the two hooks \verb|\rotboxAtShippingHook| and |
| 125 |
\verb|\rotboxAtRotationHook| is the following: the |
| 126 |
\verb|\rotboxAtRotationHook| frames the page, and the |
| 127 |
\verb|\rotboxAtShippingHook| does nothing. |
| 128 |
|
| 129 |
The package \texttt{rotpages.sty} also defines a couple of lengths: |
| 130 |
\verb|\rotboxheight| and \verb|\rotboxwidth|. These are related to the |
| 131 |
size of the rotated pages/columns. It is the user responsibility to |
| 132 |
assure that the rotated pages are exactly as large as the normal ones. |
| 133 |
However, if a page is framed, one must take into account that the |
| 134 |
frame occupies space. If this fact were not considered, the rotated |
| 135 |
pages would come out with smaller characters than the normal ones. In |
| 136 |
fact, the text \emph{plus the frame} should occupy as much space as a |
| 137 |
normal page. The solution to overcome this problem is to put slightly |
| 138 |
less text on the pages which get rotated, i.e.\@ to format the text |
| 139 |
for a \emph{virtual} page which is smaller than the normal ones, |
| 140 |
accounting for the frame. The lengths \verb|\rotboxheight| and |
| 141 |
\verb|\rotboxwidth| have exactly this purpose, setting the size of the |
| 142 |
virtual pages on which the text to be rotated gets formatted. |
| 143 |
|
| 144 |
The default for \verb|\rotboxheight| and \verb|\rotboxwidth| is the |
| 145 |
size of a normal page, less the space occupied by the default frame. |
| 146 |
|
| 147 |
To conclude, the \texttt{rotpages.sty} package defines a boolean |
| 148 |
variable which can be used to test whether the current text is being |
| 149 |
rotated or not. This is the variable \verb|\boolean{rotboxactive}| |
| 150 |
which can be tested using the \verb|\ifthenelse| command. |
| 151 |
|
| 152 |
|
| 153 |
\section{Known bugs and quirks} |
| 154 |
%% |
| 155 |
The package is unable to deal with float material. Avoid float |
| 156 |
material in the rotated pages. Equations, quotations, displayed math |
| 157 |
and other non-float material can safely be used. |
| 158 |
|
| 159 |
Apart from this, the package is relatively young and no bugs are known |
| 160 |
so far. It should be observed that the \texttt{.dvi} files produced |
| 161 |
with \texttt{rotpages.sty} cannot be viewed properly with |
| 162 |
\texttt{xdvi}, \texttt{kdvi} and most dvi previewers. However, this is |
| 163 |
not a problem of \texttt{rotpages.sty}, rather of \texttt{xdvi} which |
| 164 |
does not understand correctly some of the \verb|\special|s produced by |
| 165 |
the \texttt{graphics} package which is internally invoked by |
| 166 |
\texttt{rotpages} for the page rotation. The postscript files produced |
| 167 |
by \texttt{dvips} display and print correctly. The package is also |
| 168 |
compatible with pdf\LaTeX. |
| 169 |
|
| 170 |
In order to re-arrange the pages which are rotated, the shipping of |
| 171 |
the formatted material to the \texttt{dvi} file needs to be deferred |
| 172 |
until all the rotated pages are processed. This puts a limit on the |
| 173 |
number of pages which can be rotated at once, since the deferring |
| 174 |
mechanisms uses a stack which eats up the \LaTeX\ memory. |
| 175 |
|
| 176 |
\section{Internal operation} |
| 177 |
%% |
| 178 |
The package works by redefining the \verb|\@makecol| macro, which is |
| 179 |
normally used by \LaTeX\ to format and ship a page to the dvi file. |
| 180 |
Particularly, at the \verb|\rotboxpages| command, the \verb|\@opcol| |
| 181 |
and the \verb|\@startcolumn| macros are temporarily disabled, so that |
| 182 |
no page gets shipped to the \texttt{dvi} file and no page number can |
| 183 |
be updated. Also the current page size is altered, following the |
| 184 |
\verb|\rotboxheight| and \verb|\rotboxwidth| lengths. Furthermore, the |
| 185 |
\verb|\@makecol| macro is temporarily modified, so that the formatted |
| 186 |
pages get processed by the \verb|\rotboxAtRotationHook| command, |
| 187 |
rotated and accumulated into a stack. |
| 188 |
|
| 189 |
At the \verb|\endrotboxpages| command, the behaviour of \LaTeX\ gets |
| 190 |
reset to the standard. After that, the pages that had been accumulated |
| 191 |
onto the \texttt{rotpages} stack are processed by the |
| 192 |
\verb|\rotboxAtShippingHook| command, scaled to a normal page size and |
| 193 |
flushed to the \texttt{dvi} file. The stack mechanism assures that the |
| 194 |
pages get to the \texttt{dvi} file in the correct (rearranged) order. |
| 195 |
|
| 196 |
For the page rotation, \texttt{rotpages.sty} relies on the standard |
| 197 |
\texttt{graphics} package and so does for scaling. |
| 198 |
|
| 199 |
\section{To-do} |
| 200 |
%% |
| 201 |
\begin{itemize} |
| 202 |
\item Allow the package to pass options to the underlying graphics |
| 203 |
package, particularly concerning the drivers (dvips, xdvi, etc.) to |
| 204 |
use. |
| 205 |
\item Make the package deal correctly with float material (maybe hard |
| 206 |
to do). |
| 207 |
\item Check the compatibility of the package with other packages. |
| 208 |
\end{itemize} |
| 209 |
\end{document} |
| 210 |
|
| 211 |
%%% Local Variables: |
| 212 |
%%% mode: latex |
| 213 |
%%% TeX-master: t |
| 214 |
%%% End: |