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
|
% \iffalse
%<*gobble>
% $Id: rviewport.dtx,v 1.2 2011-08-27 22:53:32 boris Exp $
%
% Copyright 2011, Boris Veytsman <borisv@lk.net>
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3 of this license or (at your option) any
% later version.
% The latest version of the license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of
% LaTeX version 2003/06/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Boris Veytsman
%
% This work consists of the file rviewport.dtx and the
% derived files rviewport.sty, rviewport.dtx.
%
% \fi
% \CheckSum{110}
%
%
%% \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 \~}
%
%\iffalse
% \begin{macrocode}
\documentclass{ltxdoc}
\usepackage{array,graphicx}
\usepackage{url,amsmath,hypdoc}
\usepackage{rviewport}
\newcommand\progname[1]{\textsl{#1}}
\DoNotIndex{\NeedsTeXFormat, \ProvidesPackage, \def, \hspace}
\DoNotIndex{\futurelet, \@gobble, \ifx, \else, \fi, \relax}
\DoNotIndex{\ifmmode, \fi, \allowbreak}
\PageIndex
\CodelineIndex
\RecordChanges
\EnableCrossrefs
\begin{document}
\DocInput{rviewport.dtx}
\end{document}
% \end{macrocode}
%</gobble>
% \fi
% \MakeShortVerb{|}
%
%\GetFileInfo{rviewport.sty}
% \title{Relative Viewport for Graphics Inclusion\thanks{\copyright
% Boris Veytsman, 2011. E-mail: \texttt{borisv@lk.net}}}
% \author{Boris Veytsman\thanks{This work was partially supported by
% The Food and Agriculture Organization of the United Nations}}
% \date{\filedate, \fileversion}
% \maketitle
%
% \begin{abstract}
% The package adds a new keyword |rviewport| to the
% \progname{graphicx} package specifiying Relative Viewport for
% graphics inclusion: a window defined by the given fractions of the
% natural width and height of the image.
% \end{abstract}
%
% \tableofcontents
%
% \clearpage
%
%\section{User Interface}
%\label{sec:interface}
%
% Package \progname{graphicx} provides a useful keyword |viewport|
% which allows to show just a part of an image. However, one needs to
% put there the actual coordinates of the viewport window. Sometimes
% it is useful to have relative coordinates as fractions of
% natural size. For example, one may want to print a large image on a
% spread, putting a half on a verso page, and another half on the next
% recto page. For this one would need a viewport occupying exactly
% one half of the file's bounding box, whatever the actual width of the
% image may be.
%
% Here we define the new option |rviewport| for
% Relative Viewport. It works like this. Suppose the image has the
% bounding box $x_{ll}$, $y_{ll}$, $x_{ur}$, $y_{ur}$. We give four
% numbers $\xi_{ll}$, $\eta_{ll}$, $\xi_{ur}$, $\eta_{ur}$, and the viewport
% coordinates become
% \begin{align*}
% x'_{ll} &= x_{ll} + \xi_{ll}\Delta_x\\
% y'_{ll} &= y_{ll} + \eta_{ll}\Delta_y\\
% x'_{ur} &= x_{ll} + \xi_{ur}\Delta_x\\
% y'_{ur} &= y_{ll} + \eta_{ur}\Delta_y
% \end{align*}
% where
% \begin{align*}
% \Delta_x &= x_{ur} - x_{ll}\\
% \Delta_y &= y_{ur} - y_{ll}
% \end{align*}
% This means that the left half of the image can be defined as
% |rviewport = 0 0 0.5 1|,
% and the right half can be defined as |rviewport = 0.5 0 1 1|.
%
% The package may be loaded before or after \progname{graphicx}
% package.
%
%
%\section{Examples}
%\label{sec:examples}
%
%
% \def\Example#1{%
% \begin{center}
% \includegraphics[rviewport=#1,clip]{vitruvian}\\*
% \cmd{\includegraphics}[rviewport=#1,clip]\texttt{\{vitruvian\}}
% \end{center}}
%
% \Example{0 0 1 1}
% \Example{0 0 0.5 1}
% \Example{0.5 0 1 1}
% \Example{0 0 0.5 0.5}
% \Example{0 0.5 1 1}
% \Example{0 0 1 0.5}
% \Example{0.4 0.6 0.6 0.9}
%
%
%\StopEventually{}
%
% \clearpage
%
% \section{Implementation}
% \label{sec:implementation}
%
%
%\subsection{Declarations}
%\label{sec:decl}
%
% We start with declaration, who we are:
%
%
% \begin{macrocode}
%<*style>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{rviewport}
[2011/08/27 v1.0 Relative viewport for graphics inclusion]
% \end{macrocode}
%
% The package \progname{graphicx} loads \progname{keyval}, but in case
% we are loaded before \progname{graphicx} we require it here:
% \begin{macrocode}
\RequirePackage{keyval}
% \end{macrocode}
%
%
%\subsection{The New Key}
%\label{sec:key}
%
% We add a new key for the \progname{graphicx} package:
% \begin{macrocode}
\define@key{Gin}{rviewport}
{\let\Gin@viewport@code\Gin@rviewport\Gread@parse@rvp#1 \\}
% \end{macrocode}
%
%
% \begin{macro}{\Gread@parse@rvp}
% We parse four numbers into the corresponding macros:
% \begin{macrocode}
\def\Gread@parse@rvp#1 #2 #3 #4 #5\\{%
\def\Gin@vllx{#1}%
\def\Gin@vlly{#2}%
\def\Gin@vurx{#3}%
\def\Gin@vury{#4}}%
% \end{macrocode}
%
% \end{macro}
%
% \begin{macro}{\Gin@rviewport}
% And the viewport code. Note that |pdftex.def| relies on
% the values of |\Gin@v...| macros, so we redefine them as well.
% \begin{macrocode}
\def\Gin@rviewport{%
\let\Gin@ollx\Gin@llx
\let\Gin@olly\Gin@lly
\let\Gin@ourx\Gin@urx
\let\Gin@oury\Gin@ury
\Gin@nat@width\Gin@urx\p@
\advance\Gin@nat@width-\Gin@llx\p@
\Gin@nat@height\Gin@ury\p@
\advance\Gin@nat@height-\Gin@lly\p@
\dimen@\Gin@vurx\Gin@nat@width
\edef\Gin@vurx{\strip@pt\dimen@}%
\advance\dimen@\Gin@llx\p@
\edef\Gin@urx{\strip@pt\dimen@}%
\dimen@\Gin@vury\Gin@nat@height
\edef\Gin@vury{\strip@pt\dimen@}%
\advance\dimen@\Gin@lly\p@
\edef\Gin@ury{\strip@pt\dimen@}%
\dimen@\Gin@vllx\Gin@nat@width
\edef\Gin@vllx{\strip@pt\dimen@}%
\advance\dimen@\Gin@llx\p@
\edef\Gin@llx{\strip@pt\dimen@}%
\dimen@\Gin@vlly\Gin@nat@height
\edef\Gin@vlly{\strip@pt\dimen@}%
\advance\dimen@\Gin@lly\p@
\edef\Gin@lly{\strip@pt\dimen@}}
% \end{macrocode}
%
% \end{macro}
%
%
%
%\subsection{The Last Words}
%\label{sec:last}
%
%
%
% \begin{macrocode}
%</style>
% \end{macrocode}
%\Finale
%\clearpage
%
%\PrintChanges
%\clearpage
%\PrintIndex
%
\endinput
|