4 %% graphicx.dtx Copyright (C) 1994 David Carlisle Sebastian Rahtz
5 %% Copyright (C) 1995--2015,2017 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 [2017/06/01 v1.1a 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|.
167 % \item[quiet] Turns off writing information about graphics to the |.log|.
168 % \item[page] The page of a multi-page PDF graphic to be used.
169 % \item[interpolate] Enables interpolation of bitmap images by viewers.
172 % The arguments are interpreted left to right. |clip|, |draft|, |bb|,,
173 % and |bbllx| etc.\ have the same effect wherever they appear. but the
174 % scaling and rotation keys interact.
176 % Any scaling that is specified \emph{before} rotation, is handled by
177 % the internal graphics inclusion function. Rotation, or any later
178 % scaling is handled by implicitly calling |\rotatebox| or |\scalebox|.
179 % So |[height=1in,angle=90]| scales the graphic to 1in, then rotates it,
180 % so it is one inch wide. |[angle=90,height=1in]| first rotates, then
181 % scales the result so that it is 1in high. A driver that can scale
182 % included graphics, but not arbitrary text will not be able to support
183 % the second form, as it will require a call to |\scalebox|, but the
184 % first form should work as there the scaling is handled by
185 % |\Ginclude@graphics|.
188 % \rotatebox\oarg{key-val list}\marg{angle}\marg{text}\\
189 % Rotate \emph{text}.
191 % The keys supported by |\rotatebox| are:
192 % \begin{description}
193 % \item[origin] Specify the centre of rotation. |origin=|\meta{label},
194 % where the labels are up to two of |lrctbB| (|B| denotes the
195 % baseline, as for PSTricks).
196 % \item[x,y] An alternative to
197 % |origin|. |x=|\meta{dimen}|,y=|\meta{dimen} The $x,y$ coordinate of
198 % the centre of rotation. As usual |\height| etc may be used.
199 % \item[units] Specify the units used in the main argument. eg
200 % |units=-360| would mean that the argument referred to degrees
201 % \emph{clockwise} instead of the default anti-clockwise rotation.
204 % As an example |\rotatebox[origin=c]{180}{text}| will rotate ``text''
205 % around its centre, thus creating a final box of the same dimensions as
206 % the original box. This is to be contrasted to the default behaviour,
207 % which rotates around the reference point on the baseline, thus
208 % producing a box that is mainly \emph{below} the baseline.
213 % \section{Implementation}
219 % One new option is handled by keyval. It suppresses the error
220 % normally generated if an unknow keyval key is used.
221 % (This helps porting between drivers that use extended interfaces.)
222 % \changes{v1.0e}{1999/01/10}{new unknownkeysallowed option}
224 \DeclareOption{unknownkeysallowed}
225 {\PassOptionsToPackage\CurrentOption{keyval}}
228 % All other options are handled by the \textsf{graphics} package.
230 \DeclareOption*{\PassOptionsToPackage\CurrentOption{graphics}}
237 % This package requires these two building blocks.
239 \RequirePackage{keyval,graphics}
243 % \subsection{Graphics Inclusion}
246 % First we declare the `bounding box' keys. These all use
247 % |\Gin@defaultbp| so that the \meta{value} can be given as a length in
248 % the usual \TeX\ units such as |cm| or as an integer, taken as |bp|.
250 % \begin{key}{Gin}{bb}
253 {\Gin@bboxtrue\Gread@parse@bb#1 \\}
257 % \begin{key}{Gin}{bbllx}
258 % \begin{key}{Gin}{bblly}
259 % \begin{key}{Gin}{bburx}
260 % \begin{key}{Gin}{bbury}
261 % \changes{v0.3b}{1994/03/11}{use bbllx not llx}
262 % \changes{v0.3b}{1994/03/11}{add natheight and natwidth}
263 % \changes{v0.6a}{1995/04/11}{New \cs{Gin@defaultbb} code}
264 % \changes{v0.6b}{1995/06/26}{typos fixed for graphics/1685}
266 \define@key{Gin}{bbllx}
267 {\Gin@bboxtrue\Gin@defaultbp\Gin@llx{#1}}
268 \define@key{Gin}{bblly}
269 {\Gin@bboxtrue\Gin@defaultbp\Gin@lly{#1}}
270 \define@key{Gin}{bburx}
271 {\Gin@bboxtrue\Gin@defaultbp\Gin@urx{#1}}
272 \define@key{Gin}{bbury}
273 {\Gin@bboxtrue\Gin@defaultbp\Gin@ury{#1}}
280 % \begin{key}{Gin}{hiresbb}
281 % \changes{v1.0b}{1996/10/29}
282 % {hiresbb key added}
283 % If set to true (the default) \TeX\ will look for bounding box
284 % comments of the form |%%HiResBoundingBox| (which typically have
285 % real values) instead of the standard |%%BoundingBox| (which should
286 % have integer values).
287 % It may be set to false to override a package option of hiresbb.
289 \define@key{Gin}{hiresbb}[true]{%
291 \@percentchar\@percentchar
292 \csname if#1\endcsname HiRes\fi
297 % \begin{key}{Gin}{natheight}
298 % \begin{key}{Gin}{natheight}
299 % \changes{v0.6d}{1995/09/22}
300 % {typos fixed in natheight and natwidth keys}
302 \let\KV@Gin@natwidth\KV@Gin@bburx
303 \let\KV@Gin@natheight\KV@Gin@bbury
308 % \begin{key}{Gin}{viewport}
309 % \begin{key}{Gin}{trim}
310 % \changes{v0.6a}{1995/04/11}{viewport and trim keys added}
311 % \changes{v0.6c}{1995/09/07}{arithmetic in viewport key fixed}
312 % A `viewport' is a user-specified area of the graphic to be included.
313 % It should not be confused with the `Bounding Box' of a PS file.
314 % In fact, the origin for a viewport specification is the (llx,lly)
315 % lower left coordinate of the bounding box. If a viewport is
316 % specified, and clipping is turned on, clipping is based on the
317 % viewport, not on the boundingbox.
319 % Both `viewport' and `trim' were suggested (and originally, but
320 % differently, implemented) by Arthur Ogawa.
322 \define@key{Gin}{viewport}
323 {\let\Gin@viewport@code\Gin@viewport\Gread@parse@vp#1 \\}
324 \define@key{Gin}{trim}
325 {\let\Gin@viewport@code\Gin@trim\Gread@parse@vp#1 \\}
330 % \begin{macro}{\Gread@parse@vp}
331 % Grabs four bounding box values like |\Gread@parse@bp| but saves them
332 % in alternative macros that are used in the viewport and trim cases to
333 % modify the bounding box read from the file.
335 \def\Gread@parse@vp#1 #2 #3 #4 #5\\{%
336 \Gin@defaultbp\Gin@vllx{#1}%
337 \Gin@defaultbp\Gin@vlly{#2}%
338 \Gin@defaultbp\Gin@vurx{#3}%
339 \Gin@defaultbp\Gin@vury{#4}}%
343 % \begin{macro}{\Gin@viewport}
344 % \changes{v1.0c}{1996/10/31}{Original bb saved}
345 % If a viewport is specified, reset the bounding box coordinates
346 % by adding the original origin, |\Gin@llx|, |\Gin@lly| to the new
347 % values specified as the viewport. The original Bounding box
348 % coordinates are saved in |\Gin@ollx|\ldots\ some drivers
349 % might need this information (currently just |tcidvi|).
352 \let\Gin@ollx\Gin@llx
353 \let\Gin@olly\Gin@lly
354 \let\Gin@ourx\Gin@urx
355 \let\Gin@oury\Gin@ury
356 \dimen@\Gin@llx\p@\advance\dimen@ \Gin@vurx\p@
357 \edef\Gin@urx{\strip@pt\dimen@}%
358 \dimen@\Gin@lly\p@\advance\dimen@ \Gin@vury\p@
359 \edef\Gin@ury{\strip@pt\dimen@}%
360 \dimen@\Gin@llx\p@\advance\dimen@ \Gin@vllx\p@
361 \edef\Gin@llx{\strip@pt\dimen@}%
362 \dimen@\Gin@lly\p@\advance\dimen@ \Gin@vlly\p@
363 \edef\Gin@lly{\strip@pt\dimen@}}
367 % \begin{macro}{\Gin@trim}
368 % \changes{v1.0c}{1996/10/31}{Original bb saved}
369 % If a trim is specified, reset the bounding box coordinates
370 % by trimming the four specified values off each side of the
374 \let\Gin@ollx\Gin@llx
375 \let\Gin@olly\Gin@lly
376 \let\Gin@ourx\Gin@urx
377 \let\Gin@oury\Gin@ury
378 \dimen@\Gin@llx\p@\advance\dimen@ \Gin@vllx\p@
379 \edef\Gin@llx{\strip@pt\dimen@}%
380 \dimen@\Gin@lly\p@\advance\dimen@ \Gin@vlly\p@
381 \edef\Gin@lly{\strip@pt\dimen@}%
382 \dimen@\Gin@urx\p@\advance\dimen@ -\Gin@vurx\p@
383 \edef\Gin@urx{\strip@pt\dimen@}%
384 \dimen@\Gin@ury\p@\advance\dimen@ -\Gin@vury\p@
385 \edef\Gin@ury{\strip@pt\dimen@}}
389 % \begin{macro}{\Gin@vllx}
390 % \begin{macro}{\Gin@vlly}
391 % \begin{macro}{\Gin@vurx}
392 % \begin{macro}{\Gin@vury}
393 % Four macros to hold the modifiers for the bounding box for viewport
394 % and trim specifications.
396 \let\Gin@vllx\Gin@llx\let\Gin@vlly\Gin@llx
397 \let\Gin@vurx\Gin@llx\let\Gin@vury\Gin@llx
404 % \begin{key}{Gin}{angle}
405 % Specify a rotation. This is just handled by wrapping the
406 % |\includegraphics| command in a call to the internal version of
407 % |\rotatebox|. Normally this is the `standard' version but if an
408 % |origin| key is used in |\includegraphics| then the \emph{keyval}
409 % version of origin is used, and the |origin| key is passed on.
411 \define@key{Gin}{angle}
414 \edef\@tempa{\toks@{\noexpand\Gin@erotate{#1}{\the\toks@}}}%
419 % \begin{key}{Gin}{origin}
420 % Pass the origin key value on to |\rotatebox|. |\Gin@erotate| is
421 % initialised to |\Grot@box@std| later in the file, after the latter has
423 % \changes{v0.6e}{1995/09/28}
426 \define@key{Gin}{origin}[c]{%
427 \def\Gin@erotate{\Grot@box@kv[origin=#1]}}
431 % \begin{key}{Gin}{width}
432 % \begin{key}{Gin}{height}
433 % Save the required height and width. The actual scaling is done later.
435 \define@key{Gin}{width}{\def\Gin@ewidth{#1}}
436 \define@key{Gin}{height}{\def\Gin@eheight{#1}}
441 % \begin{key}{Gin}{totalheight}
442 % \changes{v0.6a}{1995/04/11}{New totalheight key}
443 % The same as |height| key, but locally changes |\Gin@eresize| to
444 % |\totalheight| from its default value of |\height|.
446 \define@key{Gin}{totalheight}{%
447 \def\Gin@eresize{\totalheight}\def\Gin@eheight{#1}}
451 % \begin{key}{Gin}{keepaspectratio}
452 % Boolean valued key (like |clip|). If it is set to true,
453 % modify the meaning of the |width| and |height| (and |totalheight|)
454 % keys such that if both are specified then rather than distort the
455 % figure the figure is scaled such that neither dimension \emph{exceeds}
456 % the stated dimensions.
457 % \changes{v0.6e}{1995/09/28}
459 % \changes{v0.6h}{1995/12/06}
460 % {Name changed to keepaspectratio}
462 \define@key{Gin}{keepaspectratio}[true]{%
463 \lowercase{\Gin@boolkey{#1}}{iso}}
467 % \begin{key}{Gin}{scale}
468 % \changes{v0.6h}{1995/12/06}
469 % {Use \cs{Gin@exclamation}}
470 % If the scaling is being handled externally, wrap |\includegraphics| in
471 % the internal form of |\scalebox|, otherwise locally define
472 % |\Gin@req@sizes| to calculate the required sizes based on
475 \define@key{Gin}{scale}{%
477 \edef\@tempa{\toks@{\noexpand\Gscale@box{#1}[#1]{\the\toks@}}}%
481 \def\Gin@scalex{#1}\let\Gin@scaley\Gin@exclamation
482 \Gin@req@height\Gin@scalex\Gin@nat@height
483 \Gin@req@width\Gin@scalex\Gin@nat@width}%
489 % \begin{key}{Gin}{draft}
490 % Locally set the draft switch to true. This is used by the code in
491 % \textsf{graphics} package to suppress the file inclusion.
493 \define@key{Gin}{draft}[true]{%
494 \lowercase{\Gin@boolkey{#1}}{draft}}
498 % \begin{key}{Gin}{clip}
499 % Locally set the clip switch to true. This is used by the code in
500 % \textsf{graphics} package to suppress the printing of anything outside
501 % the bounding box specified.
503 \define@key{Gin}{clip}[true]{%
504 \lowercase{\Gin@boolkey{#1}}{clip}}
508 % \begin{key}{Gin}{type}
509 % If you use `type' you must use no extension in the main argument
510 % and you must use `ext'. You can also use `read' and `command'.
511 % \changes{v0.5a}{1994/11/29}
512 % {remove \cs{Gin@sep}}
514 \define@key{Gin}{type}{%
515 \def\Ginclude@graphics##1{%
518 \edef\@tempa{{#1}{\Gin@eread}{\Gin@ecom{##1\Gin@eext}}}%
519 \expandafter\Gin@setfile\@tempa
524 % \begin{key}{Gin}{ext}
525 % \changes{v1.0d}{1997/06/09}{initialise ext to empty}
526 % Specify an extension, for use with the `type' key.
528 \define@key{Gin}{ext}{\def\Gin@eext{#1}}
533 % \begin{key}{Gin}{read}
534 % Specify a read file, for use with the `type' key.
535 % You may want to globally set this to |*| using |\setkeys|.
536 % |*| means read the graphic file for size info, as in
537 % |\DeclareGraphicsRule|.
538 % \changes{v0.5a}{1994/11/29}
539 % {Add default * possibility.}
541 \define@key{Gin}{read}{%
543 \def\@tempa{*}\ifx\@tempa\Gin@eread\def\Gin@eread{\Gin@eext}\fi}
544 \let\Gin@eread\@empty
548 % \begin{key}{Gin}{command}
549 % Specify a command, for use with the `type' key.
551 \define@key{Gin}{command}{\def\Gin@ecom##1{#1}}
552 \let\Gin@ecom\@firstofone
556 % \begin{key}{Gin}{quiet}
557 % \changes{v1.1a}{2017/06/01}{New quiet key}
558 % Skip writing to the log.
560 \define@key{Gin}{quiet}{%
566 % \begin{key}{Gin}{page}
567 % \changes{v1.1a}{2017/06/01}{New page key}
568 % Page of a multi-page (PDF) graphic.
570 \define@key{Gin}{page}{%
574 \edef\Gin@page{\number\Gin@page}%
580 % \begin{key}{Gin}{interpolate}
581 % \changes{v1.1a}{2017/06/01}{New interpolate key}
582 % Enable/disable interpolation of bitmap images by the viewer.
584 \define@key{Gin}{interpolate}[true]{%
585 \lowercase{\Gin@boolkey{#1}}{interpolate}}
589 % \begin{macro}{\Gin@boolkey}
590 % Helper function for defining boolean valued functions. The order of
591 % arguments allows |\lowercase| to only act on the user-supplied
593 % \changes{v0.4a}{1994/04/14}{Make `empty'!=true so clip!= works}
595 \def\Gin@boolkey#1#2{%
596 \csname Gin@#2\ifx\relax#1\relax true\else#1\fi\endcsname}
600 % \begin{macro}{\Gin@esetsize}
601 % \changes{v0.6h}{1995/12/06}
602 % {Use \cs{Gin@exclamation}}
603 % Arrange for the final size to be set, either by wrapping the include
604 % graphics call in |\scalebox|, or by redefining |\Gin@req@sizes|
607 \def\Gin@eresize{\height}
609 \let\@tempa\Gin@exclamation
612 % External. Wrap the |\includegraphics| command in a call to the
613 % internal form of |\scalebox| to handle the rotation.
615 \edef\@tempa{\toks@{\noexpand
616 \Gscale@@box\noexpand\Gin@eresize
617 {\Gin@ewidth}{\Gin@eheight}{\the\toks@}}}%
621 % Internal. Handle scaling with the |\includegraphics| command directly
622 % rather than calling |\scalebox|.
624 \ifx\Gin@ewidth\@tempa
625 \ifx\Gin@eheight\@tempa
631 % Just height specified.
632 % \changes{v0.6e}{1995/09/28}
633 % {Use \cs{setlength} to support calc package}
634 % \changes{v0.6h}{1995/12/06}
635 % {Use \cs{Gin@exclamation}}
637 \let\Gin@@eheight\Gin@eheight
639 \Gscale@div\Gin@scaley\Gin@@eheight\Gin@nat@height
640 \let\Gin@scalex\Gin@exclamation
641 \setlength\Gin@req@height\Gin@@eheight
642 \Gin@req@width\Gin@scaley\Gin@nat@width}%
645 \ifx\Gin@eheight\@tempa
647 % Just width specified.
648 % \changes{v0.6e}{1995/09/28}
649 % {Use \cs{setlength} to support calc package}
650 % \changes{v0.6h}{1995/12/06}
651 % {Use \cs{Gin@exclamation}}
653 \let\Gin@@ewidth\Gin@ewidth
655 \Gscale@div\Gin@scalex\Gin@@ewidth\Gin@nat@width
656 \let\Gin@scaley\Gin@exclamation
657 \setlength\Gin@req@width\Gin@@ewidth
658 \Gin@req@height\Gin@scalex\Gin@nat@height}%
661 % Both height and width specified.
663 \let\Gin@@ewidth\Gin@ewidth
664 \let\Gin@@eheight\Gin@eheight
666 % \changes{v0.6g}{1995/11/10}
667 % {Use \cs{ifGin@iso} to support isoscale key}
668 % At this point can locally redefine |\Gin@nosize|. Instead
669 % of generating an error, just set the `natural' size to be the
670 % `requested size'. Previous versions of this package did not
671 % allow the use of |height| and |width| unless the natural size was
672 % known as otherwise \LaTeX\ can not calculate the scale factor.
673 % However many drivers (especially for bitmap formats) can work this out
674 % themselves, so as long as both |height| and |width| are given, so
675 % \LaTeX\ knows the size to leave, accept this. This assumes the code in
676 % the driver file will use the `required height' information, not the
677 % scale factors, which will be set to 1!.
678 % \changes{v1.0a}{1996/08/05}
679 % {Missing percent added for graphics/2244}
682 \KV@Gin@natwidth\Gin@@ewidth
683 \KV@Gin@natheight\Gin@@eheight}%
688 \Gscale@div\Gin@scalex\Gin@@ewidth\Gin@nat@width
689 \Gscale@div\Gin@scaley\Gin@@eheight\Gin@nat@height
691 % \changes{v0.6f}{1995/09/29}
692 % {Use \cs{ifGin@iso} to support isoscale key}
693 % Donald Arseneau requested this feature. If both |height|
694 % and |width| are chosen, choose the smaller scale factor rather than
695 % distort the graphic. This mode is turned on with the
696 % \textsf{keepaspectratio} key.
699 \ifdim\Gin@scaley\p@>\Gin@scalex\p@
700 \let\Gin@scaley\Gin@scalex
702 \let\Gin@scalex\Gin@scaley
705 \Gin@req@width\Gin@scalex\Gin@nat@width
706 \Gin@req@height\Gin@scaley\Gin@nat@height}%
710 \let\Gin@ewidth\Gin@exclamation
711 \let\Gin@eheight\Gin@ewidth}
715 % \begin{macro}{\Gin@req@height}
716 % \begin{macro}{\Gin@req@width}
717 % The required final size.
719 \newdimen\Gin@req@height
720 \newdimen\Gin@req@width
725 % \begin{macro}{\Gin@outer@scalex}
726 % \begin{macro}{\Gin@outer@scaley}
727 % Scale factors to pass to |\scalebox|.
729 \let\Gin@outer@scalex\relax
730 \let\Gin@outer@scaley\relax
735 % \begin{macro}{\Gin@angle}
742 % \begin{macro}{\Gin@ewidth}
743 % \changes{v0.6h}{1995/12/06}
744 % {Use \cs{Gin@exclamation}}
745 % \begin{macro}{\Gin@eheight}
746 % Final size, initialised for no scaling.
748 \let\Gin@ewidth\Gin@exclamation
749 \let\Gin@eheight\Gin@ewidth
754 % \begin{macro}{\Gin@scalex}
755 % \begin{macro}{\Gin@scaley}
756 % \changes{v0.6h}{1995/12/06}
757 % {Use \cs{Gin@exclamation}}
758 % Scale factors. Initialised for no scaling.
761 \let\Gin@scaley\Gin@exclamation
766 % \begin{macro}{\Gin@i}
767 % Use the same top level |\includegraphics| command as the standard
768 % interface. This will set the clipping switch, and then call |\Gin@i|.
769 % \changes{v0.3c}{1994/03/15}{Dont locally initialise width/height}
770 % \changes{v0.3c}{1994/03/15}{Always call \cmd{\Gin@ii}}
771 % \changes{v0.4c}{1994/09/12}{Use `standard' version if two opt.\ args.}
775 \Gin@req@height\Gin@nat@height
776 \Gin@req@width\Gin@nat@width}%
777 \@ifnextchar[\Gin@ii{\Gin@ii[]}}
782 % \begin{macro}{\Gin@ii}
783 % Look for a second optional argument.
784 % If one optional argument is present, call |\setkeys| to process it,
787 \def\@tempa{[}\def\@tempb{#2}%
789 \def\@tempa{\Gin@iii[#1][}%
794 \toks@{\Ginclude@graphics{#2}}%
803 % \changes{v0.4b}{1994/05/06}
804 % {Remove incorrect initialisation of \cs{Gin@scalex}}
808 % \begin{macro}{\rotatebox}
809 % Look for an optional argument.
810 % \changes{v0.3b}{1994/03/11}{Remove star form}
811 % \changes{v1.0g}{2014/04/25}{\cs{leavevmode} added graphics/1521}
815 \@ifnextchar[\Grot@box@kv\Grot@box@std}
819 % \begin{macro}{\Grot@box@std}
820 % If no KV argument, just repeat the standard definition.
821 % \changes{v1.0g}{2014/04/25}{Made long graphics/4296}
823 \long\def\Grot@box@std#1#2{%
825 \setbox\z@\hbox{{#2}}%
832 % \begin{macro}{\Grot@box@kv}
833 % \changes{v1.0g}{2014/04/25}{Made long graphics/4296}
835 \long\def\Grot@box@kv[#1]#2#3{%
836 \@begin@tempboxa\hbox{#3}%
837 \Grot@x\width \divide\Grot@x\tw@
838 \Grot@y\height \advance\Grot@y-\depth \divide\Grot@y\tw@
840 \setbox\z@\box\@tempboxa
848 % There are two ways of specifying the centre of rotation.
850 % \begin{key}{Grot}{origin}
851 % |origin=|\meta{label}, where the labels are up to two of |lrctbB|
852 % (|B| denotes the baseline, as for PSTricks).
854 \define@key{Grot}{origin}[c]{%
855 \@tfor\@tempa:=#1\do{%
856 \if l\@tempa \Grot@x\z@\else
857 \if r\@tempa \Grot@x\width\else
858 \if t\@tempa \Grot@y\height\else
859 \if b\@tempa \Grot@y-\depth\else
860 \if B\@tempa \Grot@y\z@\fi\fi\fi\fi\fi}}
864 % \begin{key}{Grot}{x}
865 % \begin{key}{Grot}{y}
866 % |x=|\meta{dimen}|,y=|\meta{dimen} The $x,y$ coordinate of the centre
867 % of rotation. As usual |\height| etc may be used.
869 \define@key{Grot}{x}{\setlength\Grot@x{#1}}
870 \define@key{Grot}{y}{\setlength\Grot@y{#1}}
875 % \begin{key}{Grot}{units}
876 % `units' specifies the number or units in one anti-clockwise circle.
877 % So the default is $360$. $-360$ gives clockwise rotation, $6.283185$
880 \define@key{Grot}{units}{%
881 \def\Grot@setangle##1{%
884 \divide\dimen@ii360\relax
885 \divide\dimen@\dimen@ii
886 \edef\Grot@angle{\number\dimen@}}}
890 % \begin{macro}{\Gin@erotate}
891 % Initialise the rotation command to use in |\includegraphics|.
892 % \changes{v0.6e}{1995/09/28}{macro added}
894 \let\Gin@erotate\Grot@box@std