Update LuaTeX testfiles for ^@ change
[latex2e.git] / latex2e-20170101 / required / graphics / graphicx.dtx
blob963acdde7ae4c2ee167f1731396333617b510f18
2 % \iffalse
4 %% graphicx.dtx Copyright (C) 1994      David Carlisle Sebastian Rahtz
5 %%              Copyright (C) 1995--2015 David Carlisle, LaTeX3 Project
6 %%
7 %% This file is part of the Standard LaTeX `Graphics Bundle'.
8 %% It may be distributed under the terms of the LaTeX Project Public
9 %% License, as described in lppl.txt in the base LaTeX distribution.
10 %% Either version 1.3c or, at your option, any later version.
12 %<*dtx>
13           \ProvidesFile{graphicx.dtx}
14 %</dtx>
15 %<package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
16 %<package>\ProvidesPackage{graphicx}
17 %<driver> \ProvidesFile{graphicx.drv}
18 % \fi
19 %         \ProvidesFile{graphicx.dtx}
20           [2014/10/28 v1.0g  Enhanced LaTeX Graphics (DPC,SPQR)]
22 % \iffalse
23 %<*driver>
24 \documentclass{ltxdoc}
25 \newenvironment{key}[2]{\expandafter\macro\expandafter{%
26    \csname KV@#1@#2\endcsname}}{\endmacro}
28 \begin{document}
29  \DocInput{graphicx.dtx}
30 \end{document}
31 %</driver>
32 % \fi
34 % \GetFileInfo{graphicx.dtx}
36 % \title{The \textsf{graphicx} package\thanks{This file
37 %        has version number \fileversion, last
38 %        revised \filedate.}}
39 % \author{D. P. Carlisle\and S. P. Q. Rahtz}
40 % \date{\filedate}
41 % \MaintainedByLaTeXTeam{graphics}
42 % \maketitle
45 % \changes{v0.3}{1994/03/01}
46 %     {First DPC version (after prototype by SPQR).}
47 % \changes{v0.4b}{1994/05/30}
48 %     {Rename from egraphics. 8+3 name for CDROM}
49 % \changes{v1.0}{1996/05/29}
50 %     {Version 1 at last}
52 % \def\star{{\ttfamily*}}
53 % \makeatletter
54 % \def\Describe@Macro#1{\endgroup
55 %              \setbox0=\lastbox\llap{\PrintDescribeMacro{#1}}}%
56 % \makeatother
57 % \marginparsep0pt
59 % \section{Introduction}
61 % This package provides an alternative interface to the \LaTeXe\
62 % graphics functions. The command names provided are the same as in the
63 % standard package, and they use the same internal functions. However
64 % the meaning of the optional arguments is different. Note \emph{only}
65 % the optional arguments have changed: any document which only uses the
66 % graphics commands with the mandatory arguments and/or the star-forms
67 % will work identically (with essentially identical implementation) with
68 % the two packages.
70 % \section{Key=Value Interface}
71 % When the decision to produce \LaTeXe\ was made, certain `guiding
72 % principles' were made (and published in the original announcement).
73 % One of these was that all new features would `conform to the
74 % conventions of version 2.09'. Specifically this meant that new
75 % commands would obey the same basic syntax rules for arguments as the
76 % existing commands.
78 % Standard \LaTeX\ optional arguments are \emph{positional}. If a
79 % command were to take three optional arguments, then there would be no
80 % way of specifying only the third, one would have to give all three,
81 % even if  the first two were repeats of the default values. Basically
82 % this means that `standard' optional arguments are not suitable if
83 % there is more than one option. Various existing packages (for
84 % \LaTeX~2.09) have recognised this, and used `named arguments' in
85 % various forms. Perhaps the two most noticeable are |psfig| and
86 % |pstricks|. With `named arguments' (sometimes called `attributes')
87 % each option is not tied to a particular position, but rather given a
88 % name (or key) and any options that must be set are set by explicitly
89 % associating this name with the desired value.
91 % The members of the \LaTeX3 project do appreciate the importance of
92 % this kind of syntax, but felt that rather than extending the syntax of
93 % \LaTeX\ in an uncoordinated way, it would be better to keep with
94 % `standard arguments' in \LaTeXe, which is intended as a `consolidation
95 % of existing \LaTeX\ variants'. The long term planning for an eventual
96 % \LaTeX3 release will then be able to consider the whole \LaTeX\
97 % user interface, and a suitable syntax for named arguments. It is
98 % important that such an interface design is not hampered by having to
99 % retain compatibility with earlier attempts at a named argument
100 % syntax. For this reason this |graphicx| package, which uses the named
101 % argument mechanism from the |keyval| package should be considered `non
102 % standard' although it is supported by the same mechanism, and same
103 % authors as the `standard' |graphics| package.
105 % \section{The User Interface}
107 % \DescribeMacro
108 %     \includegraphics\star\oarg{key-val list}\marg{file}\\
109 % \DescribeMacro
110 %     \includegraphics\star\oarg{llx,lly}\oarg{urx,ury}\marg{file}\\
111 % Include a graphics file.
113 % The star form is just for
114 % compatibility with the standard interface, and essentially just adds
115 % |clip| to the keys specified. Similarly the second, two-optional
116 % argument form is for increased compatibility with the standard
117 % package. The two optional argument form is not needed in the |keyval|
118 % interface.
120 % Various `keys' or named arguments are supported.
121 % \begin{description}
122 % \item[bb] Set the bounding box. The argument should be four
123 % dimensions, separated by spaces.
124 % \item[bbllx,bblly,bburx,bbury] Set the bounding box. Mainly for
125 % compatibility with older packages. |bbllx=a,bblly=b,bburx=c,bbury=d|
126 % is equivalent to |bb = a b c d|.
127 % \item[natwidth,natheight] Again an alternative to |bb|.
128 % |natheight=h,natwidth=w| is equivalent to |bb = 0 0 h w|.
129 % \item[viewport] Modify the bounding box specified in the file.
130 % The four values specify a bounding box \emph{relative} to the
131 % |llx|,|lly| coordinate of the original box.
132 % \item[trim] Modify the bounding box specified in the file.
133 % The four values specify the amounts to remove from
134 % the left, bottom, right and top of the original box.
135 % \item[hiresbb] Boolean valued key. Defaults to |true|.
136 % Causes \TeX\ to look for |%%HiResBoundingBox| comments rather than
137 % the standard |%%BoundingBox|. May be set to |false| to override
138 % a default setting of true specified by the |hiresbb| package option.
139 % \item[angle] Rotation angle.
140 % \item[origin] Rotation origin (see |\rotatebox|, below).
141 % \item[width] Required width, a dimension (default units |bp|). The
142 % graphic will be scaled to make the width the specified dimension.
143 % \item[height] Required height. a dimension (default units |bp|).
144 % \item[totalheight] Required totalheight (i.e., height $+$ depth). a
145 % dimension (default units |bp|). Most useful after a rotation (when the
146 % height might be zero).
147 % \item[keepaspectratio] Boolean valued key (like |clip|). If it is set
148 %  to true, modify the meaning of the |width| and |height| (and
149 % |totalheight|) keys such that if both are specified then rather than
150 % distort the figure the figure is scaled such that neither dimension
151 % \emph{exceeds} the stated dimensions.
152 % \item[scale] Scale factor.
153 % \item[clip] Either `true' or `false' (or no value, which is equivalent
154 % to `true'). Clip the graphic to the bounding box (or viewport if one
155 % is specified).
156 % \item[draft] a boolean valued key, like `clip'. locally switches to
157 % draft mode, ie.\ do not include the graphic, but leave the
158 % correct space, and print the filename.
159 % \item[type] Specify the file type. (Normally determined from the file
160 % extension.)
161 % \item[ext] Specify the file extension.
162 %        \emph{Only} for use with |type|.
163 % \item[read] Specify the `read file' which is used for determining the
164 % size of the graphic. \emph{Only} for use with |type|.
165 % \item[command] Specify the file command.
166 %         \emph{Only} for use with |type|.
167 % \end{description}
169 % The arguments are interpreted left to right. |clip|, |draft|, |bb|,,
170 % and |bbllx| etc.\ have the same effect wherever they appear. but the
171 % scaling and rotation keys interact.
173 % Any scaling that is specified \emph{before} rotation, is handled by
174 % the internal graphics inclusion function. Rotation, or any later
175 % scaling is handled by implicitly calling |\rotatebox| or |\scalebox|.
176 % So |[height=1in,angle=90]| scales the graphic to 1in, then rotates it,
177 % so it is one inch wide. |[angle=90,height=1in]|  first rotates, then
178 % scales the result so that it is 1in high. A driver that can scale
179 % included graphics, but not arbitrary text will not be able to support
180 % the second form, as it will require a call to |\scalebox|, but the
181 % first form should work as there the scaling is handled by
182 % |\Ginclude@graphics|.
184 % \DescribeMacro
185 %      \rotatebox\oarg{key-val list}\marg{angle}\marg{text}\\
186 % Rotate \emph{text}.
188 % The keys supported by |\rotatebox| are:
189 % \begin{description}
190 % \item[origin] Specify the centre of rotation. |origin=|\meta{label},
191 % where the labels are up to two of |lrctbB| (|B| denotes the
192 % baseline, as for PSTricks).
193 % \item[x,y] An alternative to
194 % |origin|. |x=|\meta{dimen}|,y=|\meta{dimen} The $x,y$ coordinate of
195 % the centre of rotation. As usual |\height| etc may be used.
196 % \item[units] Specify the units used in the main argument. eg
197 % |units=-360| would mean that the argument referred to degrees
198 % \emph{clockwise} instead of the default anti-clockwise rotation.
199 % \end{description}
201 % As an example |\rotatebox[origin=c]{180}{text}| will rotate ``text''
202 % around its centre, thus creating a final box of the same dimensions as
203 % the original box. This is to be contrasted to the default behaviour,
204 % which rotates around the reference point on the baseline, thus
205 % producing a box that is mainly \emph{below} the baseline.
207 % \StopEventually{}
210 % \section{Implementation}
212 %    \begin{macrocode}
213 %<*package>
214 %    \end{macrocode}
216 % One  new option is  handled by keyval. It suppresses the error
217 % normally generated if an unknow keyval key is used.
218 % (This helps porting between drivers that use extended interfaces.)
219 % \changes{v1.0e}{1999/01/10}{new unknownkeysallowed option}
220 %    \begin{macrocode}
221 \DeclareOption{unknownkeysallowed}
222   {\PassOptionsToPackage\CurrentOption{keyval}}
223 %    \end{macrocode}
225 % All other options are handled by the \textsf{graphics} package.
226 %    \begin{macrocode}
227 \DeclareOption*{\PassOptionsToPackage\CurrentOption{graphics}}
228 %    \end{macrocode}
230 %    \begin{macrocode}
231 \ProcessOptions
232 %    \end{macrocode}
234 % This package requires these two building blocks.
235 %    \begin{macrocode}
236 \RequirePackage{keyval,graphics}
237 %    \end{macrocode}
240 % \subsection{Graphics Inclusion}
243 % First we declare the `bounding box' keys. These all use
244 % |\Gin@defaultbp| so that the \meta{value} can be given as a length in
245 % the usual \TeX\ units such as |cm| or as an integer, taken as |bp|.
247 % \begin{key}{Gin}{bb}
248 %    \begin{macrocode}
249 \define@key{Gin}{bb}
250            {\Gin@bboxtrue\Gread@parse@bb#1 \\}
251 %    \end{macrocode}
252 % \end{key}
254 % \begin{key}{Gin}{bbllx}
255 % \begin{key}{Gin}{bblly}
256 % \begin{key}{Gin}{bburx}
257 % \begin{key}{Gin}{bbury}
258 % \changes{v0.3b}{1994/03/11}{use bbllx not llx}
259 % \changes{v0.3b}{1994/03/11}{add natheight and natwidth}
260 % \changes{v0.6a}{1995/04/11}{New \cs{Gin@defaultbb} code}
261 % \changes{v0.6b}{1995/06/26}{typos fixed for graphics/1685}
262 %    \begin{macrocode}
263 \define@key{Gin}{bbllx}
264            {\Gin@bboxtrue\Gin@defaultbp\Gin@llx{#1}}
265 \define@key{Gin}{bblly}
266            {\Gin@bboxtrue\Gin@defaultbp\Gin@lly{#1}}
267 \define@key{Gin}{bburx}
268            {\Gin@bboxtrue\Gin@defaultbp\Gin@urx{#1}}
269 \define@key{Gin}{bbury}
270            {\Gin@bboxtrue\Gin@defaultbp\Gin@ury{#1}}
271 %    \end{macrocode}
272 % \end{key}
273 % \end{key}
274 % \end{key}
275 % \end{key}
277 % \begin{key}{Gin}{hiresbb}
278 % \changes{v1.0b}{1996/10/29}
279 %      {hiresbb key added}
280 % If set to true (the default)  \TeX\ will look for bounding box
281 % comments of the form |%%HiResBoundingBox| (which typically have
282 % real values) instead of the standard |%%BoundingBox| (which should
283 % have integer values).
284 % It may be set to false to override a package option of hiresbb.
285 %    \begin{macrocode}
286 \define@key{Gin}{hiresbb}[true]{%
287   \edef\Gread@BBox{%
288     \@percentchar\@percentchar
289     \csname if#1\endcsname HiRes\fi
290     BoundingBox}}
291 %    \end{macrocode}
292 % \end{key}
294 % \begin{key}{Gin}{natheight}
295 % \begin{key}{Gin}{natheight}
296 % \changes{v0.6d}{1995/09/22}
297 %      {typos fixed in natheight and natwidth keys}
298 %    \begin{macrocode}
299 \let\KV@Gin@natwidth\KV@Gin@bburx
300 \let\KV@Gin@natheight\KV@Gin@bbury
301 %    \end{macrocode}
302 % \end{key}
303 % \end{key}
305 % \begin{key}{Gin}{viewport}
306 % \begin{key}{Gin}{trim}
307 % \changes{v0.6a}{1995/04/11}{viewport and trim keys added}
308 % \changes{v0.6c}{1995/09/07}{arithmetic in viewport key fixed}
309 % A `viewport' is a user-specified area of the graphic to be included.
310 % It should not be confused with the `Bounding Box' of a PS file.
311 % In fact, the origin for a viewport specification is the (llx,lly)
312 % lower left coordinate of the bounding box. If a viewport is
313 % specified, and clipping is turned on, clipping is based on the
314 % viewport, not on the boundingbox.
316 % Both `viewport' and `trim' were suggested (and originally, but
317 % differently, implemented) by Arthur Ogawa.
318 %    \begin{macrocode}
319 \define@key{Gin}{viewport}
320            {\let\Gin@viewport@code\Gin@viewport\Gread@parse@vp#1 \\}
321 \define@key{Gin}{trim}
322            {\let\Gin@viewport@code\Gin@trim\Gread@parse@vp#1 \\}
323 %    \end{macrocode}
324 % \end{key}
325 % \end{key}
327 % \begin{macro}{\Gread@parse@vp}
328 % Grabs four bounding box values like |\Gread@parse@bp| but saves them
329 % in alternative macros that are used in the viewport and trim cases to
330 % modify the bounding box read from the file.
331 %    \begin{macrocode}
332 \def\Gread@parse@vp#1 #2 #3 #4 #5\\{%
333   \Gin@defaultbp\Gin@vllx{#1}%
334   \Gin@defaultbp\Gin@vlly{#2}%
335   \Gin@defaultbp\Gin@vurx{#3}%
336   \Gin@defaultbp\Gin@vury{#4}}%
337 %    \end{macrocode}
338 % \end{macro}
340 % \begin{macro}{\Gin@viewport}
341 % \changes{v1.0c}{1996/10/31}{Original bb saved}
342 % If a viewport is specified, reset the bounding box coordinates
343 % by adding the original origin, |\Gin@llx|, |\Gin@lly| to the new
344 % values specified as the viewport. The original Bounding box
345 % coordinates are saved in |\Gin@ollx|\ldots\ some drivers
346 % might need this information (currently just |tcidvi|).
347 %    \begin{macrocode}
348 \def\Gin@viewport{%
349   \let\Gin@ollx\Gin@llx
350   \let\Gin@olly\Gin@lly
351   \let\Gin@ourx\Gin@urx
352   \let\Gin@oury\Gin@ury
353   \dimen@\Gin@llx\p@\advance\dimen@ \Gin@vurx\p@
354                       \edef\Gin@urx{\strip@pt\dimen@}%
355   \dimen@\Gin@lly\p@\advance\dimen@ \Gin@vury\p@
356                       \edef\Gin@ury{\strip@pt\dimen@}%
357   \dimen@\Gin@llx\p@\advance\dimen@ \Gin@vllx\p@
358                       \edef\Gin@llx{\strip@pt\dimen@}%
359   \dimen@\Gin@lly\p@\advance\dimen@ \Gin@vlly\p@
360                       \edef\Gin@lly{\strip@pt\dimen@}}
361 %    \end{macrocode}
362 % \end{macro}
364 % \begin{macro}{\Gin@trim}
365 % \changes{v1.0c}{1996/10/31}{Original bb saved}
366 % If a trim is specified, reset the bounding box coordinates
367 % by trimming the four specified values off each side of the
368 % graphic.
369 %    \begin{macrocode}
370 \def\Gin@trim{%
371   \let\Gin@ollx\Gin@llx
372   \let\Gin@olly\Gin@lly
373   \let\Gin@ourx\Gin@urx
374   \let\Gin@oury\Gin@ury
375   \dimen@\Gin@llx\p@\advance\dimen@ \Gin@vllx\p@
376                       \edef\Gin@llx{\strip@pt\dimen@}%
377   \dimen@\Gin@lly\p@\advance\dimen@ \Gin@vlly\p@
378                       \edef\Gin@lly{\strip@pt\dimen@}%
379   \dimen@\Gin@urx\p@\advance\dimen@ -\Gin@vurx\p@
380                       \edef\Gin@urx{\strip@pt\dimen@}%
381   \dimen@\Gin@ury\p@\advance\dimen@ -\Gin@vury\p@
382                       \edef\Gin@ury{\strip@pt\dimen@}}
383 %    \end{macrocode}
384 % \end{macro}
386 % \begin{macro}{\Gin@vllx}
387 % \begin{macro}{\Gin@vlly}
388 % \begin{macro}{\Gin@vurx}
389 % \begin{macro}{\Gin@vury}
390 % Four macros to hold the modifiers for the bounding box for viewport
391 % and trim specifications.
392 %    \begin{macrocode}
393 \let\Gin@vllx\Gin@llx\let\Gin@vlly\Gin@llx
394 \let\Gin@vurx\Gin@llx\let\Gin@vury\Gin@llx
395 %    \end{macrocode}
396 % \end{macro}
397 % \end{macro}
398 % \end{macro}
399 % \end{macro}
401 % \begin{key}{Gin}{angle}
402 % Specify a rotation. This is just handled by wrapping the
403 % |\includegraphics| command in a call to the internal version of
404 % |\rotatebox|. Normally this is the `standard' version but if an
405 % |origin| key is used in |\includegraphics| then the \emph{keyval}
406 % version of origin is used, and the |origin| key is passed on.
407 %    \begin{macrocode}
408 \define@key{Gin}{angle}
409            {\Gin@esetsize
410             \@tempswatrue
411             \edef\@tempa{\toks@{\noexpand\Gin@erotate{#1}{\the\toks@}}}%
412             \@tempa}
413 %    \end{macrocode}
414 % \end{key}
416 % \begin{key}{Gin}{origin}
417 % Pass the origin key value on to |\rotatebox|. |\Gin@erotate| is
418 % initialised to |\Grot@box@std| later in the file, after the latter has
419 % been defined.
420 % \changes{v0.6e}{1995/09/28}
421 %     {key added}
422 %    \begin{macrocode}
423 \define@key{Gin}{origin}[c]{%
424   \def\Gin@erotate{\Grot@box@kv[origin=#1]}}
425 %    \end{macrocode}
426 % \end{key}
428 % \begin{key}{Gin}{width}
429 % \begin{key}{Gin}{height}
430 % Save the required height and width. The actual scaling is done later.
431 %    \begin{macrocode}
432 \define@key{Gin}{width}{\def\Gin@ewidth{#1}}
433 \define@key{Gin}{height}{\def\Gin@eheight{#1}}
434 %    \end{macrocode}
435 % \end{key}
436 % \end{key}
438 % \begin{key}{Gin}{totalheight}
439 % \changes{v0.6a}{1995/04/11}{New totalheight key}
440 % The same as |height| key, but locally changes |\Gin@eresize| to
441 % |\totalheight| from its default value of |\height|.
442 %    \begin{macrocode}
443 \define@key{Gin}{totalheight}{%
444   \def\Gin@eresize{\totalheight}\def\Gin@eheight{#1}}
445 %    \end{macrocode}
446 % \end{key}
448 % \begin{key}{Gin}{keepaspectratio}
449 % Boolean valued key (like |clip|). If it is set to true,
450 % modify the meaning of the |width| and |height| (and |totalheight|)
451 % keys such that if both are specified then rather than distort the
452 % figure the figure is scaled such that neither dimension \emph{exceeds}
453 % the stated dimensions.
454 % \changes{v0.6e}{1995/09/28}
455 %     {key added}
456 % \changes{v0.6h}{1995/12/06}
457 %     {Name changed to keepaspectratio}
458 %    \begin{macrocode}
459 \define@key{Gin}{keepaspectratio}[true]{%
460   \lowercase{\Gin@boolkey{#1}}{iso}}
461 %    \end{macrocode}
462 % \end{key}
464 % \begin{key}{Gin}{scale}
465 % \changes{v0.6h}{1995/12/06}
466 %     {Use \cs{Gin@exclamation}}
467 % If the scaling is being handled externally, wrap |\includegraphics| in
468 % the internal form of |\scalebox|, otherwise locally define
469 % |\Gin@req@sizes| to calculate the required sizes based on
470 % scale factor.
471 %    \begin{macrocode}
472 \define@key{Gin}{scale}{%
473   \if@tempswa
474     \edef\@tempa{\toks@{\noexpand\Gscale@box{#1}[#1]{\the\toks@}}}%
475     \@tempa
476   \else
477     \def\Gin@req@sizes{%
478       \def\Gin@scalex{#1}\let\Gin@scaley\Gin@exclamation
479       \Gin@req@height\Gin@scalex\Gin@nat@height
480       \Gin@req@width\Gin@scalex\Gin@nat@width}%
481   \fi
482   \@tempswatrue}
483 %    \end{macrocode}
484 % \end{key}
486 % \begin{key}{Gin}{draft}
487 % Locally set the draft switch to true. This is used by the code in
488 % \textsf{graphics} package to suppress the file inclusion.
489 %    \begin{macrocode}
490 \define@key{Gin}{draft}[true]{%
491   \lowercase{\Gin@boolkey{#1}}{draft}}
492 %    \end{macrocode}
493 % \end{key}
495 % \begin{key}{Gin}{clip}
496 % Locally set the clip switch to true. This is used by the code in
497 % \textsf{graphics} package to suppress the printing of anything outside
498 % the bounding box specified.
499 %    \begin{macrocode}
500 \define@key{Gin}{clip}[true]{%
501   \lowercase{\Gin@boolkey{#1}}{clip}}
502 %    \end{macrocode}
503 % \end{key}
505 % \begin{key}{Gin}{type}
506 % If you use `type' you must use no extension in the main argument
507 % and you must use `ext'. You can also use `read' and `command'.
508 % \changes{v0.5a}{1994/11/29}
509 %     {remove \cs{Gin@sep}}
510 %    \begin{macrocode}
511 \define@key{Gin}{type}{%
512   \def\Ginclude@graphics##1{%
513     \begingroup
514     \def\Gin@base{##1}%
515     \edef\@tempa{{#1}{\Gin@eread}{\Gin@ecom{##1\Gin@eext}}}%
516     \expandafter\Gin@setfile\@tempa
517     \endgroup}}
518 %    \end{macrocode}
519 % \end{key}
521 % \begin{key}{Gin}{ext}
522 % \changes{v1.0d}{1997/06/09}{initialise ext to empty}
523 % Specify an extension, for use with the `type' key.
524 %    \begin{macrocode}
525 \define@key{Gin}{ext}{\def\Gin@eext{#1}}
526 \let\Gin@eext\@empty
527 %    \end{macrocode}
528 % \end{key}
530 % \begin{key}{Gin}{read}
531 % Specify a read file, for use with the `type' key.
532 % You may want to globally set this to |*| using |\setkeys|.
533 % |*| means read the graphic file for size info, as in
534 % |\DeclareGraphicsRule|.
535 % \changes{v0.5a}{1994/11/29}
536 %     {Add default * possibility.}
537 %    \begin{macrocode}
538 \define@key{Gin}{read}{%
539  \def\Gin@eread{#1}%
540  \def\@tempa{*}\ifx\@tempa\Gin@eread\def\Gin@eread{\Gin@eext}\fi}
541 \let\Gin@eread\@empty
542 %    \end{macrocode}
543 % \end{key}
545 % \begin{key}{Gin}{command}
546 % Specify a command, for use with the `type' key.
547 %    \begin{macrocode}
548 \define@key{Gin}{command}{\def\Gin@ecom##1{#1}}
549 \let\Gin@ecom\@firstofone
550 %    \end{macrocode}
551 % \end{key}
553 % \begin{macro}{\Gin@boolkey}
554 % Helper function for defining boolean valued functions. The order of
555 % arguments allows |\lowercase| to only act on the user-supplied
556 % argument.
557 % \changes{v0.4a}{1994/04/14}{Make `empty'!=true so clip!= works}
558 %    \begin{macrocode}
559 \def\Gin@boolkey#1#2{%
560   \csname Gin@#2\ifx\relax#1\relax true\else#1\fi\endcsname}
561 %    \end{macrocode}
562 % \end{macro}
564 % \begin{macro}{\Gin@esetsize}
565 % \changes{v0.6h}{1995/12/06}
566 %     {Use \cs{Gin@exclamation}}
567 % Arrange for the final size to be set, either by wrapping the include
568 % graphics call in |\scalebox|, or by redefining |\Gin@req@sizes|
569 % appropriately.
570 %    \begin{macrocode}
571 \def\Gin@eresize{\height}
572 \def\Gin@esetsize{%
573   \let\@tempa\Gin@exclamation
574   \if@tempswa
575 %    \end{macrocode}
576 %  External. Wrap the |\includegraphics| command in a call to the
577 %  internal form of |\scalebox| to handle the rotation.
578 %    \begin{macrocode}
579     \edef\@tempa{\toks@{\noexpand
580              \Gscale@@box\noexpand\Gin@eresize
581               {\Gin@ewidth}{\Gin@eheight}{\the\toks@}}}%
582     \@tempa
583   \else
584 %    \end{macrocode}
585 % Internal. Handle scaling with the |\includegraphics| command directly
586 % rather than calling |\scalebox|.
587 %    \begin{macrocode}
588     \ifx\Gin@ewidth\@tempa
589       \ifx\Gin@eheight\@tempa
590 %    \end{macrocode}
591 % No resizing.
592 %    \begin{macrocode}
593       \else
594 %    \end{macrocode}
595 % Just height specified.
596 % \changes{v0.6e}{1995/09/28}
597 %     {Use \cs{setlength} to support calc package}
598 % \changes{v0.6h}{1995/12/06}
599 %     {Use \cs{Gin@exclamation}}
600 %    \begin{macrocode}
601          \let\Gin@@eheight\Gin@eheight
602          \def\Gin@req@sizes{%
603            \Gscale@div\Gin@scaley\Gin@@eheight\Gin@nat@height
604            \let\Gin@scalex\Gin@exclamation
605            \setlength\Gin@req@height\Gin@@eheight
606            \Gin@req@width\Gin@scaley\Gin@nat@width}%
607       \fi
608     \else
609       \ifx\Gin@eheight\@tempa
610 %    \end{macrocode}
611 % Just width specified.
612 % \changes{v0.6e}{1995/09/28}
613 %     {Use \cs{setlength} to support calc package}
614 % \changes{v0.6h}{1995/12/06}
615 %     {Use \cs{Gin@exclamation}}
616 %    \begin{macrocode}
617          \let\Gin@@ewidth\Gin@ewidth
618          \def\Gin@req@sizes{%
619            \Gscale@div\Gin@scalex\Gin@@ewidth\Gin@nat@width
620            \let\Gin@scaley\Gin@exclamation
621            \setlength\Gin@req@width\Gin@@ewidth
622            \Gin@req@height\Gin@scalex\Gin@nat@height}%
623       \else
624 %    \end{macrocode}
625 % Both height and width specified.
626 %    \begin{macrocode}
627          \let\Gin@@ewidth\Gin@ewidth
628          \let\Gin@@eheight\Gin@eheight
629 %    \end{macrocode}
630 % \changes{v0.6g}{1995/11/10}
631 %     {Use \cs{ifGin@iso} to support isoscale key}
632 % At this point can locally redefine |\Gin@nosize|. Instead
633 % of generating an error, just set the `natural' size to be the
634 % `requested size'. Previous versions of this package did not
635 % allow the use of |height| and |width| unless the natural size was
636 % known as otherwise \LaTeX\ can not calculate the scale factor.
637 % However many drivers (especially for bitmap formats) can work this out
638 % themselves, so as long as both |height| and |width| are given, so
639 % \LaTeX\ knows the size to leave, accept this. This assumes the code in
640 % the driver file will use the `required height' information, not the
641 % scale factors, which will be set to 1!.
642 % \changes{v1.0a}{1996/08/05}
643 %     {Missing percent added for graphics/2244}
644 %    \begin{macrocode}
645          \def\Gin@nosize##1{%
646            \KV@Gin@natwidth\Gin@@ewidth
647            \KV@Gin@natheight\Gin@@eheight}%
648 %    \end{macrocode}
650 %    \begin{macrocode}
651          \def\Gin@req@sizes{%
652            \Gscale@div\Gin@scalex\Gin@@ewidth\Gin@nat@width
653            \Gscale@div\Gin@scaley\Gin@@eheight\Gin@nat@height
654 %    \end{macrocode}
655 % \changes{v0.6f}{1995/09/29}
656 %     {Use \cs{ifGin@iso} to support isoscale key}
657 % Donald Arseneau requested this feature. If both |height|
658 % and |width| are chosen, choose the smaller scale factor rather than
659 % distort the graphic. This mode is turned on with the
660 % \textsf{keepaspectratio} key.
661 %    \begin{macrocode}
662            \ifGin@iso
663              \ifdim\Gin@scaley\p@>\Gin@scalex\p@
664                \let\Gin@scaley\Gin@scalex
665              \else
666                \let\Gin@scalex\Gin@scaley
667              \fi
668            \fi
669            \Gin@req@width\Gin@scalex\Gin@nat@width
670            \Gin@req@height\Gin@scaley\Gin@nat@height}%
671        \fi
672      \fi
673   \fi
674   \let\Gin@ewidth\Gin@exclamation
675   \let\Gin@eheight\Gin@ewidth}
676 %    \end{macrocode}
677 % \end{macro}
679 % \begin{macro}{\Gin@req@height}
680 % \begin{macro}{\Gin@req@width}
681 % The required final size.
682 %    \begin{macrocode}
683 \newdimen\Gin@req@height
684 \newdimen\Gin@req@width
685 %    \end{macrocode}
686 % \end{macro}
687 % \end{macro}
689 % \begin{macro}{\Gin@outer@scalex}
690 % \begin{macro}{\Gin@outer@scaley}
691 % Scale factors to pass to |\scalebox|.
692 %    \begin{macrocode}
693 \let\Gin@outer@scalex\relax
694 \let\Gin@outer@scaley\relax
695 %    \end{macrocode}
696 % \end{macro}
697 % \end{macro}
699 % \begin{macro}{\Gin@angle}
700 % Rotation angle.
701 %    \begin{macrocode}
702 \let\Gin@angle\relax
703 %    \end{macrocode}
704 % \end{macro}
706 % \begin{macro}{\Gin@ewidth}
707 % \changes{v0.6h}{1995/12/06}
708 %     {Use \cs{Gin@exclamation}}
709 % \begin{macro}{\Gin@eheight}
710 % Final size, initialised for no scaling.
711 %    \begin{macrocode}
712 \let\Gin@ewidth\Gin@exclamation
713 \let\Gin@eheight\Gin@ewidth
714 %    \end{macrocode}
715 % \end{macro}
716 % \end{macro}
718 % \begin{macro}{\Gin@scalex}
719 % \begin{macro}{\Gin@scaley}
720 % \changes{v0.6h}{1995/12/06}
721 %     {Use \cs{Gin@exclamation}}
722 % Scale factors. Initialised for no scaling.
723 %    \begin{macrocode}
724 \def\Gin@scalex{1}
725 \let\Gin@scaley\Gin@exclamation
726 %    \end{macrocode}
727 % \end{macro}
728 % \end{macro}
730 % \begin{macro}{\Gin@i}
731 % Use the same top level |\includegraphics| command as the standard
732 % interface. This will set the clipping switch, and then call |\Gin@i|.
733 % \changes{v0.3c}{1994/03/15}{Dont locally initialise width/height}
734 % \changes{v0.3c}{1994/03/15}{Always call \cmd{\Gin@ii}}
735 % \changes{v0.4c}{1994/09/12}{Use `standard' version if two opt.\ args.}
736 %    \begin{macrocode}
737 \def\Gin@i{%
738  \def\Gin@req@sizes{%
739    \Gin@req@height\Gin@nat@height
740    \Gin@req@width\Gin@nat@width}%
741  \@ifnextchar[\Gin@ii{\Gin@ii[]}}
742 %    \end{macrocode}
743 % \end{macro}
746 % \begin{macro}{\Gin@ii}
747 % Look for a second optional argument.
748 % If one optional argument is present, call |\setkeys| to process it,
749 %    \begin{macrocode}
750 \def\Gin@ii[#1]#2{%
751     \def\@tempa{[}\def\@tempb{#2}%
752     \ifx\@tempa\@tempb
753       \def\@tempa{\Gin@iii[#1][}%
754       \expandafter\@tempa
755     \else
756      \begingroup
757        \@tempswafalse
758        \toks@{\Ginclude@graphics{#2}}%
759        \setkeys{Gin}{#1}%
760        \Gin@esetsize
761        \the\toks@
762      \endgroup
763      \fi}
764 %    \end{macrocode}
765 % \end{macro}
767 % \changes{v0.4b}{1994/05/06}
768 %     {Remove incorrect initialisation of \cs{Gin@scalex}}
770 % \section{Rotation}
772 % \begin{macro}{\rotatebox}
773 % Look for an optional argument.
774 % \changes{v0.3b}{1994/03/11}{Remove star form}
775 % \changes{v1.0g}{2014/04/25}{\cs{leavevmode} added graphics/1521}
776 %    \begin{macrocode}
777 \def\rotatebox{%
778   \leavevmode
779   \@ifnextchar[\Grot@box@kv\Grot@box@std}
780 %    \end{macrocode}
781 % \end{macro}
783 % \begin{macro}{\Grot@box@std}
784 % If no KV argument, just repeat the standard definition.
785 % \changes{v1.0g}{2014/04/25}{Made long  graphics/4296}
786 %    \begin{macrocode}
787 \long\def\Grot@box@std#1#2{%
788   \Grot@setangle{#1}%
789   \setbox\z@\hbox{{#2}}%
790   \Grot@x\z@
791   \Grot@y\z@
792   \Grot@box}
793 %    \end{macrocode}
794 % \end{macro}
796 % \begin{macro}{\Grot@box@kv}
797 % \changes{v1.0g}{2014/04/25}{Made long  graphics/4296}
798 %    \begin{macrocode}
799 \long\def\Grot@box@kv[#1]#2#3{%
800   \@begin@tempboxa\hbox{#3}%
801     \Grot@x\width \divide\Grot@x\tw@
802     \Grot@y\height \advance\Grot@y-\depth \divide\Grot@y\tw@
803     \setkeys{Grot}{#1}%
804     \setbox\z@\box\@tempboxa
805     \Grot@setangle{#2}%
806     \Grot@box
807   \@end@tempboxa}
808 %    \end{macrocode}
809 % \end{macro}
812 % There are two ways of specifying the centre of rotation.
814 % \begin{key}{Grot}{origin}
815 % |origin=|\meta{label}, where the labels are up to two of |lrctbB|
816 % (|B| denotes the baseline, as for PSTricks).
817 %    \begin{macrocode}
818 \define@key{Grot}{origin}[c]{%
819  \@tfor\@tempa:=#1\do{%
820     \if l\@tempa \Grot@x\z@\else
821     \if r\@tempa \Grot@x\width\else
822     \if t\@tempa \Grot@y\height\else
823     \if b\@tempa \Grot@y-\depth\else
824     \if B\@tempa \Grot@y\z@\fi\fi\fi\fi\fi}}
825 %    \end{macrocode}
826 % \end{key}
828 % \begin{key}{Grot}{x}
829 % \begin{key}{Grot}{y}
830 % |x=|\meta{dimen}|,y=|\meta{dimen} The $x,y$ coordinate of the centre
831 % of rotation. As usual |\height| etc may be used.
832 %    \begin{macrocode}
833 \define@key{Grot}{x}{\setlength\Grot@x{#1}}
834 \define@key{Grot}{y}{\setlength\Grot@y{#1}}
835 %    \end{macrocode}
836 % \end{key}
837 % \end{key}
839 % \begin{key}{Grot}{units}
840 % `units' specifies the number or units in one anti-clockwise circle.
841 %  So the default is $360$. $-360$ gives clockwise rotation, $6.283185$
842 %  gives radians etc.
843 %    \begin{macrocode}
844 \define@key{Grot}{units}{%
845   \def\Grot@setangle##1{%
846   \dimen@##1\p@
847   \dimen@ii#1\p@
848   \divide\dimen@ii360\relax
849   \divide\dimen@\dimen@ii
850   \edef\Grot@angle{\number\dimen@}}}
851 %    \end{macrocode}
852 % \end{key}
854 % \begin{macro}{\Gin@erotate}
855 % Initialise the rotation command to use in |\includegraphics|.
856 % \changes{v0.6e}{1995/09/28}{macro added}
857 %    \begin{macrocode}
858 \let\Gin@erotate\Grot@box@std
859 %    \end{macrocode}
860 % \end{macro}
862 %    \begin{macrocode}
863 %</package>
864 %    \end{macrocode}
866 % \Finale