%% LaTeX Macros for PostScript rotation of text %% Sebastian Rahtz, Dept. of Computer Science, Southampton University %% Paul Barton-Davis, Dept. of Computer Science, University of Washington %% 10-sep-91 pad - added code supplied by Peter Bloomfield from %% Tom Rockiki's dvips to eliminate dependence %% on the prologue. %% %% 13-Mar-89 pad - added "global" keyword to \special to stop %% dvi2ps from wrapping the rotated text %% up in @begin-, @start- and @endspecials. %% \@verbps{TEXT} outputs TEXT directly to the DVI file, with no %% surrounding context. Following are 3 definitions for 3 different %% DVI->PostScript drivers. The key part of these is that the %% \special's argument must NOT be enclosed in any context saving %% mechanism. Each driver has a different method for specifying this. %% %% For Rockiki's dvips %% \def\@verbps#1{\special{ps:#1}} % \def\@verbps#1{\special{" #1}} % my try %% from dvips.man: \special{" text} %% %% For a modified dvi2ps that has the "global" modifier for pstext %% %\def\@verbps#1{\special{global pstext="#1"}} %% %% For Bechtolstein's dvitps %% % had to UNDO this one!!! % \def\@verbps#1{\special{dvitps: Literal "#1"}} %% %% The box we put rotated text into %% \newsavebox{\swbox}\newlength{\spht}\newlength{\spwd} %% %% \begin{rotate}{DEGREES} %% TEXT %% \end{rotate} %% %% rotates TEXT by DEGREES, but puts TEXT into a box with zero size. %% Use this for special effects. The "turn" environment, below, %% is probably closer to what you want for normal rotation, %% because it calculates the correct box size. \newenvironment{rotate}[1]{\def\rotangle{#1}\savebox{\swbox}\bgroup}{% \egroup \global\spwd=\dp\swbox \global\advance\spwd by \ht\swbox \global\spht=\wd\swbox% %% do the PostScript magic \@verbps{gsave currentpoint currentpoint translate \rotangle\space rotate neg exch neg exch translate}% \dp\swbox=0pt\wd\swbox=0pt\ht\swbox=0pt% \usebox{\swbox} %% End the PostScript magic \@verbps{grestore} } % % macros to calculate sines from 90 to -90 % Jim Walker, Dept Mathematics, University of South Carolina % \newdimen\x \newdimen\y \newdimen\xsquare \newdimen\xfourth {% \catcode`\p=12 \catcode`\t=12 \gdef\numonly#1pt{% \def\xx{#1}% }% }% \def\MULTyBYx{% \expandafter\numonly\the\x \edef\b{\y=\xx\y}% \b }% \def\calcsin{% Find sin(\x) and put it in \y. Say \x is in degrees. \x=0.0174533\x % Convert to radians. \y=\x \MULTyBYx \xsquare=\y \MULTyBYx \MULTyBYx \xfourth=\y \y=1pt \advance\y by -0.1666666\xsquare \advance\y by 0.008333333\xfourth \MULTyBYx }% % % Example of use: %\x=23pt \calcsin \expandafter\numonly\the\y % Now \xx should contain the sine of 23 degrees. % % given a box with width W and height H, then its height after rotation by R % is W * sin(R) + H * cos(R), and it extends W * cos(R) to the right % and H * sin(R) to the left % (arithmetic courtesy of Nico Poppelier) % \newdimen\xh\newdimen\xw\newdimen\xtemp\newdimen\xcos\newdimen\xsin \newdimen\xleft\newdimen\xright \def\MULTxtempBYxcos{\expandafter\numonly\the\xcos\edef\b{\xtemp=\xx\xtemp}\b}% \def\MULTxtempBYxsin{\expandafter\numonly\the\xsin\edef\b{\xtemp=\xx\xtemp}\b}% %% %% %% \begin{turn}{DEGREES} %% TEXT %% \end{turn} %% %% rotates TEXT by DEGREES, and puts into a box corresponding to %% the size of the rotated material. Use this to rotate text when %% you want the surrounding material to take account of the rotation. \newenvironment{turn}[1]{\def\rotangle{#1}\savebox{\swbox}\bgroup}{% \egroup \global\spht=\dp\swbox \global\advance\spht by \ht\swbox \global\spwd=\wd\swbox% \xtemp=\rotangle pt % convert rotation to dimension \multiply\xtemp by -1 \x=\xtemp\calcsin\xsin=\y \multiply\xtemp by -1\advance\xtemp by 90pt\x=\xtemp\calcsin\xcos=\y % \xsin =sin (R) and \xcos = cos(R) \xtemp=\spwd\MULTxtempBYxsin\xh=\xtemp \xtemp=\spht\MULTxtempBYxcos\advance\xh by \xtemp %\xh contains the height \xtemp=\spht\MULTxtempBYxsin\xleft=\xtemp \xtemp\spwd\MULTxtempBYxcos\xright=\xtemp % \xleft and \right are offsets \rule{\xleft}{0pt}% %% do the PostScript magic \@verbps{gsave currentpoint currentpoint translate \rotangle\space rotate neg exch neg exch translate}% \dp\swbox=0pt\wd\swbox=0pt\ht\swbox=0pt% \rlap{\usebox{\swbox}}% \@verbps{grestore} \rlap{\rule{0pt}{\xh}}\rule{\xright}{0pt}% } %% %% Print it sideways %% \newenvironment{sideways}{\begin{turn}{-90}}{\end{turn}} %1994 April 17 %landscape/rotate/3 % %Host zebra.cns.udel.edu (128.175.8.11) %Last updated 10:46 2 Apr 1994 % %Location: /pub/tex/workshoptug92/LaTeXstyles %FILE -rw-r--r-- 4348 bytes 00:00 4 Aug 1992 nrotate.sty % % %1. alter nrotate to be %%% For Rockiki's dvips %%% %\def\@verbps#1{\special{ps:#1}} % %2. alter nrotate to remove %% \def\@verbps#1{\special{dvitps: Literal "#1"}} % %3. \documentstyle[12pt,nrotate]{article} % %4. useage: %******************************************************************************** %\documentstyle[12pt,nrotate]{article} % %\begin{document} % %here is some regular text % %\begin{sideways} %Try just a bit of pure % %text first %\end{sideways} % %and a bit more of the same % %\begin{table}[P] %\begin{center} %\begin{sideways} %\begin{tabular}{|llcc|} %\hline % %bubble %& burble %& bake %& buy %\\ % %& bunch %& bungie %& bungle %\\ \hline % %{\em diamond} %& pretty %& hopeful %& never %\\ % %{\em gold} %& ugly %& tearful %& silly %\\ % %{\em tea} %& turtle %& taxes %& trampoline %\\ \hline %\end{tabular} %\end{sideways} %\end{center} % %\caption{A silly example} \label{table.example} %This is just a made up example. %\end{table} % %\end{document} %******************************************************************************** % %The table and center environments cannot be put inside the sideways.