| 1 |
% Psfig/TeX |
| 2 |
\def\PsfigVersion{1.9} |
| 3 |
% dvips version |
| 4 |
% |
| 5 |
% All psfig/tex software, documentation, and related files |
| 6 |
% in this distribution of psfig/tex are |
| 7 |
% Copyright 1987, 1988, 1991 Trevor J. Darrell |
| 8 |
% |
| 9 |
% Permission is granted for use and non-profit distribution of psfig/tex |
| 10 |
% providing that this notice is clearly maintained. The right to |
| 11 |
% distribute any portion of psfig/tex for profit or as part of any commercial |
| 12 |
% product is specifically reserved for the author(s) of that portion. |
| 13 |
% |
| 14 |
% *** Feel free to make local modifications of psfig as you wish, |
| 15 |
% *** but DO NOT post any changed or modified versions of ``psfig'' |
| 16 |
% *** directly to the net. Send them to me and I'll try to incorporate |
| 17 |
% *** them into future versions. If you want to take the psfig code |
| 18 |
% *** and make a new program (subject to the copyright above), distribute it, |
| 19 |
% *** (and maintain it) that's fine, just don't call it psfig. |
| 20 |
% |
| 21 |
% Bugs and improvements to [email protected]. |
| 22 |
% |
| 23 |
% Thanks to Greg Hager (GDH) and Ned Batchelder for their contributions |
| 24 |
% to the original version of this project. |
| 25 |
% |
| 26 |
% Modified by J. Daniel Smith on 9 October 1990 to accept the |
| 27 |
% %%BoundingBox: comment with or without a space after the colon. Stole |
| 28 |
% file reading code from Tom Rokicki's EPSF.TEX file (see below). |
| 29 |
% |
| 30 |
% More modifications by J. Daniel Smith on 29 March 1991 to allow the |
| 31 |
% the included PostScript figure to be rotated. The amount of |
| 32 |
% rotation is specified by the "angle=" parameter of the \psfig command. |
| 33 |
% |
| 34 |
% Modified by Robert Russell on June 25, 1991 to allow users to specify |
| 35 |
% .ps filenames which don't yet exist, provided they explicitly provide |
| 36 |
% boundingbox information via the \psfig command. Note: This will only work |
| 37 |
% if the "file=" parameter follows all four "bb???=" parameters in the |
| 38 |
% command. This is due to the order in which psfig interprets these params. |
| 39 |
% |
| 40 |
% 3 Jul 1991 JDS check if file already read in once |
| 41 |
% 4 Sep 1991 JDS fixed incorrect computation of rotated |
| 42 |
% bounding box |
| 43 |
% 25 Sep 1991 GVR expanded synopsis of \psfig |
| 44 |
% 14 Oct 1991 JDS \fbox code from LaTeX so \psdraft works with TeX |
| 45 |
% changed \typeout to \ps@typeout |
| 46 |
% 17 Oct 1991 JDS added \psscalefirst and \psrotatefirst |
| 47 |
% |
| 48 |
|
| 49 |
% From: [email protected] (George V. Reilly) |
| 50 |
% |
| 51 |
% \psdraft draws an outline box, but doesn't include the figure |
| 52 |
% in the DVI file. Useful for previewing. |
| 53 |
% |
| 54 |
% \psfull includes the figure in the DVI file (default). |
| 55 |
% |
| 56 |
% \psscalefirst width= or height= specifies the size of the figure |
| 57 |
% before rotation. |
| 58 |
% \psrotatefirst (default) width= or height= specifies the size of the |
| 59 |
% figure after rotation. Asymetric figures will |
| 60 |
% appear to shrink. |
| 61 |
% |
| 62 |
% \psfigurepath#1 sets the path to search for the figure |
| 63 |
% |
| 64 |
% \psfig |
| 65 |
% usage: \psfig{file=, figure=, height=, width=, |
| 66 |
% bbllx=, bblly=, bburx=, bbury=, |
| 67 |
% rheight=, rwidth=, clip=, angle=, silent=} |
| 68 |
% |
| 69 |
% "file" is the filename. If no path name is specified and the |
| 70 |
% file is not found in the current directory, |
| 71 |
% it will be looked for in directory \psfigurepath. |
| 72 |
% "figure" is a synonym for "file". |
| 73 |
% By default, the width and height of the figure are taken from |
| 74 |
% the BoundingBox of the figure. |
| 75 |
% If "width" is specified, the figure is scaled so that it has |
| 76 |
% the specified width. Its height changes proportionately. |
| 77 |
% If "height" is specified, the figure is scaled so that it has |
| 78 |
% the specified height. Its width changes proportionately. |
| 79 |
% If both "width" and "height" are specified, the figure is scaled |
| 80 |
% anamorphically. |
| 81 |
% "bbllx", "bblly", "bburx", and "bbury" control the PostScript |
| 82 |
% BoundingBox. If these four values are specified |
| 83 |
% *before* the "file" option, the PSFIG will not try to |
| 84 |
% open the PostScript file. |
| 85 |
% "rheight" and "rwidth" are the reserved height and width |
| 86 |
% of the figure, i.e., how big TeX actually thinks |
| 87 |
% the figure is. They default to "width" and "height". |
| 88 |
% The "clip" option ensures that no portion of the figure will |
| 89 |
% appear outside its BoundingBox. "clip=" is a switch and |
| 90 |
% takes no value, but the `=' must be present. |
| 91 |
% The "angle" option specifies the angle of rotation (degrees, ccw). |
| 92 |
% The "silent" option makes \psfig work silently. |
| 93 |
% |
| 94 |
|
| 95 |
% check to see if macros already loaded in (maybe some other file says |
| 96 |
% "\input psfig") ... |
| 97 |
\ifx\undefined\psfig\else\endinput\fi |
| 98 |
|
| 99 |
% |
| 100 |
% from a suggestion by [email protected] to allow |
| 101 |
% loading as a style file. Changed to avoid problems |
| 102 |
% with amstex per suggestion by [email protected] |
| 103 |
|
| 104 |
\let\LaTeXAtSign=\@ |
| 105 |
\let\@=\relax |
| 106 |
\edef\psfigRestoreAt{\catcode`\@=\number\catcode`@\relax} |
| 107 |
%\edef\psfigRestoreAt{\catcode`@=\number\catcode`@\relax} |
| 108 |
\catcode`\@=11\relax |
| 109 |
\newwrite\@unused |
| 110 |
\def\ps@typeout#1{{\let\protect\string\immediate\write\@unused{#1}}} |
| 111 |
%\ps@typeout{psfig/tex \PsfigVersion} |
| 112 |
|
| 113 |
%% Here's how you define your figure path. Should be set up with null |
| 114 |
%% default and a user useable definition. |
| 115 |
|
| 116 |
\def\figurepath{./} |
| 117 |
\def\psfigurepath#1{\edef\figurepath{#1}} |
| 118 |
|
| 119 |
% |
| 120 |
% @psdo control structure -- similar to Latex @for. |
| 121 |
% I redefined these with different names so that psfig can |
| 122 |
% be used with TeX as well as LaTeX, and so that it will not |
| 123 |
% be vunerable to future changes in LaTeX's internal |
| 124 |
% control structure, |
| 125 |
% |
| 126 |
\def\@nnil{\@nil} |
| 127 |
\def\@empty{} |
| 128 |
\def\@psdonoop#1\@@#2#3{} |
| 129 |
\def\@psdo#1:=#2\do#3{\edef\@psdotmp{#2}\ifx\@psdotmp\@empty \else |
| 130 |
\expandafter\@psdoloop#2,\@nil,\@nil\@@#1{#3}\fi} |
| 131 |
\def\@psdoloop#1,#2,#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else |
| 132 |
#5\def#4{#2}\ifx #4\@nnil \else#5\@ipsdoloop #3\@@#4{#5}\fi\fi} |
| 133 |
\def\@ipsdoloop#1,#2\@@#3#4{\def#3{#1}\ifx #3\@nnil |
| 134 |
\let\@nextwhile=\@psdonoop \else |
| 135 |
#4\relax\let\@nextwhile=\@ipsdoloop\fi\@nextwhile#2\@@#3{#4}} |
| 136 |
\def\@tpsdo#1:=#2\do#3{\xdef\@psdotmp{#2}\ifx\@psdotmp\@empty \else |
| 137 |
\@tpsdoloop#2\@nil\@nil\@@#1{#3}\fi} |
| 138 |
\def\@tpsdoloop#1#2\@@#3#4{\def#3{#1}\ifx #3\@nnil |
| 139 |
\let\@nextwhile=\@psdonoop \else |
| 140 |
#4\relax\let\@nextwhile=\@tpsdoloop\fi\@nextwhile#2\@@#3{#4}} |
| 141 |
% |
| 142 |
% \fbox is defined in latex.tex; so if \fbox is undefined, assume that |
| 143 |
% we are not in LaTeX. |
| 144 |
% Perhaps this could be done better??? |
| 145 |
\ifx\undefined\fbox |
| 146 |
% \fbox code from modified slightly from LaTeX |
| 147 |
\newdimen\fboxrule |
| 148 |
\newdimen\fboxsep |
| 149 |
\newdimen\ps@tempdima |
| 150 |
\newbox\ps@tempboxa |
| 151 |
\fboxsep = 3pt |
| 152 |
\fboxrule = .4pt |
| 153 |
\long\def\fbox#1{\leavevmode\setbox\ps@tempboxa\hbox{#1}\ps@tempdima\fboxrule |
| 154 |
\advance\ps@tempdima \fboxsep \advance\ps@tempdima \dp\ps@tempboxa |
| 155 |
\hbox{\lower \ps@tempdima\hbox |
| 156 |
{\vbox{\hrule height \fboxrule |
| 157 |
\hbox{\vrule width \fboxrule \hskip\fboxsep |
| 158 |
\vbox{\vskip\fboxsep \box\ps@tempboxa\vskip\fboxsep}\hskip |
| 159 |
\fboxsep\vrule width \fboxrule} |
| 160 |
\hrule height \fboxrule}}}} |
| 161 |
\fi |
| 162 |
% |
| 163 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 164 |
% file reading stuff from epsf.tex |
| 165 |
% EPSF.TEX macro file: |
| 166 |
% Written by Tomas Rokicki of Radical Eye Software, 29 Mar 1989. |
| 167 |
% Revised by Don Knuth, 3 Jan 1990. |
| 168 |
% Revised by Tomas Rokicki to accept bounding boxes with no |
| 169 |
% space after the colon, 18 Jul 1990. |
| 170 |
% Portions modified/removed for use in PSFIG package by |
| 171 |
% J. Daniel Smith, 9 October 1990. |
| 172 |
% |
| 173 |
\newread\ps@stream |
| 174 |
\newif\ifnot@eof % continue looking for the bounding box? |
| 175 |
\newif\if@noisy % report what you're making? |
| 176 |
\newif\if@atend % %%BoundingBox: has (at end) specification |
| 177 |
\newif\if@psfile % does this look like a PostScript file? |
| 178 |
% |
| 179 |
% PostScript files should start with `%!' |
| 180 |
% |
| 181 |
{\catcode`\%=12\global\gdef\epsf@start{%!}} |
| 182 |
\def\epsf@PS{PS} |
| 183 |
% |
| 184 |
\def\epsf@getbb#1{% |
| 185 |
% |
| 186 |
% The first thing we need to do is to open the |
| 187 |
% PostScript file, if possible. |
| 188 |
% |
| 189 |
\openin\ps@stream=#1 |
| 190 |
\ifeof\ps@stream\ps@typeout{Error, File #1 not found}\else |
| 191 |
% |
| 192 |
% Okay, we got it. Now we'll scan lines until we find one that doesn't |
| 193 |
% start with %. We're looking for the bounding box comment. |
| 194 |
% |
| 195 |
{\not@eoftrue \chardef\other=12 |
| 196 |
\def\do##1{\catcode`##1=\other}\dospecials \catcode`\ =10 |
| 197 |
\loop |
| 198 |
\if@psfile |
| 199 |
\read\ps@stream to \epsf@fileline |
| 200 |
\else{ |
| 201 |
\obeyspaces |
| 202 |
\read\ps@stream to \epsf@tmp\global\let\epsf@fileline\epsf@tmp} |
| 203 |
\fi |
| 204 |
\ifeof\ps@stream\not@eoffalse\else |
| 205 |
% |
| 206 |
% Check the first line for `%!'. Issue a warning message if its not |
| 207 |
% there, since the file might not be a PostScript file. |
| 208 |
% |
| 209 |
\if@psfile\else |
| 210 |
\expandafter\epsf@test\epsf@fileline:. \\% |
| 211 |
\fi |
| 212 |
% |
| 213 |
% We check to see if the first character is a % sign; |
| 214 |
% if so, we look further and stop only if the line begins with |
| 215 |
% `%%BoundingBox:' and the `(atend)' specification was not found. |
| 216 |
% That is, the only way to stop is when the end of file is reached, |
| 217 |
% or a `%%BoundingBox: llx lly urx ury' line is found. |
| 218 |
% |
| 219 |
\expandafter\epsf@aux\epsf@fileline:. \\% |
| 220 |
\fi |
| 221 |
\ifnot@eof\repeat |
| 222 |
}\closein\ps@stream\fi}% |
| 223 |
% |
| 224 |
% This tests if the file we are reading looks like a PostScript file. |
| 225 |
% |
| 226 |
\long\def\epsf@test#1#2#3:#4\\{\def\epsf@testit{#1#2} |
| 227 |
\ifx\epsf@testit\epsf@start\else |
| 228 |
\ps@typeout{Warning! File does not start with `\epsf@start'. It may not be a PostScript file.} |
| 229 |
\fi |
| 230 |
\@psfiletrue} % don't test after 1st line |
| 231 |
% |
| 232 |
% We still need to define the tricky \epsf@aux macro. This requires |
| 233 |
% a couple of magic constants for comparison purposes. |
| 234 |
% |
| 235 |
{\catcode`\%=12\global\let\epsf@percent=%\global\def\epsf@bblit{%BoundingBox}} |
| 236 |
% |
| 237 |
% |
| 238 |
% So we're ready to check for `%BoundingBox:' and to grab the |
| 239 |
% values if they are found. We continue searching if `(at end)' |
| 240 |
% was found after the `%BoundingBox:'. |
| 241 |
% |
| 242 |
\long\def\epsf@aux#1#2:#3\\{\ifx#1\epsf@percent |
| 243 |
\def\epsf@testit{#2}\ifx\epsf@testit\epsf@bblit |
| 244 |
\@atendfalse |
| 245 |
\epsf@atend #3 . \\% |
| 246 |
\if@atend |
| 247 |
\if@verbose{ |
| 248 |
\ps@typeout{psfig: found `(atend)'; continuing search} |
| 249 |
}\fi |
| 250 |
\else |
| 251 |
\epsf@grab #3 . . . \\% |
| 252 |
\not@eoffalse |
| 253 |
\global\no@bbfalse |
| 254 |
\fi |
| 255 |
\fi\fi}% |
| 256 |
% |
| 257 |
% Here we grab the values and stuff them in the appropriate definitions. |
| 258 |
% |
| 259 |
\def\epsf@grab #1 #2 #3 #4 #5\\{% |
| 260 |
\global\def\epsf@llx{#1}\ifx\epsf@llx\empty |
| 261 |
\epsf@grab #2 #3 #4 #5 .\\\else |
| 262 |
\global\def\epsf@lly{#2}% |
| 263 |
\global\def\epsf@urx{#3}\global\def\epsf@ury{#4}\fi}% |
| 264 |
% |
| 265 |
% Determine if the stuff following the %%BoundingBox is `(atend)' |
| 266 |
% J. Daniel Smith. Copied from \epsf@grab above. |
| 267 |
% |
| 268 |
\def\epsf@atendlit{(atend)} |
| 269 |
\def\epsf@atend #1 #2 #3\\{% |
| 270 |
\def\epsf@tmp{#1}\ifx\epsf@tmp\empty |
| 271 |
\epsf@atend #2 #3 .\\\else |
| 272 |
\ifx\epsf@tmp\epsf@atendlit\@atendtrue\fi\fi} |
| 273 |
|
| 274 |
|
| 275 |
% End of file reading stuff from epsf.tex |
| 276 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 277 |
|
| 278 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 279 |
% trigonometry stuff from "trig.tex" |
| 280 |
\chardef\psletter = 11 % won't conflict with \begin{letter} now... |
| 281 |
\chardef\other = 12 |
| 282 |
|
| 283 |
\newif \ifdebug %%% turn me on to see TeX hard at work ... |
| 284 |
\newif\ifc@mpute %%% don't need to compute some values |
| 285 |
\c@mputetrue % but assume that we do |
| 286 |
|
| 287 |
\let\then = \relax |
| 288 |
\def\r@dian{pt } |
| 289 |
\let\r@dians = \r@dian |
| 290 |
\let\dimensionless@nit = \r@dian |
| 291 |
\let\dimensionless@nits = \dimensionless@nit |
| 292 |
\def\internal@nit{sp } |
| 293 |
\let\internal@nits = \internal@nit |
| 294 |
\newif\ifstillc@nverging |
| 295 |
\def \Mess@ge #1{\ifdebug \then \message {#1} \fi} |
| 296 |
|
| 297 |
{ %%% Things that need abnormal catcodes %%% |
| 298 |
\catcode `\@ = \psletter |
| 299 |
\gdef \nodimen {\expandafter \n@dimen \the \dimen} |
| 300 |
\gdef \term #1 #2 #3% |
| 301 |
{\edef \t@ {\the #1}%%% freeze parameter 1 (count, by value) |
| 302 |
\edef \t@@ {\expandafter \n@dimen \the #2\r@dian}% |
| 303 |
%%% freeze parameter 2 (dimen, by value) |
| 304 |
\t@rm {\t@} {\t@@} {#3}% |
| 305 |
} |
| 306 |
\gdef \t@rm #1 #2 #3% |
| 307 |
{{% |
| 308 |
\count 0 = 0 |
| 309 |
\dimen 0 = 1 \dimensionless@nit |
| 310 |
\dimen 2 = #2\relax |
| 311 |
\Mess@ge {Calculating term #1 of \nodimen 2}% |
| 312 |
\loop |
| 313 |
\ifnum \count 0 < #1 |
| 314 |
\then \advance \count 0 by 1 |
| 315 |
\Mess@ge {Iteration \the \count 0 \space}% |
| 316 |
\Multiply \dimen 0 by {\dimen 2}% |
| 317 |
\Mess@ge {After multiplication, term = \nodimen 0}% |
| 318 |
\Divide \dimen 0 by {\count 0}% |
| 319 |
\Mess@ge {After division, term = \nodimen 0}% |
| 320 |
\repeat |
| 321 |
\Mess@ge {Final value for term #1 of |
| 322 |
\nodimen 2 \space is \nodimen 0}% |
| 323 |
\xdef \Term {#3 = \nodimen 0 \r@dians}% |
| 324 |
\aftergroup \Term |
| 325 |
}} |
| 326 |
\catcode `\p = \other |
| 327 |
\catcode `\t = \other |
| 328 |
\gdef \n@dimen #1pt{#1} %%% throw away the ``pt'' |
| 329 |
} |
| 330 |
|
| 331 |
\def \Divide #1by #2{\divide #1 by #2} %%% just a synonym |
| 332 |
|
| 333 |
\def \Multiply #1by #2%%% allows division of a dimen by a dimen |
| 334 |
{{%%% should really freeze parameter 2 (dimen, passed by value) |
| 335 |
\count 0 = #1\relax |
| 336 |
\count 2 = #2\relax |
| 337 |
\count 4 = 65536 |
| 338 |
\Mess@ge {Before scaling, count 0 = \the \count 0 \space and |
| 339 |
count 2 = \the \count 2}% |
| 340 |
\ifnum \count 0 > 32767 %%% do our best to avoid overflow |
| 341 |
\then \divide \count 0 by 4 |
| 342 |
\divide \count 4 by 4 |
| 343 |
\else \ifnum \count 0 < -32767 |
| 344 |
\then \divide \count 0 by 4 |
| 345 |
\divide \count 4 by 4 |
| 346 |
\else |
| 347 |
\fi |
| 348 |
\fi |
| 349 |
\ifnum \count 2 > 32767 %%% while retaining reasonable accuracy |
| 350 |
\then \divide \count 2 by 4 |
| 351 |
\divide \count 4 by 4 |
| 352 |
\else \ifnum \count 2 < -32767 |
| 353 |
\then \divide \count 2 by 4 |
| 354 |
\divide \count 4 by 4 |
| 355 |
\else |
| 356 |
\fi |
| 357 |
\fi |
| 358 |
\multiply \count 0 by \count 2 |
| 359 |
\divide \count 0 by \count 4 |
| 360 |
\xdef \product {#1 = \the \count 0 \internal@nits}% |
| 361 |
\aftergroup \product |
| 362 |
}} |
| 363 |
|
| 364 |
\def\r@duce{\ifdim\dimen0 > 90\r@dian \then % sin(x+90) = sin(180-x) |
| 365 |
\multiply\dimen0 by -1 |
| 366 |
\advance\dimen0 by 180\r@dian |
| 367 |
\r@duce |
| 368 |
\else \ifdim\dimen0 < -90\r@dian \then % sin(-x) = sin(360+x) |
| 369 |
\advance\dimen0 by 360\r@dian |
| 370 |
\r@duce |
| 371 |
\fi |
| 372 |
\fi} |
| 373 |
|
| 374 |
\def\Sine#1% |
| 375 |
{{% |
| 376 |
\dimen 0 = #1 \r@dian |
| 377 |
\r@duce |
| 378 |
\ifdim\dimen0 = -90\r@dian \then |
| 379 |
\dimen4 = -1\r@dian |
| 380 |
\c@mputefalse |
| 381 |
\fi |
| 382 |
\ifdim\dimen0 = 90\r@dian \then |
| 383 |
\dimen4 = 1\r@dian |
| 384 |
\c@mputefalse |
| 385 |
\fi |
| 386 |
\ifdim\dimen0 = 0\r@dian \then |
| 387 |
\dimen4 = 0\r@dian |
| 388 |
\c@mputefalse |
| 389 |
\fi |
| 390 |
% |
| 391 |
\ifc@mpute \then |
| 392 |
% convert degrees to radians |
| 393 |
\divide\dimen0 by 180 |
| 394 |
\dimen0=3.141592654\dimen0 |
| 395 |
% |
| 396 |
\dimen 2 = 3.1415926535897963\r@dian %%% a well-known constant |
| 397 |
\divide\dimen 2 by 2 %%% we only deal with -pi/2 : pi/2 |
| 398 |
\Mess@ge {Sin: calculating Sin of \nodimen 0}% |
| 399 |
\count 0 = 1 %%% see power-series expansion for sine |
| 400 |
\dimen 2 = 1 \r@dian %%% ditto |
| 401 |
\dimen 4 = 0 \r@dian %%% ditto |
| 402 |
\loop |
| 403 |
\ifnum \dimen 2 = 0 %%% then we've done |
| 404 |
\then \stillc@nvergingfalse |
| 405 |
\else \stillc@nvergingtrue |
| 406 |
\fi |
| 407 |
\ifstillc@nverging %%% then calculate next term |
| 408 |
\then \term {\count 0} {\dimen 0} {\dimen 2}% |
| 409 |
\advance \count 0 by 2 |
| 410 |
\count 2 = \count 0 |
| 411 |
\divide \count 2 by 2 |
| 412 |
\ifodd \count 2 %%% signs alternate |
| 413 |
\then \advance \dimen 4 by \dimen 2 |
| 414 |
\else \advance \dimen 4 by -\dimen 2 |
| 415 |
\fi |
| 416 |
\repeat |
| 417 |
\fi |
| 418 |
\xdef \sine {\nodimen 4}% |
| 419 |
}} |
| 420 |
|
| 421 |
% Now the Cosine can be calculated easily by calling \Sine |
| 422 |
\def\Cosine#1{\ifx\sine\UnDefined\edef\Savesine{\relax}\else |
| 423 |
\edef\Savesine{\sine}\fi |
| 424 |
{\dimen0=#1\r@dian\advance\dimen0 by 90\r@dian |
| 425 |
\Sine{\nodimen 0} |
| 426 |
\xdef\cosine{\sine} |
| 427 |
\xdef\sine{\Savesine}}} |
| 428 |
% end of trig stuff |
| 429 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 430 |
|
| 431 |
\def\psdraft{ |
| 432 |
\def\@psdraft{0} |
| 433 |
%\ps@typeout{draft level now is \@psdraft \space . } |
| 434 |
} |
| 435 |
\def\psfull{ |
| 436 |
\def\@psdraft{100} |
| 437 |
%\ps@typeout{draft level now is \@psdraft \space . } |
| 438 |
} |
| 439 |
|
| 440 |
\psfull |
| 441 |
|
| 442 |
\newif\if@scalefirst |
| 443 |
\def\psscalefirst{\@scalefirsttrue} |
| 444 |
\def\psrotatefirst{\@scalefirstfalse} |
| 445 |
\psrotatefirst |
| 446 |
|
| 447 |
\newif\if@draftbox |
| 448 |
\def\psnodraftbox{ |
| 449 |
\@draftboxfalse |
| 450 |
} |
| 451 |
\def\psdraftbox{ |
| 452 |
\@draftboxtrue |
| 453 |
} |
| 454 |
\@draftboxtrue |
| 455 |
|
| 456 |
\newif\if@prologfile |
| 457 |
\newif\if@postlogfile |
| 458 |
\def\pssilent{ |
| 459 |
\@noisyfalse |
| 460 |
} |
| 461 |
\def\psnoisy{ |
| 462 |
\@noisytrue |
| 463 |
} |
| 464 |
\psnoisy |
| 465 |
%%% These are for the option list. |
| 466 |
%%% A specification of the form a = b maps to calling \@p@@sa{b} |
| 467 |
\newif\if@bbllx |
| 468 |
\newif\if@bblly |
| 469 |
\newif\if@bburx |
| 470 |
\newif\if@bbury |
| 471 |
\newif\if@height |
| 472 |
\newif\if@width |
| 473 |
\newif\if@rheight |
| 474 |
\newif\if@rwidth |
| 475 |
\newif\if@angle |
| 476 |
\newif\if@clip |
| 477 |
\newif\if@verbose |
| 478 |
\def\@p@@sclip#1{\@cliptrue} |
| 479 |
|
| 480 |
|
| 481 |
\newif\if@decmpr |
| 482 |
|
| 483 |
%%% GDH 7/26/87 -- changed so that it first looks in the local directory, |
| 484 |
%%% then in a specified global directory for the ps file. |
| 485 |
%%% RPR 6/25/91 -- changed so that it defaults to user-supplied name if |
| 486 |
%%% boundingbox info is specified, assuming graphic will be created by |
| 487 |
%%% print time. |
| 488 |
%%% TJD 10/19/91 -- added bbfile vs. file distinction, and @decmpr flag |
| 489 |
|
| 490 |
\def\@p@@sfigure#1{\def\@p@sfile{null}\def\@p@sbbfile{null} |
| 491 |
\openin1=#1.bb |
| 492 |
\ifeof1\closein1 |
| 493 |
\openin1=\figurepath#1.bb |
| 494 |
\ifeof1\closein1 |
| 495 |
\openin1=#1 |
| 496 |
\ifeof1\closein1% |
| 497 |
\openin1=\figurepath#1 |
| 498 |
\ifeof1 |
| 499 |
\ps@typeout{Error, File #1 not found} |
| 500 |
\if@bbllx\if@bblly |
| 501 |
\if@bburx\if@bbury |
| 502 |
\def\@p@sfile{#1}% |
| 503 |
\def\@p@sbbfile{#1}% |
| 504 |
\@decmprfalse |
| 505 |
\fi\fi\fi\fi |
| 506 |
\else\closein1 |
| 507 |
\def\@p@sfile{\figurepath#1}% |
| 508 |
\def\@p@sbbfile{\figurepath#1}% |
| 509 |
\@decmprfalse |
| 510 |
\fi% |
| 511 |
\else\closein1% |
| 512 |
\def\@p@sfile{#1} |
| 513 |
\def\@p@sbbfile{#1} |
| 514 |
\@decmprfalse |
| 515 |
\fi |
| 516 |
\else |
| 517 |
\def\@p@sfile{\figurepath#1} |
| 518 |
\def\@p@sbbfile{\figurepath#1.bb} |
| 519 |
\@decmprtrue |
| 520 |
\fi |
| 521 |
\else |
| 522 |
\def\@p@sfile{#1} |
| 523 |
\def\@p@sbbfile{#1.bb} |
| 524 |
\@decmprtrue |
| 525 |
\fi} |
| 526 |
|
| 527 |
\def\@p@@sfile#1{\@p@@sfigure{#1}} |
| 528 |
|
| 529 |
\def\@p@@sbbllx#1{ |
| 530 |
%\ps@typeout{bbllx is #1} |
| 531 |
\@bbllxtrue |
| 532 |
\dimen100=#1 |
| 533 |
\edef\@p@sbbllx{\number\dimen100} |
| 534 |
} |
| 535 |
\def\@p@@sbblly#1{ |
| 536 |
%\ps@typeout{bblly is #1} |
| 537 |
\@bbllytrue |
| 538 |
\dimen100=#1 |
| 539 |
\edef\@p@sbblly{\number\dimen100} |
| 540 |
} |
| 541 |
\def\@p@@sbburx#1{ |
| 542 |
%\ps@typeout{bburx is #1} |
| 543 |
\@bburxtrue |
| 544 |
\dimen100=#1 |
| 545 |
\edef\@p@sbburx{\number\dimen100} |
| 546 |
} |
| 547 |
\def\@p@@sbbury#1{ |
| 548 |
%\ps@typeout{bbury is #1} |
| 549 |
\@bburytrue |
| 550 |
\dimen100=#1 |
| 551 |
\edef\@p@sbbury{\number\dimen100} |
| 552 |
} |
| 553 |
\def\@p@@sheight#1{ |
| 554 |
\@heighttrue |
| 555 |
\dimen100=#1 |
| 556 |
\edef\@p@sheight{\number\dimen100} |
| 557 |
%\ps@typeout{Height is \@p@sheight} |
| 558 |
} |
| 559 |
\def\@p@@swidth#1{ |
| 560 |
%\ps@typeout{Width is #1} |
| 561 |
\@widthtrue |
| 562 |
\dimen100=#1 |
| 563 |
\edef\@p@swidth{\number\dimen100} |
| 564 |
} |
| 565 |
\def\@p@@srheight#1{ |
| 566 |
%\ps@typeout{Reserved height is #1} |
| 567 |
\@rheighttrue |
| 568 |
\dimen100=#1 |
| 569 |
\edef\@p@srheight{\number\dimen100} |
| 570 |
} |
| 571 |
\def\@p@@srwidth#1{ |
| 572 |
%\ps@typeout{Reserved width is #1} |
| 573 |
\@rwidthtrue |
| 574 |
\dimen100=#1 |
| 575 |
\edef\@p@srwidth{\number\dimen100} |
| 576 |
} |
| 577 |
\def\@p@@sangle#1{ |
| 578 |
%\ps@typeout{Rotation is #1} |
| 579 |
\@angletrue |
| 580 |
% \dimen100=#1 |
| 581 |
\edef\@p@sangle{#1} %\number\dimen100} |
| 582 |
} |
| 583 |
\def\@p@@ssilent#1{ |
| 584 |
\@verbosefalse |
| 585 |
} |
| 586 |
\def\@p@@sprolog#1{\@prologfiletrue\def\@prologfileval{#1}} |
| 587 |
\def\@p@@spostlog#1{\@postlogfiletrue\def\@postlogfileval{#1}} |
| 588 |
\def\@cs@name#1{\csname #1\endcsname} |
| 589 |
\def\@setparms#1=#2,{\@cs@name{@p@@s#1}{#2}} |
| 590 |
% |
| 591 |
% initialize the defaults (size the size of the figure) |
| 592 |
% |
| 593 |
\def\ps@init@parms{ |
| 594 |
\@bbllxfalse \@bbllyfalse |
| 595 |
\@bburxfalse \@bburyfalse |
| 596 |
\@heightfalse \@widthfalse |
| 597 |
\@rheightfalse \@rwidthfalse |
| 598 |
\def\@p@sbbllx{}\def\@p@sbblly{} |
| 599 |
\def\@p@sbburx{}\def\@p@sbbury{} |
| 600 |
\def\@p@sheight{}\def\@p@swidth{} |
| 601 |
\def\@p@srheight{}\def\@p@srwidth{} |
| 602 |
\def\@p@sangle{0} |
| 603 |
\def\@p@sfile{} \def\@p@sbbfile{} |
| 604 |
\def\@p@scost{10} |
| 605 |
\def\@sc{} |
| 606 |
\@prologfilefalse |
| 607 |
\@postlogfilefalse |
| 608 |
\@clipfalse |
| 609 |
\if@noisy |
| 610 |
\@verbosetrue |
| 611 |
\else |
| 612 |
\@verbosefalse |
| 613 |
\fi |
| 614 |
} |
| 615 |
% |
| 616 |
% Go through the options setting things up. |
| 617 |
% |
| 618 |
\def\parse@ps@parms#1{ |
| 619 |
\@psdo\@psfiga:=#1\do |
| 620 |
{\expandafter\@setparms\@psfiga,}} |
| 621 |
% |
| 622 |
% Compute bb height and width |
| 623 |
% |
| 624 |
\newif\ifno@bb |
| 625 |
\def\bb@missing{ |
| 626 |
\if@verbose{ |
| 627 |
\ps@typeout{psfig: searching \@p@sbbfile \space for bounding box} |
| 628 |
}\fi |
| 629 |
\no@bbtrue |
| 630 |
\epsf@getbb{\@p@sbbfile} |
| 631 |
\ifno@bb \else \bb@cull\epsf@llx\epsf@lly\epsf@urx\epsf@ury\fi |
| 632 |
} |
| 633 |
\def\bb@cull#1#2#3#4{ |
| 634 |
\dimen100=#1 bp\edef\@p@sbbllx{\number\dimen100} |
| 635 |
\dimen100=#2 bp\edef\@p@sbblly{\number\dimen100} |
| 636 |
\dimen100=#3 bp\edef\@p@sbburx{\number\dimen100} |
| 637 |
\dimen100=#4 bp\edef\@p@sbbury{\number\dimen100} |
| 638 |
\no@bbfalse |
| 639 |
} |
| 640 |
% rotate point (#1,#2) about (0,0). |
| 641 |
% The sine and cosine of the angle are already stored in \sine and |
| 642 |
% \cosine. The result is placed in (\p@intvaluex, \p@intvaluey). |
| 643 |
\newdimen\p@intvaluex |
| 644 |
\newdimen\p@intvaluey |
| 645 |
\def\rotate@#1#2{{\dimen0=#1 sp\dimen1=#2 sp |
| 646 |
% calculate x' = x \cos\theta - y \sin\theta |
| 647 |
\global\p@intvaluex=\cosine\dimen0 |
| 648 |
\dimen3=\sine\dimen1 |
| 649 |
\global\advance\p@intvaluex by -\dimen3 |
| 650 |
% calculate y' = x \sin\theta + y \cos\theta |
| 651 |
\global\p@intvaluey=\sine\dimen0 |
| 652 |
\dimen3=\cosine\dimen1 |
| 653 |
\global\advance\p@intvaluey by \dimen3 |
| 654 |
}} |
| 655 |
\def\compute@bb{ |
| 656 |
\no@bbfalse |
| 657 |
\if@bbllx \else \no@bbtrue \fi |
| 658 |
\if@bblly \else \no@bbtrue \fi |
| 659 |
\if@bburx \else \no@bbtrue \fi |
| 660 |
\if@bbury \else \no@bbtrue \fi |
| 661 |
\ifno@bb \bb@missing \fi |
| 662 |
\ifno@bb \ps@typeout{FATAL ERROR: no bb supplied or found} |
| 663 |
\no-bb-error |
| 664 |
\fi |
| 665 |
% |
| 666 |
%\ps@typeout{BB: \@p@sbbllx, \@p@sbblly, \@p@sbburx, \@p@sbbury} |
| 667 |
% |
| 668 |
% store height/width of original (unrotated) bounding box |
| 669 |
\count203=\@p@sbburx |
| 670 |
\count204=\@p@sbbury |
| 671 |
\advance\count203 by -\@p@sbbllx |
| 672 |
\advance\count204 by -\@p@sbblly |
| 673 |
\edef\ps@bbw{\number\count203} |
| 674 |
\edef\ps@bbh{\number\count204} |
| 675 |
%\ps@typeout{ psbbh = \ps@bbh, psbbw = \ps@bbw } |
| 676 |
\if@angle |
| 677 |
\Sine{\@p@sangle}\Cosine{\@p@sangle} |
| 678 |
{\dimen100=\maxdimen\xdef\r@p@sbbllx{\number\dimen100} |
| 679 |
\xdef\r@p@sbblly{\number\dimen100} |
| 680 |
\xdef\r@p@sbburx{-\number\dimen100} |
| 681 |
\xdef\r@p@sbbury{-\number\dimen100}} |
| 682 |
% |
| 683 |
% Need to rotate all four points and take the X-Y extremes of the new |
| 684 |
% points as the new bounding box. |
| 685 |
\def\minmaxtest{ |
| 686 |
\ifnum\number\p@intvaluex<\r@p@sbbllx |
| 687 |
\xdef\r@p@sbbllx{\number\p@intvaluex}\fi |
| 688 |
\ifnum\number\p@intvaluex>\r@p@sbburx |
| 689 |
\xdef\r@p@sbburx{\number\p@intvaluex}\fi |
| 690 |
\ifnum\number\p@intvaluey<\r@p@sbblly |
| 691 |
\xdef\r@p@sbblly{\number\p@intvaluey}\fi |
| 692 |
\ifnum\number\p@intvaluey>\r@p@sbbury |
| 693 |
\xdef\r@p@sbbury{\number\p@intvaluey}\fi |
| 694 |
} |
| 695 |
% lower left |
| 696 |
\rotate@{\@p@sbbllx}{\@p@sbblly} |
| 697 |
\minmaxtest |
| 698 |
% upper left |
| 699 |
\rotate@{\@p@sbbllx}{\@p@sbbury} |
| 700 |
\minmaxtest |
| 701 |
% lower right |
| 702 |
\rotate@{\@p@sbburx}{\@p@sbblly} |
| 703 |
\minmaxtest |
| 704 |
% upper right |
| 705 |
\rotate@{\@p@sbburx}{\@p@sbbury} |
| 706 |
\minmaxtest |
| 707 |
\edef\@p@sbbllx{\r@p@sbbllx}\edef\@p@sbblly{\r@p@sbblly} |
| 708 |
\edef\@p@sbburx{\r@p@sbburx}\edef\@p@sbbury{\r@p@sbbury} |
| 709 |
%\ps@typeout{rotated BB: \r@p@sbbllx, \r@p@sbblly, \r@p@sbburx, \r@p@sbbury} |
| 710 |
\fi |
| 711 |
\count203=\@p@sbburx |
| 712 |
\count204=\@p@sbbury |
| 713 |
\advance\count203 by -\@p@sbbllx |
| 714 |
\advance\count204 by -\@p@sbblly |
| 715 |
\edef\@bbw{\number\count203} |
| 716 |
\edef\@bbh{\number\count204} |
| 717 |
%\ps@typeout{ bbh = \@bbh, bbw = \@bbw } |
| 718 |
} |
| 719 |
% |
| 720 |
% \in@hundreds performs #1 * (#2 / #3) correct to the hundreds, |
| 721 |
% then leaves the result in @result |
| 722 |
% |
| 723 |
\def\in@hundreds#1#2#3{\count240=#2 \count241=#3 |
| 724 |
\count100=\count240 % 100 is first digit #2/#3 |
| 725 |
\divide\count100 by \count241 |
| 726 |
\count101=\count100 |
| 727 |
\multiply\count101 by \count241 |
| 728 |
\advance\count240 by -\count101 |
| 729 |
\multiply\count240 by 10 |
| 730 |
\count101=\count240 %101 is second digit of #2/#3 |
| 731 |
\divide\count101 by \count241 |
| 732 |
\count102=\count101 |
| 733 |
\multiply\count102 by \count241 |
| 734 |
\advance\count240 by -\count102 |
| 735 |
\multiply\count240 by 10 |
| 736 |
\count102=\count240 % 102 is the third digit |
| 737 |
\divide\count102 by \count241 |
| 738 |
\count200=#1\count205=0 |
| 739 |
\count201=\count200 |
| 740 |
\multiply\count201 by \count100 |
| 741 |
\advance\count205 by \count201 |
| 742 |
\count201=\count200 |
| 743 |
\divide\count201 by 10 |
| 744 |
\multiply\count201 by \count101 |
| 745 |
\advance\count205 by \count201 |
| 746 |
% |
| 747 |
\count201=\count200 |
| 748 |
\divide\count201 by 100 |
| 749 |
\multiply\count201 by \count102 |
| 750 |
\advance\count205 by \count201 |
| 751 |
% |
| 752 |
\edef\@result{\number\count205} |
| 753 |
} |
| 754 |
\def\compute@wfromh{ |
| 755 |
% computing : width = height * (bbw / bbh) |
| 756 |
\in@hundreds{\@p@sheight}{\@bbw}{\@bbh} |
| 757 |
%\ps@typeout{ \@p@sheight * \@bbw / \@bbh, = \@result } |
| 758 |
\edef\@p@swidth{\@result} |
| 759 |
%\ps@typeout{w from h: width is \@p@swidth} |
| 760 |
} |
| 761 |
\def\compute@hfromw{ |
| 762 |
% computing : height = width * (bbh / bbw) |
| 763 |
\in@hundreds{\@p@swidth}{\@bbh}{\@bbw} |
| 764 |
%\ps@typeout{ \@p@swidth * \@bbh / \@bbw = \@result } |
| 765 |
\edef\@p@sheight{\@result} |
| 766 |
%\ps@typeout{h from w : height is \@p@sheight} |
| 767 |
} |
| 768 |
\def\compute@handw{ |
| 769 |
\if@height |
| 770 |
\if@width |
| 771 |
\else |
| 772 |
\compute@wfromh |
| 773 |
\fi |
| 774 |
\else |
| 775 |
\if@width |
| 776 |
\compute@hfromw |
| 777 |
\else |
| 778 |
\edef\@p@sheight{\@bbh} |
| 779 |
\edef\@p@swidth{\@bbw} |
| 780 |
\fi |
| 781 |
\fi |
| 782 |
} |
| 783 |
\def\compute@resv{ |
| 784 |
\if@rheight \else \edef\@p@srheight{\@p@sheight} \fi |
| 785 |
\if@rwidth \else \edef\@p@srwidth{\@p@swidth} \fi |
| 786 |
%\ps@typeout{rheight = \@p@srheight, rwidth = \@p@srwidth} |
| 787 |
} |
| 788 |
% |
| 789 |
% Compute any missing values |
| 790 |
\def\compute@sizes{ |
| 791 |
\compute@bb |
| 792 |
\if@scalefirst\if@angle |
| 793 |
% at this point the bounding box has been adjsuted correctly for |
| 794 |
% rotation. PSFIG does all of its scaling using \@bbh and \@bbw. If |
| 795 |
% a width= or height= was specified along with \psscalefirst, then the |
| 796 |
% width=/height= value needs to be adjusted to match the new (rotated) |
| 797 |
% bounding box size (specifed in \@bbw and \@bbh). |
| 798 |
% \ps@bbw width= |
| 799 |
% ------- = ---------- |
| 800 |
% \@bbw new width= |
| 801 |
% so `new width=' = (width= * \@bbw) / \ps@bbw; where \ps@bbw is the |
| 802 |
% width of the original (unrotated) bounding box. |
| 803 |
\if@width |
| 804 |
\in@hundreds{\@p@swidth}{\@bbw}{\ps@bbw} |
| 805 |
\edef\@p@swidth{\@result} |
| 806 |
\fi |
| 807 |
\if@height |
| 808 |
\in@hundreds{\@p@sheight}{\@bbh}{\ps@bbh} |
| 809 |
\edef\@p@sheight{\@result} |
| 810 |
\fi |
| 811 |
\fi\fi |
| 812 |
\compute@handw |
| 813 |
\compute@resv} |
| 814 |
|
| 815 |
% |
| 816 |
% \psfig |
| 817 |
% usage : \psfig{file=, height=, width=, bbllx=, bblly=, bburx=, bbury=, |
| 818 |
% rheight=, rwidth=, clip=} |
| 819 |
% |
| 820 |
% "clip=" is a switch and takes no value, but the `=' must be present. |
| 821 |
\def\psfig#1{\vbox { |
| 822 |
% do a zero width hard space so that a single |
| 823 |
% \psfig in a centering enviornment will behave nicely |
| 824 |
%{\setbox0=\hbox{\ }\ \hskip-\wd0} |
| 825 |
% |
| 826 |
\ps@init@parms |
| 827 |
\parse@ps@parms{#1} |
| 828 |
\compute@sizes |
| 829 |
% |
| 830 |
\ifnum\@p@scost<\@psdraft{ |
| 831 |
% |
| 832 |
\special{ps::[begin] \@p@swidth \space \@p@sheight \space |
| 833 |
\@p@sbbllx \space \@p@sbblly \space |
| 834 |
\@p@sbburx \space \@p@sbbury \space |
| 835 |
startTexFig \space } |
| 836 |
\if@angle |
| 837 |
\special {ps:: \@p@sangle \space rotate \space} |
| 838 |
\fi |
| 839 |
\if@clip{ |
| 840 |
\if@verbose{ |
| 841 |
\ps@typeout{(clip)} |
| 842 |
}\fi |
| 843 |
\special{ps:: doclip \space } |
| 844 |
}\fi |
| 845 |
\if@prologfile |
| 846 |
\special{ps: plotfile \@prologfileval \space } \fi |
| 847 |
\if@decmpr{ |
| 848 |
\if@verbose{ |
| 849 |
\ps@typeout{psfig: including \@[email protected] \space } |
| 850 |
}\fi |
| 851 |
\special{ps: plotfile "`zcat \@[email protected]" \space } |
| 852 |
}\else{ |
| 853 |
\if@verbose{ |
| 854 |
\ps@typeout{psfig: including \@p@sfile \space } |
| 855 |
}\fi |
| 856 |
\special{ps: plotfile \@p@sfile \space } |
| 857 |
}\fi |
| 858 |
\if@postlogfile |
| 859 |
\special{ps: plotfile \@postlogfileval \space } \fi |
| 860 |
\special{ps::[end] endTexFig \space } |
| 861 |
% Create the vbox to reserve the space for the figure. |
| 862 |
\vbox to \@p@srheight sp{ |
| 863 |
% 1/92 TJD Changed from "true sp" to "sp" for magnification. |
| 864 |
\hbox to \@p@srwidth sp{ |
| 865 |
\hss |
| 866 |
} |
| 867 |
\vss |
| 868 |
} |
| 869 |
}\else{ |
| 870 |
% draft figure, just reserve the space and print the |
| 871 |
% path name. |
| 872 |
\if@draftbox{ |
| 873 |
% Verbose draft: print file name in box |
| 874 |
\hbox{\frame{\vbox to \@p@srheight sp{ |
| 875 |
\vss |
| 876 |
\hbox to \@p@srwidth sp{ \hss \@p@sfile \hss } |
| 877 |
\vss |
| 878 |
}}} |
| 879 |
}\else{ |
| 880 |
% Non-verbose draft |
| 881 |
\vbox to \@p@srheight sp{ |
| 882 |
\vss |
| 883 |
\hbox to \@p@srwidth sp{\hss} |
| 884 |
\vss |
| 885 |
} |
| 886 |
}\fi |
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
}\fi |
| 891 |
}} |
| 892 |
\psfigRestoreAt |
| 893 |
\let\@=\LaTeXAtSign |
| 894 |
|
| 895 |
|
| 896 |
|