Move a tag
[latex2e.git] / latex2e-20170415 / required / graphics / graphics.dtx
blob028f065852716b559b769de5fb3bdeec6ebab22c
2 % \iffalse
4 %% graphics.dtx Copyright (C) 1994      David Carlisle Sebastian Rahtz
5 %%              Copyright (C) 1995--2017 David Carlisle, LaTeX3 Project
6 %%
7 %% This file is part of the Standard LaTeX `Graphics Bundle'.
8 %% It may be distributed under the terms of the LaTeX Project Public
9 %% License, as described in lppl.txt in the base LaTeX distribution.
10 %% Either version 1.3c or, at your option, any later version.
12 %% This file has the LPPL maintenance status "maintained".
14 %<*dtx>
15           \ProvidesFile{graphics.dtx}
16 %</dtx>
17 %<package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
18 %<package>\ProvidesPackage{graphics}
19 %<driver> \ProvidesFile{graphics.drv}
20 % \fi
21 %         \ProvidesFile{graphics.dtx}
22           [2017/06/25 v1.2c  Standard LaTeX Graphics (DPC,SPQR)]
24 % \iffalse
25 %<*driver>
26 \documentclass{ltxdoc}
27 \newenvironment{option}[1]{\expandafter\macro\expandafter{%
28    \csname ds@#1\endcsname}}{\endmacro}
29 \begin{document}
30  \DocInput{graphics.dtx}
31 \end{document}
32 %</driver>
33 % \fi
35 % \GetFileInfo{graphics.dtx}
37 % \title{The \textsf{graphics} package\thanks{This file
38 %        has version number \fileversion, last
39 %        revised \filedate.}}
40 % \author{D. P. Carlisle\and S. P. Q. Rahtz}
41 % \date{\filedate}
42 % \MaintainedByLaTeXTeam{graphics}
43 % \maketitle
46 % \changes{v0.3a}{1994/02/24}
47 %     {First DPC version (after prototype by SPQR).}
48 % \changes{v0.4e}{1994/05/30}
49 %     {Rename egraphics to graphicx}
50 % \changes{v1.0}{1996/05/29}
51 %     {Version 1 at last}
54 % \def\star{{\ttfamily*}}
55 % \makeatletter
56 % \def\Describe@Macro#1{\endgroup
57 %              \setbox0=\lastbox\llap{\PrintDescribeMacro{#1}}}%
58 % \makeatother
59 % \marginparsep0pt
61 % \section{Introduction}
63 % This package implements various `graphics' functions. The main
64 % features are a) inclusion of `graphics' files. b) Rotation of sections
65 % of the page, c) Scaling of sections of the page.
67 % The design is split into three `levels'.
68 % \begin{itemize}
69 % \item The user interface. This is the collection of commands designed
70 % to appear in a document text. Actually two separate user interface
71 % have been implemented. The `standard' interface, described here, and a
72 % more powerful, and more `user-friendly' interface provided by the
73 % |graphicx| package.
74 % \item The core functions. These functions, which are also implemented
75 % in this file do all the `main work'. The `user-interface functions
76 % just collect together the information from any optional-arguments or
77 % star-forms, and then call one of these functions.
78 % \item The driver files. It is not possible to achieve the
79 % functionality of this package just using \TeX. The |dvi| driver used
80 % must be given additional instructions. (Using the |\special| command
81 % of \TeX.) Unfortunately, the capabilities of various drivers differ,
82 % and the syntax required to pass instructions to the drivers is also
83 % not standardised. So the `core functions' never access |\special|
84 % directly, but rather call a series of commands that must be defined in
85 % a special file customised for each driver. The accompanying file,
86 % |drivers.dtx| has suitable files for a range of popular drivers.
87 % \end{itemize}
89 % \section{Package Options}
90 % Most of the options, such as |dvips|, |textures| etc., specify the
91 % driver that is to be used to print the document. You may wish to set
92 % up a configuration file so that this option always takes effect, even
93 % if not specified in the document. To do this, produce a file
94 % |graphics.cfg| containing the line:\\
95 % |\ExecuteOptions{dvips}|\\
96 % (or whichever other driver you wish.)
98 % Apart from the driver options there are a few other options to control
99 % the behaviour of the package.
100 % \begin{description}
101 % \item[draft]
102 % Do not include graphics files, but instead print a box of the size
103 % the graphic would take up, and the file name. This greatly speeds up
104 % previewing on most systems.
105 % \item[final]
106 % Turns off the |draft| option.
107 % \item[debugshow]
108 % Show a lot of tracing information on the terminal. If you are not me
109 % you probably do not want to use this option.
110 % \item[hiderotate]
111 % Do not show rotated text. Sometimes useful if your previewer can not
112 % rotate text.
113 % \item[hidescale]
114 % Do not show scaled text.
115 % \item[hiresbb]
116 % Look for Bounding Box lines of the form |%%HiResBoundingBox| instead
117 % of the standard |%%BoundingBox|. These are used by some applications
118 % to get round the restriction that BoundingBox comments should only
119 % have integer values.
120 % \item[setpagesize, nosetpagesize]
121 % The |setpagesize| option requests that the driver option sets the page size.
122 % (Whichever option is used, the page size is not set by this package if |\mag|
123 % has been changed from its default value.)
124 % \item[demo] Instead of including a graphics file, make
125 %   |\includegraphics| insert a black rectangle of size 150\,pt by
126 %   100\,pt unless either dimension was already specified by another
127 %   option.
128 % \end{description}
130 % \section{Standard Interface}
132 % \subsection{Graphics Inclusion}
134 % \DescribeMacro
135 %     \includegraphics\star\oarg{llx,lly}\oarg{urx,ury}\marg{file}\\
136 % Include a graphics file.
138 % If \star\ is present, then the graphic is `clipped' to the size
139 % specified. If \star\ is omitted, then any part  of the graphic that is
140 % outside the specified `bounding box' will  over-print the surrounding
141 % text.
143 % If the optional arguments are omitted, then the size of the graphic
144 % will be determined by reading an external file as described below.
145 % If \oarg{urx,ury} is present, then it should specify the coordinates
146 % of the top right corner of the image, as a pair of \TeX\ dimensions.
147 % If the units are omitted they default to |bp|. So |[1in,1in]| and
148 % |[72,72]| are equivalent. If only one optional argument appears, the
149 % lower left corner of the image is assumed to be at |[0,0]|. Otherwise
150 % \oarg{llx,lly} may be used to specify the coordinates of this point.
152 % \DescribeMacro
153 %    \graphicspath\marg{dir-list}\\
154 % This optional declaration may be used to specify a list of directories
155 % in which to search for graphics files. The format is as for the
156 % \LaTeXe\ primitive |\input@path|, a list of directories, each in a
157 % |{}| group (even if there is only one in the list). For example:
158 %  |\graphicspath{{eps/}{tiff/}}|
159 % would cause the system to look in the subdirectories |eps| and |tiff|
160 % of the current directory. The default setting of this path is
161 % |\input@path| that is: graphics files will be found wherever \TeX\
162 % files are found.
164 % \DescribeMacro
165 %   \DeclareGraphicsExtensions\marg{ext-list}\\
166 % This specifies the behaviour of the system when the filename argument to
167 % |\includegraphics| does not have an extension specified.
168 % Here \marg{ext-list} should be a comma-separated list of file
169 % extensions, each with a leading period (\texttt{.}).
170 % A file name is produced by appending \emph{sep} and one extension.
171 % If a file is found, the system acts as if that extension had been
172 % specified. If not, the next extension in \emph{ext-list} is tried.
173 % \changes{v1.0m}{2001/06/07}{Extended documentation (CAR) graphics/3228}
175 % Each use of |\DeclareGraphicsExtensions| overwrites all previous
176 % definitions. It is not possible to add an extension to an
177 % existing list.
179 % Early versions of this package defined a default argument for this
180 % command. This has been removed.
182 % \DescribeMacro
183 % \DeclareGraphicsRule
184 %                \marg{ext}\marg{type}\marg{read-file}\marg{command}\\
185 % Any number of these declarations can be made. They determine how the
186 % system behaves when a file with extension \emph{ext} is specified.
187 % (The extension may be specified explicitly or, if the argument to
188 % |\includegraphics| does not have an extension, it may be a default
189 % extension from the \emph{ext-list} specified with
190 % |\DeclareGraphicsExtensions|.)
192 % \emph{ext} is the \emph{extension} of the file. Any file with this
193 % extension will be processed by this graphics rule. Normally a file
194 % with an extension for which no rule has been declared will generate an
195 % error, however you may use |*| as the extension to define a
196 % \emph{default rule}. For instance the |dvips| driver file declares all
197 % files to be of type |eps| unless a more specific rule is declared.
199 % Since Version v0.6, extensions should be specified including the |.|
200 % that is, |.eps| not |eps|.
202 % \emph{type} is the `type' of file involved. All files of the same type
203 % will be input with the same internal command (which must be defined in
204 % a `driver file'). For example files with extensions |ps|, |eps|,
205 % |ps.gz| may all be classed as type |eps|.
207 % \emph{read-file} determines the extension of the file that should be
208 % read to determine size information. It may be the same as \emph{ext}
209 % but it may be different, for example |.ps.gz| files are not readable
210 % easily by \TeX, so you may want to put the bounding box information in
211 % a separate file with extension |.ps.bb|. If \emph{read-file} is empty,
212 % |{}|, then the system will not try to locate an external file for size
213 % info, and the size must be specified in the arguments of
214 % |\includegraphics|. As a special case |*| may be used to denote the
215 % same extension as the graphic file. This is mainly of use in
216 % conjunction with using |*| as the extension, as in that case the
217 % particular graphic extension is not known. For example
218 %\begin{verbatim}
219 % \DeclareGraphicsRule{*}{eps}{*}{}
220 %\end{verbatim}
221 % This would declare a default rule, such that all unknown extensions
222 % would be treated as EPS files, and the graphic file would be read for
223 % a BoundingBox comment.
225 % If the driver file specifies a procedure for
226 % reading size files for \emph{type}, that will be used, otherwise the
227 % procedure for reading |eps| files will be used. Thus the size of
228 % bitmap files may be specified in a file with a PostScript style
229 % |%%BoundingBox| line, if no other specific format is available.
231 % \emph{command} is usually empty, but if non empty it is used in place
232 % of the filename in the |\special|. Within this argument, |#1| may be
233 % used to denote the filename. Thus using the dvips driver, one may
234 % use\\
235 % |\DeclareGraphicsRule{.ps.gz}{eps}{.ps.bb}{`zcat #1}|\\
236 % the final argument causes dvips to use the |zcat| command to unzip the
237 % file before inserting it into the PostScript output.
239 % \subsection{Rotation}
241 % \DescribeMacro
242 %   \rotatebox\marg{angle}\marg{text}\\
243 % Rotate \emph{text} \emph{angle} degrees anti-clockwise. Normally
244 % the rotation is about the left-hand end of the baseline of
245 % \emph{text}.
247 % \subsection{Scaling}
249 % \DescribeMacro
250 %   \scalebox\marg{h-scale}\oarg{v-scale}\marg{text}\\
251 % Scale \emph{text} by the specified amounts. If \emph{v-scale} is
252 % omitted, the vertical scale factor is the same as the horizontal one.
254 % \DescribeMacro
255 %   \resizebox\star\marg{h-length}\marg{v-length}\marg{text}\\
256 % Scale \emph{text} so that the width is \emph{h-length}.
257 % If |!| is used as either length argument, the other argument is used
258 % to determine a scale factor that is used in both directions.
259 % Normally \emph{v-length} refers to the height of the box, but in the
260 % star form, it refers to the `height +  depth'.
261 % As normal for \LaTeXe\ box length arguments, |\height|,
262 % |\width|, |\totalheight| and |\depth| may be used to refer to the
263 % original size of the box.
265 % \section{The Key=Value Interface}
266 % As mentioned in the introduction, apart from the above `standard
267 % interface', there is an alternative syntax to the |\includegraphics|
268 % and |\rotatebox| commands that some people may prefer. It is provided
269 % by the accompanying |graphicx| package.
271 % \StopEventually{}
273 % \section{The Graphics Kernel Functions}
275 % \subsection{Graphics Inclusion}
277 % \DescribeMacro
278 %   {\Ginclude@graphics}\marg{file}\\
279 % Insert the contents of the file \emph{file} at the current point.
280 % |\Ginclude@graphics| may use the four macros |\Gin@llx|, |\Gin@lly|,
281 % |\Gin@urx|, |\Gin@ury| to determine the `bounding box' of the graphic.
282 % The result will be a \TeX\ box of width $\mathit{urx}-\mathit{llx}$
283 % and height $\mathit{ury}-\mathit{lly}$. If |\Gin@clip| is \meta{true}
284 % then part of the graphic that is outside this box should not be
285 % displayed. (Not all drivers can support this `clipping'.) Normally all
286 % these parameters are set by the `user interface level'.
289 % \DescribeMacro
290 %   {\Gread@eps}\marg{file}\\
291 % For each \emph{type} of graphics file supported, the driver file must
292 % define |\Ginclude@|\emph{type} and, optionally |\Gread@|\emph{type}.
293 % The read command is responsible for obtaining size information from
294 % the file specified in the |\DeclareGraphicsRule| command. However the
295 % kernel defines a function, |\Gread@eps|,  which can read PostScript
296 % files to find the
297 % |%%BoundingBox| comment. This function will be used for any type for
298 % which a specific function has not been declared. |\Gread@eps| accepts
299 % a generalised version of the bounding box comment. \TeX\ units may be
300 % used (but there must be no space before the unit). If the unit is
301 % omitted |bp| is assumed. So\\
302 % |%%BoundingBox 0 0 2in 3in|\\
303 % Would be accepted by this function, to produce a 2in wide, by 3in high
304 % graphic.
306 % \subsection{Rotation}
308 % \DescribeMacro
309 %   {\Grot@box}\\
310 % Rotate the contents of |\box0| through |\Grot@angle| degrees
311 % (anti-clockwise). The user-interface is responsible for setting the
312 % macro |\Grot@angle|, and putting the appropriate text in |\Grot@box|.
314 % \subsection{Scaling}
316 % \DescribeMacro
317 %   {\Gscale@box}\marg{xscale}\oarg{yscale}\marg{text}\\
318 % (The second argument is not optional.)
319 % Scale \emph{text} by the appropriate scale factors.
321 % \DescribeMacro
322 %  {\Gscale@box@dd}\marg{dima}\marg{dimb}\marg{text}\\
323 % Scale \emph{text} in both directions by a factor
324 % \emph{dima}/\emph{dimb}.
326 % \DescribeMacro
327 % {\Gscale@box@dddd}
328 %        \marg{dima}\marg{dimb}\marg{dimc}\marg{dimd}\marg{text}\\
329 % Scale \emph{text} in horizontally by a factor \emph{dima}/\emph{dimb},
330 % and vertically by a factor of  \emph{dimc}/\emph{dimd}.
332 % \DescribeMacro
333 % {\Gscale@div}\marg{cmd}\marg{dima}\marg{dimb}\\
334 % Define the macro \emph{cmd} to be the ratio of the lengths
335 % \emph{dima}/\emph{dimb}.
338 % \section{Interface to the Driver Files}
340 % \subsection{Graphics Inclusion}
342 % Each driver file must declare that its driver can include graphics of
343 % certain \emph{types}. It does this by declaring for each type a
344 % command of the form:\\
345 % |\Ginclude@|\emph{type}\\
346 % The Graphics kernel function will call this driver-defined function
347 % with the filename as argument, and certain additional information will
348 % be provided as follows.:
350 % \noindent\begin{tabular}{p{.4\textwidth}p{.5\textwidth}}
351 % |\Gin@llx|, |\Gin@lly|,\newline
352 % |\Gin@urx|, |\Gin@ury| &Macros storing the `bounding box'\\
353 % |\Gin@nat@width|\newline |\Gin@nat@height| &
354 %               Registers storing the natural size.\\
355 % |\Gin@req@width|\newline |\Gin@req@height| &
356 %               Registers storing the required size, after scaling.\\
357 % |\Gin@scalex|, |\Gin@scaley| & macros with the scale factors. A value
358 % of |!| means: Scale by the same amount as the other direction.\\
359 % |\ifGin@clip| & |\newif| token, true if the graphic should be
360 %                 `clipped' to  the bounding box.
361 % \end{tabular}
363 % Optionally the driver may define a command of the form:\\
364 % |\Gread@|\emph{type}\\
365 % This is responsible for reading an external file to find the bounding
366 % box information. If such a command is not declared, but a read-file is
367 % specified the command |\Gread@eps|, which is defined in the Graphics
368 % Kernel will be used.
370 % \subsection{Literal Postscript}
371 % Drivers that are producing PostScript output may want to define
372 % the following macros. They each take one argument which should be
373 % passed to an appropriate special. They are not used directly by this
374 % package but allow other packages to use the standard configuration
375 % file and package options to customise to various drivers:\\
376 % |\Gin@PS@raw|, Literal PostScript special.\\
377 % |\Gin@PS@restored|, Literal PostScript special, the driver will
378 %                    surround this with a save-restore pair.\\
379 % |\Gin@PS@literal@header|, Postscript to be inserted in the header
380 %                           section of the PostScript file.\\
381 % |\Gin@PS@file@header|, external file to be inserted in the header
382 %                           section of the PostScript file.
385 % \subsection{Rotation}
387 % |\Grot@start|, |\Grot@end| These macros must be defined to insert the
388 % appropriate |\special| to rotate the text between them by
389 % |\Grot@angle| degrees. The kernel function will make sure that the
390 % correct \TeX\ spacing is produced, these functions only need insert
391 % the |\special|.
393 % \subsection{Scaling}
395 % |\Gscale@start|, |\Gscale@end|, as for rotation, but here scale the
396 % text by |\Gscale@x| and |\Gscale@y|.
399 % \section{Implementation}
401 %    \begin{macrocode}
402 %<*package>
403 %    \end{macrocode}
405 % \subsection{Initialisation}
407 % \begin{macro}{\Gin@codes}
408 % First we save the catcodes of some characters, and set them to
409 % fixed values whilst this file is being read.
410 % \changes{v0.5a}{1994/07/20}
411 %     {Save and restore catcodes}
412 %    \begin{macrocode}
413 \edef\Gin@codes{%
414  \catcode`\noexpand\^^A\the\catcode`\^^A\relax
415  \catcode`\noexpand\"\the\catcode`\"\relax
416  \catcode`\noexpand\*\the\catcode`\*\relax
417  \catcode`\noexpand\!\the\catcode`\!\relax
418  \catcode`\noexpand\:\the\catcode`\:\relax}
419 %    \end{macrocode}
421 %    \begin{macrocode}
422 \catcode`\^^A=\catcode`\%
423 \@makeother\"%
424 \catcode`\*=11
425 \@makeother\!%
426 \@makeother\:%
427 %    \end{macrocode}
428 % \end{macro}
430 % We will need to have an implementation of the trigonometric
431 % functions for the rotation feature. May as well load it now.
432 %    \begin{macrocode}
433 \RequirePackage{trig}
434 %    \end{macrocode}
436 %  \begin{macro}{\Grot@start}
437 %  \begin{macro}{\Grot@end}
438 % Initialise the rotation primitives.
439 %    \begin{macrocode}
440 \providecommand\Grot@start{\@latex@error{Rotation not supported}\@ehc
441             \global\let\Grot@start\relax}
442 \providecommand\Grot@end{}
443 %    \end{macrocode}
444 %  \end{macro}
445 %  \end{macro}
447 %  \begin{macro}{\Gscale@start}
448 %  \begin{macro}{\Gscale@end}
449 % Initialise the scaling primitives.
450 %    \begin{macrocode}
451 \providecommand\Gscale@start{\@latex@error{Scaling not supported}\@ehc
452             \global\let\Gscale@start\relax}
453 \providecommand\Gscale@end{}
454 %    \end{macrocode}
455 %  \end{macro}
456 %  \end{macro}
458 % \begin{macro}{\Gread@BBox}
459 % \changes{v1.0b}{1996/10/29}
460 %     {Moved to initial section, for hiresbb option}
461 % |%%BoundingBox| as a macro for testing with |\ifx|.
462 % This may be redefined by the hiresbb option.
463 %    \begin{macrocode}
464 \edef\Gread@BBox{\@percentchar\@percentchar BoundingBox}
465 %    \end{macrocode}
466 % \end{macro}
468 % \subsection{Options}
470 % \begin{option}{draft}
471 % \begin{option}{final}
472 % \changes{v0.3i}{1994/03/23}
473 %     {notdraft option added}
474 % \changes{v0.4a}{1994/04/13}
475 %     {Rename option to nodraft}
476 % \changes{v0.4d}{1994/05/06}
477 %     {Rename option to final}
478 %    \begin{macrocode}
479 \DeclareOption{draft}{\Gin@drafttrue}
480 \DeclareOption{final}{\Gin@draftfalse}
481 %    \end{macrocode}
482 % \end{option}
483 % \end{option}
485 %  \begin{macro}{\ifGin@draft}
486 % True in draft mode.
487 %    \begin{macrocode}
488 \newif\ifGin@draft
489 %    \end{macrocode}
490 %  \end{macro}
492 % \begin{option}{hiresbb}
493 % \changes{v1.0b}{1996/10/29}
494 %     {hiresbb option added}
495 % If given this option the package will look for bounding box comments
496 % of the form |%%HiResBoundingBox| (which typically have real values)
497 % instead of the standard |%%BoundingBox| (which should have integer
498 % values).
499 %    \begin{macrocode}
500 \DeclareOption{hiresbb}{%
501   \edef\Gread@BBox{\@percentchar\@percentchar HiResBoundingBox}}
502 %    \end{macrocode}
503 % \end{option}
505 % \begin{option}{demo}
506 %   \changes{v1.0o}{2006/02/20}{demo option added}
507 %   If given this option the package will disregard the actual
508 %   graphics file and insert a black box unless width or height are
509 %   already specified.
510 %    \begin{macrocode}
511 \DeclareOption{demo}{%
512   \AtBeginDocument{%
513     \def\Ginclude@graphics#1{%
514       \rule{\@ifundefined{Gin@@ewidth}{150pt}{\Gin@@ewidth}}%
515       {\@ifundefined{Gin@@eheight}{100pt}{\Gin@@eheight}}}}}
516 %    \end{macrocode}
517 % \end{option}
519 % \begin{option}{setpagesize}
520 % \begin{option}{nosetpagesize}
521 % The |setpagesize| option requests that the driver option sets the page size.
522 % (Whichever option is used, the page size is not set by this package if |\mag|
523 % has been changed from its default value.)
524 % \changes{v1.0s}{2016/06/02}
525 %     {(no)setpagesize options added}
526 %    \begin{macrocode}
527 \newif\ifGin@setpagesize\Gin@setpagesizetrue
528 \DeclareOption{setpagesize}{\Gin@setpagesizetrue}
529 \DeclareOption{nosetpagesize}{\Gin@setpagesizefalse}
530 %    \end{macrocode}
531 % \end{option}
532 % \end{option}
534 %  \begin{macro}{\Gin@driver}
535 % Driver in use.
536 %    \begin{macrocode}
537 \providecommand\Gin@driver{}
538 %    \end{macrocode}
539 %  \end{macro}
541 % \begin{option}{dvips}
542 % \changes{v0.3g}{1994/03/15}
543 %     {Use dvips def file not development version}
544 % \begin{option}{xdvi}
545 % Tomas Rockicki's  PostScript driver (unix, MSDOS, VMS\ldots).
546 % The |X11| previewer |xdvi| supports basically the same set of
547 % |\specials|.
548 %    \begin{macrocode}
549 \DeclareOption{dvips}{\def\Gin@driver{dvips.def}}
550 \DeclareOption{xdvi}{\ExecuteOptions{dvips}}
551 %    \end{macrocode}
552 % \end{option}
553 % \end{option}
555 % \begin{option}{dvipdf}
556 % \changes{v1.0c}{1996/10/31}
557 %     {dvipdf added}
558 % Sergey Lesenko's dvipdf driver.
559 %    \begin{macrocode}
560 \DeclareOption{dvipdf}{\def\Gin@driver{dvipdf.def}}
561 %    \end{macrocode}
562 % \end{option}
564 % \begin{option}{dvipdfm}
565 % \changes{v1.0k}{1999/01/13}
566 %     {dvipdfm added}
567 % \changes{v1.2a}{2017/06/01}
568 %     {make dvipdfm an alias for dvipdfmx}
569 % Mark Wick's dvipdfm driver (now merged with xdvipdfmx).
570 %    \begin{macrocode}
571 \DeclareOption{dvipdfm}{\def\Gin@driver{dvipdfmx.def}}
572 %    \end{macrocode}
573 % \end{option}
575 % \begin{option}{dvipdfmx}
576 % \changes{v1.0m}{2005/11/14}
577 %     {dvipdfmx added}
578 % The driver for the dvipdfmx project (also supports xdvipdfmx).
579 %    \begin{macrocode}
580 \DeclareOption{dvipdfmx}{\def\Gin@driver{dvipdfmx.def}}
581 %    \end{macrocode}
582 % \end{option}
584 % \begin{option}{xetex}
585 % \changes{v1.0m}{2005/11/14}
586 %     {xetex added}
587 %  Jonathan Kew's \TeX\ variant.
588 %    \begin{macrocode}
589 \DeclareOption{xetex}{\def\Gin@driver{xetex.def}}
590 %    \end{macrocode}
591 % \end{option}
593 % \begin{option}{pdftex}
594 % \changes{v1.0d}{1997/06/07}
595 %     {pdftex added}
596 %  Han The Thanh's \TeX\ variant.
597 %    \begin{macrocode}
598 \DeclareOption{pdftex}{\def\Gin@driver{pdftex.def}}
599 %    \end{macrocode}
600 % \end{option}
602 % \begin{option}{luatex}
603 % \changes{v1.0q}{2016/01/03}
604 %     {luatex added}
605 %  Lua\TeX\ \TeX\ variant.
606 %    \begin{macrocode}
607 \DeclareOption{luatex}{\def\Gin@driver{luatex.def}}
608 %    \end{macrocode}
609 % \end{option}
611 % \begin{option}{luatex}
612 % \changes{v1.0r}{2016/05/09}
613 %     {dvisvgm added}
614 %  dvisvgm driver.
615 %    \begin{macrocode}
616 \DeclareOption{dvisvgm}{\def\Gin@driver{dvisvgm.def}}
617 %    \end{macrocode}
618 % \end{option}
620 % \begin{option}{dvipsone}
621 % \begin{option}{dviwindo}
622 % \changes{v0.3c}{1994/03/04}
623 %     {dviwindo support.}
624 % \changes{v0.7c}{1995/09/07}
625 %     {Merge dviwindo option with dvipsone}
626 % The drivers for the Y\&Y \TeX\ system.
627 %    \begin{macrocode}
628 \DeclareOption{dvipsone}{\def\Gin@driver{dvipsone.def}}
629 \DeclareOption{dviwindo}{\ExecuteOptions{dvipsone}}
630 %    \end{macrocode}
631 % \end{option}
632 % \end{option}
634 % \begin{option}{emtex}
635 % \begin{option}{dviwin}
636 % Two freely available sets of drivers for MSDOS, OS/2 and Windows.
637 %    \begin{macrocode}
638 \DeclareOption{emtex}{\def\Gin@driver{emtex.def}}
639 \DeclareOption{dviwin}{\def\Gin@driver{dviwin.def}}
640 %    \end{macrocode}
641 % \end{option}
642 % \end{option}
644 % \begin{option}{oztex}
645 % \changes{v1.0f}{1997/09/09}
646 %     {Merge dvips and oztex options}
647 % Oz\TeX\ (Macintosh).
648 % Since release 3 of Oz\TeX, merge with dvips back end.
649 %    \begin{macrocode}
650 \DeclareOption{oztex}{\ExecuteOptions{dvips}}
651 %    \end{macrocode}
652 % \end{option}
654 % \begin{option}{textures}
655 % Textures (Macintosh).
656 %    \begin{macrocode}
657 \DeclareOption{textures}{\def\Gin@driver{textures.def}}
658 %    \end{macrocode}
659 % \end{option}
661 % \begin{option}{pctexps}
662 % \begin{option}{pctexwin}
663 % \begin{option}{pctexhp}
664 % \begin{option}{pctex32}
665 % \changes{v1.0b}{1996/10/29}
666 %     {pctex32 option added}
667 % PC\TeX\ (MSDOS/Windows) .
668 %    \begin{macrocode}
669 \DeclareOption{pctexps}{\def\Gin@driver{pctexps.def}}
670 \DeclareOption{pctexwin}{\def\Gin@driver{pctexwin.def}}
671 \DeclareOption{pctexhp}{\def\Gin@driver{pctexhp.def}}
672 \DeclareOption{pctex32}{\def\Gin@driver{pctex32.def}}
673 %    \end{macrocode}
674 % \end{option}
675 % \end{option}
676 % \end{option}
677 % \end{option}
679 % \begin{option}{truetex}
680 % \changes{v1.0b}{1996/10/29}
681 %     {truetex and tcidef options added}
682 % \begin{option}{tcidvi}
683 % Kinch TrueTeX, and its version with extended special support as
684 % shipped by Scientific Word.
685 %    \begin{macrocode}
686 \DeclareOption{truetex}{\def\Gin@driver{truetex.def}}
687 \DeclareOption{tcidvi}{\def\Gin@driver{tcidvi.def}}
688 %    \end{macrocode}
689 % \end{option}
690 % \end{option}
692 % \begin{option}{vtex}
693 % \changes{v1.0h}{1998/05/27}
694 %     {vtex option added}
695 % V\TeX\ driver.
696 %    \begin{macrocode}
697 \DeclareOption{vtex}{\def\Gin@driver{vtex.def}}
698 %    \end{macrocode}
699 % \end{option}
701 % \begin{option}{dvi2ps}
702 % \begin{option}{dvialw}
703 % \begin{option}{dvilaser}
704 % \begin{option}{dvitops}
705 % \begin{option}{psprint}
706 % \begin{option}{pubps}
707 % \begin{option}{ln}
708 % \changes{v0.6b}{1994/12/12}
709 %     {ln support (untested)}
710 % \changes{v1.0b}{1996/10/29}
711 %     {options for historic drivers depreciated}
712 % If \emph{anyone} is using any of these driver options
713 % would they let me know. All these are essentially untried
714 % and untested as far as I know.
715 %    \begin{macrocode}
716 %\DeclareOption{dvi2ps}{\def\Gin@driver{dvi2ps.def}}
717 %\DeclareOption{dvialw}{\def\Gin@driver{dvialw.def}}
718 %\DeclareOption{dvilaser}{\def\Gin@driver{dvilaser.def}}
719 %\DeclareOption{dvitops}{\def\Gin@driver{dvitops.def}}
720 %\DeclareOption{psprint}{\def\Gin@driver{psprint.def}}
721 %\DeclareOption{pubps}{\def\Gin@driver{pubps.def}}
722 %\DeclareOption{ln}{\def\Gin@driver{ln.def}}
723 %    \end{macrocode}
724 % \end{option}
725 % \end{option}
726 % \end{option}
727 % \end{option}
728 % \end{option}
729 % \end{option}
730 % \end{option}
732 % \begin{option}{debugshow}
733 % You probably don't want to use this\ldots
734 %    \begin{macrocode}
735 \DeclareOption{debugshow}{\catcode`\^^A=9 \let\GDebug\typeout}
736 %    \end{macrocode}
737 % \end{option}
739 % A local configuration file may define more options.
740 % It should also make one driver option the default, by calling
741 % |\ExecuteOptions| with the appropriate option.
742 % \changes{v0.4f}{1994/07/27}
743 %      {Add missing 3rd argument to \cs{InputIfFileExists}}
744 %    \begin{macrocode}
745 \InputIfFileExists{graphics.cfg}{}{}
746 %    \end{macrocode}
748 % \begin{option}{hiderotate}
749 % \changes{v0.4a}{1994/04/13}
750 %     {Rename option to hiderotate}
751 %    \begin{macrocode}
752 \DeclareOption{hiderotate}{%
753   \def\Grot@start{\begingroup\setbox\z@\hbox\bgroup}
754   \def\Grot@end{\egroup\endgroup}}
755 %    \end{macrocode}
756 % \end{option}
758 % \begin{option}{hidescale}
759 % \changes{v0.4a}{1994/04/13}
760 %     {Rename option to hidescale}
761 %    \begin{macrocode}
762 \DeclareOption{hidescale}{%
763   \def\Gscale@start{\begingroup\setbox\z@\hbox\bgroup}
764   \def\Gscale@end{\egroup\endgroup}}
765 %    \end{macrocode}
766 % \end{option}
768 % After the options are processed, load the appropriate driver file.
769 % If a site wants a default driver (eg |textures|) it just needs to put
770 % |\ExecuteOptions{textures}| in a |graphics.cfg| file.
771 %    \begin{macrocode}
772 \ProcessOptions
773 %    \end{macrocode}
775 % Check that a driver has been specified (either as an option, or as a
776 % default option in the configuration file). Then load the `def' file
777 % for that option, if it has not already been loaded by some other
778 % package (for instance the \textsf{color} package).
779 % \changes{v0.5c}{1994/10/03}
780 %     {Error if no driver specified}
781 %    \begin{macrocode}
782 \if!\Gin@driver!
783   \PackageError{graphics}
784     {No driver specified}
785     {You should make a default driver option in a file \MessageBreak
786      graphics.cfg\MessageBreak
787      eg: \protect\ExecuteOptions{textures}%
788      }
789 \else
790   \PackageInfo{graphics}{Driver file: \Gin@driver}
791   \@ifundefined{ver@\Gin@driver}{\input{\Gin@driver}}{}
793 %    \end{macrocode}
796 % \subsection{Graphics Inclusion}
798 % This Graphics package uses a lot of dimension registers. \TeX\ only
799 % has a limited number of registers, so rather than allocate new ones,
800 % re-use some existing \LaTeX\ registers. This is safe as long as all
801 % uses of the registers are \emph{local}, and that you can be sure
802 % that you \emph{never} need to have access to both uses within the
803 % same scope.
805 % \begin{macro}{\Gin@llx}
806 % \begin{macro}{\Gin@lly}
807 % \begin{macro}{\Gin@urx}
808 % \begin{macro}{\Gin@ury}
809 % In fact these four lengths are now stored as macros not as dimen
810 % registers, mainly so that integer |bp| lengths may be passed exactly.
811 % \changes{v0.7a}{1995/04/11}
812 %     {Bounding box coords no longer in registers}
813 %    \begin{macrocode}
814 \def\Gin@llx{0}
815 \let\Gin@lly\Gin@llx
816 \let\Gin@urx\Gin@llx
817 \let\Gin@ury\Gin@llx
818 %    \end{macrocode}
819 % \end{macro}
820 % \end{macro}
821 % \end{macro}
822 % \end{macro}
824 % \begin{macro}{\Gin@nat@width}
825 % \begin{macro}{\Gin@nat@height}
826 % The `natural' size of the graphic, before any scaling.
827 %    \begin{macrocode}
828 \let\Gin@nat@width\leftmarginv
829 \let\Gin@nat@height\leftmarginvi
830 %    \end{macrocode}
831 % \end{macro}
832 % \end{macro}
834 %  \begin{macro}{\ifGin@clip}
835 % This switch is \meta{true} if any graphics outside the specified
836 % bounding box (really viewport) should not be printed.
837 %    \begin{macrocode}
838 \newif\ifGin@clip
839 %    \end{macrocode}
840 % \end{macro}
842 % \begin{macro}{\DeclareGraphicsExtensions}
843 % \changes{v0.6a}{1994/11/29}
844 %     {Remove optional argument, ignore spaces in main argument.}
845 % Declare a comma separated list of default extensions to be used
846 % if the file is specified with no extension.
847 %    \begin{macrocode}
848 \newcommand\DeclareGraphicsExtensions[1]{%
849   \edef\Gin@extensions{\zap@space#1 \@empty}}
850 %    \end{macrocode}
851 % \end{macro}
853 %  \begin{macro}{\Gin@extensions}
854 % Initialise the list of possible extensions.
855 % \changes{v0.4b}{1994/04/20}
856 %     {Use \cmd{\providecommand} in case a previous def file has
857 %     already defined it}
858 %    \begin{macrocode}
859 \providecommand\Gin@extensions{}
860 %    \end{macrocode}
861 %  \end{macro}
863 % \begin{macro}{\includegraphics}
864 % \changes{v1.1a}{2017/03/17}
865 % {\cs{leavevmode} added before the group in \cs{Gin@iii} so that
866 % settings in \cs{everypar} are cleared}
867 % Top level command for the standard interface, just look for a |*|.
868 %    \begin{macrocode}
869 \def\includegraphics{%
870 %    \end{macrocode}
871 % Clear |\everypar| before starting a group.
872 %    \begin{macrocode}
873   \leavevmode
874 %    \end{macrocode}
876 %    \begin{macrocode}
877   \@ifstar
878     {\Gin@cliptrue\Gin@i}%
879     {\Gin@clipfalse\Gin@i}}
880 %    \end{macrocode}
881 % \end{macro}
883 % \begin{macro}{\Gin@i}
884 %  If an optional argument is present, call |\Gin@ii| to process it,
885 %    otherwise call |\Ginclude@graphics|.
886 % \changes{v0.3e}{1994/03/09}
887 %     {Now specify ll before ur coordinate}
888 %    \begin{macrocode}
889 \def\Gin@i{%
890   \@ifnextchar[%]
891     \Gin@ii
892     {\Gin@bboxfalse\Ginclude@graphics}}
893 %    \end{macrocode}
894 % \end{macro}
896 % \begin{macro}{\Gin@ii}
897 % Look for a second optional argument.
898 %    \begin{macrocode}
899 \def\Gin@ii[#1]{%
900   \@ifnextchar[%]
901     {\Gin@iii[#1]}
902     {\Gin@iii[0,0][#1]}}
903 %    \end{macrocode}
904 % \end{macro}
906 % \begin{macro}{\Gin@iii}
907 % Set the coordinates of the {\bfseries l}lower {\bfseries l}eft corner,
908 % and the coordinates of the {\bfseries u}pper {\bfseries r}ight
909 % corner. The coordinates may be any \TeX\ dimension, defaulting to |bp|.
910 % \changes{v0.6c}{1994/12/15}
911 %     {(Denis Roegel) Extra group to keep bb settings local}
912 %    \begin{macrocode}
913 \def\Gin@iii[#1,#2][#3,#4]#5{%
914   \begingroup
915   \Gin@bboxtrue
916   \Gin@defaultbp\Gin@llx{#1}%
917   \Gin@defaultbp\Gin@lly{#2}%
918   \Gin@defaultbp\Gin@urx{#3}%
919   \Gin@defaultbp\Gin@ury{#4}%
920   \Ginclude@graphics{#5}%
921   \endgroup}
922 %    \end{macrocode}
923 % \end{macro}
925 %  \begin{macro}{\Gin@defaultbp}
926 % \changes{v0.7a}{1995/04/11}{Macro added}
927 %  \begin{macro}{\Gin@def@bp}
928 % \changes{v0.7a}{1995/04/11}{Macro added}
929 % This macro grabs a length, |#2|,  which may or may not have a unit,
930 % and if a unit is supplied, converts to `bp' and stores the value in
931 % |#1|. If a unit is not supplied `bp' is assumed, and |#2| is directly
932 % stored in |#1|. Note that supplying `bp' is not quite the same as
933 % supplying no units, as in the former case a conversion via `pt' and
934 % back to `bp' takes place which can introduce rounding error. The error
935 % is invisibly small but files conforming to Adobe  DSC should have
936 % \emph{integer} Bounding Box Coordinates, and conceivably some drivers
937 % might demand integer values.
938 % (Although most seem to accept real values (if they accept bounding box
939 % coordinates at all) in the |\special|. This is the reason why the
940 % mechanism uses |\def| and not \TeX\ lengths, as in earlier releases of
941 % the package.
942 %    \begin{macrocode}
943 \def\Gin@defaultbp#1#2{%
944   \afterassignment\Gin@def@bp\dimen@#2bp\relax{#1}{#2}}
945 %    \end{macrocode}
947 %    \begin{macrocode}
948 \def\Gin@def@bp#1\relax#2#3{%
949    \if!#1!%
950      \def#2{#3}%
951     \else
952       \dimen@.99626\dimen@
953       \edef#2{\strip@pt\dimen@}%
954     \fi}
955 %    \end{macrocode}
956 %  \end{macro}
957 %  \end{macro}
959 % \begin{macro}{\DeclareGraphicsRule}
960 % Declare what actions should be taken for a particular file
961 % extension.
963 %  |#1| extension, |#2| type, |#3| read-file, |#4| command,
964 % \changes{v0.5d}{1994/10/24}
965 %     {(Arthur Ogawa) Check arg3 is *, not arg2.}
966 %    \begin{macrocode}
967 \def\DeclareGraphicsRule#1#2#3#4{%
968   \edef\@tempa{\string *}\def\@tempb{#3}%
969   \expandafter\edef\csname Gin@rule@#1\endcsname##1%
970        {{#2}%
971         {\ifx\@tempa\@tempb\noexpand\Gin@ext\else#3\fi}%
972         {\ifx\indent#4\indent##1\else#4\fi}}}
973 %    \end{macrocode}
974 % \end{macro}
976 % An example rule base.
977 %\begin{verbatim}
978 %                    ext    type  read  command
979 % \DeclareGraphicsRule{.ps}   {eps} {.ps}    {}
980 % \DeclareGraphicsRule{.eps}  {eps} {.eps}   {}
981 % \DeclareGraphicsRule{.ps.gz}{eps} {.ps.bb} {`zcat #1}
982 % \DeclareGraphicsRule{.pcx}  {bmp} {}      {}
983 %\end{verbatim}
985 % \begin{macro}{\graphicspath}
986 % User level command to set the input path for graphics files.
987 % A list of directories, each in a |{}| group.
988 %    \begin{macrocode}
989 \def\graphicspath#1{\def\Ginput@path{#1}}
990 %    \end{macrocode}
991 % \end{macro}
993 % \begin{macro}{\Ginput@path}
994 % The default graphic path is |\input@path|.
995 %    \begin{macrocode}
996 \ifx\Ginput@path\@undefined
997   \let\Ginput@path\input@path
999 %    \end{macrocode}
1000 % \end{macro}
1002 % \begin{macro}{\Gin@getbase}
1003 % \changes{v0.6a}{1994/11/29}
1004 %     {remove \cs{Gin@sep}}
1005 % Given a possible extension, |#1|, check whether the file exists. If
1006 % it does set |\Gin@base| and |\Gin@ext| to the filename stripped of
1007 % the extension, and the extension, respectively.
1008 %    \begin{macrocode}
1009 \def\Gin@getbase#1{%
1010   \edef\Gin@tempa{%
1011     \def\noexpand\@tempa####1#1\space{%
1012       \def\noexpand\Gin@base{####1}}}%
1013   \IfFileExists{\filename@area\filename@base#1}%
1014     {\Gin@tempa
1015      \expandafter\@tempa\@filef@und
1016      \edef\Gin@ext{#1}}{}}%
1017 %    \end{macrocode}
1018 % \end{macro}
1020 % \begin{macro}{\Gin@ext}
1021 % Initialise the macro to hold the extension.
1022 %    \begin{macrocode}
1023 \let\Gin@ext\relax
1024 %    \end{macrocode}
1025 % \end{macro}
1027 % \begin{macro}{\Gin@sepdefault}
1028 % \changes{v0.6a}{1994/11/29}
1029 %     {remove \cs{Gin@sep}}
1030 % This must match the token used by |\filename@parse| to delimit the
1031 % extension.
1032 %    \begin{macrocode}
1033 \def\Gin@sepdefault{.}
1034 %    \end{macrocode}
1035 % \end{macro}
1037 % \begin{macro}{\Ginclude@graphics}
1038 %  The main internal function implementing graphics file inclusion.
1039 %  |#1| is the file name.
1040 % \changes{v0.4c}{1994/04/28}
1041 %     {Improve the wording of error messages}
1042 % \changes{v0.5a}{1994/07/20}
1043 %     {Add default (*) rule possibility}
1044 % \changes{v0.6a}{1994/11/29}
1045 %     {remove \cs{Gin@sepdefault}}
1046 %    \begin{macrocode}
1047 \def\Ginclude@graphics#1{%
1048   \begingroup
1049   \let\input@path\Ginput@path
1050   \filename@parse{#1}%
1051   \ifx\filename@ext\relax
1052     \@for\Gin@temp:=\Gin@extensions\do{%
1053       \ifx\Gin@ext\relax
1054         \Gin@getbase\Gin@temp
1055       \fi}%
1056   \else
1057     \Gin@getbase{\Gin@sepdefault\filename@ext}%
1058 %    \end{macrocode}
1059 % \changes{v0.4d}{1994/05/06}
1060 %     {Make file not found a warning not an error}
1061 % \changes{v0.6a}{1994/11/29}
1062 %     {remove \cs{Gin@sep}}
1063 % If the user supplied an explicit extension, just give a warning if the
1064 % file does not exist. (It may be created later.)
1065 %    \begin{macrocode}
1066     \ifx\Gin@ext\relax
1067        \@warning{File `#1' not found}%
1068        \def\Gin@base{\filename@area\filename@base}%
1069 %    \end{macrocode}
1070 % \changes{v0.6c}{1994/12/15}
1071 %     {(Piet van Oostrum) include `.' in \cs{Gin@ext}}%
1072 %    \begin{macrocode}
1073        \edef\Gin@ext{\Gin@sepdefault\filename@ext}%
1074     \fi
1075   \fi
1076 %    \end{macrocode}
1077 % If no extension is supplied, it is an error if the file does not
1078 % exist, as there is no way for the system to know which extension to
1079 % supply.
1080 %    \begin{macrocode}
1081     \ifx\Gin@ext\relax
1082          \@latex@error{File `#1' not found}%
1083          {I could not locate the file with any of these extensions:^^J%
1084           \Gin@extensions^^J\@ehc}%
1085     \else
1086        \@ifundefined{Gin@rule@\Gin@ext}%
1087 %    \end{macrocode}
1088 % \changes{v0.5a}{1994/07/20}
1089 %     {Add default (*) rule possibility}
1090 % Handle default rule.
1091 %    \begin{macrocode}
1092          {\ifx\Gin@rule@*\@undefined
1093             \@latex@error{Unknown graphics extension: \Gin@ext}\@ehc
1094           \else
1095             \expandafter\Gin@setfile\Gin@rule@*{\Gin@base\Gin@ext}%
1096            \fi}%
1097          {\expandafter\expandafter\expandafter\Gin@setfile
1098              \csname Gin@rule@\Gin@ext\endcsname{\Gin@base\Gin@ext}}%
1099     \fi
1100   \endgroup}
1101 %    \end{macrocode}
1102 % \end{macro}
1104 % \begin{macro}{\ifGread@}
1105 % True if a file should be read to obtain the natural size.
1106 %    \begin{macrocode}
1107 \newif\ifGread@\Gread@true
1108 %    \end{macrocode}
1109 % \end{macro}
1111 % \begin{macro}{\Gin@setfile}
1112 % Set a file to the size specified in arguments, or in a `read file'.
1113 % \changes{v0.5d}{1994/10/24}
1114 %     {(Arthur Ogawa) Add missing \cs{expandafter}}
1115 %    \begin{macrocode}
1116 \def\Gin@setfile#1#2#3{%
1117   \ifx\\#2\\\Gread@false\fi
1118   \ifGin@bbox\else
1119     \ifGread@
1120       \csname Gread@%
1121          \expandafter\ifx\csname Gread@#1\endcsname\relax
1122            eps%
1123          \else
1124            #1%
1125          \fi
1126       \endcsname{\Gin@base#2}%
1127     \else
1128 %    \end{macrocode}
1129 % \changes{v0.5a}{1994/07/20}
1130 %     {New error trap for missing size arguments}
1131 % \changes{v0.7f}{1995/11/10}
1132 %     {Use \cs{Gin@nosize}}
1133 % By now the natural size should be known either from arguments or
1134 % from the file. If not generate an error. (The \textsf{graphicx}
1135 % interface relaxes this condition slightly.)
1136 %    \begin{macrocode}
1137       \Gin@nosize{#3}%
1138     \fi
1139   \fi
1140 %    \end{macrocode}
1141 % \changes{v0.7a}{1995/04/11}{\cs{Gin@viewport@code} added.}
1142 % The following call will modify the `natural size' if the user has
1143 % supplied a viewport or trim specification. (Not available in the
1144 % standard interface.)
1145 %    \begin{macrocode}
1146   \Gin@viewport@code
1147 %    \end{macrocode}
1148 % Save the natural size, and then call |\Gin@req@sizes| which (in the
1149 % key-val interface) will calculate the required size from the natural
1150 % size, and any scaling info.
1151 %    \begin{macrocode}
1152   \Gin@nat@height\Gin@ury bp%
1153   \advance\Gin@nat@height-\Gin@lly bp%
1154   \Gin@nat@width\Gin@urx bp%
1155   \advance\Gin@nat@width-\Gin@llx bp%
1156   \Gin@req@sizes
1157 %    \end{macrocode}
1159 % Call |\Ginclude@|\emph{type} to include the figure unless
1160 % this is not defined, or draft mode is being used.
1161 % \changes{v0.7h}{1996/02/20}
1162 %      {missing \texttt{@} added in \texttt{Gread@} csnames}
1163 %    \begin{macrocode}
1164   \expandafter\ifx\csname Ginclude@#1\endcsname\relax
1165     \Gin@drafttrue
1166     \expandafter\ifx\csname Gread@#1\endcsname\relax
1167       \@latex@error{Can not include graphics of type: #1}\@ehc
1168       \global\expandafter\let\csname Gread@#1\endcsname\@empty
1169     \fi
1170   \fi
1171   \leavevmode
1172   \ifGin@draft
1173       \hb@xt@\Gin@req@width{%
1174         \vrule\hss
1175         \vbox to \Gin@req@height{%
1176            \hrule \@width \Gin@req@width
1177            \vss
1178            \edef\@tempa{#3}%
1179            \rlap{ \ttfamily\expandafter\strip@prefix\meaning\@tempa}%
1180            \vss
1181            \hrule}%
1182         \hss\vrule}%
1183   \else
1184 %    \end{macrocode}
1185 % \changes{v0.3i}{1994/3/23}
1186 %     {Add file list info}
1187 % Support |\listfiles| and then set the final box to the required size.
1188 %    \begin{macrocode}
1189     \@addtofilelist{#3}%
1190     \ProvidesFile{#3}[Graphic file (type #1)]%
1191     \setbox\z@\hbox{\csname Ginclude@#1\endcsname{#3}}%
1192     \dp\z@\z@
1193     \ht\z@\Gin@req@height
1194     \wd\z@\Gin@req@width
1195   \box\z@
1196   \fi}
1197 %    \end{macrocode}
1198 % \end{macro}
1200 % \begin{macro}{\Gin@decode}
1201 % \changes{v1.2c}{2017/06/25}
1202 %     {New macro}
1203 % In the standard interface this is a no-op, but needs to be defined
1204 % to allow the caching code to be set up.
1205 %    \begin{macrocode}
1206 \let\Gin@decode\@empty
1207 %    \end{macrocode}
1208 % \end{macro}
1210 %  \begin{macro}{\Gin@exclamation}
1211 % \changes{v0.7g}{1995/12/06}{Macro added}
1212 % Catcode 12 |!|, in case of French, or other language styles.
1213 %    \begin{macrocode}
1214 \def\Gin@exclamation{!}
1215 %    \end{macrocode}
1216 %  \end{macro}
1218 % \begin{macro}{\Gin@page}
1219 % \changes{v1.2a}{2017/06/01}
1220 %     {New macro}
1221 % In the standard interface this is a no-op, but needs to be defined
1222 % to allow the caching code to be set up.
1223 %    \begin{macrocode}
1224 \let\Gin@page\@empty
1225 %    \end{macrocode}
1226 % \end{macro}
1228 % \begin{macro}{\Gin@pagebox}
1229 % \changes{v1.2a}{2017/06/01}
1230 %     {New macro}
1231 % In the standard interface always points to the |cropbox|.
1232 %    \begin{macrocode}
1233 \def\Gin@pagebox{cropbox}
1234 %    \end{macrocode}
1235 % \end{macro}
1237 % \begin{macro}{\ifGin@interpolate}
1238 % \changes{v1.2a}{2017/06/01}
1239 %     {New macro}
1240 %  In the standard setting a no-op.
1241 %    \begin{macrocode}
1242 \newif\ifGin@interpolate
1243 %    \end{macrocode}
1244 % \end{macro}
1246 % \begin{macro}{\Gin@log}
1247 %   \changes{v1.2a}{2017/06/01} {New macro} In the standard interface
1248 %   this prints to the log but can be changed via keys in \textsf{graphicx}.
1249 %    \begin{macrocode}
1250 \let\Gin@log\wlog
1251 %    \end{macrocode}
1252 % \end{macro}
1255 %  \begin{macro}{\Gin@req@sizes}
1256 %  \begin{macro}{\Gin@scalex}
1257 %  \begin{macro}{\Gin@scaley}
1258 %  \begin{macro}{\Gin@req@height}
1259 %  \begin{macro}{\Gin@req@width}
1260 % In the standard interface there is no scaling, so the required size
1261 % is the same as the natural size. In other interfaces |\Gin@req@sizes|
1262 % will be responsible for setting these parameters. Here we can set them
1263 % globally.
1264 % \changes{v0.3g}{1994/03/15}
1265 %     {Initialise y-scale to !!}
1266 % \changes{v1.0g}{1998/05/14}
1267 %     {Fix !! usage in changes entries. graphics/2724}
1268 %    \begin{macrocode}
1269 \let\Gin@req@sizes\relax
1270 \def\Gin@scalex{1}%
1271 \let\Gin@scaley\Gin@exclamation
1272 \let\Gin@req@height\Gin@nat@height
1273 \let\Gin@req@width\Gin@nat@width
1274 %    \end{macrocode}
1275 %  \end{macro}
1276 %  \end{macro}
1277 %  \end{macro}
1278 %  \end{macro}
1279 %  \end{macro}
1281 %  \begin{macro}{\Gin@viewport@code}
1282 % In the standard interface there is no possibility of specifying
1283 % a viewport, so this is a no-op.
1284 % \changes{v0.7a}{1995/04/11}{Macro added}
1285 %    \begin{macrocode}
1286 \let\Gin@viewport@code\relax
1287 %    \end{macrocode}
1288 %  \end{macro}
1290 %  \begin{macro}{\Gin@nosize}
1291 % \changes{v1.0p}{2014/10/14}{Fixed typo in error message}
1292 % \changes{v0.7f}{1995/11/10}
1293 %     {Macro added}
1294 % This command is called in the case that the graphics type
1295 % specifies no `read file' and the user supplied no size arguments.
1296 % In the standard interface can only generate an error.
1297 %    \begin{macrocode}
1298 \def\Gin@nosize#1{%
1299   \@latex@error
1300       {Cannot determine size of graphic in #1 (no size specified)}%
1301       \@ehc}
1302 %    \end{macrocode}
1303 %  \end{macro}
1305 % \subsection{Reading the BoundingBox in EPS files}
1307 % \begin{macro}{\ifGin@bbox}
1308 % \changes{v0.7a}{1995/04/11}{Name changed from \cs{ifGin@viewport}}
1309 % This switch should be set \meta{true} once a size has been found,
1310 % either in an argument, or in an external file.
1311 %    \begin{macrocode}
1312 \newif\ifGin@bbox
1313 %    \end{macrocode}
1314 %  \end{macro}
1316 % \begin{macro}{\Gread@generic}
1317 % \changes{v1.2a}{2017/06/01}
1318 %     {New macro}
1319 % \begin{macro}{\Gread@generic@aux}
1320 % \begin{macro}{\Gread@eps}
1321 % Read an EPS file (|#1|) and search for a line
1322 % starting with |%%BoundingBox| and returns the result
1323 % by setting four dimension registers
1324 % |\Gin@llx|, |\Gin@lly|, |\Gin@urx| and |\Gin@ury|.
1325 % \changes{v0.5e}{1994/1l/02}
1326 %     {Fix the catcodes of \cs{endlinechar} and ctrl-D}
1327 % \changes{v0.7a}{1995/04/11}
1328 %     {Fix more catcodes, for binary headers of eps files}
1329 % \changes{v1.2a}{2017/06/01}
1330 %     {Split to allow code reuse by \cs{Gread@extractbb} in
1331 %     \texttt{dvipdfmx.def} driver}
1332 % \begin{macro}{\Gread@eps@aux}
1333 %    \begin{macrocode}
1334 \def\Gread@generic#1#2{%
1335   \edef\Gread@attr@hash{%
1336     \ifx\Gin@pagebox\@empty\else
1337       :\Gin@pagebox
1338     \fi
1339     \ifx\Gin@page\@empty\else
1340       :P\Gin@page
1341     \fi
1342   }%
1343   \@ifundefined{#1 bbox\Gread@attr@hash}%
1344     {\Gread@generic@aux{#1}{#2}}
1345     {%
1346       \expandafter\global\expandafter\let\expandafter\@gtempa
1347         \csname #1 bbox\Gread@attr@hash\endcsname
1348     }%
1349   \expandafter\Gread@parse@bb\@gtempa\\%
1351 \def\Gread@generic@aux#1#2{%
1352   \begingroup
1353 %    \end{macrocode}
1354 % Make it reasonably safe to have binary headers in the EPS file
1355 % before the bounding box line.
1356 %    \begin{macrocode}
1357   \@tempcnta\z@
1358   \loop\ifnum\@tempcnta<\@xxxii
1359      \catcode\@tempcnta14 %
1360      \advance\@tempcnta\@ne
1361   \repeat
1362   \catcode`\^^?14 %
1363   \let\do\@makeother
1364   \dospecials
1365 %    \end{macrocode}
1366 % Make sure tab and space are accepted as white space.
1367 % \changes{v1.0e}{1997/09/02}
1368 %     {Allow TAB in DSC comments graphics/2587}
1369 % \changes{v1.0i}{1999/01/07}
1370 %     {Fix catcode of hyphen. graphics/2846}
1371 %    \begin{macrocode}
1372   \catcode`\ 10 %
1373   \catcode`\^^I10 %
1374   \catcode\endlinechar5 %
1375   \@makeother\:%
1376   \@makeother\-%
1377 %    \end{macrocode}
1378 % The first thing we need to do is to open the
1379 % information file, if possible.
1380 % \changes{v0.4d}{1994/05/06}
1381 %     {Improve the error message if the info file is not there.}
1382 % \changes{v1.2a}{2017/06/01}
1383 %     {Allow for spaces in name of a file}
1384 %    \begin{macrocode}
1385   \immediate\openin\@inputcheck"#1" %
1386   #2{#1}%
1387 %    \end{macrocode}
1388 % \changes{v0.3i}{1994/03/23}
1389 %     {Wording of error message improved}
1390 % \changes{v1.0}{1996/05/29}
1391 %     {Use \cs{@gtempa} not \cs{g@tempa} /2090}
1392 % \changes{v1.2b}{2017/06/13}
1393 %     {Stored bounding box data for reuse}
1394 %    \begin{macrocode}
1395   \ifGin@bbox
1396     \expandafter\xdef\csname #1 bbox\Gread@attr@hash\endcsname{\@gtempa}%
1397   \else
1398     \@latex@error
1399       {Cannot determine size of graphic in #1 (no BoundingBox)}%
1400       \@ehc
1401     \gdef\@gtempa{0 0 72 72 }%
1402   \fi
1403   \endgroup
1405 \def\Gread@eps#1{%
1406   \Gread@generic{#1}\Gread@eps@aux
1408 \def\Gread@eps@aux#1{%
1409   \ifeof\@inputcheck
1410     \@latex@error{File `#1' not found}\@ehc
1411   \else
1412 %    \end{macrocode}
1413 % Now we'll scan lines until we find one that starts with
1414 % |%%BoundingBox:|
1415 % We need to reset the catcodes to read the file, and so this
1416 % is done in a group.
1417 %    \begin{macrocode}
1418      \Gread@true
1419      \let\@tempb\Gread@false
1420      \loop
1421        \read\@inputcheck to\@tempa
1422        \ifeof\@inputcheck
1423          \Gread@false
1424        \else
1425          \expandafter\Gread@find@bb\@tempa:.\\%
1426        \fi
1427      \ifGread@
1428      \repeat
1429     \immediate\closein\@inputcheck
1430   \fi
1432 %    \end{macrocode}
1433 % \end{macro}
1434 % \end{macro}
1435 % \end{macro}
1436 % \end{macro}
1438 % \begin{macro}{\Gread@find@bb}
1439 % If a line in the EPS file starts with a |%%BoundingBox:|, we
1440 % will examine it more closely. Note using the `extra' argument |#2#3|
1441 % causes any space after the |:| to be gobbled.
1442 %    \begin{macrocode}
1443 \long\def\Gread@find@bb#1:#2#3\\{%
1444   \def\@tempa{#1}%
1445   \ifx\@tempa\Gread@BBox
1446     \Gread@test@atend#2#3()\\%
1447   \fi}
1448 %    \end{macrocode}
1449 % \end{macro}
1450 % \begin{macro}{\Gread@test@atend}
1451 % Determine if the stuff following the |%%BoundingBox| is `(atend)',
1452 % which will involve further reading of the file. This is accomplished
1453 % by making |\@tempb| into a no-op, so that finding a |%%BoundingBox|
1454 % does not stop the loop.
1455 %    \begin{macrocode}
1456 \def\Gread@test@atend#1(#2)#3\\{%
1457   \def\@tempa{#2}%
1458   \ifx\@tempa\Gread@atend
1459     \Gread@true
1460     \let\@tempb\relax
1461   \else
1462     \gdef\@gtempa{#1}%
1463     \@tempb
1464     \Gin@bboxtrue
1465   \fi}
1466 %    \end{macrocode}
1467 % \end{macro}
1468 % \begin{macro}{\Gread@parse@bb}
1469 % We have |%%BoundingBox| and what follows is not `(atend)' so we
1470 % will parse the rest of the line as a BB with four elements.
1471 % PostScript files should never have units specified in the
1472 % BoundingBox comment, but we allow arbitrary \TeX\ units in external
1473 % files, or in other interfaces.
1474 %    \begin{macrocode}
1475 \def\Gread@parse@bb#1 #2 #3 #4 #5\\{%
1476   \Gin@defaultbp\Gin@llx{#1}%
1477   \Gin@defaultbp\Gin@lly{#2}%
1478   \Gin@defaultbp\Gin@urx{#3}%
1479   \Gin@defaultbp\Gin@ury{#4}}%
1480 %    \end{macrocode}
1481 % \end{macro}
1483 % \begin{macro}{\Gread@atend}
1484 % |atend| as a macro for testing with |\ifx|.
1485 %    \begin{macrocode}
1486 \def\Gread@atend{atend}
1487 %    \end{macrocode}
1488 % \end{macro}
1491 % \subsection{Rotation}
1493 % As above, we will re-use some existing local registers.
1495 % \begin{macro}{\Grot@height}
1496 % \begin{macro}{\Grot@left}
1497 % \begin{macro}{\Grot@right}
1498 % \begin{macro}{\Grot@depth}
1499 % Final Rotated box dimensions
1500 %    \begin{macrocode}
1501 \let\Grot@height\@ovxx
1502 \let\Grot@left\@ovyy
1503 \let\Grot@right\@ovdx
1504 \let\Grot@depth\@ovdy
1505 %    \end{macrocode}
1506 % \end{macro}
1507 % \end{macro}
1508 % \end{macro}
1509 % \end{macro}
1511 % \begin{macro}{\Grot@h}
1512 % \begin{macro}{\Grot@l}
1513 % \begin{macro}{\Grot@r}
1514 % \begin{macro}{\Grot@d}
1515 % Original box dimensions
1516 %    \begin{macrocode}
1517 \let\Grot@l\@ovro
1518 \let\Grot@r\@ovri
1519 \let\Grot@h\@xdim
1520 \let\Grot@d\@ydim
1521 %    \end{macrocode}
1522 % \end{macro}
1523 % \end{macro}
1524 % \end{macro}
1525 % \end{macro}
1527 % \begin{macro}{\Grot@x}
1528 % \begin{macro}{\Grot@y}
1529 % Coordinates of centre of rotation.
1530 %    \begin{macrocode}
1531 \let\Grot@x\@linelen
1532 \let\Grot@y\@dashdim
1533 %    \end{macrocode}
1534 % \end{macro}
1535 % \end{macro}
1537 % \begin{macro}{\rotatebox}
1538 % The angle is specified by |#1|. The box to be rotated is |#2|.
1539 % In the standard interface the centre of rotation is $(0,0)$.
1540 % Then finally call |\Grot@box| to rotate the box.
1541 % \changes{v0.3f}{1994/03/11}{Remove star form}
1542 % \changes{v0.3h}{1994/03/17}{Fix Typo}
1543 % \changes{v0.7a}{1995/04/11}{\cs{leavevmode} added graphics/1521}
1544 % \changes{v1.0n}{2001/07/07}
1545 %     {Made long (CAR) graphics/2908 and 3345}
1546 %    \begin{macrocode}
1547 \long\def\rotatebox#1#2{%
1548   \leavevmode
1549   \Grot@setangle{#1}%
1550   \setbox\z@\hbox{{#2}}%
1551   \Grot@x\z@
1552   \Grot@y\z@
1553   \Grot@box}
1554 %    \end{macrocode}
1555 % \end{macro}
1558 % \begin{macro}{\Grot@setangle}
1559 % Set the internal macro used by |\Grot@box|. In the standard
1560 % interface this is trivial, but other interfaces may have more
1561 % interesting definitions. For example:
1562 %\begin{verbatim}
1563 % \def\Grot@setangle#1{%
1564 %   \dimen@#1\p@
1565 %   \dimen@-57.2968\dimen@
1566 %   \edef\Grot@angle{\strip@pt\dimen@}}
1567 %\end{verbatim}
1568 % This would cause the argument of |\rotatebox| to be interpreted as
1569 % an angle specified in \emph{radians}, \emph{clockwise}.
1570 %    \begin{macrocode}
1571 \def\Grot@setangle#1{\edef\Grot@angle{#1}}
1572 %    \end{macrocode}
1573 % \end{macro}
1575 % \subsection{Deriving a `bounding box' for rotated object}
1576 % We want to know the size of a `bounding box' enclosing the rotated
1577 % box.
1578 % We define two formulae (as \TeX\ macros) to work out the $x$ and $y$
1579 % coordinates of vertices of the rotated box
1580 % in relation to its original coordinates (i.e., its width, height
1581 % and depth). The box we visualize with vertices $B$, $C$,
1582 % $D$ and $E$ is illustrated below. The vertex
1583 % $S$ is the reference point on the baseline. $O$ is the centre of
1584 % rotation, which in the standard interface is always $S$.
1586 % \begin{center}
1587 % \setlength{\unitlength}{3pt}%
1589 % \begin{picture}(34,36)(12,44)
1590 % \thicklines
1591 % \put(20,52){\dashbox{1}(20,21){}}
1592 % \put(20,80){\line(0,-1){36}}
1593 % \put(12,58){\line(1, 0){34}}
1594 % \put(41,59){A}
1595 % \put(40,74){B}
1596 % \put(21,74){C}
1597 % \put(21,49){D}
1598 % \put(40,49){E}
1599 % \put(21,59){S}
1600 % \put(33,65){O}
1601 % \put(33,65){\circle*{1}}
1602 % \end{picture}
1603 % \end{center}
1605 % The formulae are, for a point $P$ and angle $\alpha$:
1607 % \begin{array}{l}
1608 % P'_x = P_x - O_x \\
1609 % P'_y = P_y - O_y \\
1610 % P''_x =  ( P'_x \times \cos(\alpha)) - ( P'_y \times \sin(\alpha) ) \\
1611 % P''_y =  ( P'_x \times \sin(\alpha)) + ( P'_y \times \cos(\alpha) ) \\
1612 % P'''_x = P''_x + O_x + L_x \\
1613 % P'''_y = P''_y + O_y
1614 % \end{array}
1615 % \]
1616 % The `extra' horizontal translation $L_x$ at the end is calculated so
1617 % that the leftmost point of the resulting box has $x$-coordinate $0$.
1618 % This is desirable as \TeX\ boxes must have the reference point at
1619 % the left edge of the box.
1621 % \begin{macro}{\Grot@Px}
1622 % Work out new $x$ coordinate of point after rotation. The parameters
1623 % |#2| and |#3| are the original $x$ and $y$ coordinates of the point.
1624 % The new $x$ coordinate is stored in |#1|.
1625 %    \begin{macrocode}
1626 \def\Grot@Px#1#2#3{%
1627         #1\Grot@cos#2%
1628         \advance#1-\Grot@sin#3}
1629 %    \end{macrocode}
1630 % \end{macro}
1631 % \begin{macro}{\Grot@Py}
1632 % Work out new $y$ coordinate of point after rotation. The parameters
1633 % |#2| and |#3| are the original $x$ and $y$ coordinates of the point.
1634 % The new $y$ coordinate is stored in |#1|.
1635 %    \begin{macrocode}
1636 \def\Grot@Py#1#2#3{%
1637         #1\Grot@sin#2%
1638         \advance#1\Grot@cos#3}
1639 %    \end{macrocode}
1640 % \end{macro}
1642 % \begin{macro}{\Grot@box}
1643 % This is the tricky bit. We can rotate the box, but then need
1644 % to work out how much space to leave for it on the page.
1646 % We simplify matters by working out first which quadrant we are in, and
1647 % then picking just the right values.
1649 %    \begin{macrocode}
1650 \def\Grot@box{%
1651   \begingroup
1652 %    \end{macrocode}
1653 % We are going to need to know the sine and cosine
1654 % of  the angle; simplest to calculate these now.
1655 %    \begin{macrocode}
1656   \CalculateSin\Grot@angle
1657   \CalculateCos\Grot@angle
1658   \edef\Grot@sin{\UseSin\Grot@angle}%
1659   \edef\Grot@cos{\UseCos\Grot@angle}%
1660 ^^A   \GDebug{Rotate: angle \Grot@angle, sine is \Grot@sin,
1661 ^^A             cosine is \Grot@cos}%
1662 %    \end{macrocode}
1663 % Save the four extents of the original box.
1664 %    \begin{macrocode}
1665   \Grot@r\wd\z@  \advance\Grot@r-\Grot@x
1666   \Grot@l\z@     \advance\Grot@l-\Grot@x
1667   \Grot@h\ht\z@  \advance\Grot@h-\Grot@y
1668   \Grot@d-\dp\z@ \advance\Grot@d-\Grot@y
1669 %    \end{macrocode}
1670 % Now a straightforward test to see which quadrant we are
1671 % operating in;
1672 %    \begin{macrocode}
1673   \ifdim\Grot@sin\p@>\z@
1674     \ifdim\Grot@cos\p@>\z@
1675 %    \end{macrocode}
1676 % First quadrant:
1677 % Height=$By$, Right=$Ex$, Left=$Cx$, Depth=$Dy$
1678 %    \begin{macrocode}
1679       \Grot@Py\Grot@height \Grot@r\Grot@h%B
1680       \Grot@Px\Grot@right  \Grot@r\Grot@d%E
1681       \Grot@Px\Grot@left   \Grot@l\Grot@h%C
1682       \Grot@Py\Grot@depth  \Grot@l\Grot@d%D
1683     \else
1684 %    \end{macrocode}
1685 % Second quadrant:
1686 % Height=$Ey$, Right=$Dx$, Left=$Bx$, Depth=$Cy$
1687 %    \begin{macrocode}
1688       \Grot@Py\Grot@height \Grot@r\Grot@d%E
1689       \Grot@Px\Grot@right  \Grot@l\Grot@d%D
1690       \Grot@Px\Grot@left   \Grot@r\Grot@h%B
1691       \Grot@Py\Grot@depth  \Grot@l\Grot@h%C
1692     \fi
1693   \else
1694     \ifdim\Grot@cos\p@<\z@
1695 %    \end{macrocode}
1696 % Third quadrant:
1697 % Height=$Dy$, Right=$Cx$, Left=$Ex$, Depth=$By$
1698 %    \begin{macrocode}
1699       \Grot@Py\Grot@height \Grot@l\Grot@d%D
1700       \Grot@Px\Grot@right  \Grot@l\Grot@h%C
1701       \Grot@Px\Grot@left   \Grot@r\Grot@d%E
1702       \Grot@Py\Grot@depth  \Grot@r\Grot@h%B
1703     \else
1704 %    \end{macrocode}
1705 % Fourth quadrant:
1706 % Height=$Cy$, Right=$Bx$, Left=$Dx$, Depth=$Ey$
1707 %    \begin{macrocode}
1708       \Grot@Py\Grot@height \Grot@l\Grot@h%C
1709       \Grot@Px\Grot@right  \Grot@r\Grot@h%B
1710       \Grot@Px\Grot@left   \Grot@l\Grot@d%D
1711       \Grot@Py\Grot@depth  \Grot@r\Grot@d%E
1712     \fi
1713   \fi
1714 %    \end{macrocode}
1715 % Now we should translate back by $(O_x,O_y)$, but \TeX\ can not really
1716 % deal with boxes that do not have the reference point at the left edge.
1717 % (Everything with a $-$ve $x$-coordinate would over-print earlier
1718 % text). So we modify the horizontal translation so that the
1719 % reference point as understood by \TeX\ \emph{is} at the left edge.
1720 % This means that the `centre of rotation' is not fixed by |\rotatebox|,
1721 % but typically moves horizontally. We also need to find the image of
1722 % the original reference point, $S$, as that is where the rotation
1723 % specials must be inserted.
1725 %    \begin{macrocode}
1726   \advance\Grot@height\Grot@y
1727   \advance\Grot@depth\Grot@y
1728   \Grot@Px\dimen@  \Grot@x\Grot@y
1729   \Grot@Py\dimen@ii \Grot@x\Grot@y
1730   \dimen@-\dimen@     \advance\dimen@-\Grot@left
1731   \dimen@ii-\dimen@ii \advance\dimen@ii\Grot@y
1732 %    \end{macrocode}
1734 %    \begin{macrocode}
1735 ^^A   \GDebug{Rotate: (l,r,h,d)^^J%
1736 ^^A Original \the\Grot@l,\the\Grot@r,\the\Grot@h,\the\Grot@d,^^J%
1737 ^^A New..... \the\Grot@left,\the\Grot@right,%
1738 ^^A          \the\Grot@height,\the\Grot@depth}%
1739 %    \end{macrocode}
1741 %    \begin{macrocode}
1742   \setbox\z@\hbox{%
1743     \kern\dimen@
1744     \raise\dimen@ii\hbox{\Grot@start\box\z@\Grot@end}}%
1745   \ht\z@\Grot@height
1746   \dp\z@-\Grot@depth
1747   \advance\Grot@right-\Grot@left\wd\z@\Grot@right
1748   \leavevmode\box\z@
1749   \endgroup}
1750 %    \end{macrocode}
1751 % \end{macro}
1754 % \subsection{Stretching and Scaling}
1757 %  \begin{macro}{\scalebox}
1758 % The top level |\scalebox|. If the vertical scale factor is omitted it
1759 % defaults to the horizontal scale factor, |#1|.
1760 % \changes{v0.3d}{1994/03/06}{Better support for negative arguments.}
1761 %    \begin{macrocode}
1762 \def\scalebox#1{%
1763   \@ifnextchar[{\Gscale@box{#1}}{\Gscale@box{#1}[#1]}}
1764 %    \end{macrocode}
1765 %  \end{macro}
1767 %  \begin{macro}{\Gscale@box}
1768 % Internal version of |\scalebox|.
1769 % \changes{v0.7a}{1995/04/11}
1770 %     {\cs{leavevmode} moved earlier. graphics/1521}
1771 % \changes{v1.0j}{1999/01/07}
1772 %     {made long. graphics/2908}
1773 % \changes{v1.1b}{2017/04/14}
1774 %     {Adjust box resizing for math mode gh issue 6}
1775 %    \begin{macrocode}
1776 \long\def\Gscale@box#1[#2]#3{%
1777   \leavevmode
1778   \def\Gscale@x{#1}\def\Gscale@y{#2}%
1779   \setbox\z@\hbox{{#3}}%
1780   \setbox\tw@\hbox{\Gscale@start\rlap{\copy\z@}\Gscale@end}%
1781   \ifdim#2\p@<\z@
1782     \ht\tw@-#2\dp\z@
1783     \dp\tw@-#2\ht\z@
1784   \else
1785     \ht\tw@#2\ht\z@
1786     \dp\tw@#2\dp\z@
1787   \fi
1788   \ifdim#1\p@<\z@
1789     \hb@xt@-#1\wd\z@{\kern-#1\wd\z@\box\tw@\hss}%
1790   \else
1791     \hb@xt@#1\wd\z@{\box\tw@\kern#1\wd\z@\hss}%
1792   \fi}
1793 %    \end{macrocode}
1794 %  \end{macro}
1797 %  \begin{macro}{\reflectbox}
1798 % Just an abbreviation for the appropriate scale to get reflection.
1799 % \changes{v0.3e}{1994/03/09}{Macro added}
1800 %    \begin{macrocode}
1801 \def\reflectbox{\Gscale@box-1[1]}
1802 %    \end{macrocode}
1803 %  \end{macro}
1806 %  \begin{macro}{\resizebox}
1807 % \changes{v0.3b}{1994/03/01}{Recode \cmd\resizebox.}
1808 % \changes{v0.7b}{1995/04/27}
1809 %         {Add \cs{leavevmode} for graphics/1512}
1810 % Look for a |*|, which specifies that a final vertical size refers to
1811 % `height + depth' not just `height'.
1812 %    \begin{macrocode}
1813 \def\resizebox{%
1814   \leavevmode
1815   \@ifstar{\Gscale@@box\totalheight}{\Gscale@@box\height}}
1816 %    \end{macrocode}
1817 %  \end{macro}
1819 %  \begin{macro}{\Gscale@@box}
1820 % Look for the |!| in the arguments.
1821 % \changes{v0.5a}{1994/07/20}
1822 %     {Support French active !!}
1823 % \changes{v0.5d}{1994/10/24}
1824 %     {Correct the support for !!}
1825 % \changes{v0.7g}
1826 %     {1995/12/06}{Use \cs{Gin@exclamation}}
1827 %    \begin{macrocode}
1828 \def\Gscale@@box#1#2#3{%
1829   \let\@tempa\Gin@exclamation
1830   \expandafter\def\expandafter\@tempb\expandafter{\string#2}%
1831   \expandafter\def\expandafter\@tempc\expandafter{\string#3}%
1832   \ifx\@tempb\@tempa
1833     \ifx\@tempc\@tempa
1834       \toks@{\mbox}%
1835     \else
1836       \toks@{\Gscale@box@dd{#3}#1}%
1837     \fi
1838   \else
1839     \ifx\@tempc\@tempa
1840       \toks@{\Gscale@box@dd{#2}\width}%
1841     \else
1842       \toks@{\Gscale@box@dddd{#2}\width{#3}#1}%
1843     \fi
1844   \fi
1845   \the\toks@}
1846 %    \end{macrocode}
1847 %  \end{macro}
1849 %  \begin{macro}{\Gscale@box@dd}
1850 % Scale the text |#3| in both directions by a factor $|#1|/|#2|$.
1851 % \changes{v0.3i}{1994/03/23}
1852 %     {Missing percent added}
1853 % \changes{v1.0i}{1999/01/07}
1854 %     {made long. graphics/2908}
1855 %    \begin{macrocode}
1856 \long\def\Gscale@box@dd#1#2#3{%
1857   \@begin@tempboxa\hbox{#3}%
1858     \setlength\@tempdima{#1}%
1859     \setlength\@tempdimb{#2}%
1860     \Gscale@div\@tempa\@tempdima\@tempdimb
1861     \Gscale@box\@tempa[\@tempa]{\box\@tempboxa}%
1862   \@end@tempboxa}
1863 %    \end{macrocode}
1864 %  \end{macro}
1866 %  \begin{macro}{\Gscale@box@dddd}
1867 % Scale the text |#5| horizontally by a factor $|#1|/|#2|$ and
1868 % vertically by a factor $|#3|/|#4|$.
1869 % \changes{v0.3i}{1994/03/23}
1870 %     {Missing percent added}
1871 % \changes{v0.7e}{1995/09/29}
1872 %     {Add \cs{ifGin@iso} code added}
1873 % \changes{v1.0i}{1999/01/07}
1874 %     {made long. graphics/2908}
1875 %    \begin{macrocode}
1876 \long\def\Gscale@box@dddd#1#2#3#4#5{%
1877   \@begin@tempboxa\hbox{#5}%
1878     \setlength\@tempdima{#1}%
1879     \setlength\@tempdimb{#2}%
1880     \Gscale@div\@tempa\@tempdima\@tempdimb
1881     \setlength\@tempdima{#3}%
1882     \setlength\@tempdimb{#4}%
1883     \Gscale@div\@tempb\@tempdima\@tempdimb
1884     \ifGin@iso
1885       \ifdim\@tempa\p@>\@tempb\p@
1886         \let\@tempa\@tempb
1887       \else
1888         \let\@tempb\@tempa
1889       \fi
1890     \fi
1891     \Gscale@box\@tempa[\@tempb]{\box\@tempboxa}%
1892   \@end@tempboxa}
1893 %    \end{macrocode}
1894 %  \end{macro}
1896 % \begin{macro}{\ifGin@iso}
1897 % If this flag is true, then specifying two lengths to |\resizebox|
1898 % scales the box by the same factor in either direction, such that
1899 % neither length \emph{exceeds} the stated amount. No user interface
1900 % to this flag in the standard package, but it is used by the
1901 % |keepaspectratio| key to |\includegraphics| in the \textsf{graphicx}
1902 % package.
1903 % \changes{v0.7e}{1995/09/29}
1904 %     {Macro added}
1905 %    \begin{macrocode}
1906 \newif\ifGin@iso
1907 %    \end{macrocode}
1908 %  \end{macro}
1910 %  \begin{macro}{\Gscale@div}
1911 % The macro |#1| is set to the ratio of the lengths |#2| and |#3|.
1912 % \changes{v0.7a}{1995/04/11}
1913 %     {Add trap for division by 0}
1914 % \changes{v0.7d}{1995/09/27}
1915 %     {Use \cs{setlength} to support calc package}
1916 % \changes{v1.0a}{1996/09/16}
1917 %     {Stop infinite loop if 2nd arg zero. graphics/2259}
1918 %    \begin{macrocode}
1919 \def\Gscale@div#1#2#3{%
1920   \setlength\dimen@{#3}%
1921   \ifdim\dimen@=\z@
1922     \PackageError{graphics}{Division by 0}\@eha
1923     \dimen@#2%
1924   \fi
1925   \edef\@tempd{\the\dimen@}%
1926   \setlength\dimen@{#2}%
1927   \count@65536\relax
1928   \ifdim\dimen@<\z@
1929     \dimen@-\dimen@
1930     \count@-\count@
1931   \fi
1932   \ifdim\dimen@>\z@
1933     \loop
1934 %    \end{macrocode}
1936 % \changes{v1.0u}{2016/10/09}
1937 %     {avoid overflow for small lengths eg 5sp divided by 2sp}
1938 %    \begin{macrocode}
1939       \ifdim\ifnum\count@<\tw@\maxdimen\else\dimen@\fi<8192\p@
1940         \dimen@\tw@\dimen@
1941         \divide\count@\tw@
1942     \repeat
1943     \dimen@ii\@tempd\relax
1944     \divide\dimen@ii\count@
1945     \divide\dimen@\dimen@ii
1946   \fi
1947   \edef#1{\strip@pt\dimen@}}
1948 %    \end{macrocode}
1949 %  \end{macro}
1951 % Restore Catcodes
1952 %    \begin{macrocode}
1953 \Gin@codes
1954 \let\Gin@codes\relax
1955 %    \end{macrocode}
1957 %    \begin{macrocode}
1958 %</package>
1959 %    \end{macrocode}
1961 % \Finale