Debian Codegraph @

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

raw
1 %
2 % \iffalse
3 %
4 %% graphicx.dtx Copyright (C) 1994 David Carlisle Sebastian Rahtz
5 %% Copyright (C) 1995-2026 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 [2026-04-08 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 % \item[decodearray] Applies a \texttt{Decode} array to the included image,
178 % as described in the PDF reference: the array is passed as-is to the
179 % backend.
180 % \end{description}
181 %
182 % The arguments are interpreted left to right. |clip|, |draft|, |bb|,,
183 % and |bbllx| etc.\ have the same effect wherever they appear. but the
184 % scaling and rotation keys interact.
185 %
186 % Any scaling that is specified \emph{before} rotation, is handled by
187 % the internal graphics inclusion function. Rotation, or any later
188 % scaling is handled by implicitly calling |\rotatebox| or |\scalebox|.
189 % So |[height=1in,angle=90]| scales the graphic to 1in, then rotates it,
190 % so it is one inch wide. |[angle=90,height=1in]| first rotates, then
191 % scales the result so that it is 1in high. A driver that can scale
192 % included graphics, but not arbitrary text will not be able to support
193 % the second form, as it will require a call to |\scalebox|, but the
194 % first form should work as there the scaling is handled by
195 % |\Ginclude@graphics|.
196 %
197 % \DescribeMacro
198 % \rotatebox\oarg{key-val list}\marg{angle}\marg{text}\\
199 % Rotate \emph{text}.
200 %
201 % The keys supported by |\rotatebox| are:
202 % \begin{description}
203 % \item[origin] Specify the centre of rotation. |origin=|\meta{label},
204 % where the labels are up to two of |lrctbB| (|B| denotes the
205 % baseline, as for PSTricks).
206 % \item[x,y] An alternative to
207 % |origin|. |x=|\meta{dimen}|,y=|\meta{dimen} The $x,y$ coordinate of
208 % the centre of rotation. As usual |\height| etc may be used.
209 % \item[units] Specify the units used in the main argument. eg
210 % |units=-360| would mean that the argument referred to degrees
211 % \emph{clockwise} instead of the default anti-clockwise rotation.
212 % \end{description}
213 %
214 % As an example |\rotatebox[origin=c]{180}{text}| will rotate ``text''
215 % around its centre, thus creating a final box of the same dimensions as
216 % the original box. This is to be contrasted to the default behaviour,
217 % which rotates around the reference point on the baseline, thus
218 % producing a box that is mainly \emph{below} the baseline.
219 %
220 % \MaybeStop{}
221 %
222 %
223 % \section{Implementation}
224 %
225 % \begin{macrocode}
226 %<*package>
227 % \end{macrocode}
228 %
229 % One new option is handled by keyval. It suppresses the error
230 % normally generated if an unknow keyval key is used.
231 % (This helps porting between drivers that use extended interfaces.)
232 % \changes{v1.0e}{1999/01/10}{new unknownkeysallowed option}
233 % \begin{macrocode}
234 \DeclareOption{unknownkeysallowed}
235 {\PassOptionsToPackage\CurrentOption{keyval}}
236 % \end{macrocode}
237 %
238 % All other options are handled by the \textsf{graphics} package.
239 % \begin{macrocode}
240 \DeclareOption*{\PassOptionsToPackage\CurrentOption{graphics}}
241 % \end{macrocode}
242 %
243 % \begin{macrocode}
244 \ProcessOptions
245 % \end{macrocode}
246 %
247 % This package requires these two building blocks.
248 % \begin{macrocode}
249 \RequirePackage{keyval,graphics}
250 % \end{macrocode}
251 %
252 %
253 % \subsection{Graphics Inclusion}
254 %
255 %
256 % First we declare the `bounding box' keys. These all use
257 % |\Gin@defaultbp| so that the \meta{value} can be given as a length in
258 % the usual \TeX\ units such as |cm| or as an integer, taken as |bp|.
259 %
260 % \begin{key}{Gin}{bb}
261 % \begin{macrocode}
262 \define@key{Gin}{bb}
263 {\Gin@bboxtrue\Gread@parse@bb#1 \\}
264 % \end{macrocode}
265 % \end{key}
266 %
267 % \begin{key}{Gin}{bbllx}
268 % \begin{key}{Gin}{bblly}
269 % \begin{key}{Gin}{bburx}
270 % \begin{key}{Gin}{bbury}
271 % \changes{v0.3b}{1994/03/11}{use bbllx not llx}
272 % \changes{v0.3b}{1994/03/11}{add natheight and natwidth}
273 % \changes{v0.6a}{1995/04/11}{New \cs{Gin@defaultbb} code}
274 % \changes{v0.6b}{1995/06/26}{typos fixed for graphics/1685}
275 % \begin{macrocode}
276 \define@key{Gin}{bbllx}
277 {\Gin@bboxtrue\Gin@defaultbp\Gin@llx{#1}}
278 \define@key{Gin}{bblly}
279 {\Gin@bboxtrue\Gin@defaultbp\Gin@lly{#1}}
280 \define@key{Gin}{bburx}
281 {\Gin@bboxtrue\Gin@defaultbp\Gin@urx{#1}}
282 \define@key{Gin}{bbury}
283 {\Gin@bboxtrue\Gin@defaultbp\Gin@ury{#1}}
284 % \end{macrocode}
285 % \end{key}
286 % \end{key}
287 % \end{key}
288 % \end{key}
289 %
290 % \begin{key}{Gin}{hiresbb}
291 % \changes{v1.0b}{1996/10/29}
292 % {hiresbb key added}
293 % If set to true (the default) \TeX\ will look for bounding box
294 % comments of the form |%%HiResBoundingBox| (which typically have
295 % real values) instead of the standard |%%BoundingBox| (which should
296 % have integer values).
297 % It may be set to false to override a package option of hiresbb.
298 % \begin{macrocode}
299 \define@key{Gin}{hiresbb}[true]{%
300 \edef\Gread@BBox{%
301 \@percentchar\@percentchar
302 \csname if#1\endcsname HiRes\fi
303 BoundingBox}}
304 % \end{macrocode}
305 % \end{key}
306 %
307 % \begin{key}{Gin}{natheight}
308 % \begin{key}{Gin}{natheight}
309 % \changes{v0.6d}{1995/09/22}
310 % {typos fixed in natheight and natwidth keys}
311 % \begin{macrocode}
312 \let\KV@Gin@natwidth\KV@Gin@bburx
313 \let\KV@Gin@natheight\KV@Gin@bbury
314 % \end{macrocode}
315 % \end{key}
316 % \end{key}
317 %
318 % \begin{key}{Gin}{viewport}
319 % \begin{key}{Gin}{trim}
320 % \changes{v0.6a}{1995/04/11}{viewport and trim keys added}
321 % \changes{v0.6c}{1995/09/07}{arithmetic in viewport key fixed}
322 % A `viewport' is a user-specified area of the graphic to be included.
323 % It should not be confused with the `Bounding Box' of a PS file.
324 % In fact, the origin for a viewport specification is the (llx,lly)
325 % lower left coordinate of the bounding box. If a viewport is
326 % specified, and clipping is turned on, clipping is based on the
327 % viewport, not on the boundingbox.
328 %
329 % Both `viewport' and `trim' were suggested (and originally, but
330 % differently, implemented) by Arthur Ogawa.
331 % \begin{macrocode}
332 \define@key{Gin}{viewport}
333 {\let\Gin@viewport@code\Gin@viewport\Gread@parse@vp#1 \\}
334 \define@key{Gin}{trim}
335 {\let\Gin@viewport@code\Gin@trim\Gread@parse@vp#1 \\}
336 % \end{macrocode}
337 % \end{key}
338 % \end{key}
339 %
340 % \begin{macro}{\Gread@parse@vp}
341 % Grabs four bounding box values like |\Gread@parse@bp| but saves them
342 % in alternative macros that are used in the viewport and trim cases to
343 % modify the bounding box read from the file.
344 % \begin{macrocode}
345 \def\Gread@parse@vp#1 #2 #3 #4 #5\\{%
346 \Gin@defaultbp\Gin@vllx{#1}%
347 \Gin@defaultbp\Gin@vlly{#2}%
348 \Gin@defaultbp\Gin@vurx{#3}%
349 \Gin@defaultbp\Gin@vury{#4}}%
350 % \end{macrocode}
351 % \end{macro}
352 %
353 %
354 % \begin{key}{Gin}{angle}
355 % Specify a rotation. This is just handled by wrapping the
356 % |\includegraphics| command in a call to the internal version of
357 % |\rotatebox|. Normally this is the `standard' version but if an
358 % |origin| key is used in |\includegraphics| then the \emph{keyval}
359 % version of origin is used, and the |origin| key is passed on.
360 % \begin{macrocode}
361 \define@key{Gin}{angle}
362 {\Gin@esetsize
363 \@tempswatrue
364 \edef\@tempa{\toks@{\noexpand\Gin@erotate{#1}{\the\toks@}}}%
365 \@tempa}
366 % \end{macrocode}
367 % \end{key}
368 %
369 % \begin{key}{Gin}{origin}
370 % Pass the origin key value on to |\rotatebox|. |\Gin@erotate| is
371 % initialised to |\Grot@box@std| later in the file, after the latter has
372 % been defined.
373 % \changes{v0.6e}{1995/09/28}
374 % {key added}
375 % \begin{macrocode}
376 \define@key{Gin}{origin}[c]{%
377 \def\Gin@erotate{\Grot@box@kv[origin=#1]}}
378 % \end{macrocode}
379 % \end{key}
380 %
381 % \begin{key}{Gin}{width}
382 % \begin{key}{Gin}{height}
383 % Save the required height and width. The actual scaling is done later.
384 % \begin{macrocode}
385 \define@key{Gin}{width}{\def\Gin@ewidth{#1}}
386 \define@key{Gin}{height}{\def\Gin@eheight{#1}}
387 % \end{macrocode}
388 % \end{key}
389 % \end{key}
390 %
391 % \begin{key}{Gin}{totalheight}
392 % \changes{v0.6a}{1995/04/11}{New totalheight key}
393 % The same as |height| key, but locally changes |\Gin@eresize| to
394 % |\totalheight| from its default value of |\height|.
395 % \begin{macrocode}
396 \define@key{Gin}{totalheight}{%
397 \def\Gin@eresize{\totalheight}\def\Gin@eheight{#1}}
398 % \end{macrocode}
399 % \end{key}
400 %
401 % \begin{key}{Gin}{keepaspectratio}
402 % Boolean valued key (like |clip|). If it is set to true,
403 % modify the meaning of the |width| and |height| (and |totalheight|)
404 % keys such that if both are specified then rather than distort the
405 % figure the figure is scaled such that neither dimension \emph{exceeds}
406 % the stated dimensions.
407 % \changes{v0.6e}{1995/09/28}
408 % {key added}
409 % \changes{v0.6h}{1995/12/06}
410 % {Name changed to keepaspectratio}
411 % \begin{macrocode}
412 \define@key{Gin}{keepaspectratio}[true]{%
413 \lowercase{\Gin@boolkey{#1}}{iso}}
414 % \end{macrocode}
415 % \end{key}
416 %
417 % \begin{key}{Gin}{scale}
418 % \changes{v0.6h}{1995/12/06}
419 % {Use \cs{Gin@exclamation}}
420 % If the scaling is being handled externally, wrap |\includegraphics| in
421 % the internal form of |\scalebox|, otherwise locally define
422 % |\Gin@req@sizes| to calculate the required sizes based on
423 % scale factor.
424 % \begin{macrocode}
425 \define@key{Gin}{scale}{%
426 \if@tempswa
427 \edef\@tempa{\toks@{\noexpand\Gscale@box{#1}[#1]{\the\toks@}}}%
428 \@tempa
429 \else
430 \def\Gin@req@sizes{%
431 \def\Gin@scalex{#1}\let\Gin@scaley\Gin@exclamation
432 \Gin@req@height\Gin@scalex\Gin@nat@height
433 \Gin@req@width\Gin@scalex\Gin@nat@width}%
434 \fi
435 \@tempswatrue}
436 % \end{macrocode}
437 % \end{key}
438 %
439 % \begin{key}{Gin}{draft}
440 % Locally set the draft switch to true. This is used by the code in
441 % \textsf{graphics} package to suppress the file inclusion.
442 % \begin{macrocode}
443 \define@key{Gin}{draft}[true]{%
444 \lowercase{\Gin@boolkey{#1}}{draft}}
445 % \end{macrocode}
446 % \end{key}
447 %
448 % \begin{key}{Gin}{clip}
449 % Locally set the clip switch to true. This is used by the code in
450 % \textsf{graphics} package to suppress the printing of anything outside
451 % the bounding box specified.
452 % \begin{macrocode}
453 \define@key{Gin}{clip}[true]{%
454 \lowercase{\Gin@boolkey{#1}}{clip}}
455 % \end{macrocode}
456 % \end{key}
457 %
458 % \begin{key}{Gin}{type}
459 % If you use `type' you must use no extension in the main argument
460 % and you must use `ext'. You can also use `read' and `command'.
461 % \changes{v0.5a}{1994/11/29}
462 % {remove \cs{Gin@sep}}
463 % \begin{macrocode}
464 \define@key{Gin}{type}{%
465 \def\Ginclude@graphics##1{%
466 \begingroup
467 \def\Gin@base{##1}%
468 \edef\@tempa{{#1}{\Gin@eread}{\Gin@ecom{##1\Gin@eext}}}%
469 \expandafter\Gin@setfile\@tempa
470 \endgroup}}
471 % \end{macrocode}
472 % \end{key}
473 %
474 % \begin{key}{Gin}{ext}
475 % \changes{v1.0d}{1997/06/09}{initialise ext to empty}
476 % Specify an extension, for use with the `type' key.
477 % \begin{macrocode}
478 \define@key{Gin}{ext}{\def\Gin@eext{#1}}
479 \let\Gin@eext\@empty
480 % \end{macrocode}
481 % \end{key}
482 %
483 % \begin{key}{Gin}{read}
484 % Specify a read file, for use with the `type' key.
485 % You may want to globally set this to |*| using |\setkeys|.
486 % |*| means read the graphic file for size info, as in
487 % |\DeclareGraphicsRule|.
488 % \changes{v0.5a}{1994/11/29}
489 % {Add default * possibility.}
490 % \begin{macrocode}
491 \define@key{Gin}{read}{%
492 \def\Gin@eread{#1}%
493 \def\@tempa{*}\ifx\@tempa\Gin@eread\def\Gin@eread{\Gin@eext}\fi}
494 \let\Gin@eread\@empty
495 % \end{macrocode}
496 % \end{key}
497 %
498 % \begin{key}{Gin}{command}
499 % Specify a command, for use with the `type' key.
500 % \begin{macrocode}
501 \define@key{Gin}{command}{\def\Gin@ecom##1{#1}}
502 \let\Gin@ecom\@firstofone
503 % \end{macrocode}
504 % \end{key}
505 %
506 % \begin{key}{Gin}{decodearray}
507 % \changes{v1.1b}{2017/06/25}{New decodearray key}
508 % For manipulating bitmap images.
509 % \begin{macrocode}
510 \define@key{Gin}{decodearray}{%
511 \def\Gin@decode{#1}%
512 }
513 % \end{macrocode}
514 % \end{key}
515 %
516 % \begin{key}{Gin}{quiet}
517 % \changes{v1.1a}{2017/06/01}{New quiet key}
518 % \changes{v1.2c}{2020/12/05}{fix missing default value}
519 % Skip writing to the log.
520 % \begin{macrocode}
521 \define@key{Gin}{quiet}[]{%
522 \let\Gin@log\@gobble
523 }
524 % \end{macrocode}
525 % \end{key}
526 %
527 % \begin{key}{Gin}{page}
528 % \changes{v1.1a}{2017/06/01}{New page key}
529 % Page of a multi-page (PDF) graphic.
530 % \begin{macrocode}
531 \define@key{Gin}{page}{%
532 \def\Gin@page{#1}%
533 \ifx\Gin@page\@empty
534 \else
535 \edef\Gin@page{\number\Gin@page}%
536 \fi
537 }
538 % \end{macrocode}
539 % \end{key}
540 %
541 % \begin{key}{Gin}{interpolate}
542 % \changes{v1.1a}{2017/06/01}{New interpolate key}
543 % Enable/disable interpolation of bitmap images by the viewer.
544 % \begin{macrocode}
545 \define@key{Gin}{interpolate}[true]{%
546 \lowercase{\Gin@boolkey{#1}}{interpolate}}
547 % \end{macrocode}
548 % \end{key}
549 %
550 % \begin{key}{Gin}{pagebox}
551 % \changes{v1.1a}{2017/06/01}{New pagebox key}
552 % Specify which PDF box to use for the natural image size in PDF inclusions.
553 % \begin{macrocode}
554 \define@key{Gin}{pagebox}{%
555 \expandafter\let\expandafter\Gin@pagebox
556 \csname Gin@pagebox@#1\endcsname
557 \ifx\Gin@pagebox\relax
558 \let\Gin@pagebox\Gin@pagebox@cropbox
559 \@warning{%
560 Unknown value `#1' for `pagebox'.\MessageBreak
561 Supported values:\MessageBreak
562 mediabox, cropbox, bleedbox, trimbox, artbox%
563 }%
564 \fi
565 }
566 \def\Gin@pagebox@mediabox{mediabox}%
567 \def\Gin@pagebox@cropbox{cropbox}%
568 \def\Gin@pagebox@bleedbox{bleedbox}%
569 \def\Gin@pagebox@trimbox{trimbox}%
570 \def\Gin@pagebox@artbox{artbox}%
571 % \end{macrocode}
572 % \end{key}
573 %
574 % \begin{key}{Gin}{alt}
575 % \changes{v1.2d}{2021/09/16}{alt key gh/651}
576 % By default the |alt| key does nothing but may be used
577 % for alternative text for accessibility uses in extensions.
578 % \begin{macrocode}
579 \define@key{Gin}{alt}{}
580 % \end{macrocode}
581 % \end{key}
582 %
583 % \begin{key}{Gin}{actualtext}
584 % \changes{v1.2e}{2024/12/31}{actualtext key gh/1552}
585 % By default the |actualtext| key does nothing but may be used
586 % for ActualText text for accessibility uses in extensions.
587 % \begin{macrocode}
588 \define@key{Gin}{actualtext}{}
589 % \end{macrocode}
590 % \end{key}
591 %
592 % \begin{key}{Gin}{artifact}
593 % \changes{v1.2e}{2024/12/31}{artifact key gh/1552}
594 % By default the |artifact| key does nothing but may be used
595 % to mark graphicas as an artifact for accessibility uses in extensions.
596 % \begin{macrocode}
597 \define@key{Gin}{artifact}[true]{%
598 \lowercase{\Gin@boolkey{#1}}{artifact}}
599 % \end{macrocode}
600 % \end{key}
601 %
602 % \begin{macro}{\Gin@boolkey}
603 % Helper function for defining boolean valued functions. The order of
604 % arguments allows |\lowercase| to only act on the user-supplied
605 % argument.
606 % \changes{v0.4a}{1994/04/14}{Make `empty'!=true so clip!= works}
607 % \begin{macrocode}
608 \def\Gin@boolkey#1#2{%
609 \csname Gin@#2\ifx\relax#1\relax true\else#1\fi\endcsname}
610 % \end{macrocode}
611 % \end{macro}
612 %
613 % \begin{macro}{\Gin@esetsize}
614 % \changes{v0.6h}{1995/12/06}
615 % {Use \cs{Gin@exclamation}}
616 % Arrange for the final size to be set, either by wrapping the include
617 % graphics call in |\scalebox|, or by redefining |\Gin@req@sizes|
618 % appropriately.
619 % \begin{macrocode}
620 \def\Gin@eresize{\height}
621 \def\Gin@esetsize{%
622 \let\@tempa\Gin@exclamation
623 \if@tempswa
624 % \end{macrocode}
625 % External. Wrap the |\includegraphics| command in a call to the
626 % internal form of |\scalebox| to handle the rotation.
627 % \begin{macrocode}
628 \edef\@tempa{\toks@{\noexpand
629 \Gscale@@box\noexpand\Gin@eresize
630 {\Gin@ewidth}{\Gin@eheight}{\the\toks@}}}%
631 \@tempa
632 \else
633 % \end{macrocode}
634 % Internal. Handle scaling with the |\includegraphics| command directly
635 % rather than calling |\scalebox|.
636 % \begin{macrocode}
637 \ifx\Gin@ewidth\@tempa
638 \ifx\Gin@eheight\@tempa
639 % \end{macrocode}
640 % No resizing.
641 % \begin{macrocode}
642 \else
643 % \end{macrocode}
644 % Just height specified.
645 % \changes{v0.6e}{1995/09/28}
646 % {Use \cs{setlength} to support calc package}
647 % \changes{v0.6h}{1995/12/06}
648 % {Use \cs{Gin@exclamation}}
649 % \begin{macrocode}
650 \let\Gin@@eheight\Gin@eheight
651 \def\Gin@req@sizes{%
652 \Gscale@div\Gin@scaley\Gin@@eheight\Gin@nat@height
653 \let\Gin@scalex\Gin@exclamation
654 \setlength\Gin@req@height\Gin@@eheight
655 \Gin@req@width\Gin@scaley\Gin@nat@width}%
656 \fi
657 \else
658 \ifx\Gin@eheight\@tempa
659 % \end{macrocode}
660 % Just width specified.
661 % \changes{v0.6e}{1995/09/28}
662 % {Use \cs{setlength} to support calc package}
663 % \changes{v0.6h}{1995/12/06}
664 % {Use \cs{Gin@exclamation}}
665 % \begin{macrocode}
666 \let\Gin@@ewidth\Gin@ewidth
667 \def\Gin@req@sizes{%
668 \Gscale@div\Gin@scalex\Gin@@ewidth\Gin@nat@width
669 \let\Gin@scaley\Gin@exclamation
670 \setlength\Gin@req@width\Gin@@ewidth
671 \Gin@req@height\Gin@scalex\Gin@nat@height}%
672 \else
673 % \end{macrocode}
674 % Both height and width specified.
675 % \begin{macrocode}
676 \let\Gin@@ewidth\Gin@ewidth
677 \let\Gin@@eheight\Gin@eheight
678 % \end{macrocode}
679 % \changes{v0.6g}{1995/11/10}
680 % {Use \cs{ifGin@iso} to support isoscale key}
681 % At this point can locally redefine |\Gin@nosize|. Instead
682 % of generating an error, just set the `natural' size to be the
683 % `requested size'. Previous versions of this package did not
684 % allow the use of |height| and |width| unless the natural size was
685 % known as otherwise \LaTeX\ can not calculate the scale factor.
686 % However many drivers (especially for bitmap formats) can work this out
687 % themselves, so as long as both |height| and |width| are given, so
688 % \LaTeX\ knows the size to leave, accept this. This assumes the code in
689 % the driver file will use the `required height' information, not the
690 % scale factors, which will be set to 1!.
691 % \changes{v1.0a}{1996/08/05}
692 % {Missing percent added for graphics/2244}
693 % \begin{macrocode}
694 \def\Gin@nosize##1{%
695 \KV@Gin@natwidth\Gin@@ewidth
696 \KV@Gin@natheight\Gin@@eheight}%
697 % \end{macrocode}
698 %
699 % \begin{macrocode}
700 \def\Gin@req@sizes{%
701 \Gscale@div\Gin@scalex\Gin@@ewidth\Gin@nat@width
702 \Gscale@div\Gin@scaley\Gin@@eheight\Gin@nat@height
703 % \end{macrocode}
704 % \changes{v0.6f}{1995/09/29}
705 % {Use \cs{ifGin@iso} to support isoscale key}
706 % Donald Arseneau requested this feature. If both |height|
707 % and |width| are chosen, choose the smaller scale factor rather than
708 % distort the graphic. This mode is turned on with the
709 % \textsf{keepaspectratio} key.
710 % \begin{macrocode}
711 \ifGin@iso
712 \ifdim\Gin@scaley\p@>\Gin@scalex\p@
713 \let\Gin@scaley\Gin@scalex
714 \else
715 \let\Gin@scalex\Gin@scaley
716 \fi
717 \fi
718 \Gin@req@width\Gin@scalex\Gin@nat@width
719 \Gin@req@height\Gin@scaley\Gin@nat@height}%
720 \fi
721 \fi
722 \fi
723 \let\Gin@ewidth\Gin@exclamation
724 \let\Gin@eheight\Gin@ewidth}
725 % \end{macrocode}
726 % \end{macro}
727 %
728 % \begin{macro}{\Gin@req@height}
729 % \begin{macro}{\Gin@req@width}
730 % The required final size.
731 % \begin{macrocode}
732 \newdimen\Gin@req@height
733 \newdimen\Gin@req@width
734 % \end{macrocode}
735 % \end{macro}
736 % \end{macro}
737 %
738 % \begin{macro}{\Gin@outer@scalex}
739 % \begin{macro}{\Gin@outer@scaley}
740 % Scale factors to pass to |\scalebox|.
741 % \begin{macrocode}
742 \let\Gin@outer@scalex\relax
743 \let\Gin@outer@scaley\relax
744 % \end{macrocode}
745 % \end{macro}
746 % \end{macro}
747 %
748 % \begin{macro}{\Gin@angle}
749 % Rotation angle.
750 % \begin{macrocode}
751 \let\Gin@angle\relax
752 % \end{macrocode}
753 % \end{macro}
754 %
755 % \begin{macro}{\Gin@ewidth}
756 % \changes{v0.6h}{1995/12/06}
757 % {Use \cs{Gin@exclamation}}
758 % \begin{macro}{\Gin@eheight}
759 % Final size, initialised for no scaling.
760 % \begin{macrocode}
761 \let\Gin@ewidth\Gin@exclamation
762 \let\Gin@eheight\Gin@ewidth
763 % \end{macrocode}
764 % \end{macro}
765 % \end{macro}
766 %
767 % \begin{macro}{\Gin@scalex}
768 % \begin{macro}{\Gin@scaley}
769 % \changes{v0.6h}{1995/12/06}
770 % {Use \cs{Gin@exclamation}}
771 % Scale factors. Initialised for no scaling.
772 % \begin{macrocode}
773 \def\Gin@scalex{1}
774 \let\Gin@scaley\Gin@exclamation
775 % \end{macrocode}
776 % \end{macro}
777 % \end{macro}
778 %
779 % \begin{macro}{\Gin@i}
780 % Use the same top level |\includegraphics| command as the standard
781 % interface. This will set the clipping switch, and then call |\Gin@i|.
782 % \changes{v0.3c}{1994/03/15}{Dont locally initialise width/height}
783 % \changes{v0.3c}{1994/03/15}{Always call \cmd{\Gin@ii}}
784 % \changes{v0.4c}{1994/09/12}{Use `standard' version if two opt.\ args.}
785 % \begin{macrocode}
786 \def\Gin@i{%
787 \def\Gin@req@sizes{%
788 \Gin@req@height\Gin@nat@height
789 \Gin@req@width\Gin@nat@width}%
790 \@ifnextchar[\Gin@ii{\Gin@ii[]}}
791 % \end{macrocode}
792 % \end{macro}
793 %
794 %
795 % \begin{macro}{\Gin@ii}
796 % Look for a second optional argument.
797 % If one optional argument is present, call |\setkeys| to process it,
798 % \begin{macrocode}
799 \def\Gin@ii[#1]#2{%
800 \def\@tempa{[}\def\@tempb{#2}%
801 \ifx\@tempa\@tempb
802 \def\@tempa{\Gin@iii[#1][}%
803 \expandafter\@tempa
804 \else
805 \begingroup
806 \@tempswafalse
807 \toks@{\Ginclude@graphics{#2}}%
808 \setkeys{Gin}{#1}%
809 \Gin@esetsize
810 \the\toks@
811 \endgroup
812 \fi}
813 % \end{macrocode}
814 % \end{macro}
815 %
816 % \changes{v0.4b}{1994/05/06}
817 % {Remove incorrect initialisation of \cs{Gin@scalex}}
818 %
819 % \section{Rotation}
820 %
821 % \begin{macro}{\rotatebox}
822 % Look for an optional argument.
823 % \changes{v0.3b}{1994/03/11}{Remove star form}
824 % \changes{v1.0g}{2014/04/25}{\cs{leavevmode} added graphics/1521}
825 % \changes{v1.2a}{2019/11/30}{Add \cs{protected} gh/208}
826 % \begin{macrocode}
827 \protected\def\rotatebox{%
828 \leavevmode
829 \@ifnextchar[\Grot@box@kv\Grot@box@std}
830 % \end{macrocode}
831 % \end{macro}
832 %
833 % \begin{macro}{\Grot@box@std}
834 % If no KV argument, just repeat the standard definition.
835 % \changes{v1.0g}{2014/04/25}{Made long graphics/4296}
836 % \begin{macrocode}
837 \long\def\Grot@box@std#1#2{%
838 \Grot@setangle{#1}%
839 \setbox\z@\hbox{{#2}}%
840 \Grot@x\z@
841 \Grot@y\z@
842 \Grot@box}
843 % \end{macrocode}
844 % \end{macro}
845 %
846 % \begin{macro}{\Grot@box@kv}
847 % \changes{v1.0g}{2014/04/25}{Made long graphics/4296}
848 % \begin{macrocode}
849 \long\def\Grot@box@kv[#1]#2#3{%
850 \@begin@tempboxa\hbox{#3}%
851 \Grot@x\width \divide\Grot@x\tw@
852 \Grot@y\height \advance\Grot@y-\depth \divide\Grot@y\tw@
853 \setkeys{Grot}{#1}%
854 \setbox\z@\box\@tempboxa
855 \Grot@setangle{#2}%
856 \Grot@box
857 \@end@tempboxa}
858 % \end{macrocode}
859 % \end{macro}
860 %
861 %
862 % There are two ways of specifying the centre of rotation.
863 %
864 % \begin{key}{Grot}{origin}
865 % |origin=|\meta{label}, where the labels are up to two of |lrctbB|
866 % (|B| denotes the baseline, as for PSTricks).
867 % \begin{macrocode}
868 \define@key{Grot}{origin}[c]{%
869 \@tfor\@tempa:=#1\do{%
870 \if l\@tempa \Grot@x\z@\else
871 \if r\@tempa \Grot@x\width\else
872 \if t\@tempa \Grot@y\height\else
873 \if b\@tempa \Grot@y-\depth\else
874 \if B\@tempa \Grot@y\z@\fi\fi\fi\fi\fi}}
875 % \end{macrocode}
876 % \end{key}
877 %
878 % \begin{key}{Grot}{x}
879 % \begin{key}{Grot}{y}
880 % |x=|\meta{dimen}|,y=|\meta{dimen} The $x,y$ coordinate of the centre
881 % of rotation. As usual |\height| etc may be used.
882 % \begin{macrocode}
883 \define@key{Grot}{x}{\setlength\Grot@x{#1}}
884 \define@key{Grot}{y}{\setlength\Grot@y{#1}}
885 % \end{macrocode}
886 % \end{key}
887 % \end{key}
888 %
889 % \begin{key}{Grot}{units}
890 % `units' specifies the number or units in one anti-clockwise circle.
891 % So the default is $360$. $-360$ gives clockwise rotation, $6.283185$
892 % gives radians etc.
893 % \begin{macrocode}
894 \define@key{Grot}{units}{%
895 \def\Grot@setangle##1{%
896 \dimen@##1\p@
897 \dimen@ii#1\p@
898 \divide\dimen@ii360\relax
899 \divide\dimen@\dimen@ii
900 \edef\Grot@angle{\number\dimen@}}}
901 % \end{macrocode}
902 % \end{key}
903 %
904 % \begin{macro}{\Gin@erotate}
905 % Initialise the rotation command to use in |\includegraphics|.
906 % \changes{v0.6e}{1995/09/28}{macro added}
907 % \begin{macrocode}
908 \let\Gin@erotate\Grot@box@std
909 % \end{macrocode}
910 % \end{macro}
911 %
912 % \begin{macrocode}
913 %</package>
914 % \end{macrocode}
915 %
916 % \Finale
917 %