| 1 |
%%% -*-TeX-*- |
| 2 |
%%% ==================================================================== |
| 3 |
%%% @TeX-file{ |
| 4 |
%%% author = "Tom Rokicki", |
| 5 |
%%% version = "2.7.4", |
| 6 |
%%% date = "14 February 2011", |
| 7 |
%%% time = "15:44:06 MST", |
| 8 |
%%% filename = "epsf.tex", |
| 9 |
%%% address = "Tom Rokicki |
| 10 |
%%% Box 2081 |
| 11 |
%%% Stanford, CA 94309 |
| 12 |
%%% USA", |
| 13 |
%%% telephone = "+1 415 855 9989", |
| 14 |
%%% checksum = "29223 653 3100 27123", |
| 15 |
%%% email = "[email protected] (Internet)", |
| 16 |
%%% codetable = "ISO/ASCII", |
| 17 |
%%% copyright = "This file is freely redistributable and |
| 18 |
%%% placed into the public domain by Tomas |
| 19 |
%%% Rokicki.", |
| 20 |
%%% keywords = "PostScript, TeX", |
| 21 |
%%% license = "public domain", |
| 22 |
%%% supported = "yes", |
| 23 |
%%% abstract = "This file contains macros to support the |
| 24 |
%%% inclusion of Encapsulated PostScript files |
| 25 |
%%% in TeX documents.", |
| 26 |
%%% docstring = "This file contains TeX macros to include an |
| 27 |
%%% Encapsulated PostScript graphic. It works |
| 28 |
%%% by finding the bounding box comment, |
| 29 |
%%% calculating the correct scale values, and |
| 30 |
%%% inserting a vbox of the appropriate size at |
| 31 |
%%% the current position in the TeX document. |
| 32 |
%%% |
| 33 |
%%% To use, simply use |
| 34 |
%%% |
| 35 |
%%% \input epsf % somewhere early on in your TeX file |
| 36 |
%%% |
| 37 |
%%% % then where you want to insert a vbox for a figure: |
| 38 |
%%% \epsfbox{filename.ps} |
| 39 |
%%% |
| 40 |
%%% Alternatively, you can supply your own |
| 41 |
%%% bounding box by |
| 42 |
%%% |
| 43 |
%%% \epsfbox[0 0 30 50]{filename.ps} |
| 44 |
%%% |
| 45 |
%%% This will not read in the file, and will |
| 46 |
%%% instead use the bounding box you specify. |
| 47 |
%%% |
| 48 |
%%% The effect will be to typeset the figure as |
| 49 |
%%% a TeX box, at the point of your \epsfbox |
| 50 |
%%% command. By default, the graphic will have |
| 51 |
%%% its `natural' width (namely the width of |
| 52 |
%%% its bounding box, as described in |
| 53 |
%%% filename.ps). The TeX box will have depth |
| 54 |
%%% zero. |
| 55 |
%%% |
| 56 |
%%% You can enlarge or reduce the figure by |
| 57 |
%%% using |
| 58 |
%%% |
| 59 |
%%% \epsfxsize = <dimen> \epsfbox{filename.ps} |
| 60 |
%%% or |
| 61 |
%%% \epsfysize = <dimen> \epsfbox{filename.ps} |
| 62 |
%%% |
| 63 |
%%% instead. Then the width of the TeX box will |
| 64 |
%%% be \epsfxsize and its height will be scaled |
| 65 |
%%% proportionately (or the height will be |
| 66 |
%%% \epsfysize and its width will be scaled |
| 67 |
%%% proportionately). |
| 68 |
%%% |
| 69 |
%%% The width (and height) is restored to zero |
| 70 |
%%% after each use, so \epsfxsize or \epsfysize |
| 71 |
%%% must be specified before EACH use of |
| 72 |
%%% \epsfbox. |
| 73 |
%%% |
| 74 |
%%% A more general facility for sizing is |
| 75 |
%%% available by defining the \epsfsize macro. |
| 76 |
%%% Normally you can redefine this macro to do |
| 77 |
%%% almost anything. The first parameter is |
| 78 |
%%% the natural x size of the PostScript |
| 79 |
%%% graphic, the second parameter is the |
| 80 |
%%% natural y size of the PostScript graphic. |
| 81 |
%%% It must return the xsize to use, or 0 if |
| 82 |
%%% natural scaling is to be used. Common uses |
| 83 |
%%% include: |
| 84 |
%%% |
| 85 |
%%% \epsfxsize % just leave the old value alone |
| 86 |
%%% 0pt % use the natural sizes |
| 87 |
%%% #1 % use the natural sizes |
| 88 |
%%% \hsize % scale to full width |
| 89 |
%%% 0.5#1 % scale to 50% of natural size |
| 90 |
%%% \ifnum #1 > \hsize \hsize \else #1\fi |
| 91 |
%%% % smaller of natural, hsize |
| 92 |
%%% |
| 93 |
%%% If you want TeX to report the size of the |
| 94 |
%%% figure (as a message on your terminal when |
| 95 |
%%% it processes each figure), use |
| 96 |
%%% `\epsfverbosetrue'. |
| 97 |
%%% |
| 98 |
%%% If you only want to get the bounding box |
| 99 |
%%% extents, without producing any output boxes |
| 100 |
%%% or \special{}, then use \epsfgetbb{filename}. |
| 101 |
%%% The bounding box corner coordinates are saved |
| 102 |
%%% in the macros \epsfllx, \epsflly, \epsfurx, |
| 103 |
%%% and \epsfury in PostScript units of big |
| 104 |
%%% points. |
| 105 |
%%% |
| 106 |
%%% Revision history: |
| 107 |
%%% |
| 108 |
%%% --------------------------------------------- |
| 109 |
%%% epsf.tex macro file: |
| 110 |
%%% Originally written by Tomas Rokicki of |
| 111 |
%%% Radical Eye Software, 29 Mar 1989. |
| 112 |
%%% |
| 113 |
%%% --------------------------------------------- |
| 114 |
%%% Revised by Don Knuth, 3 Jan 1990. |
| 115 |
%%% |
| 116 |
%%% --------------------------------------------- |
| 117 |
%%% Revised by Tomas Rokicki, 18 Jul 1990. |
| 118 |
%%% Accept bounding boxes with no space after |
| 119 |
%%% the colon. |
| 120 |
%%% |
| 121 |
%%% --------------------------------------------- |
| 122 |
%%% Revised by Nelson H. F. Beebe |
| 123 |
%%% <[email protected]>, 03 Dec 1991 [2.0]. |
| 124 |
%%% Add version number and date typeout. |
| 125 |
%%% |
| 126 |
%%% Use \immediate\write16 instead of \message |
| 127 |
%%% to ensure output on new line. |
| 128 |
%%% |
| 129 |
%%% Handle nested EPS files. |
| 130 |
%%% |
| 131 |
%%% Handle %%BoundingBox: (atend) lines. |
| 132 |
%%% |
| 133 |
%%% Do not quit when blank lines are found. |
| 134 |
%%% |
| 135 |
%%% Add a few percents to remove generation of |
| 136 |
%%% spurious blank space. |
| 137 |
%%% |
| 138 |
%%% Move \special output to |
| 139 |
%%% \epsfspecial{filename} so that other macro |
| 140 |
%%% packages can input this one, then change |
| 141 |
%%% the definition of \epsfspecial to match |
| 142 |
%%% another DVI driver. |
| 143 |
%%% |
| 144 |
%%% Move size computation to \epsfsetsize which |
| 145 |
%%% can be called by the user; the verbose |
| 146 |
%%% output of the bounding box and scaled width |
| 147 |
%%% and height happens here. |
| 148 |
%%% |
| 149 |
%%% --------------------------------------------- |
| 150 |
%%% Revised by Nelson H. F. Beebe |
| 151 |
%%% <[email protected]>, 05 May 1992 [2.1]. |
| 152 |
%%% Wrap \leavevmode\hbox{} around \vbox{} with |
| 153 |
%%% the \special so that \epsffile{} can be |
| 154 |
%%% used inside \begin{center}...\end{center} |
| 155 |
%%% |
| 156 |
%%% --------------------------------------------- |
| 157 |
%%% Revised by Nelson H. F. Beebe |
| 158 |
%%% <[email protected]>, 09 Dec 1992 [2.2]. |
| 159 |
%%% Introduce \epsfshow{true,false} and |
| 160 |
%%% \epsfframe{true,false} macros; the latter |
| 161 |
%%% suppresses the insertion of the PostScript, |
| 162 |
%%% and instead just creates an empty box, |
| 163 |
%%% which may be handy for rapid prototyping. |
| 164 |
%%% |
| 165 |
%%% --------------------------------------------- |
| 166 |
%%% Revised by Nelson H. F. Beebe |
| 167 |
%%% <[email protected]>, 14 Dec 1992 [2.3]. |
| 168 |
%%% Add \epsfshowfilename{true,false}. When |
| 169 |
%%% true, and \epsfshowfalse is specified, the |
| 170 |
%%% PostScript file name will be displayed |
| 171 |
%%% centered in the figure box. |
| 172 |
%%% |
| 173 |
%%% --------------------------------------------- |
| 174 |
%%% Revised by Nelson H. F. Beebe |
| 175 |
%%% <[email protected]>, 20 June 1993 [2.4]. |
| 176 |
%%% Remove non-zero debug setting of \epsfframemargin, |
| 177 |
%%% and change margin handling to preserve EPS image |
| 178 |
%%% size and aspect ratio, so that the actual |
| 179 |
%%% box is \epsfxsize+\epsfframemargin wide by |
| 180 |
%%% \epsfysize+\epsfframemargin high. |
| 181 |
%%% Reduce output of \epsfshowfilenametrue to |
| 182 |
%%% just the bare file name. |
| 183 |
%%% |
| 184 |
%%% --------------------------------------------- |
| 185 |
%%% Revised by Nelson H. F. Beebe |
| 186 |
%%% <[email protected]>, 13 July 1993 [2.5]. |
| 187 |
%%% Add \epsfframethickness for control of |
| 188 |
%%% \epsfframe frame lines. |
| 189 |
%%% |
| 190 |
%%% --------------------------------------------- |
| 191 |
%%% Revised by Nelson H. F. Beebe |
| 192 |
%%% <[email protected]>, 02 July 1996 [2.6] |
| 193 |
%%% Add missing initialization \epsfatendfalse; |
| 194 |
%%% the lack of this resulted in the wrong |
| 195 |
%%% BoundingBox being picked up, mea culpa, sigh... |
| 196 |
%%% |
| 197 |
%%% --------------------------------------------- |
| 198 |
%%% Revised by Nelson H. F. Beebe |
| 199 |
%%% <[email protected]>, 25 October 1996 [2.7] |
| 200 |
%%% Update to match changes in from dvips 5-600 |
| 201 |
%%% distribution: new user-accessible macros: |
| 202 |
%%% \epsfclipon, \epsfclipoff, \epsfdrafton, |
| 203 |
%%% \epsfdraftoff, change \empty to \epsfempty. |
| 204 |
%%% |
| 205 |
%%% --------------------------------------------- |
| 206 |
%%% Revised by Nelson H. F. Beebe |
| 207 |
%%% <[email protected]>, 18 May 2002 [2.7.1] |
| 208 |
%%% Add write statements to echo input file |
| 209 |
%%% names. Prior to that change, an error in |
| 210 |
%%% such a file could be quite hard to track |
| 211 |
%%% down: a long list of TeX page numbers could |
| 212 |
%%% suddenly be followed by ``TeX buffer |
| 213 |
%%% capacity'' exceeded, without any indication |
| 214 |
%%% of the file that was responsible. |
| 215 |
%%% |
| 216 |
%%% --------------------------------------------- |
| 217 |
%%% Revised by Nelson H. F. Beebe |
| 218 |
%%% <[email protected]>, 16 May 2003 [2.7.2] |
| 219 |
%%% Supply two critical percent characters that |
| 220 |
%%% were mistakenly omitted in version 2.7.1, |
| 221 |
%%% and resulted in a small amount of spurious |
| 222 |
%%% horizontal space. |
| 223 |
%%% |
| 224 |
%%% --------------------------------------------- |
| 225 |
%%% Revised by Nelson H. F. Beebe |
| 226 |
%%% <[email protected]>, 14 Feb 2011 [2.7.3] |
| 227 |
%%% Add previously-missing \space in rwi |
| 228 |
%%% assignments (bug reported 14-Feb-2011 by |
| 229 |
%%% Stefan Rueger <[email protected]>). |
| 230 |
%%% |
| 231 |
%%% --------------------------------------------- |
| 232 |
%%% Revised by Nelson H. F. Beebe |
| 233 |
%%% <[email protected]>, Karl Berry |
| 234 |
%%% <[email protected]>, and Robin Fairbairns |
| 235 |
%%% <[email protected]>, |
| 236 |
%%% 23 July 2005 [2.7.3] |
| 237 |
%%% Add critical \hbox{} wrapper in \epsfsetgraph |
| 238 |
%%% so that \epsfbox{} does not conflict with |
| 239 |
%%% LaTeX center environment when \epsfbox{} is |
| 240 |
%%% surrounded by other horizonal objects. |
| 241 |
%%% Improve macro readability by adding legal, |
| 242 |
%%% but invisible-in-typeset-output, spaces. |
| 243 |
%%% Ensure that verbose status reports come |
| 244 |
%%% inside (filename ...) list. |
| 245 |
%%% |
| 246 |
%%% --------------------------------------------- |
| 247 |
%%% The checksum field above contains a CRC-16 |
| 248 |
%%% checksum as the first value, followed by |
| 249 |
%%% the equivalent of the standard UNIX wc |
| 250 |
%%% (word count) utility output of lines, |
| 251 |
%%% words, and characters. This is produced by |
| 252 |
%%% Robert Solovay's checksum utility.", |
| 253 |
%%% } |
| 254 |
%%% ==================================================================== |
| 255 |
|
| 256 |
%\immediate \write16 {This is `epsf.tex' v2.0 <02 Dec 1991>}% |
| 257 |
%\immediate \write16 {This is `epsf.tex' v2.1 <05 May 1992>}% |
| 258 |
%\immediate \write16 {This is `epsf.tex' v2.2 <09 Dec 1992>}% |
| 259 |
%\immediate \write16 {This is `epsf.tex' v2.3 <14 Dec 1992>}% |
| 260 |
%\immediate \write16 {This is `epsf.tex' v2.4 <20 June 1993>}% |
| 261 |
%\immediate \write16 {This is `epsf.tex' v2.5 <13 July 1993>}% |
| 262 |
%\immediate \write16 {This is `epsf.tex' v2.6 <02 July 1996>}% |
| 263 |
%\immediate \write16 {This is `epsf.tex' v2.7 <25 October 1996>}% |
| 264 |
%\immediate \write16 {This is `epsf.tex' v2.7.1 <18 May 2002>}% |
| 265 |
%\immediate \write16 {This is `epsf.tex' v2.7.2 <16 May 2003>}% |
| 266 |
%\immediate \write16 {This is `epsf.tex' v2.7.3 <23 July 2005>}% |
| 267 |
\immediate \write16 {This is `epsf.tex' v2.7.4 <14 February 2011>}% |
| 268 |
% |
| 269 |
\newread \epsffilein % file to \read |
| 270 |
\newif \ifepsfatend % need to scan to LAST %%BoundingBox comment? |
| 271 |
\newif \ifepsfbbfound % success? |
| 272 |
\newif \ifepsfdraft % use draft mode? |
| 273 |
\newif \ifepsffileok % continue looking for the bounding box? |
| 274 |
\newif \ifepsfframe % frame the bounding box? |
| 275 |
\newif \ifepsfshow % show PostScript file, or just bounding box? |
| 276 |
\epsfshowtrue % default is to display PostScript file |
| 277 |
\newif \ifepsfshowfilename % show the file name if \epsfshowfalse specified? |
| 278 |
\newif \ifepsfverbose % report what you're making? |
| 279 |
\newdimen \epsfframemargin % margin between box and frame |
| 280 |
\newdimen \epsfframethickness % thickness of frame rules |
| 281 |
\newdimen \epsfrsize % vertical size before scaling |
| 282 |
\newdimen \epsftmp % register for arithmetic manipulation |
| 283 |
\newdimen \epsftsize % horizontal size before scaling |
| 284 |
\newdimen \epsfxsize % horizontal size after scaling |
| 285 |
\newdimen \epsfysize % vertical size after scaling |
| 286 |
\newdimen \pspoints % conversion factor |
| 287 |
% |
| 288 |
\pspoints = 1bp % Adobe points are `big' |
| 289 |
\epsfxsize = 0pt % default value, means `use natural size' |
| 290 |
\epsfysize = 0pt % ditto |
| 291 |
\epsfframemargin = 0pt % default value: frame box flush around picture |
| 292 |
\epsfframethickness = 0.4pt % TeX's default rule thickness |
| 293 |
% |
| 294 |
\def \epsfbox #1{% |
| 295 |
\global \def \epsfllx {72}% |
| 296 |
\global \def \epsflly {72}% |
| 297 |
\global \def \epsfurx {540}% |
| 298 |
\global \def \epsfury {720}% |
| 299 |
\def \lbracket {[}% |
| 300 |
\def \testit {#1}% |
| 301 |
\ifx \testit \lbracket |
| 302 |
\let \next = \epsfgetlitbb |
| 303 |
\else |
| 304 |
\let \next = \epsfnormal |
| 305 |
\fi |
| 306 |
\next{#1}% |
| 307 |
}% |
| 308 |
% |
| 309 |
% We use \epsfgetlitbb if the user specified an explicit bounding box, |
| 310 |
% and \epsfnormal otherwise. Because \epsfgetbb can be called |
| 311 |
% separately to retrieve the bounding box, we move the verbose |
| 312 |
% printing the bounding box extents and size on the terminal to |
| 313 |
% \epsfstatus. Therefore, when the user provided the bounding box, |
| 314 |
% \epsfgetbb will not be called, so we must call \epsfsetsize and |
| 315 |
% \epsfstatus ourselves. |
| 316 |
% |
| 317 |
\def \epsfgetlitbb #1#2 #3 #4 #5]#6{% |
| 318 |
\epsfgrab #2 #3 #4 #5 .\\% |
| 319 |
\epsfsetsize |
| 320 |
\epsfstatus{#6}% |
| 321 |
\epsfsetgraph{#6}% |
| 322 |
}% |
| 323 |
% |
| 324 |
\def \epsfnormal #1{% |
| 325 |
\epsfgetbb{#1}% |
| 326 |
\epsfsetgraph{#1}% |
| 327 |
}% |
| 328 |
% |
| 329 |
\def \epsfgetbb #1{% |
| 330 |
% |
| 331 |
% The first thing we need to do is to open the |
| 332 |
% PostScript file, if possible. |
| 333 |
% |
| 334 |
\openin\epsffilein=#1 |
| 335 |
\immediate \write16 {(#1}% |
| 336 |
\ifeof \epsffilein |
| 337 |
\errmessage{Could not open file #1, ignoring it}% |
| 338 |
\else %process the file |
| 339 |
{% %start a group to contain catcode changes |
| 340 |
% Make all special characters, except space, to be of type |
| 341 |
% `other' so we process the file in almost verbatim mode |
| 342 |
% (TeXbook, p. 344). |
| 343 |
\chardef \other = 12% |
| 344 |
\def \do ##1{\catcode`##1=\other}% |
| 345 |
\dospecials |
| 346 |
\catcode `\ = 10% |
| 347 |
\epsffileoktrue %true while we are looping |
| 348 |
\epsfatendfalse %[02-Jul-1996]: add forgotten initialization |
| 349 |
\loop %reading lines from the EPS file |
| 350 |
\read \epsffilein to \epsffileline |
| 351 |
\ifeof \epsffilein %then no more input |
| 352 |
\epsffileokfalse %so set completion flag |
| 353 |
\else %otherwise process one line |
| 354 |
\expandafter \epsfaux \epsffileline :. \\% |
| 355 |
\fi |
| 356 |
\ifepsffileok |
| 357 |
\repeat |
| 358 |
\ifepsfbbfound |
| 359 |
\else |
| 360 |
\ifepsfverbose |
| 361 |
\immediate \write16 {No BoundingBox comment found in % |
| 362 |
file #1; using defaults}% |
| 363 |
\fi |
| 364 |
\fi |
| 365 |
}% %end catcode changes |
| 366 |
\closein\epsffilein |
| 367 |
\fi %end of file processing |
| 368 |
\epsfsetsize %compute size parameters |
| 369 |
\epsfstatus{#1}% |
| 370 |
\immediate \write16 {)}% |
| 371 |
}% |
| 372 |
% |
| 373 |
% Clipping control: |
| 374 |
\def \epsfclipon {\def \epsfclipstring { clip}}% |
| 375 |
\def \epsfclipoff {\def \epsfclipstring {\ifepsfdraft \space clip\fi}}% |
| 376 |
\epsfclipoff % default for dvips is OFF |
| 377 |
% |
| 378 |
% The special that is emitted by \epsfsetgraph comes from this macro. |
| 379 |
% It is defined separately to allow easy customization by other |
| 380 |
% packages that first \input epsf.tex, then redefine \epsfspecial. |
| 381 |
% This macro is invoked in the lower-left corner of a box of the |
| 382 |
% width and height determined from the arguments to \epsffile, or |
| 383 |
% from the %%BoundingBox in the EPS file itself. |
| 384 |
% |
| 385 |
% This version is for dvips: |
| 386 |
\def \epsfspecial #1{% |
| 387 |
\epsftmp=10\epsfxsize |
| 388 |
\divide \epsftmp by \pspoints |
| 389 |
\ifnum \epsfrsize = 0% |
| 390 |
\relax |
| 391 |
\special{PSfile=\ifepsfdraft psdraft.ps\else#1\fi\space |
| 392 |
llx=\epsfllx\space |
| 393 |
lly=\epsflly\space |
| 394 |
urx=\epsfurx\space |
| 395 |
ury=\epsfury\space |
| 396 |
rwi=\number\epsftmp\space |
| 397 |
\epsfclipstring |
| 398 |
}% |
| 399 |
\else |
| 400 |
\epsfrsize=10\epsfysize |
| 401 |
\divide \epsfrsize by \pspoints |
| 402 |
\special{PSfile=\ifepsfdraft psdraft.ps\else#1\fi\space |
| 403 |
llx=\epsfllx\space |
| 404 |
lly=\epsflly\space |
| 405 |
urx=\epsfurx\space |
| 406 |
ury=\epsfury\space |
| 407 |
rwi=\number\epsftmp\space |
| 408 |
rhi=\number\epsfrsize |
| 409 |
\epsfclipstring |
| 410 |
}% |
| 411 |
\fi |
| 412 |
}% |
| 413 |
% |
| 414 |
% \epsfframe macro adapted from the TeXbook, exercise 21.3, p. 223, 331. |
| 415 |
% but modified to set the box width to the natural width, rather |
| 416 |
% than the line width, and to include space for margins and rules |
| 417 |
\def \epsfframe #1% |
| 418 |
{% |
| 419 |
% method for detecting latex suggested by Robin Fairbairns, May 2005. |
| 420 |
\ifx \documentstyle \epsfundefined |
| 421 |
\relax |
| 422 |
\else |
| 423 |
% \leavevmode % so we can put this inside |
| 424 |
% a latex centered environment |
| 425 |
% The \leavevmode breaks under plain when this is inside a box, |
| 426 |
% because it forces the figure to be the entire \hsize. On the |
| 427 |
% other hand, we need the \leavevmode for it to work in LaTeX, |
| 428 |
% because the {center} environment works by adjusting TeX's |
| 429 |
% paragraph parameters. |
| 430 |
% |
| 431 |
% Compare the LaTeX sequence |
| 432 |
% \begin{center} |
| 433 |
% \epsfbox{tip.eps}q |
| 434 |
% \end{center} |
| 435 |
% (needs the \leavevmode to put the q right next to the image) |
| 436 |
% |
| 437 |
% with the plain TeX sequence: |
| 438 |
% \leftline{\vbox{\epsfbox{tip.eps}}q} |
| 439 |
% (had the q all the way over to the right, when \leavevmode was used) |
| 440 |
\fi |
| 441 |
% |
| 442 |
\setbox0 = \hbox{#1}% |
| 443 |
\dimen0 = \wd0 % natural width of argument |
| 444 |
\advance \dimen0 by 2\epsfframemargin % plus width of 2 margins |
| 445 |
\advance \dimen0 by 2\epsfframethickness % plus width of 2 rule lines |
| 446 |
\relax |
| 447 |
\hbox{% |
| 448 |
\vbox |
| 449 |
{% |
| 450 |
\hrule height \epsfframethickness depth 0pt |
| 451 |
\hbox to \dimen0 |
| 452 |
{% |
| 453 |
\hss |
| 454 |
\vrule width \epsfframethickness |
| 455 |
\kern \epsfframemargin |
| 456 |
\vbox {\kern \epsfframemargin \box0 \kern \epsfframemargin }% |
| 457 |
\kern \epsfframemargin |
| 458 |
\vrule width \epsfframethickness |
| 459 |
\hss |
| 460 |
}% end hbox |
| 461 |
\hrule height 0pt depth \epsfframethickness |
| 462 |
}% end vbox |
| 463 |
}% end hbox |
| 464 |
\relax |
| 465 |
}% |
| 466 |
% |
| 467 |
\def \epsfsetgraph #1% |
| 468 |
{% |
| 469 |
% |
| 470 |
% Make the vbox and stick in a \special that the DVI driver can |
| 471 |
% parse. \vfil and \hfil are used to place the \special origin at |
| 472 |
% the lower-left corner of the vbox. \epsfspecial can be redefined |
| 473 |
% to produce alternate \special syntaxes. |
| 474 |
% |
| 475 |
\ifvmode \leavevmode \fi |
| 476 |
\relax |
| 477 |
\hbox{% so we can put this in \begin{center}...\end{center} |
| 478 |
\ifepsfframe \expandafter \epsfframe \fi |
| 479 |
{\vbox to\epsfysize |
| 480 |
{% |
| 481 |
\ifepsfshow |
| 482 |
% output \special{} at lower-left corner of figure box |
| 483 |
\vfil |
| 484 |
\hbox to \epsfxsize{\epsfspecial{#1}\hfil}% |
| 485 |
\else |
| 486 |
\vfil |
| 487 |
\hbox to\epsfxsize{% |
| 488 |
\hss |
| 489 |
\ifepsfshowfilename |
| 490 |
{% |
| 491 |
\epsfframemargin=3pt % local change of margin |
| 492 |
\epsfframe{{\tt #1}}% |
| 493 |
}% |
| 494 |
\fi |
| 495 |
\hss |
| 496 |
}% |
| 497 |
\vfil |
| 498 |
\fi |
| 499 |
}% |
| 500 |
}}% |
| 501 |
\relax |
| 502 |
% |
| 503 |
% Reset \epsfxsize and \epsfysize, as documented above. |
| 504 |
% |
| 505 |
\global \epsfxsize = 0pt |
| 506 |
\global \epsfysize = 0pt |
| 507 |
}% |
| 508 |
% |
| 509 |
% Now we have to calculate the scale and offset values to use. |
| 510 |
% First we compute the natural sizes. |
| 511 |
% |
| 512 |
\def \epsfsetsize |
| 513 |
{% |
| 514 |
\epsfrsize = \epsfury \pspoints |
| 515 |
\advance \epsfrsize by -\epsflly \pspoints |
| 516 |
\epsftsize = \epsfurx \pspoints |
| 517 |
\advance \epsftsize by -\epsfllx \pspoints |
| 518 |
% |
| 519 |
% If `epsfxsize' is 0, we default to the natural size of the picture. |
| 520 |
% Otherwise we scale the graph to be \epsfxsize wide. |
| 521 |
% |
| 522 |
\epsfxsize = \epsfsize{\epsftsize}{\epsfrsize}% |
| 523 |
\ifnum \epsfxsize = 0 |
| 524 |
\ifnum \epsfysize = 0 |
| 525 |
\epsfxsize = \epsftsize |
| 526 |
\epsfysize = \epsfrsize |
| 527 |
\epsfrsize = 0pt |
| 528 |
% |
| 529 |
% We have a sticky problem here: TeX doesn't do floating point arithmetic! |
| 530 |
% Our goal is to compute y = rx/t. The following loop does this reasonably |
| 531 |
% fast, with an error of at most about 16 sp (about 1/4000 pt). |
| 532 |
% |
| 533 |
\else |
| 534 |
\epsftmp = \epsftsize |
| 535 |
\divide \epsftmp by \epsfrsize |
| 536 |
\epsfxsize = \epsfysize |
| 537 |
\multiply \epsfxsize by \epsftmp |
| 538 |
\multiply \epsftmp by \epsfrsize |
| 539 |
\advance \epsftsize by -\epsftmp |
| 540 |
\epsftmp = \epsfysize |
| 541 |
\loop |
| 542 |
\advance \epsftsize by \epsftsize |
| 543 |
\divide \epsftmp by 2 |
| 544 |
\ifnum \epsftmp > 0 |
| 545 |
\ifnum \epsftsize < \epsfrsize |
| 546 |
\else |
| 547 |
\advance \epsftsize -\epsfrsize |
| 548 |
\advance \epsfxsize \epsftmp |
| 549 |
\fi |
| 550 |
\repeat |
| 551 |
\epsfrsize = 0pt |
| 552 |
\fi |
| 553 |
\else |
| 554 |
\ifnum \epsfysize = 0 |
| 555 |
\epsftmp = \epsfrsize |
| 556 |
\divide \epsftmp by \epsftsize |
| 557 |
\epsfysize = \epsfxsize |
| 558 |
\multiply \epsfysize by \epsftmp |
| 559 |
\multiply \epsftmp by \epsftsize |
| 560 |
\advance \epsfrsize by -\epsftmp |
| 561 |
\epsftmp = \epsfxsize |
| 562 |
\loop |
| 563 |
\advance \epsfrsize by \epsfrsize |
| 564 |
\divide \epsftmp by 2 |
| 565 |
\ifnum \epsftmp > 0 |
| 566 |
\ifnum \epsfrsize < \epsftsize |
| 567 |
\else |
| 568 |
\advance \epsfrsize by -\epsftsize |
| 569 |
\advance \epsfysize by \epsftmp |
| 570 |
\fi |
| 571 |
\repeat |
| 572 |
\epsfrsize = 0pt |
| 573 |
\else |
| 574 |
\epsfrsize = \epsfysize |
| 575 |
\fi |
| 576 |
\fi |
| 577 |
}% |
| 578 |
% |
| 579 |
% Issue some status messages if the user requested them |
| 580 |
% |
| 581 |
\def \epsfstatus #1{% arg = filename |
| 582 |
\ifepsfverbose |
| 583 |
\immediate \write16 {#1: BoundingBox: |
| 584 |
llx = \epsfllx \space lly = \epsflly \space |
| 585 |
urx = \epsfurx \space ury = \epsfury \space}% |
| 586 |
\immediate \write16 {#1: scaled width = \the\epsfxsize \space |
| 587 |
scaled height = \the\epsfysize}% |
| 588 |
\fi |
| 589 |
}% |
| 590 |
% |
| 591 |
% We still need to define the tricky \epsfaux macro. This requires |
| 592 |
% a couple of magic constants for comparison purposes. |
| 593 |
% |
| 594 |
{\catcode`\%=12 \global \let \epsfpercent=%\global \def \epsfbblit {%BoundingBox}}% |
| 595 |
\global \def \epsfatend{(atend)}% |
| 596 |
% |
| 597 |
% So we're ready to check for `%BoundingBox:' and to grab the |
| 598 |
% values if they are found. |
| 599 |
% |
| 600 |
% If we find a line |
| 601 |
% |
| 602 |
% %%BoundingBox: (atend) |
| 603 |
% |
| 604 |
% then we ignore it, but set a flag to force parsing all of the |
| 605 |
% file, so the last %%BoundingBox parsed will be the one used. This |
| 606 |
% is necessary, because EPS files can themselves contain other EPS |
| 607 |
% files with their own %%BoundingBox comments. |
| 608 |
% |
| 609 |
% If we find a line |
| 610 |
% |
| 611 |
% %%BoundingBox: llx lly urx ury |
| 612 |
% |
| 613 |
% then we save the 4 values in \epsfllx, \epsflly, \epsfurx, \epsfury. |
| 614 |
% Then, if we have not previously parsed an (atend), we flag completion |
| 615 |
% and can stop reading the file. Otherwise, we must keep on reading |
| 616 |
% to end of file so that we find the values on the LAST %%BoundingBox. |
| 617 |
\long \def \epsfaux#1#2:#3\\% |
| 618 |
{% |
| 619 |
\def \testit {#2}% % save second character up to just before colon |
| 620 |
\ifx#1\epsfpercent % then first char is percent (quick test) |
| 621 |
\ifx \testit \epsfbblit % then (slow test) we have %%BoundingBox |
| 622 |
\epsfgrab #3 . . . \\% |
| 623 |
\ifx \epsfllx\epsfatend % then ignore %%BoundingBox: (atend) |
| 624 |
\global \epsfatendtrue |
| 625 |
\else % else found %%BoundingBox: llx lly urx ury |
| 626 |
\ifepsfatend % then keep parsing ALL %%BoundingBox lines |
| 627 |
\else % else stop after first one parsed |
| 628 |
\epsffileokfalse |
| 629 |
\fi |
| 630 |
\global \epsfbbfoundtrue |
| 631 |
\fi |
| 632 |
\fi |
| 633 |
\fi |
| 634 |
}% |
| 635 |
% |
| 636 |
% Here we grab the values and stuff them in the appropriate definitions. |
| 637 |
% |
| 638 |
\def \epsfempty {}% |
| 639 |
\def \epsfgrab #1 #2 #3 #4 #5\\{% |
| 640 |
\global \def \epsfllx {#1}\ifx \epsfllx\epsfempty |
| 641 |
\epsfgrab #2 #3 #4 #5 .\\\else |
| 642 |
\global \def \epsflly {#2}% |
| 643 |
\global \def \epsfurx {#3}\global \def \epsfury {#4}\fi |
| 644 |
}% |
| 645 |
% |
| 646 |
% We default the epsfsize macro. |
| 647 |
% |
| 648 |
\def \epsfsize #1#2{\epsfxsize}% |
| 649 |
% |
| 650 |
% Finally, another definition for compatibility with older macros. |
| 651 |
% |
| 652 |
\let \epsffile = \epsfbox |
| 653 |
\endinput |