summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/isorot/isorot.dtx
blob: b027b4cc6709943aa6e2ac4de26c92bc1801538b (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
% \iffalse meta-comment
%
% isorot.dtx
%
%
%    This program is provided under the terms of the
% LaTeX Project Public License distributed from CTAN
% archives in directory macros/latex/base/lppl.txt.
%
% Author: Peter Wilson (CUA) 
%         now at: peter.r.wilson@boeing.com
% 
% \fi
% \CheckSum{1619}
%
%
% \def\fileversion{v2.1}
% \def\filedate{2000/02/15}
% \title{\LaTeX{} files for typesetting ISO Standards: \\
%        Source code: The isorot package\thanks{This
%        file has version number \fileversion, last revised
%        \filedate.}}
%
% \author{%
% Peter Wilson\\
% Catholic University of America\thanks{This work was originally
% performed at Rensselaer Polytechnic Institute.} \\
% Now at \texttt{peter.r.wilson@boeing.com}
% }
% \date{\filedate}
% \maketitle
% \tableofcontents
%
% \StopEventually{}
%
% 
%
% \section{Introduction}
%
% This document provides the commented source for \LaTeX{}
% package files designed for the typesetting of
% documents according to the rules for ISO international standards.
% A seperate document provides the user manual~\cite{PRW96i}.
% This manual is typeset according to the conventions of the
% \LaTeX{} \textsc{docstrip} utility which enables the automatic
% extraction of the \LaTeX{} macro source files~\cite{GOOSSENS94}.
%
%    ISO (the International Organization for Standardisation) specify
% their document layout requirements in ISO Directives~\cite{ISOD397}.
% Unfortunately these Directives do not completely define the document
% layout, leaving several aspects open to interpretation by the
% document editor and re-interpretation by the ISO editorial board.
% The following specifications are a re-implementation of the \LaTeX{}
% macros that have been used for the production of camera ready copy
% for the ISO~10303 standard {\em Product data representation and
% exchange}. The initial release of ISO~10303:1994 consisted of twelve
% parts and over 2400 pages. The editorial board of the ISO Central
% Secretariat in Geneva accepted the typographic conventions embodied
% in these macros.
%
%    This manual is provided as a service for future developers
% and maintainers of the
% class and packages for ISO standards. It is assumed that any 
% any such person is \LaTeX{} literate and accustomed to supporting
% complex class and package files~\cite{GOOSSENS94}.
%
%
%    Section~\ref{sec:docstrip} describes some
% administrative elements and code for general use later in the specification.
% Section~\ref{sec:rot} specifies
% the macros for rotation of textual and tabular elements.
% 
% \section{The {\sc docstrip} modules} \label{sec:docstrip}
%
% The following modules are used in the implementation to direct
% {\sc docstrip} in generating the external files:
% \begin{center}
% \begin{tabular}{ll}
%   rot     & produce the isorot package\\
%   rotne   & produce the isorotne style file\\
%   driver  & produce a documentation driver file \\
% \end{tabular}
% \end{center}
%
% \subsection{A driver for this document}
%
% The next series of code contains the documentation driver file for
% \LaTeX, i.e., the file that will produce the documentation you are
% currently reading. This will be extracted from this file by the 
% {\sc docstrip} program.
%
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
%    \end{macrocode}
%
%    We do not want the following basic elements to appear in the index.
%    \begin{macrocode}
\DoNotIndex{\',\.,\@M,\@@input,\@addtoreset,\@arabic,\@badmath}
\DoNotIndex{\@centercr,\@cite}
\DoNotIndex{\@dotsep,\@empty,\@float,\@gobble,\@gobbletwo,\@ignoretrue}
\DoNotIndex{\@input,\@ixpt,\@m}
\DoNotIndex{\@minus,\@mkboth,\@ne,\@nil,\@nomath,\@plus,\@set@topoint}
\DoNotIndex{\@tempboxa,\@tempcnta,\@tempdima,\@tempdimb}
\DoNotIndex{\@tempswafalse,\@tempswatrue,\@viipt,\@viiipt,\@vipt}
\DoNotIndex{\@vpt,\@warning,\@xiipt,\@xipt,\@xivpt,\@xpt,\@xviipt}
\DoNotIndex{\@xxpt,\@xxvpt,\\,\ ,\addpenalty,\addtolength,\addvspace}
\DoNotIndex{\advance,\Alph,\alph}
\DoNotIndex{\arabic,\ast,\begin,\begingroup,\bfseries,\bgroup,\box}
\DoNotIndex{\bullet}
\DoNotIndex{\cdot,\cite,\CodelineIndex,\cr,\day,\DeclareOption}
\DoNotIndex{\def,\DisableCrossrefs,\divide,\DocInput,\documentclass}
\DoNotIndex{\DoNotIndex,\egroup,\ifdim,\else,\fi,\em,\endtrivlist}
\DoNotIndex{\EnableCrossrefs,\end,\end@dblfloat,\end@float,\endgroup}
\DoNotIndex{\endlist,\everycr,\everypar,\ExecuteOptions,\expandafter}
\DoNotIndex{\fbox}
\DoNotIndex{\filedate,\filename,\fileversion,\fontsize,\framebox,\gdef}
\DoNotIndex{\global,\halign,\hangindent,\hbox,\hfil,\hfill,\hrule}
\DoNotIndex{\hsize,\hskip,\hspace,\hss,\if@tempswa,\ifcase,\or,\fi,\fi}
\DoNotIndex{\ifhmode,\ifvmode,\ifnum,\iftrue,\ifx,\fi,\fi,\fi,\fi,\fi}
\DoNotIndex{\input}
\DoNotIndex{\jobname,\kern,\leavevmode,\let,\leftmark}
\DoNotIndex{\list,\llap,\long,\m@ne,\m@th,\mark,\markboth,\markright}
\DoNotIndex{\month,\newcommand,\newcounter,\newenvironment}
\DoNotIndex{\NeedsTeXFormat,\newdimen}
\DoNotIndex{\newlength,\newpage,\nobreak,\noindent,\null,\number}
\DoNotIndex{\numberline,\OldMakeindex,\OnlyDescription,\p@}
\DoNotIndex{\pagestyle,\par,\paragraph,\paragraphmark,\parfillskip}
\DoNotIndex{\penalty,\PrintChanges,\PrintIndex,\ProcessOptions}
\DoNotIndex{\protect,\ProvidesClass,\raggedbottom,\raggedright}
\DoNotIndex{\refstepcounter,\relax,\renewcommand,\reset@font}
\DoNotIndex{\rightmargin,\rightmark,\rightskip,\rlap,\rmfamily,\roman}
\DoNotIndex{\roman,\secdef,\selectfont,\setbox,\setcounter,\setlength}
\DoNotIndex{\settowidth,\sfcode,\skip,\sloppy,\slshape,\space}
\DoNotIndex{\symbol,\the,\trivlist,\typeout,\tw@,\undefined,\uppercase}
\DoNotIndex{\usecounter,\usefont,\usepackage,\vfil,\vfill,\viiipt}
\DoNotIndex{\viipt,\vipt,\vskip,\vspace}
\DoNotIndex{\wd,\xiipt,\year,\z@}
%    \end{macrocode}
%    We do want an index, using linenumbers, but not update information.
%    \begin{macrocode}
\EnableCrossrefs
\CodelineIndex
%%%% \RecordChanges
%    \end{macrocode}
%    We may use so many \file{docstrip} modules that we set the
%    \texttt{StandardModuleDepth} counter to 1.
%    \begin{macrocode}
\setcounter{StandardModuleDepth}{1}
%    \end{macrocode}
%    Some commonly used abbreviations
%    \begin{macrocode}
\newcommand*{\Lopt}[1]{\textsf {#1}}            % typeset an option
\newcommand*{\file}[1]{\texttt {#1}}            % typeset a file
\newcommand*{\Lcount}[1]{\textsl {\small#1}}    % typeset a counter
\newcommand*{\pstyle}[1]{\textsl {#1}}          % typeset a pagestyle
\newcommand*{\Lenv}[1]{\texttt {#1}}            % typeset an environment
%    \end{macrocode}
%    We want the full details printed.
%    \begin{macrocode}
\begin{document}
\DocInput{isorot.dtx}
\end{document}
%</driver>
%    \end{macrocode}
%
%
% \section{Identification} \label{sec:id}
%
%    Announce the name, option files and version for \LaTeX 2e files:
%    \begin{macrocode}
%<rot>\ProvidesPackage{isorot}[2000/02/15 v2.1 ISO rotation package]
%    \end{macrocode}
%
%    These files are for use with \LaTeX\ v2.09 or a disadvantaged \LaTeX 2e
% distribution.
%    \begin{macrocode}
%<rotne>\typeout{isorotne.sty [1997/12/02 v2 LaTeX 2.09 ISO rotation package]}
%    \end{macrocode}
%
%
% \section{The \file{isorot} package and \file{isorotne} style} \label{sec:rot}
%
%    The \file{isorot} package provides a specialization of the \file{rotating} 
%    package
%    for use within ISO standard documents. The principal modifications
%    relate to the table and figure environments. The original \file{rotating}
%    package was developed by 
%    Sebastian Rahtz and Leonor Barroca\footnote{Sebastian Rahtz and Leonor
%    Barroca, {\em A style option for rotated objects in TeX,} TUGboat, 13, 2,
%    pp 156--180, July 1992.}.
%
%    Apparently not all distributions of \LaTeX{} contain the necessary
%    packages for a simple implementation. The \file{isorotne} style provides 
%    the same capabilities for these users.
%    This essentially replaces all \LaTeX 2e facilities from \file{rotating}
%    by generic ones, and includes the relevent package sources within the one
%    file.
%
% \changes{v11}{1997/09/30}{Added new dvi drivers to isrotne package}
% \changes{v2}{1997/12/02}{Updated rotations to rotating v2.12}
% \changes{v2.1}{2000/02/15}{Updated to latest ISO class, and generalised for any class}
%    \begin{macrocode}
%<*rot|rotne>
%    \end{macrocode}
%
%    The package takes one option which prints debugging information.
%
% \begin{macro}{\PWRFc@tracing}
%    A counter controlling debug printing.
%    \begin{macrocode}
\newcount\PWRFc@tracing
\DeclareOption{errorshow}{\PWRFc@tracing\z@}
\DeclareOption{debugshow}{\PWRFc@tracing5\relax}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{graphics}}
\ProcessOptions
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\PWRF@trace}
%    A macro that gets the trace message as its argument.
%    \begin{macrocode}
\newcommand\PWRF@trace[2]{%
  \ifnum\PWRFc@tracing>#1\relax
    \GenericWarning
      {(isorot)\@spaces\@spaces}
      {Package isorot: #2}%
  \fi
}
%    \end{macrocode}
% \end{macro}
%
%    For the \file{isorot} package most of the work is done by the 
%    \file{graphicx} package, so make sure it is loaded. Also, David
%    Carlisle's \file{lscape} package is required for landscaping some
%    pages or long wide tables.
%    \begin{macrocode}
%<*rot>
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{graphicx}
\RequirePackage{lscape}
%</rot>
%    \end{macrocode}
%
%    For the disadvantaged user, the required basic facilities are
%    a portion of the \file{graphics} package, which in turn requires
%    the \file{trig} package. We also need the code from the
%    \file{lscape} package.
%
%    \begin{macrocode}
%<*rotne>
%    \end{macrocode}
%    Firstly, here is the code from the \file{trig} package.
%
% \subsection{Trigonometry functions}
%
%    \emph{The following is the contents of the \file{trig} package written by
%    David Carlisle. The code and explanations are from \file{trig.dtx}
%    version 1.08, dated 1994/10/16. The original file should be consulted
%    for a full explanation.} 
%
%
% These macros implement the trigonometric functions, sin, cos and tan.
% In each case two commands are defined. For instance the command
% |\CalculateSin{33}| may be isued at some point, and then anywhere
% later in the document, the command |\UseSin{33}| will return the
% decimal expansion of $\sin(33^\circ)$.
%
% The arguments to these macros do not have to be whole numbers,
% although in the case of whole numbers, \LaTeX\ or plain \TeX\ counters
% may be used. In \TeX{}Book syntax, arguments must be  of type:
% \meta{optional signs}\meta{factor}
%
% Some other examples are:\\
% |\CalculateSin{22.5}|, |\UseTan{\value{mycounter}}|,
% |\UseCos{\count@}|.
%
% Note that unlike the psfig macros, these save all previously
% computed values. This could easily be changed, but I thought that in
% many applications one would want many instances of the
% same value. (eg rotating all the headings of a table by the
% \emph{same} amount).
%
% Some useful constants for converting between degrees and radians.
% $$\frac{\pi}{180}\simeq\frac{355}{113\times180}=\frac{71}{4068}$$
%    \begin{macrocode}
\chardef\nin@ty=90
\chardef\@clxx=180
\chardef\@lxxi=71
\mathchardef\@mmmmlxviii=4068
%    \end{macrocode}
%
% The approximation to $\sin$.
% \begin{eqnarray*}
%  \sin(x)& \simeq& x - (1/3!)x^3 + (1/5!)x^5 - (1/7!)x^7 + (1/9!)x^9\\
%  &\simeq&\frac{((((7!/9!x^2-7!/7!)x^2+7!/5!)x^2 +7!/3!)x^2+7!/1!)x}
% {7!}\\
%  &=&\frac{((((1/72x^2-1)x^2+42)x^2 +840)x^2+5040)x}
% {5040}
% \end{eqnarray*}
%
%    \begin{macrocode}
\chardef\@coeffz=72
%\chardef\@coefa=1
\chardef\@coefb=42
\mathchardef\@coefc=840
\mathchardef\@coefd=5040
%    \end{macrocode}
%
%    \begin{macrocode}
{\catcode`t=12\catcode`p=12\gdef\noPT#1pt{#1}}
\def\TG@rem@pt#1{\expandafter\noPT\the#1\space}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\TG@term#1{%
 \dimen@\@tempb\dimen@
 \advance\dimen@ #1\p@}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\TG@series{%
 \dimen@\@lxxi\dimen@
 \divide \dimen@ \@mmmmlxviii
 \edef\@tempa{\TG@rem@pt\dimen@}%
 \dimen@\@tempa\dimen@
 \edef\@tempb{\TG@rem@pt\dimen@}%
 \divide\dimen@\@coeffz
 \advance\dimen@\m@ne\p@
 \TG@term\@coefb
 \TG@term{-\@coefc}%
 \TG@term\@coefd
 \dimen@\@tempa\dimen@
 \divide\dimen@ \@coefd}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\CalculateSin#1{{%
  \expandafter\ifx\csname sin(\number#1)\endcsname\relax
    \dimen@=#1\p@\TG@@sin
    \expandafter\xdef\csname sin(\number#1)\endcsname
                                    {\TG@rem@pt\dimen@}%
  \fi}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\CalculateCos#1{{%
  \expandafter\ifx\csname cos(\number#1)\endcsname\relax
    \dimen@=\nin@ty\p@
    \advance\dimen@-#1\p@
    \TG@@sin
    \expandafter\xdef\csname cos(\number#1)\endcsname
                                     {\TG@rem@pt\dimen@}%
  \fi}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\TG@reduce#1#2{%
\dimen@#1#2\nin@ty\p@
  \advance\dimen@#2-\@clxx\p@
  \dimen@-\dimen@
  \TG@@sin}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\TG@@sin{%
  \ifdim\TG@reduce>+%
  \else\ifdim\TG@reduce<-%
  \else\TG@series\fi\fi}%
%    \end{macrocode}
%
%    \begin{macrocode}
\def\UseSin#1{\csname sin(\number#1)\endcsname}
\def\UseCos#1{\csname cos(\number#1)\endcsname}
%    \end{macrocode}
%
%    \begin{macrocode}
\chardef\z@num\z@
\expandafter\let\csname sin(0)\endcsname\z@num
\expandafter\let\csname cos(0)\endcsname\@ne
\expandafter\let\csname sin(90)\endcsname\@ne
\expandafter\let\csname cos(90)\endcsname\z@num
\expandafter\let\csname sin(-90)\endcsname\m@ne
\expandafter\let\csname cos(-90)\endcsname\z@num
\expandafter\let\csname sin(180)\endcsname\z@num
\expandafter\let\csname cos(180)\endcsname\m@ne
%    \end{macrocode}
%
% This is accurate to 4 decimal places for angles up to
% $50^\circ$, after that the accuracy tails off, giving
% 57.47894 instead of 57.2900 for $89^\circ$.
%    \begin{macrocode}
\def\CalculateTan#1{{%
  \expandafter\ifx\csname tan(\number#1)\endcsname\relax
    \CalculateSin{#1}%
    \CalculateCos{#1}%
    \@tempdima\UseCos{#1}\p@
    \divide\@tempdima\@iv
    \@tempdimb\UseSin{#1}\p@
    \@tempdimb\two@fourteen\@tempdimb
    \divide\@tempdimb\@tempdima
    \expandafter\xdef\csname tan(\number#1)\endcsname
                                        {\TG@rem@pt\@tempdimb}%
  \fi}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\UseTan#1{\csname tan(\number#1)\endcsname}
%    \end{macrocode}
%
%    \begin{macrocode}
\mathchardef\two@fourteen=16384
\chardef\@iv=4
%    \end{macrocode}
%
%    \begin{macrocode}
\expandafter\def\csname tan(90)\endcsname{\errmessage{Infinite tan !}}
\expandafter\let\csname tan(-90)\expandafter\endcsname
                                       \csname tan(90)\endcsname
%    \end{macrocode}
%
% \subsection{Landscape environment}
%
%    The \file{lscape} package by David Carlisle provides a landscape
%    environment which prints the enclosed pages in landscape rather
%    than portrait. For 2.09 this package does not work, so we provide
%    for the functionality here. The following code is taken from
%    the \file{lscape} package.\footnote{Version 3.0, last revised
%    1994/10/05.}
%
% \begin{environment}{landscape}
%    \begin{macrocode}
\let\LS@makecol=\@makecol
\let\LS@makefcolumn=\@makefcolumn
\def\LS@rot{%
  \setbox\@outputbox\vbox{\hbox{\rotatebox{90}{\box\@outputbox}}}}
\def\landscape{%
  \clearpage
  \begingroup
  \vsize=\textwidth
  \hsize=\textheight
  \linewidth=\hsize
  \columnwidth=\hsize
  \@colroom=\vsize
  \textheight=\vsize
  \@colht=\vsize
  \def\@makecol{\LS@makecol\LS@rot}%
  \def\@makefcolumn##1{\LS@makefcolumn{##1}\LS@rot}}
\def\endlandscape{%
  \clearpage
  \endgroup
  \global\@colht=\textheight
  \global\vsize=\textheight
  \global\@colroom=\textheight}
%    \end{macrocode}
% \end{environment}
%
%    \begin{macrocode}
%</rotne>
%    \end{macrocode}
%
% \subsection{Drivers}
%
%    Rotation is not done within \TeX\ but by the device drivers via |\special|
%    commands appropriate for each driver.
%
%    \begin{macrocode}
%<*rot>
\def\rotdriver#1{%
  \message{The .dvi file is to be processed by the #1 driver.}
  \typeout{Change rotdriver in the source accordingly if you do not have this.}
  \makeatletter\input{#1.def}\makeatother}
%</rot>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*rotne>
%    \end{macrocode}
%
%    Life is much more difficult for the \file{isorotne} style as we have to
% include source (runnable under 2.09) that the \file{isorot} package 
% gets for free.
%
% \begin{macro}{\Grot@start}
% \begin{macro}{\Grot@end}
%    The commands |\Grot@start| and |\Grot@end| are defined which assume
%    that the macro |\Grot@angle| contains the rotation angle. First
%    set these to do nothing, just in case the user calls for an unsupported
%    driver.
%    \begin{macrocode}
  \def\Grot@start{}
  \def\Grot@end{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\Dvitops@count}
%    A counter for the DVITOPS driver.
%    \begin{macrocode}
\newcount\Dvitops@count
\Dvitops@count=\@ne
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\listrotdrivers}
%    Writes out the list of currently available rotdrivers.
%    \begin{macrocode}
\newcommand{\listrotdrivers}{%
  \typeout{If you do not have this driver then change rotdriver in your source.}
  \typeout{Available rotdrivers are:}
  \typeout{ \space\space dvipdf, dvips, dvipsone, dvitops, dviwindo,}
  \typeout{ \space\space pctex32, pctexps, pubps, textures}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rotdriver}
%    The command |\rotdriver{|\meta{driver}|}| must be put in the preamble,
%    where \meta{driver} is the identification of one of the drivers that
%    support rotation.
%    \begin{macrocode}
\newcommand{\rotdriver}[1]{%
%    \end{macrocode}
%    Put the argument into an uppercase string
%    \begin{macrocode}
  \bgroup\edef\next{\def\noexpand\tempa{#1}}%
    \uppercase\expandafter{\next}%
%    \end{macrocode}
% \begin{macro}{\ISOROTSTD}
% \begin{macro}{\DVIPS}
% \begin{macro}{\DVIPSONE}
% \begin{macro}{\DVITOPS}
% \begin{macro}{\PCTEXPS}
% \begin{macro}{\PUBPS}
% \begin{macro}{\TEXTURES}
% \begin{macro}{\DVIPDF}
% \begin{macro}{\DVIWINDO}
% \begin{macro}{\PCTEX32}
%    These are the currently supported drivers that can cope with rotations.
%    The code for the drivers has been taken from 
%    \file{drivers.dtx}\footnote{Version v3.0d, revised 1996/12/12.} by
%    Sebastian Rahtz and David Carlisle.
%
%    The |isorotstd| driver is included against the (improbable) time
%    when there might be one `standard' driver, or at least all the
%    |\special| code for rotations might be common.
%    \begin{macrocode}
  \def\ISOROTSTD{ISOROTSTD}
  \def\DVIPS{DVIPS}
  \def\DVIPSONE{DVIPSONE}
  \def\DVITOPS{DVITOPS}
  \def\PCTEXPS{PCTEXPS}
  \def\PUBPS{PUBPS}
  \def\TEXTURES{TEXTURES}
  \def\DVIPDF{DVIPDF}
  \def\DVIWINDO{DVIWINDO}
  \def\PCTEXxxxii{PCTEX32}
%    \end{macrocode}
%    Later we will use a case statement for picking the proper code. Define
%    a numeric code for each driver.
%    \begin{macrocode}
  \global\chardef\rot@driver=0
  \ifx\tempa\ISOROTSTD
     \global\chardef\rot@driver=1\fi
  \ifx\tempa\DVIPS
     \global\chardef\rot@driver=2\fi
  \ifx\tempa\DVIPSONE
     \global\chardef\rot@driver=3\fi
  \ifx\tempa\DVITOPS
     \global\chardef\rot@driver=4\fi
  \ifx\tempa\PCTEXPS
     \global\chardef\rot@driver=5\fi
  \ifx\tempa\PUBPS
     \global\chardef\rot@driver=6\fi
  \ifx\tempa\TEXTURES
     \global\chardef\rot@driver=7\fi
  \ifx\tempa\DVIPDF
     \global\chardef\rot@driver=8\fi
  \ifx\tempa\DVIWINDO
     \global\chardef\rot@driver=9\fi
  \ifx\tempa\PCTEXxxxii
     \global\chardef\rot@driver=10\fi
  \egroup
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%    Now define the particulars for each driver. \\
%    {\bf Case 0:} We should not be here!
%    \begin{macrocode}
  \ifcase\rot@driver  % case 0
    \message{WARNING *** unknown driver --- no rotation.} \listrotdrivers
%    \end{macrocode}
%    {\bf Case 1: ISOROTSTD} Not yet available.
%    \begin{macrocode}
  \or                 % case 1: ISOROTSTD
    \message{WARNING *** isorotstd driver not available yet --- no rotation.}
    \listrotdrivers
%    \end{macrocode}
%    {\bf Case 2: DVIPS} For Tom Rokicki's {\em dvips} driver. Has been tested
%    with version 5.518 of July 1993.
%    \begin{macrocode}
  \or                 % case 2: DVIPS
    \typeout{Rotdriver set to dvips.} \listrotdrivers
    \def\Grot@start{%
       \special{ps: gsave currentpoint
                currentpoint translate \Grot@angle\space neg
                rotate neg exch neg exch translate}}
    \def\Grot@end{%
       \special{ps: currentpoint grestore moveto}}
%    \end{macrocode}
%    {\bf Case 3: DVIPSONE} For Y\&Y's {\em dvipsone}.
%    \begin{macrocode}
  \or                 % case 3: DVIPSONE
    \typeout{Rotdriver set to dvipsone.} \listrotdrivers
    \def\Grot@start{%
       \special{ps: gsave currentpoint
                currentpoint translate \Grot@angle\space
                rotate neg exch neg exch translate}}
    \def\Grot@end{%
       \special{ps: currentpoint grestore moveto}}
%    \end{macrocode}
%    {\bf Case 4: DVITOPS} For James Clark's {\em dvitops}.
%    \begin{macrocode}
  \or                % case 4: DVITOPS
    \typeout{Rotdriver set to dvitops.} \listrotdrivers
    \def\Grot@start{%
       \special{dvitops: origin
                rot\the\@tempdima}%
       \special{dvitops: begin rot\the\Dvitops@count}}%
    \def\Grot@end{%
       \special{dvitops: end}%
       \special{dvitops: rotate rot\the\Dvips@count \space
                \Grot@angle}%
       \global\advance\Dvitops@count by\@ne}
%    \end{macrocode}
%    {\bf Case 5: PCTEXPS} For Personal TeX's PC PTI Laser/PS. Information
%    supplied by Lance Carnes and Tao Wang |<pti@crl.com>|.
%    \begin{macrocode}
  \or                % case 5: PCTEXPS
    \typeout{Rotdriver set to pctexps.} \listrotdrivers
    \def\Grot@start{%
       \special{ps:: gsave currentpoint
                currentpoint translate \Grot@angle\space
                rotate neg exch neg exch translate}}
    \def\Grot@end{%
       \special{ps:: currentpoint grestore moveto}}
%    \end{macrocode}
%    {\bf Case 6: PUBPS} For Arbortext's {\em pubps}. 
%    (Interestingly, I (PRW) note
%    that my original (circa 1991) code for this used |ps::| but the code
%    has since been modified to |ps:|.)
%    \begin{macrocode}
  \or                % case 6: PUBPS
    \typeout{Rotdriver set to pubps.} \listrotdrivers
    \def\Grot@start{%
       \special{ps: gsave currentpoint
                currentpoint translate \Grot@angle\space
                rotate neg exch neg exch translate}}
    \def\Grot@end{%
       \special{ps: currentpoint grestore moveto}}
%    \end{macrocode}
%    {\bf Case 7: TEXTURES} For Blue Sky's {\em Textures}. This code is liable
%    to change as there is ongoing work to produce a new version of Textures.
%    \begin{macrocode}
  \or               % case 7: TEXTURES
    \typeout{Rotdriver set to textures.} \listrotdrivers
    \def\Grot@start{%
      \special{postscript
        0 0 transform
        grestore
        matrix currentmatrix
        3 1 roll
        itransform
        dup 3 -1 roll
        dup 4 1 roll exch
        translate
        \Grot@angle\space neg rotate
        neg exch neg exch translate
        gsave}}
    \def\Grot@end{\special{postscript grestore setmatrix gsave}}
%    \end{macrocode}
%    {\bf Case 8: DVIPDF} For the {\em dvipdf} driver.
%    \begin{macrocode}
  \or               % case 8: DVIPDF
    \typeout{Rotdriver set to dvipdf.} \listofdrivers
    \def\Grot@start{%
      \special{pdf: /ROT \Grot@angle\space << }}
    \def\Grot@end{\special{pdf: /ROT >> }}
%    \end{macrocode}
%    {\bf Case 9: DVIWINDO} For Y\&Y's {\em dviwindo} driver.
%    \begin{macrocode}
  \or               % case 9: DVIWINDO (same as DVIPSONE)
    \typeout{Rotdriver set to dviwindo.} \listofdrivers
    \def\Grot@start{%
       \special{ps: gsave currentpoint
                currentpoint translate \Grot@angle\space
                rotate neg exch neg exch translate}}
    \def\Grot@end{%
       \special{ps: currentpoint grestore moveto}}
%    \end{macrocode}
%    {\bf Case 10: PCTEX32} For Personal TeX's PC TeX for 32 bit Windows.
%    (Code supplied by Tao Wang |<pti@crl.com>|).
%    \begin{macrocode}
  \or               % case 10: PCTEX32
    \typeout{Rotdriver set to pctex32.} \listofdrivers
    \def\Grot@start{%
       \special{ps:: gsave currentpoint
         currentpoint translate \Grot@angle\space neg
         rotate neg exch neg exch translate}}
     \def\Grot@end{\special{ps:: currentpoint grestore moveto}}
%    \end{macrocode}
%
%    {\bf Case unknown:} We should not have got here!
%    \begin{macrocode}
  \else
    \message{WARNING *** unknown driver --- no rotation.} \listrotdrivers
  \fi
}
%    \end{macrocode}
% \end{macro}
%    Set up a default driver (use DVIPS as it appears the most popular).
%    \begin{macrocode}
\rotdriver{DVIPS}
%    \end{macrocode}
%    The default driver has been set to DVIPS for both \file{isorot} and
% \file{isorotne}.
%
%    \begin{macrocode}
%</rotne>
%    \end{macrocode}
%
% \subsection{Box rotation}
%
%    The \file{isorotne} package needs some code that is part of the
% \file{graphics} package.
%
%    The following code has been mainly taken from the graphics package 
%    \file{graphics.dtx}\footnote{Version v1.0d, last revised 1997/06/07.}
%    by D.P. Carlisle and S.P.Q. Rahtz.
%
%
%    The \file{isorotne} package requires some macros that are in the
%    2e kernel but not the 2.09 kernel.
%    The following macros are defined in the 2e kernel but
%    not in all v2.09 kernels. We need them. We use \verb|\def| instead 
%    of \verb|\newcommand|
%    just in case a v2.09 document is processed in compatibility
%    mode, but additionally check if 2e is being used.
%
%    \begin{macrocode}
%<*rotne>
\ifx\usepackage\undefined
%    \end{macrocode}
%
% \begin{macro}{\@plus}
% \begin{macro}{\@minus}
%    Save some string space.
%    \begin{macrocode}
  \def\@plus{plus}
  \def\@minus{minus}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\on@line}
%    \begin{macrocode}
  \ifnum\inputlineno=\m@ne
    \let\on@line\empty
  \else
    \def\on@line{ on input line \the\inputlineno}
  \fi
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rem@pt}
%    Utility macro to assist in removing the string `pt' from a dimension. 
%    It is complicated but appears to work.
%    \begin{macrocode}
  \begingroup
    \catcode`P=12
    \catcode`T=12
    \lowercase{
      \def\x{\def\rem@pt##1.##2PT{##1\ifnum##2>\z@.##2\fi}}}
    \expandafter\endgroup\x
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\strip@pt}
%     Call this to strip `pt' from a dimension like |\strip@pt\dim|.
%    \begin{macrocode}
  \def\strip@pt{\expandafter\rem@pt\the}
%    \end{macrocode}
% \end{macro}
%    The end of \LaTeX 2e kernel macros.
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
% \begin{macro}{\color@begingroup}
% \begin{macro}{\color@endgroup}
% \begin{macro}{\color@setgroup}
% \begin{macro}{\normalcolor}
% \begin{macro}{\color@hbox}
% \begin{macro}{\color@vbox}
% \begin{macro}{\color@endbox}
%     These are normally no-ops (but are redefined by the \file{color} package).
%    \begin{macrocode}
\let\color@begingroup\relax
\let\color@endgroup\relax
\let\color@setgroup\relax
\let\normalcolor\relax
\let\color@hbox\relax
\let\color@vbox\relax
\let\color@endbox\relax
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{environment}{lrbox}
%    A new 2e environment form of |\sbox|. (This is why the color stuff is
%    needed.)
%    \begin{macrocode}
\def\lrbox#1{%
  \edef\reserved@a{%
    \endgroup
    \setbox#1\hbox{%
      \begingroup\aftergroup}%
        \def\noexpand\@currenvir{\@currenvir}%
        \def\noexpand\@currenvline{\on@line}}%
  \reserved@a
    \@endpefalse
    \color@setgroup
      \ignorespaces}
\def\endlrbox{\unskip\color@endgroup}
%    \end{macrocode}
% \end{environment}
%
%    We are now basically back to the \file{graphics} package code.
%
%    Some registers are needed to store some sizes and angles. 
%    Local registers are re-used (see the Graphics package documentation).
% \begin{macro}{\Grot@height}
% \begin{macro}{\Grot@depth}
% \begin{macro}{\Grot@right}
% \begin{macro}{\Grot@left}
%    Final rotated box dimensions.
% \changes{v2}{1997/12/02}{Graphics updated to version v1.0d}
%    \begin{macrocode}
\let\Grot@height\@ovxx
\let\Grot@depth\@ovdy
\let\Grot@right\@ovdx
\let\Grot@left\@ovyy
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\Grot@h}
% \begin{macro}{\Grot@d}
% \begin{macro}{\Grot@r}
% \begin{macro}{\Grot@l}
%    The original box dimensions.
%    \begin{macrocode}
\let\Grot@h\@xdim
\let\Grot@d\@ydim
\let\Grot@r\@ovri
\let\Grot@l\@ovro
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\Grot@x}
% \begin{macro}{\Grot@y}
%    Coordinates of the centre of rotation.
%    \begin{macrocode}
\let\Grot@x\@linelen
\let\Grot@y\@dashdim
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\rotatebox}
%    The rotation angle is specified by parameter |#1| and the box to be
%    rotated by |#2|. In the standard interface the center of rotation
%    is $(0,0)$. Finally |\Grot@box| is called to rotate the box.
% 
%    |\rotatebox{|\meta{degrees}|}{|\meta{text}|}| rotates \meta{text}
%    by \meta{degrees} anticlockwise. The rotation is about the left hand
%    end of the baseline of \meta{text}.
% \changes{v2}{1997/12/02}{Added call to \cs{leavevmode}}
%    \begin{macrocode}
\def\rotatebox#1#2{%
  \leavevmode
  \Grot@setangle{#1}%
  \setbox\z@\hbox{{#2}}%
  \Grot@x\z@
  \Grot@y\z@
  \Grot@box}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Grot@setangle}
% \begin{macro}{\Grot@angle}
%    These set the internal macro |\Grot@angle| used by |\Grot@box|.
%    |\Grot@setangle| is the `standard' definition from the \file{graphics}
%    package.
%    \begin{macrocode}
\def\Grot@setangle#1{\edef\Grot@angle{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%    We need to know the size of the enclosing rectangle of a rotated box.
%    Two macros are used for calculating coordinate positions. (See Graphics
%    documentation for details.)
%
% \begin{macro}{\Grot@Px}
%    Calculate the x coordinate of a point after rotation. The new x
%    coordinate is parameter |#1| and the original point coordinates
%    are parameters |#2| and |#3|.
%    \begin{macrocode}
\def\Grot@Px#1#2#3{%
    #1\Grot@cos#2%
    \advance#1-\Grot@sin#3}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Grot@Py}
%    Similarly for the y coordinate.
%    \begin{macrocode}
\def\Grot@Py#1#2#3{%
    #1\Grot@sin#2%
    \advance#1\Grot@cos#3}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Grot@box}
%    Rotates |\box0| through |\Grot@angle| degrees anticlockwise.
%
%    For details, consult the Graphics documentation.
%
%    \begin{macrocode}
\def\Grot@box{%
  \begingroup
    \CalculateSin\Grot@angle
    \CalculateCos\Grot@angle
    \edef\Grot@sin{\UseSin\Grot@angle}%
    \edef\Grot@cos{\UseCos\Grot@angle}%
    \Grot@r\wd\z@  \advance\Grot@r-\Grot@x
    \Grot@l\z@     \advance\Grot@l-\Grot@x
    \Grot@h\ht\z@  \advance\Grot@h-\Grot@y
    \Grot@d-\dp\z@ \advance\Grot@d-\Grot@y
    \ifdim\Grot@sin\p@>\z@
      \ifdim\Grot@cos\p@>\z@
         \Grot@Py\Grot@height \Grot@r\Grot@h
         \Grot@Px\Grot@right  \Grot@r\Grot@d
         \Grot@Px\Grot@left   \Grot@l\Grot@h
         \Grot@Py\Grot@depth  \Grot@l\Grot@d
      \else
         \Grot@Py\Grot@height \Grot@r\Grot@d
         \Grot@Px\Grot@right  \Grot@l\Grot@d
         \Grot@Px\Grot@left   \Grot@r\Grot@h
         \Grot@Py\Grot@depth  \Grot@l\Grot@h
      \fi
    \else
      \ifdim\Grot@cos\p@<\z@  
         \Grot@Py\Grot@height \Grot@l\Grot@d
         \Grot@Px\Grot@right  \Grot@l\Grot@h
         \Grot@Px\Grot@left   \Grot@r\Grot@d
         \Grot@Py\Grot@depth  \Grot@r\Grot@h
       \else
         \Grot@Py\Grot@height \Grot@l\Grot@h
         \Grot@Px\Grot@right  \Grot@r\Grot@h
         \Grot@Px\Grot@left   \Grot@l\Grot@d
         \Grot@Py\Grot@depth  \Grot@r\Grot@d
       \fi
     \fi
     \advance\Grot@height\Grot@y
     \advance\Grot@depth\Grot@y
     \Grot@Px\dimen@   \Grot@x\Grot@y
     \Grot@Py\dimen@ii \Grot@x\Grot@y
     \dimen@-\dimen@     \advance\dimen@-\Grot@left
     \dimen@ii-\dimen@ii \advance\dimen@ii\Grot@y
     \setbox\z@\hbox{%
       \kern\dimen@
       \raise\dimen@ii\hbox{\Grot@start\box\z@\Grot@end}}%
     \ht\z@\Grot@height
     \dp\z@-\Grot@depth
     \advance\Grot@right-\Grot@left\wd\z@\Grot@right
     \leavevmode\box\z@
  \endgroup}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</rotne>
%    \end{macrocode}
%
% \subsection{The rotating code}
%
%    Much of the code from here on is taken from the 
%    \file{rotating.dtx}\footnote{Version v2.9, last revised 1995/04/07.} 
%    package file by Leonor Barroca, but some is hacked for 2.09 users.
% Extensions are made to accomodate the special requirements for ISO
% typesetting.
%
% \subsubsection{Initial macros}
%
%    Define some general helper macros.
%
% \begin{macro}{\if@rot@twoside}
%    A flag for one or two sided.
%    \begin{macrocode}
\newif\if@rot@twoside
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Grot@setnegangle}
%  \emph{Extension:}  |\Grot@setnegangle| sets |\Grot@angle| to be the 
%     negative of its input
%     parameter. We use this for changing rotation direction.
%    \begin{macrocode}
\def\Grot@setnegangle#1{%
  \dimen@#1\p@
  \dimen@-\dimen@
  \edef\Grot@angle{\strip@pt\dimen@}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ifcl@ckwise}
% \begin{macro}{\figuresleft}
% \begin{macro}{\figuresright}
% \begin{macro}{\clockwise}
% \begin{macro}{\counterclockwise}
% \emph{Extension:} The \file{rotating} package has some options. 
%  Our packages instead define some additional
%    macros to enable these to be expressed as commands.
%
%    A flag for the desired rotational direction.
%    \begin{macrocode}
\newif\ifcl@ckwise
%    \end{macrocode}
%    The extension commands:
%    \begin{macrocode}
\newcommand{\figuresleft}{%
  \@rot@twosidefalse
  \def\rot@LR{0}%
}
\newcommand{\figuresright}{%
  \@rot@twosidefalse
  \def\rot@LR{-1}%
}
\newcommand{\clockwise}{%
  \cl@ckwisetrue
}
\newcommand{\counterclockwise}{%
  \cl@ckwisefalse
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\r@protected@write}
% \begin{macro}{\therpage}
% \begin{macro}{\rot@label}
%
%    The \file{rotating} package used to use the |\label| command. It now
% uses a special |\rot@label| version. This variant writes the \emph{true}
% page number, not the value of |\thepage|. It also involves a variant
% |\protected@write|\footnote{The original author states `\ldots for reasons 
% which I do not fully understand.'}.
%
% \changes{v2}{1997/12/03}{Added \cs{r@protected@write}, \cs{therpage} and \cs{rot@label}}
%    \begin{macrocode}
\long\def\r@protected@write#1#2#3{%
  \begingroup
    \let\therpage\relax
    #2%
    \let\protect\@unexpandable@protect
    \edef\reserved@a{\write#1{#3}}%
    \reserved@a
  \endgroup
  \if@nobreak\ifvmode\nobreak\fi\fi
}
\def\therpage{\arabic{page}}
\def\rot@label#1{\@bsphack
  \r@protected@write\@auxout{}%
    {\string\newlabel{#1}{{\@currentlabel}{\therpage}}}%
  \@esphack}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\r@tfl@t}
%    A counter for use later in matching rotations to page numbers.
% \changes{v2}{1997/12/02}{Changed \cs{r@tfl@t} to a \cs{newcounter}}
%    \begin{macrocode}
\newcounter{r@tfl@t}
\setcounter{r@tfl@t}{0}
%    \end{macrocode}
% \end{macro}
%
%    Sideways floats take up the whole page. They can be rotated so that
%    the bottom of the float is on the left or the right; the default
%    is to always turn to the right. If the main document uses the
%    \Lopt{twoside} option then the floats are rotated according to the
%    page number (requiring at least two passes through \LaTeX). The
%    \Lopt{figuresleft} and \Lopt{figuresright} `options' will ensure
%    a constant rotation direction when \Lopt{twoside} is in effect.
%
%    \begin{macrocode}
\if@twoside
  \@rot@twosidetrue
\else
  \@rot@twosidefalse
\fi
%    \end{macrocode}
%
% \begin{macro}{\rotatedirection}
%    For setting rotation direction for positive angle. The |\rotatedirection|
%    command is provided for backwards compatibility.
%    \begin{macrocode}
\newcommand{\rotatedirection}[1]{%
  \def\@tempa{#1}\def\@tempb{clockwise}%
  \ifx\@temp\@tempb
    \cl@ckwisetrue
  \else
    \cl@ckwisefalse
  \fi}
%    \end{macrocode}
% \end{macro}
%
%    Set default to be \Lopt{clockwise} rotation for positive angles,
%    and \Lopt{figuresright} to make all bottoms of sideways floats
%    to be at the righthand edge of the paper.
%    \begin{macrocode}
\clockwise
\figuresright
%    \end{macrocode}
%
% \subsubsection{Turn and rotation environments}
%
%    These are general rotational environments.
%
% \begin{environment}{sideways}
%    The \Lenv{sideways} environment rotates its contents through the fixed
%    angle of 90 degrees counterclockwise.
%    \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{environment}
%
% \begin{environment}{turn}
%    The \Lenv{turn} environment rotates its contents through the given
%    angle, leaving the appropriate space.
%
% \emph{Extension:} We take account of the specified rotational direction.
%    \begin{macrocode}
\def\turn#1{%
  \ifcl@ckwise
    \Grot@setnegangle{#1}
  \else
    \Grot@setangle{#1}
  \fi
  \setbox\z@\hbox\bgroup\ignorespaces}
\def\endturn{%
  \unskip\egroup
  \Grot@x\z@
  \Grot@y\z@
  \Grot@box
}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{rotate}
%    The \Lenv{rotate} environment rotates its contents through the given
%    angle, leaving no space.
%
% \emph{Extension:} We take account of the specified rotational direction.
%    \begin{macrocode}
\def\rotate#1{%
  \ifcl@ckwise
    \Grot@setnegangle{#1}
  \else
    \Grot@setangle{#1}
  \fi
  \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{environment}
%
% \begin{macro}{\turnbox}
%    A macro version of the \Lenv{rotate} environment.
%
%    |\turnbox{|\meta{degrees}|}{|\meta{text}|}|
%    \begin{macrocode}
\def\turnbox#1#2{%
  \ifcl@ckwise
    \Grot@setnegangle{#1}
  \else
    \Grot@setangle{#1}
  \fi
  \setbox\z@\hbox{{#2}}%
  \Grot@x\z@
  \Grot@y\z@
  \wd0\z@\dp0\z@\ht0\z@
  \Grot@box
}  
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Sideways figures and tables}
%
%    Rotation of floats through a fixed angle of 90 degrees.
%
%    First, a generalized |rotfloat| environment.
% \begin{macro}{\rot@float@box}
% \begin{macro}{\@rotfloat}
% \begin{macro}{\@xrotfloat}
%    \begin{macrocode}
\newsavebox\rot@float@box
\def\@rotfloat#1{%
  \@ifnextchar[%
    {\@xrotfloat{#1}}%
    {\edef\@tempa{\noexpand\@xrotfloat{#1}[\csname fps@#1\endcsname]}\@tempa}%
}
\def\@xrotfloat#1[#2]{%
  \@float{#1}[#2]%
%    \end{macrocode}
%    Set the float contents in a box of |\textheight| instead of
% |\columnwidth|.
%    \begin{macrocode}
  \begin{lrbox}\rot@float@box
  \begin{minipage}\textheight
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\end@rotfloat}
%
%    We call |\end@float| having previously rotated the box |\@currbox|.
% The rotation is either clockwise or counterclockwise, depending on
% whether the page is odd or even. In |oneside| mode it is always odd.
% See the \file{rotating} package documentation for further details.
%
% \emph{Extension:} Generalised the output messages.
% \changes{v2}{1997/12/02}{Using \cs{rot@label} instead of \cs{label}}
%    \begin{macrocode}
\def\end@rotfloat{%
  \end{minipage}\end{lrbox}%
  \global\addtocounter{r@tfl@t}{1}%
  \rot@label{RF\ther@tfl@t}%
  \def\R@@page{\pageref{RF\ther@fl@t}}%
  \wd\rot@float@box\z@
  \ht\rot@float@box\z@
  \dp\rot@float@box\z@
  \vbox to \textheight{%
    \if@rot@twoside
      \def\R@@page{\pageref{RF\ther@tfl@t}}%
    \else
      \let\R@@page\rot@LR
    \fi
    \ifodd\R@@page
       \PWRF@trace\tw@{Adding sideways float on right hand page}%
       \vfill
       \centerline{\rotatebox{90}{\box\rot@float@box}}%
    \else
       \PWRF@trace\tw@{Adding sideways float on left hand page}%
       \centerline{\rotatebox{-90}{\box\rot@float@box}}%
       \vfill
    \fi
  }%
  \end@float
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@rotdblfloat}
% \begin{macro}{\@rotdblflt}
% \begin{macro}{\@rotxdblfloat}
%     General macros for double column floats.
% \changes{v2}{1997/12/03}{Added code for double column floats}
%    \begin{macrocode}
\def\@rotdblfloat{%
  \if@twocolumn\let\reserved@a\@rotdblflt\else\let\reserved@a\@rotfloat\fi
  \reserved@a}
\def\@rotdblflt#1{\@ifnextchar[{\@rotxdblfloat{#1}}{\@rotxdblfloat{#1}[tp]}}
\def\@rotxdblfloat#1[#2]{%
  \hsize\textwidth\linewidth\textwidth
  \@float{#1}[#2]%
  \begin{lrbox}\rot@float@box
  \begin{minipage}\textheight
}
\def\end@rotdblfloat{%
  \end{minipage}\end{lrbox}%
  \global\addtocounter{r@tfl@t}{1}%
  \rot@label{RF\ther@tfl@t}%
  \def\R@@page{\pageref{RF\ther@tfl@t}}%
  \@tempdima\ht\rot@float@box
  \advance\@tempdima by \dp\rot@float@box
  \PWRF@trace\thr@@{BOX wd: \the\wd\rot@float@box, ht: \the\ht\rot@float@box, dp: \the\dp\rot@float@box: so shift by .5 of \the\@tempdima}%
  \wd\rot@float@box\z@
  \ht\rot@float@box\z@
  \dp\rot@float@box\z@
  \vbox to \textheight{%
    \if@rot@twoside
      \def\R@@page{\pageref{RF\ther@tfl@t}}%
    \else
      \let\R@@page\rot@LR
    \fi
    \ifodd\R@@page
      \PWRF@trace\tw@{Adding sideways float on right hand page}%
      \vfill
      \hbox to \textwidth{\hfill\rotatebox{90}{\box\rot@float@box}\hfill}%
    \else
      \PWRF@trace\tw@{Adding sideways float on left hand page}%
      \hbox to \textwidth{\hfill\rotatebox{-90}{\box\rot@float@box}\hfill}%
      \vfill
    \fi
  }
  \end@dblfloat
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@initisofig}
% \begin{macro}{\@initisotab}
% \begin{macro}{\rotcapfont}
%  \emph{Extension:} The following definitions implement some of
% the ISO-specific stuff. They basically provide for the setting up of
% the \file{lof} and \file{lot} files. |\rotcapfont| is the font for
% typesetting any captions. For ISO it is bold and may be larger than normal.
%
% \changes{v2}{1997/12/03}{Added \cs{PWRF@initfig} and \cs{PWRF@inittab}}
% \changes{v2.1}{2000/02/15}{Added check for iso class}
% \changes{v2.1}{2000/02/15}{Used \cs{@initisofig} instead of 
%                 \cs{PWRF@initfig} and same for tables}
%    \begin{macrocode}
\@ifundefined{@initisofig}{%
  \newcommand{\@initisofig}{}
  \newcommand{\@initisotab}{}
  \newif\ifinfloat
  \newcommand{\rotcapfont}{}}{\newcommand{\rotcapfont}{\captionsize\bf}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{environment}{sidewaysfigure}
%    Use |\def| instead of |\...environment| in order to be OK for both
%    redefining the \file{rotating} environment and creating a new 2.09
%    environment.
%    \begin{macrocode}
\def\sidewaysfigure{%
  \@initisofig
  \@rotfloat{figure}}
\def\endsidewaysfigure{\end@rotfloat\infloatfalse}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{sidewaystable}
%    The \Lenv{sidewaystable} environment is similar.
%    It also requires redefinition to take account of the ISO peculiarities.
%    \begin{macrocode}
\def\sidewaystable{%
  \@initisotab
  \@rotfloat{table}}
\def\endsidewaystable{\end@rotfloat\infloatfalse}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{sidewaysfigure*}
% \begin{environment}{sidewaystable*}
%    These are for rotations in a two column setting. The definitions
% are similar to the previous ones for single column.
% \changes{v2}{1997/12/03}{Added sidewaysfigure and sidewaystable for double columns}
%    \begin{macrocode}
\newenvironment{sidewaysfigure*}{%
  \@initisofig
  \@rotdblfloat{figure}}{%
  \end@rotdblfloat\infloatfalse}
\newenvironment{sidewaystable*}{%
  \@initisotab
  \@rotdblfloat{table}}{%
  \end@rotdblfloat\infloatfalse}
%    \end{macrocode}
% \end{environment}
% \end{environment}
%
% \subsubsection{Rotated captions}
%
% \begin{macro}{\rotcaption}
% \begin{macro}{\@rotcaption}
%    This inserts a caption rotated through 90 degrees. The code, which is
%    essentially a copy of the normal |\caption| code, is defined
%    in the \file{rotation} package.
%    \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}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@makerotcaption}
%    The workhorse for rotated captions.
%    \begin{macrocode}
\long\def\@makerotcaption#1#2{%
  \hspace{\abovecaptionskip}
  \setbox\@tempboxa\hbox{{\rotcapfont #1 -- #2}}%
  \ifdim \wd\@tempboxa > .8\vsize
      \rotatebox{90}{%
      \begin{minipage}{.8\textheight}{\centering{\rotcapfont #1 -- #2}\par}\end{minipage}%
      }\par
  \else%
    \rotatebox{90}{\box\@tempboxa}%
  \fi
  \hspace{\belowcaptionskip}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\controtcaption}
%    A rotated continuation caption.
%    \begin{macrocode}
\newcommand{\controtcaption}{\@controtcaption\@captype}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@controtcaption}
%    The worker for a rotated continuation caption.
%    \begin{macrocode}
\long\def\@controtcaption#1#2{%
  \begingroup
    \@parboxrestore
    \normalsize
    \@makerotcaption{\csname fnum@#1\endcsname}{\ignorespaces #2}\par
  \endgroup}
%    \end{macrocode}
% \end{macro}
%
%    The end of the package code.
%    \begin{macrocode}
%</rot|rotne>
%    \end{macrocode}
%
%
%
% \bibliographystyle{alpha}
%
% \begin{thebibliography}{GMS94}
%
% \bibitem[GMS94]{GOOSSENS94}
% Michel Goossens, Frank Mittelbach, and Alexander Samarin.
% \newblock {\em The LaTeX Companion}.
% \newblock Addison-Wesley Publishing Company, 1994.
%
% \bibitem[ISO97]{ISOD397}
% {\em {ISO/IEC Directives Part 3 --- Drafting and presentation of International
%   Standards}}, third edition, 1997.
%
% \bibitem[Wil96]{PRW96i}
% Peter~R. Wilson.
% \newblock {\em {LaTeX for standards: The LaTeX package files user manual}}.
% \newblock NIST Report NISTIR, June 1996.
%
% \end{thebibliography}
%
% 
% \Finale
% \PrintIndex
%
\endinput

%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}