Debian Codegraph @

texmf-dist/source/latex/graphics/graphicx.dtx

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