-
Notifications
You must be signed in to change notification settings - Fork 5
/
pdflscape.sty
165 lines (159 loc) · 4.72 KB
/
pdflscape.sty
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
% File: pdflscape.sty
% Version: 2001/02/04 v0.2
% Author: Heiko Oberdiek
% Email: <[email protected]>
%
% Copyright: Copyright (C) 2001 Heiko Oberdiek.
%
% This program may be distributed and/or modified under
% the conditions of the LaTeX Project Public License,
% either version 1.2 of this license or (at your option)
% any later version. The latest version of this license
% is in
% http://www.latex-project.org/lppl.txt
% and version 1.2 or later is part of all distributions
% of LaTeX version 1999/12/01 or later.
%
% Function: Package `pdflscape' adds PDF support to the
% environment `landscape' of package `lscape'
% by setting the PDF page attribute `/Rotate'.
% Both the pdfTeX route and the dvips method
% are supported.
%
% Required: * The package `lscape'.
%
% Use: Load this package instead of package `lscape':
% \usepackage{pdflscape}
% \begin{landscape}...\end{landscape}
%
% History: 2001/01/15 v0.1:
% * first public version,
% published in de.comp.text.tex.
% 2001/02/04 v0.2:
% * minor documentation update.
% * CTAN.
%
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{pdflscape}
[2001/02/04 v0.2 Landscape pages in PDF (HO)]
\DeclareOption*{\PassOptionsToPackage\CurrentOption{lscape}}
\ProcessOptions
\RequirePackage{lscape}
% Driver stuff:
% * \PLS@AddRotate#1
% it expects the correct rotation number in #1
% and implements the adding of the /Rotation entry
% in the /Page object of the current page.
% * \PLS@RemoveRotate
% it removes a previous /Rotate entry, if necessary.
% Detecting the driver
\def\PLS@temp#1{}%
\ifcase 0\ifnum 1=0\ifx\pdfoutput\@undefined\else
\ifx\pdfoutput\relax\else
\ifnum\pdfoutput>0 1\fi\fi\fi\space
1\else
\ifx\Gin@PS@raw\@undefined\else
\ifx\Gin@PS@raw\relax\else
\ifx\Gin@PS@raw\PLS@temp
\else
2\fi\fi\fi\fi
\relax
% case 0: no pdfTeX, no PostScript
\PackageError{pdflscape}{%
Neither pdfTeX nor PostScript driver found%
}\@ehc
\expandafter\endinput
\or
% case 1: pdfTeX
\def\PLS@AddRotate#1{%
\ifnum#1=0
% already the default
\else
\global\pdfpageattr\expandafter{%
\the\pdfpageattr
/Rotate #1%
}%
\fi
}
% Removes a /Rotate entry. It has to be called inside
% a group.
\def\PLS@RemoveRotate{%
\global\pdfpageattr\expandafter{\expandafter}%
\expandafter\PLS@@RemoveRotate
\the\pdfpageattr /Rotate\@nil
}
\def\PLS@@RemoveRotate#1/Rotate#2\@nil{%
% append /Rotate free stuff to \pdfpageattr
\global\pdfpageattr\expandafter{\the\pdfpageattr#1}%
\ifx\\#2\\%
% ready, because the detected /Rotate is part of
% the end marker: /Rotate\@nil
\else
% first read in the argument of /Rotate,
% then continue parsing.
\afterassignment\PLS@@RemoveRotate
\count0=#2\@nil
\fi
}
\or
% case 2: PostScript
\def\PLS@AddRotate#1{%
\ifnum#1=0
\else
\Gin@PS@raw{%
[{ThisPage}\string<\string</Rotate #1\string>\string>%
/PUT pdfmark%
}%
\fi
}%
\let\PLS@RemoveRotate\relax
\fi
% Driver independent stuff
%
% The landscape environment is extended by
% adding the correct /Rotate entries.
\g@addto@macro{\landscape}{\PLS@Rotate{90}}
\g@addto@macro{\endlandscape}{\PLS@Rotate{0}}
% Main macro, that sets the /Rotate entry.
% Argument: any TeX number or
% nothing, that means zero.
% Driver independent.
\def\PLS@Rotate#1{%
\begingroup
% 1. Check and validate the argument
\PLS@CheckAngle{#1}%
% 2. Delete an existing /Rotate entry
\PLS@RemoveRotate
% 3. Add /Rotate entry
\expandafter\PLS@AddRotate\expandafter{\the\count@}%
\endgroup
}
% Validates the rotation angle.
% The result is stored in the count register \count@.
% Driver independent.
\def\PLS@CheckAngle#1{%
% noting means zero:
\ifx\\#1\\%
\count@=0
\else
\count@=#1\relax
\fi
% normalise to interval -360 < \count@ < 360
\@whilenum\count@>359\do{\addtocounter\count@ -360 }%
\@whilenum\count@<-359\do{\addtocounter\count@ 360 }%
% check values: 0, +/-90, +/-180, +/-270
\ifnum 1=0\ifnum\count@=0 \else
\ifnum\count@=90 \else
\ifnum\count@=-90 \else
\ifnum\count@=180 \else
\ifnum\count@=-180 \else
\ifnum\count@=270 \else
\ifnum\count@=-270 \else
1\fi\fi\fi\fi\fi\fi\fi\relax
\PackageError{pdflscape}{%
Invalid value \the\count@\space for /Rotate%
}\@ehc
\count@=0
\fi
}
\endinput