summaryrefslogtreecommitdiff
path: root/macros/generic/misc/rotate-textures.sty
blob: 89454382b6827602727c06f119442bdc84bbde82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
% Rotation of TeX output with TeXtures (and maybe? other PostScript drivers)

% Written by 
%   Charles Karney
%   Plasma Physics Laboratory   Phone:   +1 609 243 2607
%   Princeton University        MFEnet:  Karney@PPC.MFEnet
%   PO Box 451                  ARPAnet: Karney%PPC.MFEnet@NMFECC.ARPA
%   Princeton, NJ 08543-0451    Bitnet:  Karney%PPC.MFEnet@ANLVMS.Bitnet

% User instructions:

% If you use TeXtures (TeX on the Macintosh), you can rotate portions of TeX
% output by arbitrary angles.  In order to accomplish this you need to:

% (1) Transfer the file TEX$INPUTS:ROTATE.STY to your Macintosh and it in the
%     "TeX inputs" folder.
% (2) Specify rotate as an optional argument to \documentstyle, e.g.,
%     \documentstyle[11pt,rotate]{article}
% (3) Use the construction
%     {\rotate{angle}Text-to-be-rotated}

% Notes:

% (1) The rotation is made only with TeXtures outputting to a PostScript
% printer (e.g., a LaserWriter).  The screen preview and the ImageWriter
% output will show the text unrotated.

% (2) The rotation angle is measured in degrees.  It can be positive or
% negative, real or integer.  The best results are obtained when the angle is
% a multiple of 90 degrees.

% (3) The point about which the text is rotated is the location of the
% \rotate command.  In the example above it would be the bottom left corner
% of the initial "T".

% (4) Normal TeX grouping serves to delimit the scope of the rotation.
% \rotate should always appear in a group.  If you want to get all the TeX
% output rotated by 90 degrees, select Landscape mode in the Print Setup
% Dialog.

% (5) \rotate is effectively a no-op with drivers other than TeXtures.  Thus
% you can include \rotate's in a file which you print on the QMS printers.
% In order to get the rotation, however, you must transfer either the TeX
% source or the DVI file to the Mac for printing with TeXtures.

% (6) The position of the text outside the scope of the rotation is the same
% as if the \rotate command were a no-op.  Thus for example
%     abc{\rotate{-90}def}ghi
% prints as
%     abc   ghi
%        d
%        e
%        f

% (7) Rotations can be stacked, e.g.,
%     abc{\rotate{-90}def\rotate{-90}ghi}jkl
% would print as
%     abc      jlk
%        d
%        e
%        f
%     ihg
% except that the letters ``def'' would be sideways, and ``ghi'' would be
% upside down.  This is to be compared with
%     abc{\rotate{-90}def}{\rotate{-90}ghi}jkl
% which prints as
%     abc      jlk
%        d  g
%        e  h
%        f  i

% (8) \rotate can be useful in picture environments, e.g., when writing the y
% axis label.  E.g.,
%     \put(-50,100){\rotate{90}\makebox(0,0){$\tan\theta$}}
% Here the \makebox centers the argument at the location of the \put.  Thus
% the text is rotated about the bottom-center of $\tan\theta$.

% Technical details:

% The following assumptions are made about the PostScript that TeXtures
% generates:
% (1) A single transform is used for all TeXtures output.
% (2) The PostScript \special is bracketed by gsave ... grestore. 
% (3) Immediately after the gsave, the coordinate system is translated so the
%     origin is at the current point; and the y axis is flipped.
% (4) TeXtures doesn't leave anything on the stack for long periods.  (This
%     simplifies restoring the default coordinate system.)

\def\rotate#1{\aftergroup\@unrotate
\special
{postscript
  0 0 transform                 % Current location in device coordinates.
  grestore                      % Undoes TeXtures gsave.
  matrix currentmatrix          % Save default transform on stack
  3 1 roll                      % Put transform at back of current location.
  itransform                    % Current location in TeXtures coords
  dup 3 -1 roll                 % Duplicate the location
  dup 4 1 roll exch             %    x y ==> x y x y
  translate                     % Translate origin to current location.
  #1\space neg                  % Negate angle because of flip of y axis.
  rotate                        % Rotate.
  neg exch neg exch translate   % Translate origin back.
  gsave}}                       % To match grestore.

\def\@unrotate{\special
{postscript
  grestore                      % Undoes TeXtures gsave
  setmatrix                     % Restore saved transform
  gsave}}                       % To match grestore

\endinput