4 %% graphics.dtx Copyright (C) 1994 David Carlisle Sebastian Rahtz
5 %% Copyright (C) 1995--2015 David Carlisle, LaTeX3 Project
7 %% This file is part of the Standard LaTeX `Graphics Bundle'.
8 %% It may be distributed under the terms of the LaTeX Project Public
9 %% License, as described in lppl.txt in the base LaTeX distribution.
10 %% Either version 1.3c or, at your option, any later version.
12 %% This file has the LPPL maintenance status "maintained".
15 \ProvidesFile{graphics.dtx}
17 %<package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
18 %<package>\ProvidesPackage{graphics}
19 %<driver> \ProvidesFile{graphics.drv}
21 % \ProvidesFile{graphics.dtx}
22 [2014/10/28 v1.0p Standard LaTeX Graphics (DPC,SPQR)]
26 \documentclass{ltxdoc}
27 \newenvironment{option}[1]{\expandafter\macro\expandafter{%
28 \csname ds@#1\endcsname}}{\endmacro}
30 \DocInput{graphics.dtx}
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}
42 % \MaintainedByLaTeXTeam{graphics}
47 % \changes{v0.3a}{1994/02/24}
48 % {First DPC version (after prototype by SPQR).}
49 % \changes{v0.4e}{1994/05/30}
50 % {Rename egraphics to graphicx}
51 % \changes{v1.0}{1996/05/29}
55 % \def\star{{\ttfamily*}}
57 % \def\Describe@Macro#1{\endgroup
58 % \setbox0=\lastbox\llap{\PrintDescribeMacro{#1}}}%
62 % \section{Introduction}
64 % This package implements various `graphics' functions. The main
65 % features are a) inclusion of `graphics' files. b) Rotation of sections
66 % of the page, c) Scaling of sections of the page.
68 % The design is split into three `levels'.
70 % \item The user interface. This is the collection of commands designed
71 % to appear in a document text. Actually two separate user interface
72 % have been implemented. The `standard' interface, described here, and a
73 % more powerful, and more `user-friendly' interface provided by the
75 % \item The core functions. These functions, which are also implemented
76 % in this file do all the `main work'. The `user-interface functions
77 % just collect together the information from any optional-arguments or
78 % star-forms, and then call one of these functions.
79 % \item The driver files. It is not possible to achieve the
80 % functionality of this package just using \TeX. The |dvi| driver used
81 % must be given additional instructions. (Using the |\special| command
82 % of \TeX.) Unfortunately, the capabilities of various drivers differ,
83 % and the syntax required to pass instructions to the drivers is also
84 % not standardised. So the `core functions' never access |\special|
85 % directly, but rather call a series of commands that must be defined in
86 % a special file customised for each driver. The accompanying file,
87 % |drivers.dtx| has suitable files for a range of popular drivers.
90 % \section{Package Options}
91 % Most of the options, such as |dvips|, |textures| etc., specify the
92 % driver that is to be used to print the document. You may wish to set
93 % up a configuration file so that this option always takes effect, even
94 % if not specified in the document. To do this, produce a file
95 % |graphics.cfg| containing the line:\\
96 % |\ExecuteOptions{dvips}|\\
97 % (or whichever other driver you wish.)
99 % Apart from the driver options there are a few other options to control
100 % the behaviour of the package.
101 % \begin{description}
103 % Do not include graphics files, but instead print a box of the size
104 % the graphic would take up, and the file name. This greatly speeds up
105 % previewing on most systems.
107 % Turns off the |draft| option.
109 % Show a lot of tracing information on the terminal. If you are not me
110 % you probably do not want to use this option.
112 % Do not show rotated text. Sometimes useful if your previewer can not
115 % Do not show scaled text.
117 % Look for Bounding Box lines of the form |%%HiResBoundingBox| instead
118 % of the standard |%%BoundingBox|. These are used by some applications
119 % to get round the restriction that BoundingBox comments should only
120 % have integer values.
121 % \item[demo] Instead of including a graphics file, make
122 % |\includegraphics| insert a black rectangle of size 150\,pt by
123 % 100\,pt unless either dimension was already specified by another
127 % \section{Standard Interface}
129 % \subsection{Graphics Inclusion}
132 % \includegraphics\star\oarg{llx,lly}\oarg{urx,ury}\marg{file}\\
133 % Include a graphics file.
135 % If \star\ is present, then the graphic is `clipped' to the size
136 % specified. If \star\ is omitted, then any part of the graphic that is
137 % outside the specified `bounding box' will over-print the surrounding
140 % If the optional arguments are omitted, then the size of the graphic
141 % will be determined by reading an external file as described below.
142 % If \oarg{urx,ury} is present, then it should specify the coordinates
143 % of the top right corner of the image, as a pair of \TeX\ dimensions.
144 % If the units are omitted they default to |bp|. So |[1in,1in]| and
145 % |[72,72]| are equivalent. If only one optional argument appears, the
146 % lower left corner of the image is assumed to be at |[0,0]|. Otherwise
147 % \oarg{llx,lly} may be used to specify the coordinates of this point.
150 % \graphicspath\marg{dir-list}\\
151 % This optional declaration may be used to specify a list of directories
152 % in which to search for graphics files. The format is as for the
153 % \LaTeXe\ primitive |\input@path|, a list of directories, each in a
154 % |{}| group (even if there is only one in the list). For example:
155 % |\graphicspath{{eps/}{tiff/}}|
156 % would cause the system to look in the subdirectories |eps| and |tiff|
157 % of the current directory. The default setting of this path is
158 % |\input@path| that is: graphics files will be found wherever \TeX\
162 % \DeclareGraphicsExtensions\marg{ext-list}\\
163 % This specifies the behaviour of the system when the argument to
164 % |\includegraphics| does not have an extension specified.
165 % Here \marg{ext-list} should be a comma-separated list of file
166 % extensions, each with a leading period (\texttt{.}).
167 % A file name is produced by appending \emph{sep} and one extension.
168 % If a file is found, the system acts as if that extension had been
169 % specified. If not, the next extension in \emph{ext-list} is tried.
170 % \changes{v1.0m}{2001/06/07}{Extended documentation (CAR) graphics/3228}
172 % Each use of |\DeclareGraphicsExtensions| overwrites all previous
173 % definitions. It is not possible to add an extension to an
176 % Early versions of this package defined a default argument for this
177 % command. This has been removed.
180 % \DeclareGraphicsRule
181 % \marg{ext}\marg{type}\marg{read-file}\marg{command}\\
182 % Any number of these declarations can be made. They determine how the
183 % system behaves when a file with extension \emph{ext} is specified.
184 % (The extension may be specified explicitly or, if the argument to
185 % |\includegraphics| does not have an extension, it may be a default
186 % extension from the \emph{ext-list} specified with
187 % |\DeclareGraphicsExtensions|.)
189 % \emph{ext} is the \emph{extension} of the file. Any file with this
190 % extension will be processed by this graphics rule. Normally a file
191 % with an extension for which no rule has been declared will generate an
192 % error, however you may use |*| as the extension to define a
193 % \emph{default rule}. For instance the |dvips| driver file declares all
194 % files to be of type |eps| unless a more specific rule is declared.
196 % Since Version v0.6, extensions should be specified including the |.|
197 % that is, |.eps| not |eps|.
199 % \emph{type} is the `type' of file involved. All files of the same type
200 % will be input with the same internal command (which must be defined in
201 % a `driver file'). For example files with extensions |ps|, |eps|,
202 % |ps.gz| may all be classed as type |eps|.
204 % \emph{read-file} determines the extension of the file that should be
205 % read to determine size information. It may be the same as \emph{ext}
206 % but it may be different, for example |.ps.gz| files are not readable
207 % easily by \TeX, so you may want to put the bounding box information in
208 % a separate file with extension |.ps.bb|. If \emph{read-file} is empty,
209 % |{}|, then the system will not try to locate an external file for size
210 % info, and the size must be specified in the arguments of
211 % |\includegraphics|. As a special case |*| may be used to denote the
212 % same extension as the graphic file. This is mainly of use in
213 % conjunction with using |*| as the extension, as in that case the
214 % particular graphic extension is not known. For example
216 % \DeclareGraphicsRule{*}{eps}{*}{}
218 % This would declare a default rule, such that all unknown extensions
219 % would be treated as EPS files, and the graphic file would be read for
220 % a BoundingBox comment.
222 % If the driver file specifies a procedure for
223 % reading size files for \emph{type}, that will be used, otherwise the
224 % procedure for reading |eps| files will be used. Thus the size of
225 % bitmap files may be specified in a file with a PostScript style
226 % |%%BoundingBox| line, if no other specific format is available.
228 % \emph{command} is usually empty, but if non empty it is used in place
229 % of the filename in the |\special|. Within this argument, |#1| may be
230 % used to denote the filename. Thus using the dvips driver, one may
232 % |\DeclareGraphicsRule{.ps.gz}{eps}{.ps.bb}{`zcat #1}|\\
233 % the final argument causes dvips to use the |zcat| command to unzip the
234 % file before inserting it into the PostScript output.
236 % \subsection{Rotation}
239 % \rotatebox\marg{angle}\marg{text}\\
240 % Rotate \emph{text} \emph{angle} degrees anti-clockwise. Normally
241 % the rotation is about the left-hand end of the baseline of
244 % \subsection{Scaling}
247 % \scalebox\marg{h-scale}\oarg{v-scale}\marg{text}\\
248 % Scale \emph{text} by the specified amounts. If \emph{v-scale} is
249 % omitted, the vertical scale factor is the same as the horizontal one.
252 % \resizebox\star\marg{h-length}\marg{v-length}\marg{text}\\
253 % Scale \emph{text} so that the width is \emph{h-length}.
254 % If |!| is used as either length argument, the other argument is used
255 % to determine a scale factor that is used in both directions.
256 % Normally \emph{v-length} refers to the height of the box, but in the
257 % star form, it refers to the `height + depth'.
258 % As normal for \LaTeXe\ box length arguments, |\height|,
259 % |\width|, |\totalheight| and |\depth| may be used to refer to the
260 % original size of the box.
262 % \section{The Key=Value Interface}
263 % As mentioned in the introduction, apart from the above `standard
264 % interface', there is an alternative syntax to the |\includegraphics|
265 % and |\rotatebox| commands that some people may prefer. It is provided
266 % by the accompanying |graphicx| package.
270 % \section{The Graphics Kernel Functions}
272 % \subsection{Graphics Inclusion}
275 % {\Ginclude@graphics}\marg{file}\\
276 % Insert the contents of the file \emph{file} at the current point.
277 % |\Ginclude@graphics| may use the four macros |\Gin@llx|, |\Gin@lly|,
278 % |\Gin@urx|, |\Gin@ury| to determine the `bounding box' of the graphic.
279 % The result will be a \TeX\ box of width $\mathit{urx}-\mathit{llx}$
280 % and height $\mathit{ury}-\mathit{lly}$. If |\Gin@clip| is \meta{true}
281 % then part of the graphic that is outside this box should not be
282 % displayed. (Not all drivers can support this `clipping'.) Normally all
283 % these parameters are set by the `user interface level'.
287 % {\Gread@eps}\marg{file}\\
288 % For each \emph{type} of graphics file supported, the driver file must
289 % define |\Ginclude@|\emph{type} and, optionally |\Gread@|\emph{type}.
290 % The read command is responsible for obtaining size information from
291 % the file specified in the |\DeclareGraphicsRule| command. However the
292 % kernel defines a function, |\Gread@eps|, which can read PostScript
294 % |%%BoundingBox| comment. This function will be used for any type for
295 % which a specific function has not been declared. |\Gread@eps| accepts
296 % a generalised version of the bounding box comment. \TeX\ units may be
297 % used (but there must be no space before the unit). If the unit is
298 % omitted |bp| is assumed. So\\
299 % |%%BoundingBox 0 0 2in 3in|\\
300 % Would be accepted by this function, to produce a 2in wide, by 3in high
303 % \subsection{Rotation}
307 % Rotate the contents of |\box0| through |\Grot@angle| degrees
308 % (anti-clockwise). The user-interface is responsible for setting the
309 % macro |\Grot@angle|, and putting the appropriate text in |\Grot@box|.
311 % \subsection{Scaling}
314 % {\Gscale@box}\marg{xscale}\oarg{yscale}\marg{text}\\
315 % (The second argument is not optional.)
316 % Scale \emph{text} by the appropriate scale factors.
319 % {\Gscale@box@dd}\marg{dima}\marg{dimb}\marg{text}\\
320 % Scale \emph{text} in both directions by a factor
321 % \emph{dima}/\emph{dimb}.
325 % \marg{dima}\marg{dimb}\marg{dimc}\marg{dimd}\marg{text}\\
326 % Scale \emph{text} in horizontally by a factor \emph{dima}/\emph{dimb},
327 % and vertically by a factor of \emph{dimc}/\emph{dimd}.
330 % {\Gscale@div}\marg{cmd}\marg{dima}\marg{dimb}\\
331 % Define the macro \emph{cmd} to be the ratio of the lengths
332 % \emph{dima}/\emph{dimb}.
335 % \section{Interface to the Driver Files}
337 % \subsection{Graphics Inclusion}
339 % Each driver file must declare that its driver can include graphics of
340 % certain \emph{types}. It does this by declaring for each type a
341 % command of the form:\\
342 % |\Ginclude@|\emph{type}\\
343 % The Graphics kernel function will call this driver-defined function
344 % with the filename as argument, and certain additional information will
345 % be provided as follows.:
347 % \noindent\begin{tabular}{p{.4\textwidth}p{.5\textwidth}}
348 % |\Gin@llx|, |\Gin@lly|,\newline
349 % |\Gin@urx|, |\Gin@ury| &Macros storing the `bounding box'\\
350 % |\Gin@nat@width|\newline |\Gin@nat@height| &
351 % Registers storing the natural size.\\
352 % |\Gin@req@width|\newline |\Gin@req@height| &
353 % Registers storing the required size, after scaling.\\
354 % |\Gin@scalex|, |\Gin@scaley| & macros with the scale factors. A value
355 % of |!| means: Scale by the same amount as the other direction.\\
356 % |\ifGin@clip| & |\newif| token, true if the graphic should be
357 % `clipped' to the bounding box.
360 % Optionally the driver may define a command of the form:\\
361 % |\Gread@|\emph{type}\\
362 % This is responsible for reading an external file to find the bounding
363 % box information. If such a command is not declared, but a read-file is
364 % specified the command |\Gread@eps|, which is defined in the Graphics
365 % Kernel will be used.
367 % \subsection{Literal Postscript}
368 % Drivers that are producing PostScript output may want to define
369 % the following macros. They each take one argument which should be
370 % passed to an appropriate special. They are not used directly by this
371 % package but allow other packages to use the standard configuration
372 % file and package options to customise to various drivers:\\
373 % |\Gin@PS@raw|, Literal PostScript special.\\
374 % |\Gin@PS@restored|, Literal PostScript special, the driver will
375 % surround this with a save-restore pair.\\
376 % |\Gin@PS@literal@header|, Postscript to be inserted in the header
377 % section of the PostScript file.\\
378 % |\Gin@PS@file@header|, external file to be inserted in the header
379 % section of the PostScript file.
382 % \subsection{Rotation}
384 % |\Grot@start|, |\Grot@end| These macros must be defined to insert the
385 % appropriate |\special| to rotate the text between them by
386 % |\Grot@angle| degrees. The kernel function will make sure that the
387 % correct \TeX\ spacing is produced, these functions only need insert
390 % \subsection{Scaling}
392 % |\Gscale@start|, |\Gscale@end|, as for rotation, but here scale the
393 % text by |\Gscale@x| and |\Gscale@y|.
396 % \section{Implementation}
402 % \subsection{Initialisation}
404 % \begin{macro}{\Gin@codes}
405 % First we save the catcodes of some characters, and set them to
406 % fixed values whilst this file is being read.
407 % \changes{v0.5a}{1994/07/20}
408 % {Save and restore catcodes}
411 \catcode`\noexpand\^^A\the\catcode`\^^A\relax
412 \catcode`\noexpand\"\the\catcode`\"\relax
413 \catcode`\noexpand\*\the\catcode`\*\relax
414 \catcode`\noexpand\!\the\catcode`\!\relax
415 \catcode`\noexpand\:\the\catcode`\:\relax}
419 \catcode`\^^A=\catcode`\%
427 % We will need to have an implementation of the trigonometric
428 % functions for the rotation feature. May as well load it now.
430 \RequirePackage{trig}
433 % \begin{macro}{\Grot@start}
434 % \begin{macro}{\Grot@end}
435 % Initialise the rotation primitives.
437 \providecommand\Grot@start{\@latex@error{Rotation not supported}\@ehc
438 \global\let\Grot@start\relax}
439 \providecommand\Grot@end{}
444 % \begin{macro}{\Gscale@start}
445 % \begin{macro}{\Gscale@end}
446 % Initialise the scaling primitives.
448 \providecommand\Gscale@start{\@latex@error{Scaling not supported}\@ehc
449 \global\let\Gscale@start\relax}
450 \providecommand\Gscale@end{}
455 % \begin{macro}{\Gread@BBox}
456 % \changes{v1.0b}{1996/10/29}
457 % {Moved to initial section, for hiresbb option}
458 % |%%BoundingBox| as a macro for testing with |\ifx|.
459 % This may be redefined by the hiresbb option.
461 \edef\Gread@BBox{\@percentchar\@percentchar BoundingBox}
465 % \subsection{Options}
467 % \begin{option}{draft}
468 % \begin{option}{final}
469 % \changes{v0.3i}{1994/03/23}
470 % {notdraft option added}
471 % \changes{v0.4a}{1994/04/13}
472 % {Rename option to nodraft}
473 % \changes{v0.4d}{1994/05/06}
474 % {Rename option to final}
476 \DeclareOption{draft}{\Gin@drafttrue}
477 \DeclareOption{final}{\Gin@draftfalse}
482 % \begin{macro}{\ifGin@draft}
483 % True in draft mode.
489 % \begin{option}{hiresbb}
490 % \changes{v1.0b}{1996/10/29}
491 % {hiresbb option added}
492 % If given this option the package will look for bounding box comments
493 % of the form |%%HiResBoundingBox| (which typically have real values)
494 % instead of the standard |%%BoundingBox| (which should have integer
497 \DeclareOption{hiresbb}{%
498 \edef\Gread@BBox{\@percentchar\@percentchar HiResBoundingBox}}
502 % \begin{option}{demo}
503 % \changes{v1.0o}{2006/02/20}{demo option added}
504 % If given this option the package will disregard the actual
505 % graphics file and insert a black box unless width or height are
508 \DeclareOption{demo}{%
510 \def\Ginclude@graphics#1{%
511 \rule{\@ifundefined{Gin@@ewidth}{150pt}{\Gin@@ewidth}}%
512 {\@ifundefined{Gin@@eheight}{100pt}{\Gin@@eheight}}}}}
516 % \begin{macro}{\Gin@driver}
519 \providecommand\Gin@driver{}
523 % \begin{option}{dvips}
524 % \changes{v0.3g}{1994/03/15}
525 % {Use dvips def file not development version}
526 % \begin{option}{xdvi}
527 % Tomas Rockicki's PostScript driver (unix, MSDOS, VMS\ldots).
528 % The |X11| previewer |xdvi| supports basically the same set of
531 \DeclareOption{dvips}{\def\Gin@driver{dvips.def}}
532 \DeclareOption{xdvi}{\ExecuteOptions{dvips}}
537 % \begin{option}{dvipdf}
538 % \changes{v1.0c}{1996/10/31}
540 % Sergey Lesenko's dvipdf driver.
542 \DeclareOption{dvipdf}{\def\Gin@driver{dvipdf.def}}
546 % \begin{option}{dvipdfm}
547 % \changes{v1.0k}{1999/01/13}
549 % Mark Wick's dvipdfm driver.
551 \DeclareOption{dvipdfm}{\def\Gin@driver{dvipdfm.def}}
555 % \begin{option}{dvipdfmx}
556 % \changes{v1.0m}{2005/11/14}
558 % The driver for the dvipdfmx project.
560 \DeclareOption{dvipdfmx}{\def\Gin@driver{dvipdfmx.def}}
564 % \begin{option}{xetex}
565 % \changes{v1.0m}{2005/11/14}
567 % Jonathan Kew's \TeX\ variant.
569 \DeclareOption{xetex}{\def\Gin@driver{xetex.def}}
573 % \begin{option}{pdftex}
574 % \changes{v1.0d}{1997/06/07}
576 % Han The Thanh's \TeX\ variant.
578 \DeclareOption{pdftex}{\def\Gin@driver{pdftex.def}}
582 % \begin{option}{dvipsone}
583 % \begin{option}{dviwindo}
584 % \changes{v0.3c}{1994/03/04}
585 % {dviwindo support.}
586 % \changes{v0.7c}{1995/09/07}
587 % {Merge dviwindo option with dvipsone}
588 % The drivers for the Y\&Y \TeX\ system.
590 \DeclareOption{dvipsone}{\def\Gin@driver{dvipsone.def}}
591 \DeclareOption{dviwindo}{\ExecuteOptions{dvipsone}}
596 % \begin{option}{emtex}
597 % \begin{option}{dviwin}
598 % Two freely available sets of drivers for MSDOS, OS/2 and Windows.
600 \DeclareOption{emtex}{\def\Gin@driver{emtex.def}}
601 \DeclareOption{dviwin}{\def\Gin@driver{dviwin.def}}
606 % \begin{option}{oztex}
607 % \changes{v1.0f}{1997/09/09}
608 % {Merge dvips and oztex options}
609 % Oz\TeX\ (Macintosh).
610 % Since release 3 of Oz\TeX, merge with dvips back end.
612 \DeclareOption{oztex}{\ExecuteOptions{dvips}}
616 % \begin{option}{textures}
617 % Textures (Macintosh).
619 \DeclareOption{textures}{\def\Gin@driver{textures.def}}
623 % \begin{option}{pctexps}
624 % \begin{option}{pctexwin}
625 % \begin{option}{pctexhp}
626 % \begin{option}{pctex32}
627 % \changes{v1.0b}{1996/10/29}
628 % {pctex32 option added}
629 % PC\TeX\ (MSDOS/Windows) .
631 \DeclareOption{pctexps}{\def\Gin@driver{pctexps.def}}
632 \DeclareOption{pctexwin}{\def\Gin@driver{pctexwin.def}}
633 \DeclareOption{pctexhp}{\def\Gin@driver{pctexhp.def}}
634 \DeclareOption{pctex32}{\def\Gin@driver{pctex32.def}}
641 % \begin{option}{truetex}
642 % \changes{v1.0b}{1996/10/29}
643 % {truetex and tcidef options added}
644 % \begin{option}{tcidvi}
645 % Kinch TrueTeX, and its version with extended special support as
646 % shipped by Scientific Word.
648 \DeclareOption{truetex}{\def\Gin@driver{truetex.def}}
649 \DeclareOption{tcidvi}{\def\Gin@driver{tcidvi.def}}
654 % \begin{option}{vtex}
655 % \changes{v1.0h}{1998/05/27}
656 % {vtex option added}
659 \DeclareOption{vtex}{\def\Gin@driver{vtex.def}}
663 % \begin{option}{dvi2ps}
664 % \begin{option}{dvialw}
665 % \begin{option}{dvilaser}
666 % \begin{option}{dvitops}
667 % \begin{option}{psprint}
668 % \begin{option}{pubps}
670 % \changes{v0.6b}{1994/12/12}
671 % {ln support (untested)}
672 % \changes{v1.0b}{1996/10/29}
673 % {options for historic drivers depreciated}
674 % If \emph{anyone} is using any of these driver options
675 % would they let me know. All these are essentially untried
676 % and untested as far as I know.
678 %\DeclareOption{dvi2ps}{\def\Gin@driver{dvi2ps.def}}
679 %\DeclareOption{dvialw}{\def\Gin@driver{dvialw.def}}
680 %\DeclareOption{dvilaser}{\def\Gin@driver{dvilaser.def}}
681 %\DeclareOption{dvitops}{\def\Gin@driver{dvitops.def}}
682 %\DeclareOption{psprint}{\def\Gin@driver{psprint.def}}
683 %\DeclareOption{pubps}{\def\Gin@driver{pubps.def}}
684 %\DeclareOption{ln}{\def\Gin@driver{ln.def}}
694 % \begin{option}{debugshow}
695 % You probably don't want to use this\ldots
697 \DeclareOption{debugshow}{\catcode`\^^A=9 \let\GDebug\typeout}
701 % A local configuration file may define more options.
702 % It should also make one driver option the default, by calling
703 % |\ExecuteOptions| with the appropriate option.
704 % \changes{v0.4f}{1994/07/27}
705 % {Add missing 3rd argument to \cs{InputIfFileExists}}
707 \InputIfFileExists{graphics.cfg}{}{}
710 % \begin{option}{hiderotate}
711 % \changes{v0.4a}{1994/04/13}
712 % {Rename option to hiderotate}
714 \DeclareOption{hiderotate}{%
715 \def\Grot@start{\begingroup\setbox\z@\hbox\bgroup}
716 \def\Grot@end{\egroup\endgroup}}
720 % \begin{option}{hidescale}
721 % \changes{v0.4a}{1994/04/13}
722 % {Rename option to hidescale}
724 \DeclareOption{hidescale}{%
725 \def\Gscale@start{\begingroup\setbox\z@\hbox\bgroup}
726 \def\Gscale@end{\egroup\endgroup}}
730 % After the options are processed, load the appropriate driver file.
731 % If a site wants a default driver (eg |textures|) it just needs to put
732 % |\ExecuteOptions{textures}| in a |graphics.cfg| file.
737 % Check that a driver has been specified (either as an option, or as a
738 % default option in the configuration file). Then load the `def' file
739 % for that option, if it has not already been loaded by some other
740 % package (for instance the \textsf{color} package).
741 % \changes{v0.5c}{1994/10/03}
742 % {Error if no driver specified}
745 \PackageError{graphics}
746 {No driver specified}
747 {You should make a default driver option in a file \MessageBreak
748 graphics.cfg\MessageBreak
749 eg: \protect\ExecuteOptions{textures}%
752 \PackageInfo{graphics}{Driver file: \Gin@driver}
753 \@ifundefined{ver@\Gin@driver}{\input{\Gin@driver}}{}
758 % \subsection{Graphics Inclusion}
760 % This Graphics package uses a lot of dimension registers. \TeX\ only
761 % has a limited number of registers, so rather than allocate new ones,
762 % re-use some existing \LaTeX\ registers. This is safe as long as all
763 % uses of the registers are \emph{local}, and that you can be sure
764 % that you \emph{never} need to have access to both uses within the
767 % \begin{macro}{\Gin@llx}
768 % \begin{macro}{\Gin@lly}
769 % \begin{macro}{\Gin@urx}
770 % \begin{macro}{\Gin@ury}
771 % In fact these four lengths are now stored as macros not as dimen
772 % registers, mainly so that integer |bp| lengths may be passed exactly.
773 % \changes{v0.7a}{1995/04/11}
774 % {Bounding box coords no longer in registers}
786 % \begin{macro}{\Gin@nat@width}
787 % \begin{macro}{\Gin@nat@height}
788 % The `natural' size of the graphic, before any scaling.
790 \let\Gin@nat@width\leftmarginv
791 \let\Gin@nat@height\leftmarginvi
796 % \begin{macro}{\ifGin@clip}
797 % This switch is \meta{true} if any graphics outside the specified
798 % bounding box (really viewport) should not be printed.
804 % \begin{macro}{\DeclareGraphicsExtensions}
805 % \changes{v0.6a}{1994/11/29}
806 % {Remove optional argument, ignore spaces in main argument.}
807 % Declare a comma separated list of default extensions to be used
808 % if the file is specified with no extension.
810 \newcommand\DeclareGraphicsExtensions[1]{%
811 \edef\Gin@extensions{\zap@space#1 \@empty}}
815 % \begin{macro}{\Gin@extensions}
816 % Initialise the list of possible extensions.
817 % \changes{v0.4b}{1994/04/20}
818 % {Use \cmd{\providecommand} in case a previous def file has
819 % already defined it}
821 \providecommand\Gin@extensions{}
825 % \begin{macro}{\includegraphics}
826 % Top level command for the standard interface, just look for a |*|.
828 \def\includegraphics{%
830 {\Gin@cliptrue\Gin@i}%
831 {\Gin@clipfalse\Gin@i}}
835 % \begin{macro}{\Gin@i}
836 % If an optional argument is present, call |\Gin@ii| to process it,
837 % otherwise call |\Ginclude@graphics|.
838 % \changes{v0.3e}{1994/03/09}
839 % {Now specify ll before ur coordinate}
844 {\Gin@bboxfalse\Ginclude@graphics}}
848 % \begin{macro}{\Gin@ii}
849 % Look for a second optional argument.
858 % \begin{macro}{\Gin@iii}
859 % Set the coordinates of the {\bfseries l}lower {\bfseries l}eft corner,
860 % and the coordinates of the {\bfseries u}pper {\bfseries r}ight
861 % corner. The coordinates may be any \TeX\ dimension, defaulting to |bp|.
862 % \changes{v0.6c}{1994/12/15}
863 % {(Denis Roegel) Extra group to keep bb settings local}
865 \def\Gin@iii[#1,#2][#3,#4]#5{%
868 \Gin@defaultbp\Gin@llx{#1}%
869 \Gin@defaultbp\Gin@lly{#2}%
870 \Gin@defaultbp\Gin@urx{#3}%
871 \Gin@defaultbp\Gin@ury{#4}%
872 \Ginclude@graphics{#5}%
877 % \begin{macro}{\Gin@defaultbp}
878 % \changes{v0.7a}{1995/04/11}{Macro added}
879 % \begin{macro}{\Gin@def@bp}
880 % \changes{v0.7a}{1995/04/11}{Macro added}
881 % This macro grabs a length, |#2|, which may or may not have a unit,
882 % and if a unit is supplied, converts to `bp' and stores the value in
883 % |#1|. If a unit is not supplied `bp' is assumed, and |#2| is directly
884 % stored in |#1|. Note that supplying `bp' is not quite the same as
885 % supplying no units, as in the former case a conversion via `pt' and
886 % back to `bp' takes place which can introduce rounding error. The error
887 % is invisibly small but files conforming to Adobe DSC should have
888 % \emph{integer} Bounding Box Coordinates, and conceivably some drivers
889 % might demand integer values.
890 % (Although most seem to accept real values (if they accept bounding box
891 % coordinates at all) in the |\special|. This is the reason why the
892 % mechanism uses |\def| and not \TeX\ lengths, as in earlier releases of
895 \def\Gin@defaultbp#1#2{%
896 \afterassignment\Gin@def@bp\dimen@#2bp\relax{#1}{#2}}
900 \def\Gin@def@bp#1\relax#2#3{%
905 \edef#2{\strip@pt\dimen@}%
911 % \begin{macro}{\DeclareGraphicsRule}
912 % Declare what actions should be taken for a particular file
915 % |#1| extension, |#2| type, |#3| read-file, |#4| command,
916 % \changes{v0.5d}{1994/10/24}
917 % {(Arthur Ogawa) Check arg3 is *, not arg2.}
919 \def\DeclareGraphicsRule#1#2#3#4{%
920 \edef\@tempa{\string *}\def\@tempb{#3}%
921 \expandafter\edef\csname Gin@rule@#1\endcsname##1%
923 {\ifx\@tempa\@tempb\noexpand\Gin@ext\else#3\fi}%
924 {\ifx\indent#4\indent##1\else#4\fi}}}
928 % An example rule base.
930 % ext type read command
931 % \DeclareGraphicsRule{.ps} {eps} {.ps} {}
932 % \DeclareGraphicsRule{.eps} {eps} {.eps} {}
933 % \DeclareGraphicsRule{.ps.gz}{eps} {.ps.bb} {`zcat #1}
934 % \DeclareGraphicsRule{.pcx} {bmp} {} {}
937 % \begin{macro}{\graphicspath}
938 % User level command to set the input path for graphics files.
939 % A list of directories, each in a |{}| group.
941 \def\graphicspath#1{\def\Ginput@path{#1}}
945 % \begin{macro}{\Ginput@path}
946 % The default graphic path is |\input@path|.
948 \ifx\Ginput@path\@undefined
949 \let\Ginput@path\input@path
954 % \begin{macro}{\Gin@getbase}
955 % \changes{v0.6a}{1994/11/29}
956 % {remove \cs{Gin@sep}}
957 % Given a possible extension, |#1|, check whether the file exists. If
958 % it does set |\Gin@base| and |\Gin@ext| to the filename stripped of
959 % the extension, and the extension, respectively.
963 \def\noexpand\@tempa####1#1\space{%
964 \def\noexpand\Gin@base{####1}}}%
965 \IfFileExists{\filename@area\filename@base#1}%
967 \expandafter\@tempa\@filef@und
968 \edef\Gin@ext{#1}}{}}%
972 % \begin{macro}{\Gin@ext}
973 % Initialise the macro to hold the extension.
979 % \begin{macro}{\Gin@sepdefault}
980 % \changes{v0.6a}{1994/11/29}
981 % {remove \cs{Gin@sep}}
982 % This must match the token used by |\filename@parse| to delimit the
985 \def\Gin@sepdefault{.}
989 % \begin{macro}{\Ginclude@graphics}
990 % The main internal function implementing graphics file inclusion.
991 % |#1| is the file name.
992 % \changes{v0.4c}{1994/04/28}
993 % {Improve the wording of error messages}
994 % \changes{v0.5a}{1994/07/20}
995 % {Add default (*) rule possibility}
996 % \changes{v0.6a}{1994/11/29}
997 % {remove \cs{Gin@sepdefault}}
999 \def\Ginclude@graphics#1{%
1001 \let\input@path\Ginput@path
1002 \filename@parse{#1}%
1003 \ifx\filename@ext\relax
1004 \@for\Gin@temp:=\Gin@extensions\do{%
1006 \Gin@getbase\Gin@temp
1009 \Gin@getbase{\Gin@sepdefault\filename@ext}%
1011 % \changes{v0.4d}{1994/05/06}
1012 % {Make file not found a warning not an error}
1013 % \changes{v0.6a}{1994/11/29}
1014 % {remove \cs{Gin@sep}}
1015 % If the user supplied an explicit extension, just give a warning if the
1016 % file does not exist. (It may be created later.)
1019 \@warning{File `#1' not found}%
1020 \def\Gin@base{\filename@area\filename@base}%
1022 % \changes{v0.6c}{1994/12/15}
1023 % {(Piet van Oostrum) include `.' in \cs{Gin@ext}}%
1025 \edef\Gin@ext{\Gin@sepdefault\filename@ext}%
1029 % If no extension is supplied, it is an error if the file does not
1030 % exist, as there is no way for the system to know which extension to
1034 \@latex@error{File `#1' not found}%
1035 {I could not locate the file with any of these extensions:^^J%
1036 \Gin@extensions^^J\@ehc}%
1038 \@ifundefined{Gin@rule@\Gin@ext}%
1040 % \changes{v0.5a}{1994/07/20}
1041 % {Add default (*) rule possibility}
1042 % Handle default rule.
1044 {\ifx\Gin@rule@*\@undefined
1045 \@latex@error{Unknown graphics extension: \Gin@ext}\@ehc
1047 \expandafter\Gin@setfile\Gin@rule@*{\Gin@base\Gin@ext}%
1049 {\expandafter\expandafter\expandafter\Gin@setfile
1050 \csname Gin@rule@\Gin@ext\endcsname{\Gin@base\Gin@ext}}%
1056 % \begin{macro}{\ifGread@}
1057 % True if a file should be read to obtain the natural size.
1059 \newif\ifGread@\Gread@true
1063 % \begin{macro}{\Gin@setfile}
1064 % Set a file to the size specified in arguments, or in a `read file'.
1065 % \changes{v0.5d}{1994/10/24}
1066 % {(Arthur Ogawa) Add missing \cs{expandafter}}
1068 \def\Gin@setfile#1#2#3{%
1069 \ifx\\#2\\\Gread@false\fi
1073 \expandafter\ifx\csname Gread@#1\endcsname\relax
1078 \endcsname{\Gin@base#2}%
1081 % \changes{v0.5a}{1994/07/20}
1082 % {New error trap for missing size arguments}
1083 % \changes{v0.7f}{1995/11/10}
1084 % {Use \cs{Gin@nosize}}
1085 % By now the natural size should be known either from arguments or
1086 % from the file. If not generate an error. (The \textsf{graphicx}
1087 % interface relaxes this condition slightly.)
1093 % \changes{v0.7a}{1995/04/11}{\cs{Gin@viewport@code} added.}
1094 % The following call will modify the `natural size' if the user has
1095 % supplied a viewport or trim specification. (Not available in the
1096 % standard interface.)
1100 % Save the natural size, and then call |\Gin@req@sizes| which (in the
1101 % key-val interface) will calculate the required size from the natural
1102 % size, and any scaling info.
1104 \Gin@nat@height\Gin@ury bp%
1105 \advance\Gin@nat@height-\Gin@lly bp%
1106 \Gin@nat@width\Gin@urx bp%
1107 \advance\Gin@nat@width-\Gin@llx bp%
1111 % Call |\Ginclude@|\emph{type} to include the figure unless
1112 % this is not defined, or draft mode is being used.
1113 % \changes{v0.7h}{1996/02/20}
1114 % {missing \texttt{@} added in \texttt{Gread@} csnames}
1116 \expandafter\ifx\csname Ginclude@#1\endcsname\relax
1118 \expandafter\ifx\csname Gread@#1\endcsname\relax
1119 \@latex@error{Can not include graphics of type: #1}\@ehc
1120 \global\expandafter\let\csname Gread@#1\endcsname\@empty
1125 \hb@xt@\Gin@req@width{%
1127 \vbox to \Gin@req@height{%
1128 \hrule \@width \Gin@req@width
1131 \rlap{ \ttfamily\expandafter\strip@prefix\meaning\@tempa}%
1137 % \changes{v0.3i}{1994/3/23}
1138 % {Add file list info}
1139 % Support |\listfiles| and then set the final box to the required size.
1141 \@addtofilelist{#3}%
1142 \ProvidesFile{#3}[Graphic file (type #1)]%
1143 \setbox\z@\hbox{\csname Ginclude@#1\endcsname{#3}}%
1145 \ht\z@\Gin@req@height
1146 \wd\z@\Gin@req@width
1153 % \begin{macro}{\Gin@exclamation}
1154 % \changes{v0.7g}{1995/12/06}{Macro added}
1155 % Catcode 12 |!|, in case of French, or other language styles.
1157 \def\Gin@exclamation{!}
1161 % \begin{macro}{\Gin@req@sizes}
1162 % \begin{macro}{\Gin@scalex}
1163 % \begin{macro}{\Gin@scaley}
1164 % \begin{macro}{\Gin@req@height}
1165 % \begin{macro}{\Gin@req@width}
1166 % In the standard interface there is no scaling, so the required size
1167 % is the same as the natural size. In other interfaces |\Gin@req@sizes|
1168 % will be responsible for setting these parameters. Here we can set them
1170 % \changes{v0.3g}{1994/03/15}
1171 % {Initialise y-scale to !!}
1172 % \changes{v1.0g}{1998/05/14}
1173 % {Fix !! usage in changes entries. graphics/2724}
1175 \let\Gin@req@sizes\relax
1177 \let\Gin@scaley\Gin@exclamation
1178 \let\Gin@req@height\Gin@nat@height
1179 \let\Gin@req@width\Gin@nat@width
1187 % \begin{macro}{\Gin@viewport@code}
1188 % In the standard interface there is no possibility of specifying
1189 % a viewport, so this is a no-op.
1190 % \changes{v0.7a}{1995/04/11}{Macro added}
1192 \let\Gin@viewport@code\relax
1196 % \begin{macro}{\Gin@nosize}
1197 % \changes{v1.0p}{2014/10/14}{Fixed typo in error message}
1198 % \changes{v0.7f}{1995/11/10}
1200 % This command is called in the case that the graphics type
1201 % specifies no `read file' and the user supplied no size arguments.
1202 % In the standard interface can only generate an error.
1206 {Cannot determine size of graphic in #1 (no size specified)}%
1211 % \subsection{Reading the BoundingBox in EPS files}
1213 % \begin{macro}{\ifGin@bbox}
1214 % \changes{v0.7a}{1995/04/11}{Name changed from \cs{ifGin@viewport}}
1215 % This switch should be set \meta{true} once a size has been found,
1216 % either in an argument, or in an external file.
1222 % \begin{macro}{\Gread@eps}
1223 % Read an EPS file (|#1|) and search for a line
1224 % starting with |%%BoundingBox| and returns the result
1225 % by setting four dimension registers
1226 % |\Gin@llx|, |\Gin@lly|, |\Gin@urx| and |\Gin@ury|.
1227 % \changes{v0.5e}{1994/1l/02}
1228 % {Fix the catcodes of \cs{endlinechar} and ctrl-D}
1229 % \changes{v0.7a}{1995/04/11}
1230 % {Fix more catcodes, for binary headers of eps files}
1235 % Make it reasonably safe to have binary headers in the EPS file
1236 % before the bounding box line.
1239 \loop\ifnum\@tempcnta<\@xxxii
1240 \catcode\@tempcnta14 %
1241 \advance\@tempcnta\@ne
1247 % Make sure tab and space are accepted as white space.
1248 % \changes{v1.0e}{1997/09/02}
1249 % {Allow TAB in DSC comments graphics/2587}
1250 % \changes{v1.0i}{1999/01/07}
1251 % {Fix catcode of hyphen. graphics/2846}
1255 \catcode\endlinechar5 %
1259 % The first thing we need to do is to open the
1260 % information file, if possible.
1261 % \changes{v0.4d}{1994/05/06}
1262 % {Improve the error message if the info file is not there.}
1264 \immediate\openin\@inputcheck#1 %
1266 \@latex@error{File `#1' not found}\@ehc
1269 % Now we'll scan lines until we find one that starts with
1271 % We need to reset the catcodes to read the file, and so this
1272 % is done in a group.
1275 \let\@tempb\Gread@false
1277 \read\@inputcheck to\@tempa
1281 \expandafter\Gread@find@bb\@tempa:.\\%
1285 \immediate\closein\@inputcheck
1288 % \changes{v0.3i}{1994/03/23}
1289 % {Wording of error message improved}
1290 % \changes{v1.0}{1996/05/29}
1291 % {Use \cs{@gtempa} not \cs{g@tempa} /2090}
1295 {Cannot determine size of graphic in #1 (no BoundingBox)}%
1297 \gdef\@gtempa{0 0 72 72 }%
1300 \expandafter\Gread@parse@bb\@gtempa\\}
1304 % \begin{macro}{\Gread@find@bb}
1305 % If a line in the EPS file starts with a |%%BoundingBox:|, we
1306 % will examine it more closely. Note using the `extra' argument |#2#3|
1307 % causes any space after the |:| to be gobbled.
1309 \long\def\Gread@find@bb#1:#2#3\\{%
1311 \ifx\@tempa\Gread@BBox
1312 \Gread@test@atend#2#3()\\%
1316 % \begin{macro}{\Gread@test@atend}
1317 % Determine if the stuff following the |%%BoundingBox| is `(atend)',
1318 % which will involve further reading of the file. This is accomplished
1319 % by making |\@tempb| into a no-op, so that finding a |%%BoundingBox|
1320 % does not stop the loop.
1322 \def\Gread@test@atend#1(#2)#3\\{%
1324 \ifx\@tempa\Gread@atend
1334 % \begin{macro}{\Gread@parse@bb}
1335 % We have |%%BoundingBox| and what follows is not `(atend)' so we
1336 % will parse the rest of the line as a BB with four elements.
1337 % PostScript files should never have units specified in the
1338 % BoundingBox comment, but we allow arbitrary \TeX\ units in external
1339 % files, or in other interfaces.
1341 \def\Gread@parse@bb#1 #2 #3 #4 #5\\{%
1342 \Gin@defaultbp\Gin@llx{#1}%
1343 \Gin@defaultbp\Gin@lly{#2}%
1344 \Gin@defaultbp\Gin@urx{#3}%
1345 \Gin@defaultbp\Gin@ury{#4}}%
1349 % \begin{macro}{\Gread@atend}
1350 % |atend| as a macro for testing with |\ifx|.
1352 \def\Gread@atend{atend}
1357 % \subsection{Rotation}
1359 % As above, we will re-use some existing local registers.
1361 % \begin{macro}{\Grot@height}
1362 % \begin{macro}{\Grot@left}
1363 % \begin{macro}{\Grot@right}
1364 % \begin{macro}{\Grot@depth}
1365 % Final Rotated box dimensions
1367 \let\Grot@height\@ovxx
1368 \let\Grot@left\@ovyy
1369 \let\Grot@right\@ovdx
1370 \let\Grot@depth\@ovdy
1377 % \begin{macro}{\Grot@h}
1378 % \begin{macro}{\Grot@l}
1379 % \begin{macro}{\Grot@r}
1380 % \begin{macro}{\Grot@d}
1381 % Original box dimensions
1393 % \begin{macro}{\Grot@x}
1394 % \begin{macro}{\Grot@y}
1395 % Coordinates of centre of rotation.
1397 \let\Grot@x\@linelen
1398 \let\Grot@y\@dashdim
1403 % \begin{macro}{\rotatebox}
1404 % The angle is specified by |#1|. The box to be rotated is |#2|.
1405 % In the standard interface the centre of rotation is $(0,0)$.
1406 % Then finally call |\Grot@box| to rotate the box.
1407 % \changes{v0.3f}{1994/03/11}{Remove star form}
1408 % \changes{v0.3h}{1994/03/17}{Fix Typo}
1409 % \changes{v0.7a}{1995/04/11}{\cs{leavevmode} added graphics/1521}
1410 % \changes{v1.0n}{2001/07/07}
1411 % {Made long (CAR) graphics/2908 and 3345}
1413 \long\def\rotatebox#1#2{%
1416 \setbox\z@\hbox{{#2}}%
1424 % \begin{macro}{\Grot@setangle}
1425 % Set the internal macro used by |\Grot@box|. In the standard
1426 % interface this is trivial, but other interfaces may have more
1427 % interesting definitions. For example:
1429 % \def\Grot@setangle#1{%
1431 % \dimen@-57.2968\dimen@
1432 % \edef\Grot@angle{\strip@pt\dimen@}}
1434 % This would cause the argument of |\rotatebox| to be interpreted as
1435 % an angle specified in \emph{radians}, \emph{clockwise}.
1437 \def\Grot@setangle#1{\edef\Grot@angle{#1}}
1441 % \subsection{Deriving a `bounding box' for rotated object}
1442 % We want to know the size of a `bounding box' enclosing the rotated
1444 % We define two formulae (as \TeX\ macros) to work out the $x$ and $y$
1445 % coordinates of vertices of the rotated box
1446 % in relation to its original coordinates (i.e., its width, height
1447 % and depth). The box we visualize with vertices $B$, $C$,
1448 % $D$ and $E$ is illustrated below. The vertex
1449 % $S$ is the reference point on the baseline. $O$ is the centre of
1450 % rotation, which in the standard interface is always $S$.
1453 % \setlength{\unitlength}{3pt}%
1455 % \begin{picture}(34,36)(12,44)
1457 % \put(20,52){\dashbox{1}(20,21){}}
1458 % \put(20,80){\line(0,-1){36}}
1459 % \put(12,58){\line(1, 0){34}}
1467 % \put(33,65){\circle*{1}}
1471 % The formulae are, for a point $P$ and angle $\alpha$:
1474 % P'_x = P_x - O_x \\
1475 % P'_y = P_y - O_y \\
1476 % P''_x = ( P'_x \times \cos(\alpha)) - ( P'_y \times \sin(\alpha) ) \\
1477 % P''_y = ( P'_x \times \sin(\alpha)) + ( P'_y \times \cos(\alpha) ) \\
1478 % P'''_x = P''_x + O_x + L_x \\
1479 % P'''_y = P''_y + O_y
1482 % The `extra' horizontal translation $L_x$ at the end is calculated so
1483 % that the leftmost point of the resulting box has $x$-coordinate $0$.
1484 % This is desirable as \TeX\ boxes must have the reference point at
1485 % the left edge of the box.
1487 % \begin{macro}{\Grot@Px}
1488 % Work out new $x$ coordinate of point after rotation. The parameters
1489 % |#2| and |#3| are the original $x$ and $y$ coordinates of the point.
1490 % The new $x$ coordinate is stored in |#1|.
1492 \def\Grot@Px#1#2#3{%
1494 \advance#1-\Grot@sin#3}
1497 % \begin{macro}{\Grot@Py}
1498 % Work out new $y$ coordinate of point after rotation. The parameters
1499 % |#2| and |#3| are the original $x$ and $y$ coordinates of the point.
1500 % The new $y$ coordinate is stored in |#1|.
1502 \def\Grot@Py#1#2#3{%
1504 \advance#1\Grot@cos#3}
1508 % \begin{macro}{\Grot@box}
1509 % This is the tricky bit. We can rotate the box, but then need
1510 % to work out how much space to leave for it on the page.
1512 % We simplify matters by working out first which quadrant we are in, and
1513 % then picking just the right values.
1519 % We are going to need to know the sine and cosine
1520 % of the angle; simplest to calculate these now.
1522 \CalculateSin\Grot@angle
1523 \CalculateCos\Grot@angle
1524 \edef\Grot@sin{\UseSin\Grot@angle}%
1525 \edef\Grot@cos{\UseCos\Grot@angle}%
1526 ^^A \GDebug{Rotate: angle \Grot@angle, sine is \Grot@sin,
1527 ^^A cosine is \Grot@cos}%
1529 % Save the four extents of the original box.
1531 \Grot@r\wd\z@ \advance\Grot@r-\Grot@x
1532 \Grot@l\z@ \advance\Grot@l-\Grot@x
1533 \Grot@h\ht\z@ \advance\Grot@h-\Grot@y
1534 \Grot@d-\dp\z@ \advance\Grot@d-\Grot@y
1536 % Now a straightforward test to see which quadrant we are
1539 \ifdim\Grot@sin\p@>\z@
1540 \ifdim\Grot@cos\p@>\z@
1543 % Height=$By$, Right=$Ex$, Left=$Cx$, Depth=$Dy$
1545 \Grot@Py\Grot@height \Grot@r\Grot@h%B
1546 \Grot@Px\Grot@right \Grot@r\Grot@d%E
1547 \Grot@Px\Grot@left \Grot@l\Grot@h%C
1548 \Grot@Py\Grot@depth \Grot@l\Grot@d%D
1552 % Height=$Ey$, Right=$Dx$, Left=$Bx$, Depth=$Cy$
1554 \Grot@Py\Grot@height \Grot@r\Grot@d%E
1555 \Grot@Px\Grot@right \Grot@l\Grot@d%D
1556 \Grot@Px\Grot@left \Grot@r\Grot@h%B
1557 \Grot@Py\Grot@depth \Grot@l\Grot@h%C
1560 \ifdim\Grot@cos\p@<\z@
1563 % Height=$Dy$, Right=$Cx$, Left=$Ex$, Depth=$By$
1565 \Grot@Py\Grot@height \Grot@l\Grot@d%D
1566 \Grot@Px\Grot@right \Grot@l\Grot@h%C
1567 \Grot@Px\Grot@left \Grot@r\Grot@d%E
1568 \Grot@Py\Grot@depth \Grot@r\Grot@h%B
1572 % Height=$Cy$, Right=$Bx$, Left=$Dx$, Depth=$Ey$
1574 \Grot@Py\Grot@height \Grot@l\Grot@h%C
1575 \Grot@Px\Grot@right \Grot@r\Grot@h%B
1576 \Grot@Px\Grot@left \Grot@l\Grot@d%D
1577 \Grot@Py\Grot@depth \Grot@r\Grot@d%E
1581 % Now we should translate back by $(O_x,O_y)$, but \TeX\ can not really
1582 % deal with boxes that do not have the reference point at the left edge.
1583 % (Everything with a $-$ve $x$-coordinate would over-print earlier
1584 % text). So we modify the horizontal translation so that the
1585 % reference point as understood by \TeX\ \emph{is} at the left edge.
1586 % This means that the `centre of rotation' is not fixed by |\rotatebox|,
1587 % but typically moves horizontally. We also need to find the image of
1588 % the original reference point, $S$, as that is where the rotation
1589 % specials must be inserted.
1592 \advance\Grot@height\Grot@y
1593 \advance\Grot@depth\Grot@y
1594 \Grot@Px\dimen@ \Grot@x\Grot@y
1595 \Grot@Py\dimen@ii \Grot@x\Grot@y
1596 \dimen@-\dimen@ \advance\dimen@-\Grot@left
1597 \dimen@ii-\dimen@ii \advance\dimen@ii\Grot@y
1601 ^^A \GDebug{Rotate: (l,r,h,d)^^J%
1602 ^^A Original \the\Grot@l,\the\Grot@r,\the\Grot@h,\the\Grot@d,^^J%
1603 ^^A New..... \the\Grot@left,\the\Grot@right,%
1604 ^^A \the\Grot@height,\the\Grot@depth}%
1610 \raise\dimen@ii\hbox{\Grot@start\box\z@\Grot@end}}%
1613 \advance\Grot@right-\Grot@left\wd\z@\Grot@right
1620 % \subsection{Stretching and Scaling}
1623 % \begin{macro}{\scalebox}
1624 % The top level |\scalebox|. If the vertical scale factor is omitted it
1625 % defaults to the horizontal scale factor, |#1|.
1626 % \changes{v0.3d}{1994/03/06}{Better support for negative arguments.}
1629 \@ifnextchar[{\Gscale@box{#1}}{\Gscale@box{#1}[#1]}}
1633 % \begin{macro}{\Gscale@box}
1634 % Internal version of |\scalebox|.
1635 % \changes{v0.7a}{1995/04/11}
1636 % {\cs{leavevmode} moved earlier. graphics/1521}
1637 % \changes{v1.0j}{1999/01/07}
1638 % {made long. graphics/2908}
1640 \long\def\Gscale@box#1[#2]#3{%
1642 \def\Gscale@x{#1}\def\Gscale@y{#2}%
1643 \setbox\z@\hbox{{#3}}%
1644 \setbox\tw@\hbox{\Gscale@start\rlap{\copy\z@}\Gscale@end}%
1653 \hb@xt@-#1\wd\z@{\kern-#1\wd\z@\box\tw@\hss}%
1662 % \begin{macro}{\reflectbox}
1663 % Just an abbreviation for the appropriate scale to get reflection.
1664 % \changes{v0.3e}{1994/03/09}{Macro added}
1666 \def\reflectbox{\Gscale@box-1[1]}
1671 % \begin{macro}{\resizebox}
1672 % \changes{v0.3b}{1994/03/01}{Recode \cmd\resizebox.}
1673 % \changes{v0.7b}{1995/04/27}
1674 % {Add \cs{leavevmode} for graphics/1512}
1675 % Look for a |*|, which specifies that a final vertical size refers to
1676 % `height + depth' not just `height'.
1680 \@ifstar{\Gscale@@box\totalheight}{\Gscale@@box\height}}
1684 % \begin{macro}{\Gscale@@box}
1685 % Look for the |!| in the arguments.
1686 % \changes{v0.5a}{1994/07/20}
1687 % {Support French active !!}
1688 % \changes{v0.5d}{1994/10/24}
1689 % {Correct the support for !!}
1691 % {1995/12/06}{Use \cs{Gin@exclamation}}
1693 \def\Gscale@@box#1#2#3{%
1694 \let\@tempa\Gin@exclamation
1695 \expandafter\def\expandafter\@tempb\expandafter{\string#2}%
1696 \expandafter\def\expandafter\@tempc\expandafter{\string#3}%
1701 \toks@{\Gscale@box@dd{#3}#1}%
1705 \toks@{\Gscale@box@dd{#2}\width}%
1707 \toks@{\Gscale@box@dddd{#2}\width{#3}#1}%
1714 % \begin{macro}{\Gscale@box@dd}
1715 % Scale the text |#3| in both directions by a factor $|#1|/|#2|$.
1716 % \changes{v0.3i}{1994/03/23}
1717 % {Missing percent added}
1718 % \changes{v1.0i}{1999/01/07}
1719 % {made long. graphics/2908}
1721 \long\def\Gscale@box@dd#1#2#3{%
1722 \@begin@tempboxa\hbox{#3}%
1723 \setlength\@tempdima{#1}%
1724 \setlength\@tempdimb{#2}%
1725 \Gscale@div\@tempa\@tempdima\@tempdimb
1726 \Gscale@box\@tempa[\@tempa]{\box\@tempboxa}%
1731 % \begin{macro}{\Gscale@box@dddd}
1732 % Scale the text |#5| horizontally by a factor $|#1|/|#2|$ and
1733 % vertically by a factor $|#3|/|#4|$.
1734 % \changes{v0.3i}{1994/03/23}
1735 % {Missing percent added}
1736 % \changes{v0.7e}{1995/09/29}
1737 % {Add \cs{ifGin@iso} code added}
1738 % \changes{v1.0i}{1999/01/07}
1739 % {made long. graphics/2908}
1741 \long\def\Gscale@box@dddd#1#2#3#4#5{%
1742 \@begin@tempboxa\hbox{#5}%
1743 \setlength\@tempdima{#1}%
1744 \setlength\@tempdimb{#2}%
1745 \Gscale@div\@tempa\@tempdima\@tempdimb
1746 \setlength\@tempdima{#3}%
1747 \setlength\@tempdimb{#4}%
1748 \Gscale@div\@tempb\@tempdima\@tempdimb
1750 \ifdim\@tempa\p@>\@tempb\p@
1756 \Gscale@box\@tempa[\@tempb]{\box\@tempboxa}%
1761 % \begin{macro}{\ifGin@iso}
1762 % If this flag is true, then specifying two lengths to |\resizebox|
1763 % scales the box by the same factor in either direction, such that
1764 % neither length \emph{exceeds} the stated amount. No user interface
1765 % to this flag in the standard package, but it is used by the
1766 % |keepaspectratio| key to |\includegraphics| in the \textsf{graphicx}
1768 % \changes{v0.7e}{1995/09/29}
1775 % \begin{macro}{\Gscale@div}
1776 % The macro |#1| is set to the ratio of the lengths |#2| and |#3|.
1777 % \changes{v0.7a}{1995/04/11}
1778 % {Add trap for division by 0}
1779 % \changes{v0.7d}{1995/09/27}
1780 % {Use \cs{setlength} to support calc package}
1781 % \changes{v1.0a}{1996/09/16}
1782 % {Stop infinite loop if 2nd arg zero. graphics/2259}
1784 \def\Gscale@div#1#2#3{%
1785 \setlength\dimen@{#3}%
1787 \PackageError{graphics}{Division by 0}\@eha
1790 \edef\@tempd{\the\dimen@}%
1791 \setlength\dimen@{#2}%
1799 \ifdim\dimen@<8192\p@
1803 \dimen@ii\@tempd\relax
1804 \divide\dimen@ii\count@
1805 \divide\dimen@\dimen@ii
1807 \edef#1{\strip@pt\dimen@}}
1814 \let\Gin@codes\relax