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