Debian Codegraph @

texmf-dist/tex/generic/dvips/rotate.sty

raw
1 %
2 % These macros allow you to rotate or flip a \TeX\ box. Very useful for
3 % sideways tables or upsidedown answers.
4 %
5 % To use, create a box containing the information you want to rotate.
6 % (An hbox or vbox will do.) Now call \@rotr\boxnum to rotate the
7 % material and create a new box with the appropriate (flipped) dimensions.
8 % \@rotr rotates right, \@rotl rotates left, \@rotu turns upside down, and
9 % \@rotf flips. These boxes may contain other rotated boxes.
10 %
11 \newdimen\@rotdimen
12 \newbox\@rotbox
13
14 \def\@vspec#1{\special{ps:#1}}% passes #1 verbatim to the output
15 \def\@rotstart#1{\@vspec{gsave currentpoint currentpoint translate
16 #1 neg exch neg exch translate}}% #1 can be any origin-fixing transformation
17 \def\@rotfinish{\@vspec{currentpoint grestore moveto}}% gets back in synch
18 %
19 % First, the rotation right. The reference point of the rotated box
20 % is the lower right corner of the original box.
21 %
22 \def\@rotr#1{\@rotdimen=\ht#1\advance\@rotdimen by\dp#1%
23 \hbox to\@rotdimen{\hskip\ht#1\vbox to\wd#1{\@rotstart{90 rotate}%
24 \box#1\vss}\hss}\@rotfinish}
25 %
26 % Next, the rotation left. The reference point of the rotated box
27 % is the upper left corner of the original box.
28 %
29 \def\@rotl#1{\@rotdimen=\ht#1\advance\@rotdimen by\dp#1%
30 \hbox to\@rotdimen{\vbox to\wd#1{\vskip\wd#1\@rotstart{270 rotate}%
31 \box#1\vss}\hss}\@rotfinish}%
32 %
33 % Upside down is simple. The reference point of the rotated box
34 % is the upper right corner of the original box. (The box's height
35 % should be the current font's xheight, \fontdimen5\font,
36 % if you want that xheight to be at the baseline after rotation.)
37 %
38 \def\@rotu#1{\@rotdimen=\ht#1\advance\@rotdimen by\dp#1%
39 \hbox to\wd#1{\hskip\wd#1\vbox to\@rotdimen{\vskip\@rotdimen
40 \@rotstart{-1 dup scale}\box#1\vss}\hss}\@rotfinish}%
41 %
42 % And flipped end for end is pretty ysae too. We retain the baseline.
43 %
44 \def\@rotf#1{\hbox to\wd#1{\hskip\wd#1\@rotstart{-1 1 scale}%
45 \box#1\hss}\@rotfinish}%
46 %
47 % Now the user interface for LaTeX: \rotate[type]{text} where
48 % ``type'' is `l' for left, `r' for right, `u' for upside-down, or
49 % `f' for flip. `l' is the default.
50 %
51 \def\rotate{\@ifnextchar[{\@rotate}{\@rotate[l]}}
52 \def\@rotate[#1]#2{\setbox\@rotbox=\hbox{#2}\@nameuse{@rot#1}\@rotbox}
53