4 %% graphicx.dtx Copyright (C) 1994 David Carlisle Sebastian Rahtz
5 %% Copyright (C) 1995--2015 David Carlisle, LaTeX3 Project
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.
13 \ProvidesFile{graphicx.dtx}
15 %<package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
16 %<package>\ProvidesPackage{graphicx}
17 %<driver> \ProvidesFile{graphicx.drv}
19 % \ProvidesFile{graphicx.dtx}
20 [2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)]
24 \documentclass{ltxdoc}
25 \newenvironment{key}[2]{\expandafter\macro\expandafter{%
26 \csname KV@#1@#2\endcsname}}{\endmacro}
29 \DocInput{graphicx.dtx}
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}
41 % \MaintainedByLaTeXTeam{graphics}
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}
52 % \def\star{{\ttfamily*}}
54 % \def\Describe@Macro#1{\endgroup
55 % \setbox0=\lastbox\llap{\PrintDescribeMacro{#1}}}%
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
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
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}
108 % \includegraphics\star\oarg{key-val list}\marg{file}\\
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|
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
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
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|.
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|.
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.
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.
210 % \section{Implementation}
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}
221 \DeclareOption{unknownkeysallowed}
222 {\PassOptionsToPackage\CurrentOption{keyval}}
225 % All other options are handled by the \textsf{graphics} package.
227 \DeclareOption*{\PassOptionsToPackage\CurrentOption{graphics}}
234 % This package requires these two building blocks.
236 \RequirePackage{keyval,graphics}
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}
250 {\Gin@bboxtrue\Gread@parse@bb#1 \\}
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}
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}}
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.
286 \define@key{Gin}{hiresbb}[true]{%
288 \@percentchar\@percentchar
289 \csname if#1\endcsname HiRes\fi
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}
299 \let\KV@Gin@natwidth\KV@Gin@bburx
300 \let\KV@Gin@natheight\KV@Gin@bbury
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.
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 \\}
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.
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}}%
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|).
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@}}
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
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@}}
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.
393 \let\Gin@vllx\Gin@llx\let\Gin@vlly\Gin@llx
394 \let\Gin@vurx\Gin@llx\let\Gin@vury\Gin@llx
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.
408 \define@key{Gin}{angle}
411 \edef\@tempa{\toks@{\noexpand\Gin@erotate{#1}{\the\toks@}}}%
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
420 % \changes{v0.6e}{1995/09/28}
423 \define@key{Gin}{origin}[c]{%
424 \def\Gin@erotate{\Grot@box@kv[origin=#1]}}
428 % \begin{key}{Gin}{width}
429 % \begin{key}{Gin}{height}
430 % Save the required height and width. The actual scaling is done later.
432 \define@key{Gin}{width}{\def\Gin@ewidth{#1}}
433 \define@key{Gin}{height}{\def\Gin@eheight{#1}}
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|.
443 \define@key{Gin}{totalheight}{%
444 \def\Gin@eresize{\totalheight}\def\Gin@eheight{#1}}
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}
456 % \changes{v0.6h}{1995/12/06}
457 % {Name changed to keepaspectratio}
459 \define@key{Gin}{keepaspectratio}[true]{%
460 \lowercase{\Gin@boolkey{#1}}{iso}}
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
472 \define@key{Gin}{scale}{%
474 \edef\@tempa{\toks@{\noexpand\Gscale@box{#1}[#1]{\the\toks@}}}%
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}%
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.
490 \define@key{Gin}{draft}[true]{%
491 \lowercase{\Gin@boolkey{#1}}{draft}}
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.
500 \define@key{Gin}{clip}[true]{%
501 \lowercase{\Gin@boolkey{#1}}{clip}}
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}}
511 \define@key{Gin}{type}{%
512 \def\Ginclude@graphics##1{%
515 \edef\@tempa{{#1}{\Gin@eread}{\Gin@ecom{##1\Gin@eext}}}%
516 \expandafter\Gin@setfile\@tempa
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.
525 \define@key{Gin}{ext}{\def\Gin@eext{#1}}
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.}
538 \define@key{Gin}{read}{%
540 \def\@tempa{*}\ifx\@tempa\Gin@eread\def\Gin@eread{\Gin@eext}\fi}
541 \let\Gin@eread\@empty
545 % \begin{key}{Gin}{command}
546 % Specify a command, for use with the `type' key.
548 \define@key{Gin}{command}{\def\Gin@ecom##1{#1}}
549 \let\Gin@ecom\@firstofone
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
557 % \changes{v0.4a}{1994/04/14}{Make `empty'!=true so clip!= works}
559 \def\Gin@boolkey#1#2{%
560 \csname Gin@#2\ifx\relax#1\relax true\else#1\fi\endcsname}
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|
571 \def\Gin@eresize{\height}
573 \let\@tempa\Gin@exclamation
576 % External. Wrap the |\includegraphics| command in a call to the
577 % internal form of |\scalebox| to handle the rotation.
579 \edef\@tempa{\toks@{\noexpand
580 \Gscale@@box\noexpand\Gin@eresize
581 {\Gin@ewidth}{\Gin@eheight}{\the\toks@}}}%
585 % Internal. Handle scaling with the |\includegraphics| command directly
586 % rather than calling |\scalebox|.
588 \ifx\Gin@ewidth\@tempa
589 \ifx\Gin@eheight\@tempa
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}}
601 \let\Gin@@eheight\Gin@eheight
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}%
609 \ifx\Gin@eheight\@tempa
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}}
617 \let\Gin@@ewidth\Gin@ewidth
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}%
625 % Both height and width specified.
627 \let\Gin@@ewidth\Gin@ewidth
628 \let\Gin@@eheight\Gin@eheight
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}
646 \KV@Gin@natwidth\Gin@@ewidth
647 \KV@Gin@natheight\Gin@@eheight}%
652 \Gscale@div\Gin@scalex\Gin@@ewidth\Gin@nat@width
653 \Gscale@div\Gin@scaley\Gin@@eheight\Gin@nat@height
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.
663 \ifdim\Gin@scaley\p@>\Gin@scalex\p@
664 \let\Gin@scaley\Gin@scalex
666 \let\Gin@scalex\Gin@scaley
669 \Gin@req@width\Gin@scalex\Gin@nat@width
670 \Gin@req@height\Gin@scaley\Gin@nat@height}%
674 \let\Gin@ewidth\Gin@exclamation
675 \let\Gin@eheight\Gin@ewidth}
679 % \begin{macro}{\Gin@req@height}
680 % \begin{macro}{\Gin@req@width}
681 % The required final size.
683 \newdimen\Gin@req@height
684 \newdimen\Gin@req@width
689 % \begin{macro}{\Gin@outer@scalex}
690 % \begin{macro}{\Gin@outer@scaley}
691 % Scale factors to pass to |\scalebox|.
693 \let\Gin@outer@scalex\relax
694 \let\Gin@outer@scaley\relax
699 % \begin{macro}{\Gin@angle}
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.
712 \let\Gin@ewidth\Gin@exclamation
713 \let\Gin@eheight\Gin@ewidth
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.
725 \let\Gin@scaley\Gin@exclamation
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.}
739 \Gin@req@height\Gin@nat@height
740 \Gin@req@width\Gin@nat@width}%
741 \@ifnextchar[\Gin@ii{\Gin@ii[]}}
746 % \begin{macro}{\Gin@ii}
747 % Look for a second optional argument.
748 % If one optional argument is present, call |\setkeys| to process it,
751 \def\@tempa{[}\def\@tempb{#2}%
753 \def\@tempa{\Gin@iii[#1][}%
758 \toks@{\Ginclude@graphics{#2}}%
767 % \changes{v0.4b}{1994/05/06}
768 % {Remove incorrect initialisation of \cs{Gin@scalex}}
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}
779 \@ifnextchar[\Grot@box@kv\Grot@box@std}
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}
787 \long\def\Grot@box@std#1#2{%
789 \setbox\z@\hbox{{#2}}%
796 % \begin{macro}{\Grot@box@kv}
797 % \changes{v1.0g}{2014/04/25}{Made long graphics/4296}
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@
804 \setbox\z@\box\@tempboxa
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).
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}}
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.
833 \define@key{Grot}{x}{\setlength\Grot@x{#1}}
834 \define@key{Grot}{y}{\setlength\Grot@y{#1}}
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$
844 \define@key{Grot}{units}{%
845 \def\Grot@setangle##1{%
848 \divide\dimen@ii360\relax
849 \divide\dimen@\dimen@ii
850 \edef\Grot@angle{\number\dimen@}}}
854 % \begin{macro}{\Gin@erotate}
855 % Initialise the rotation command to use in |\includegraphics|.
856 % \changes{v0.6e}{1995/09/28}{macro added}
858 \let\Gin@erotate\Grot@box@std