| 1 |
%%%% pinlabel.sty v1.2 |
| 2 |
%%%% |
| 3 |
%%%% Written by Colin Rourke |
| 4 |
%%%% |
| 5 |
%%%% Based on geompsfi.sty by Silvio Levy |
| 6 |
%%%% Based on psfig.sty by Trevor Darrell |
| 7 |
%%%% |
| 8 |
%%%% Copyright 2006-11 Mathematical Sciences Publishers (MSP) |
| 9 |
%%%% |
| 10 |
%%%% NOTICE |
| 11 |
%%%% |
| 12 |
%%%% This package may be distributed and/or modified under the |
| 13 |
%%%% conditions of the LaTeX Project Public License, either version |
| 14 |
%%%% 1.3 of this license or (at your option) any later version. |
| 15 |
%%%% The latest version of this license is in |
| 16 |
%%%% |
| 17 |
%%%% http://www.latex-project.org/lppl.txt |
| 18 |
%%%% |
| 19 |
%%%% and version 1.3 or later is part of all distributions of LaTeX |
| 20 |
%%%% version 2005/12/01 or later. |
| 21 |
%%%% |
| 22 |
%%%% This package has the LPPL maintenance status `maintained' and is |
| 23 |
%%%% currently maintained by MSP: [email protected] |
| 24 |
%%%% |
| 25 |
%%%% It comprises the files: pinlabel.sty (this file) and the manual |
| 26 |
%%%% pinlabdoc.pdf where full documentation may be found, togther |
| 27 |
%%%% with the source files for the documentation. |
| 28 |
%%%% |
| 29 |
%%%% |
| 30 |
%%%% pinlabel.sty is designed for inserting perfectly formatted TeX |
| 31 |
%%%% labels in eps or pdf files for inclusion in documents. |
| 32 |
%%%% It uses the coordinates provided by ghostview (or gv) to |
| 33 |
%%%% position the label and reads the relevant bounding box |
| 34 |
%%%% information from the eps file (or alternatively ps or pdf |
| 35 |
%%%% file). You must supply one of these three. To label a jpg |
| 36 |
%%%% for example, you need to convert it first to eps or pdf. |
| 37 |
%%%% Several features are provided which facilitate perfect |
| 38 |
%%%% first-time label positioning, of which the most important |
| 39 |
%%%% is auto-spacing, which sets the label a predetermined gap |
| 40 |
%%%% away from the figure object which is being labelled. The |
| 41 |
%%%% gap is \hair (a TeX dimension, preset to 3pt, but settable |
| 42 |
%%%% on the fly) and the direction of the spacing is chosen |
| 43 |
%%%% automatically. The result is consistent and eye-pleasing |
| 44 |
%%%% spacing. |
| 45 |
%%%% In use, read the position of the object that you wish to |
| 46 |
%%%% label and do not guess the position of the actual label. |
| 47 |
%%%% Then choose the orientation of the label (eg [tr] which |
| 48 |
%%%% means top-right) and the label will automatically be set |
| 49 |
%%%% so that top-right of the label bounding box is set one |
| 50 |
%%%% \hair away from the object being labelled. |
| 51 |
%%%% |
| 52 |
%%%% |
| 53 |
%%%% pinlabel.sty was written specifically for the use of editors and |
| 54 |
%%%% authors of MSP papers and is the recommended package for |
| 55 |
%%%% use for labelling diagrams for MSP. |
| 56 |
%%%% |
| 57 |
%%%% pinlabel.sty is a revised version of geomsfig.sty with improved |
| 58 |
%%%% functionality and simpler syntax. The old syntax remains |
| 59 |
%%%% available for backwards compatibility, see below. |
| 60 |
%%%% |
| 61 |
%%%% new syntax: \pinlabel {label} by x-pin y-pin at x-location y-location |
| 62 |
%%%% and \pinlabel* {label} by x-pin y-pin at x-location y-location |
| 63 |
%%%% |
| 64 |
%%%% where "x-pin y-pin" is the point in intrinsic coords in label |
| 65 |
%%%% space where we are placing the pin and "x-location y-location" |
| 66 |
%%%% is the point in diagram space (in PS points as read in gv) where |
| 67 |
%%%% the label is pinned. \pinlabel uses \hair autospacing \pinlabel* |
| 68 |
%%%% does not. See the manual for full details. |
| 69 |
%%%% \mathsurround is set to 0pt for parsing the label |
| 70 |
%%%% |
| 71 |
%%%% options: "by x-pin y-pin" may be omitted the default is 0 0 |
| 72 |
%%%% orientation commands [r], [l] etc may replace "by x-pin y-pin" |
| 73 |
%%%% [r] is right-centre (same as "by 0 1") etc |
| 74 |
%%%% a manual adjustment "<x-adj, y-adj>" may be added before "at" |
| 75 |
%%%% or directly after the label |
| 76 |
%%%% |
| 77 |
%%%% Examples \pinlabel $a^b$ [l] <-2pt,1pt> at 231 47 |
| 78 |
%%%% Same as \pinlabel $a^b$ by -1 0 <-2pt,1pt> at 231 47 |
| 79 |
%%%% Same as \pinlabel $a^b$ <-2pt,1pt> [l] at 231 47 |
| 80 |
%%%% Same as \pinlabel $a^b$ <-2pt,1pt> by -1 0 at 231 47 |
| 81 |
%%%% |
| 82 |
%%%% which pins "$a^b$" by centre-left at 231 47 with two |
| 83 |
%%%% adjustments: \hair (autospacing) and then (-2pt,1pt) manual |
| 84 |
%%%% |
| 85 |
%%%% \pinlabel* {A nice figure} [Bl] <-5pt,0pt> at 231 47 |
| 86 |
%%%% |
| 87 |
%%%% which pins "A nice figure" by baseline-left at 231 47 |
| 88 |
%%%% with one adjustment: (-5pt,0pt) |
| 89 |
%%%% |
| 90 |
%%%% Full list of orientation commands: r=right, l=left, t=top, b=bottom |
| 91 |
%%%% and B=baseline, default is centre and any sensible combination |
| 92 |
%%%% of two commands may be give (in either order) eg |
| 93 |
%%%% [tl]=[lt]=top-left of label bounding box |
| 94 |
%%%% |
| 95 |
%%%% NB the commands are syntax sensitive and use spaces as separators so |
| 96 |
%%%% they DON'T work with \obeyspaces set. Braces must be placed |
| 97 |
%%%% around labels containing spaces but may be omitted if there are |
| 98 |
%%%% no spaces in the label code (see the examples above and below). |
| 99 |
%%%% |
| 100 |
%%%% Label instructions go either in the file inside \labellist |
| 101 |
%%%% ... \endlabellist or in a separate .lab file (ie if fig |
| 102 |
%%%% is fig4-1.eps or .ps, then labels go in \figdir/fig4-1.lab |
| 103 |
%%%% where \figdir/ is the directory containing fig4-1.eps). |
| 104 |
%%%% The \labellist overrides a .lab file. |
| 105 |
%%%% \labellist ... \endlabellist can be given at any time before |
| 106 |
%%%% the next figure, but typically will be included in the figure |
| 107 |
%%%% code, as in the following example. |
| 108 |
%%%% |
| 109 |
%%%% Here is a complete example of a relabelled figure: |
| 110 |
%%%% |
| 111 |
%%%% \begin{figure}[ht!] |
| 112 |
%%%% \labellist\small\hair 2.5pt |
| 113 |
%%%% \pinlabel {$\partial _1 X$} by 1 0 at 156 426 |
| 114 |
%%%% \pinlabel {$\partial _2 X$} by -1 1 at 334 429 |
| 115 |
%%%% \pinlabel $X_1$ at 431 513 |
| 116 |
%%%% \pinlabel $X_2$ at 428 460 |
| 117 |
%%%% \pinlabel $H_X$ [lb] at 311 622 |
| 118 |
%%%% \pinlabel* $H_X'$ [tr] <-1.5pt,-2pt> at 178 370 |
| 119 |
%%%% \endlabellist |
| 120 |
%%%% \centerline{\psfig{file=\figdir/decomp,width=3in}} |
| 121 |
%%%% \caption{Labelling the boundary components of $X$} |
| 122 |
%%%% \label{Fig:decomp} |
| 123 |
%%%% \end{figure} |
| 124 |
%%%% |
| 125 |
%%%% The actual figure can be included by using either psfig or |
| 126 |
%%%% graphicx. psfig is used by the code, but graphicx |
| 127 |
%%%% commands are translated automatically, so in the above |
| 128 |
%%%% example the alternative code: |
| 129 |
%%%% |
| 130 |
%%%% \centerline{\includegraphics[width=3in]{\figdir/decomp}} |
| 131 |
%%%% |
| 132 |
%%%% would produce identical results. Automatic translation ONLY |
| 133 |
%%%% takes place is a labellist is present, so if you use a .lab |
| 134 |
%%%% file then you MUST use the psfig syntax. |
| 135 |
%%%% |
| 136 |
%%%% |
| 137 |
%%%% VERY IMPORTANT |
| 138 |
%%%% ============== |
| 139 |
%%%% |
| 140 |
%%%% The file extension MUST NOT be given. The program will find |
| 141 |
%%%% the correct file (\figdir/decomp.eps or .ps or .pdf). |
| 142 |
%%%% |
| 143 |
%%%% READ THE BUGS below before using \includegraphics with pinlabel. |
| 144 |
%%%% |
| 145 |
%%%% |
| 146 |
%%%% old syntax: \setlabel is unchanged (but \mathsurround is set to 0pt) |
| 147 |
%%%% \setlabel* is a new variant which sets \hair to 0pt (no |
| 148 |
%%%% autospacing) and an optional manual adjustment may be added |
| 149 |
%%%% eg: |
| 150 |
%%%% |
| 151 |
%%%% \setlabel<-2pt,-1pt>{a^b}{321}{33}{1}{1} |
| 152 |
%%%% \setlabel*<-2pt,-1pt>{a^b}{321}{33}{1}{1} |
| 153 |
%%%% \setlabel{a^b}{321}{33}{1}{1} |
| 154 |
%%%% \setlabel*{a^b}{321}{33}{1}{1} |
| 155 |
%%%% |
| 156 |
%%%% the first uses autospacing and adds a (-2pt,-1pt) manual |
| 157 |
%%%% adjustment; the second uses just the manual adjustment, |
| 158 |
%%%% the third just autospacing and the fourth nothing. |
| 159 |
%%%% |
| 160 |
%%%% old and new syntax may be mixed in a label list and given |
| 161 |
%%%% either in a .lab file or inside \labellist ... \endlabellist |
| 162 |
%%%% |
| 163 |
%%%% ***Users of geomsfig note the change to \mathsurround. If you |
| 164 |
%%%% do not use it, there will be no change in label positioning. |
| 165 |
%%%% If you do, labels may move a small amount horizontally.*** |
| 166 |
%%%% |
| 167 |
%%%% |
| 168 |
%%%% !!!NBNB label is in horizontal mode in new syntax and math mode in old!!! |
| 169 |
%%%% |
| 170 |
%%%% |
| 171 |
%%%% BUGS: NO spaces are permitted in the file argument of \psfig |
| 172 |
%%%% Autotranslation of \includegraphics[]{} means that no |
| 173 |
%%%% spaces are permitted in the file argument to \includegraphics |
| 174 |
%%%% Eg \includegraphics[width=4in]{ foo } will produce errors, |
| 175 |
%%%% use \includegraphics[width=4in]{foo}. Spaces are permitted |
| 176 |
%%%% with other arguments. |
| 177 |
%%%% |
| 178 |
%%%% Many of the options in graphicx are not supported. The |
| 179 |
%%%% supported ones are: width, height, scale, bbllx, bblly |
| 180 |
%%%% bburx, bbury and clip. The syntax for clip is "clip=". |
| 181 |
%%%% Replace "keepaspectratio=true" by "proportional=". |
| 182 |
%%%% |
| 183 |
%%%% The command \reallyincludegraphics will force the use of |
| 184 |
%%%% graphicx (ie cancel autotranslation). Since code will use |
| 185 |
%%%% graphicx automatically if there is no labellist present, |
| 186 |
%%%% \reallyincludegraphics will only be needed if a labellist |
| 187 |
%%%% has already been given for a later figure. |
| 188 |
%%%% |
| 189 |
%%%% \graphicspath{} is not supported. Use \figdir instead. |
| 190 |
%%%% |
| 191 |
%%%% |
| 192 |
%%%% Automatic configuration for dvips and pdflatex is included |
| 193 |
%%%% in this file. No support is provided for other drivers. |
| 194 |
%%%% |
| 195 |
%%%% NB \psfig ouputs a vbox, which is not centred in latex' {center} |
| 196 |
%%%% environment. Either use \centerline{} or type \leavevmode |
| 197 |
%%%% before \psfig{..}. The translator adds \leavevmode for |
| 198 |
%%%% \includegraphics, which therefore centres correctly as usual |
| 199 |
%%%% in the {center} environment. |
| 200 |
%%%% |
| 201 |
%%%% PLAIN TeX compatibility: uses miniltx.tex and works with dvips |
| 202 |
%%%% but NOT with pdftex. For pdf output from plain TeX use dvips |
| 203 |
%%%% followed by ps2pdf. |
| 204 |
%%%% |
| 205 |
%%%% NEW FOR VERSION 1.2: Thanks to Mark Petelier, you no longer |
| 206 |
%%%% need to convert a pdf figure to eps. pinlabel now reads the |
| 207 |
%%%% BB from a pdf file if no ps or eps file is supplied. |
| 208 |
|
| 209 |
\edef\atcatcode{\the\catcode`\@} \catcode`@=11 |
| 210 |
\def\@message#1{\immediate\write16{#1}} |
| 211 |
|
| 212 |
\newif\ifoldlabels \oldlabelsfalse |
| 213 |
\expandafter\ifx\csname @ifundefined\endcsname\relax |
| 214 |
\long\def\@ifundefined#1#2#3{\expandafter\ifx\csname |
| 215 |
#1\endcsname\relax#2\else#3\fi} |
| 216 |
|
| 217 |
\def\@iden#1{#1} |
| 218 |
%\newdimen\@tempdima |
| 219 |
\alloc@1\dimen\dimendef\insc@unt\@tempdima |
| 220 |
\def\@warning#1{\@message{Warning: #1.}} |
| 221 |
\fi |
| 222 |
|
| 223 |
%%% if not latex \input miniltx (for plain tex compatibility) |
| 224 |
\@ifundefined{RequirePackage}{\input miniltx}{\relax} |
| 225 |
|
| 226 |
%%% make sure graphicx is loaded |
| 227 |
\RequirePackage{graphicx} |
| 228 |
\let\@includegraphics@\includegraphics %%% for auto translation of graphicx |
| 229 |
\let\reallyincludegraphics\@includegraphics@ %%% to override translation |
| 230 |
|
| 231 |
\@ifundefined{ps@init}{}{\endinput} |
| 232 |
|
| 233 |
\@ifundefined{hyperactivelabels}{\let\hyperactivelabels\relax}{} |
| 234 |
|
| 235 |
%%% in-line label list handling %%% |
| 236 |
\long\def\labellist#1\endlabellist{\gdef\thelabellist{#1}} |
| 237 |
\let\thelabellist\relax %%%% initialise |
| 238 |
|
| 239 |
\newif\if@topspecials %false for Rokicki's dvips: \special is at bottom of box |
| 240 |
% true for dvitps, dvi2ps |
| 241 |
|
| 242 |
\newif\ifdvi\dvitrue |
| 243 |
\@ifundefined{pdfoutput}{}{\ifnum\pdfoutput>0 \dvifalse\fi} |
| 244 |
\ifdvi |
| 245 |
%%% start of driver.chg |
| 246 |
{\catcode`\p=12 \catcode`\t=12 \gdef\read@PT#1pt{#1}} |
| 247 |
\def\sp@topt#1#2{\psfig@dimen=#2sp \if\psfig@dimen=0pt \psfig@dimen=1sp\fi |
| 248 |
\edef#1{\expandafter\read@PT \the\psfig@dimen}} |
| 249 |
\def\sp@tobp#1#2{\psfig@dimen=#2sp \if\psfig@dimen=0pt \psfig@dimen=1sp\fi |
| 250 |
\expandafter\@tempdima\expandafter\read@PT \the\psfig@dimen bp |
| 251 |
\advance\[email protected] \@tempdima \multiply\psfig@dimen 2 |
| 252 |
\edef#1{\expandafter\read@PT \the\psfig@dimen}} |
| 253 |
\def\ps@init{} |
| 254 |
\def\ps@begin{\sp@tobp\@tempa\@p@sbbllx \sp@tobp\@tempb\@p@sbblly |
| 255 |
\sp@tobp\@tempc\@p@sbburx \sp@tobp\@tempd\@p@sbbury |
| 256 |
\sp@tobp\@tempe{\@p@swidth0} \sp@tobp\@tempf{\@p@sheight0} |
| 257 |
\special{PSfile=\@p@sfile\space llx=\@tempa\space lly=\@tempb\space |
| 258 |
urx=\@tempc\space ury=\@tempd\space rwi=\@tempe\space rhi=\@tempf}} |
| 259 |
% rwi is the total width, in tenths of the units used for the |
| 260 |
% other dimensions (this is dvips's brain damage) |
| 261 |
\def\ps@prolog{} |
| 262 |
\def\ps@clip{} % |
| 263 |
\def\ps@include{} % |
| 264 |
\def\ps@postlog{} % |
| 265 |
\def\ps@end{} % |
| 266 |
%%% end of driver.chg |
| 267 |
\else |
| 268 |
\@ifundefined{usepackage}{\@message{} |
| 269 |
\@message {!!! pinlabel.sty cannot be used for direct pdf output except with latex !!!} |
| 270 |
\@message {For pdf output from plain tex use dvips and ps2pdf} |
| 271 |
\@message{}}{} |
| 272 |
%%% start of gpdftex.chg |
| 273 |
{\catcode`\p=12 \catcode`\t=12 \gdef\read@PT#1pt{#1}} |
| 274 |
\def\sp@topt#1#2{\psfig@dimen=#2sp \if\psfig@dimen=0pt \psfig@dimen=1sp\fi |
| 275 |
\edef#1{\expandafter\read@PT \the\psfig@dimen}} |
| 276 |
\def\sp@tobp#1#2{\psfig@dimen=#2sp \if\psfig@dimen=0pt \psfig@dimen=1sp\fi |
| 277 |
\expandafter\@tempdima\expandafter\read@PT \the\psfig@dimen bp |
| 278 |
\advance\[email protected] \@tempdima \multiply\psfig@dimen 2 |
| 279 |
\edef#1{\expandafter\read@PT \the\psfig@dimen}} |
| 280 |
\def\ps@init{} |
| 281 |
\def\ps@begin{\sp@tobp\@tempa\@p@sbbllx \sp@tobp\@tempb\@p@sbblly |
| 282 |
\sp@tobp\@tempc\@p@sbburx \sp@tobp\@tempd\@p@sbbury |
| 283 |
\sp@tobp\@tempe\@p@swidth \sp@tobp\@tempf\@p@sheight% |
| 284 |
\edef\foobar{[width=\@p@swidth sp,height=\@p@sheight sp]{\@p@dffile}}% |
| 285 |
%,viewport=\@tempa\space\@tempb\space\@tempc\space\@tempd |
| 286 |
\@message{\string\@includegraphics@\foobar}% |
| 287 |
\rlap{\smash{\expandafter\@includegraphics@\foobar}}% |
| 288 |
} |
| 289 |
% rwi is the total width, in tenths of the units used for the |
| 290 |
% other dimensions (this is dvips's brain damage) |
| 291 |
\def\ps@prolog{} |
| 292 |
\def\ps@clip{} % |
| 293 |
\def\ps@include{} % |
| 294 |
\def\ps@postlog{} % |
| 295 |
\def\ps@end{} % |
| 296 |
%%%% end of gpdftex.chg |
| 297 |
\fi |
| 298 |
|
| 299 |
%%%% graphicx translation |
| 300 |
%%%% first set a flag to detect use of graphicx and initialise |
| 301 |
%%%% the default is \relax (graphicx not used) any other value |
| 302 |
%%%% means graphicx is used |
| 303 |
\let\inc@graph@flag\relax |
| 304 |
|
| 305 |
%%%% redefine \includegraphics to mimic \psfig ONLY IF a labellist is present |
| 306 |
\def\includegraphics{\ifx\thelabellist\relax\let\next\@includegraphicsnolist@% |
| 307 |
\else\let\next\@includegraphics@list@\fi\next} |
| 308 |
|
| 309 |
\let\@includegraphicsnolist@\reallyincludegraphics |
| 310 |
|
| 311 |
\def\@includegraphics@list@{\def\inc@graph@flag{1}% |
| 312 |
\@ifnextchar[{\includegraphicswithoptions}{\includegraphicsplain}} |
| 313 |
\def\includegraphicswithoptions[#1]#2{\leavevmode\psfig{file=#2,#1}} |
| 314 |
\def\includegraphicsplain#1{\leavevmode\psfig{file=#1}} |
| 315 |
|
| 316 |
|
| 317 |
\newcount\psfc@a |
| 318 |
\newcount\psfc@b |
| 319 |
\newcount\psfc@c |
| 320 |
\newcount\psfc@d |
| 321 |
\newcount\psfc@e |
| 322 |
\newcount\psfc@f |
| 323 |
\newcount\psfc@g |
| 324 |
\newcount\psfc@h |
| 325 |
\newcount\psfc@i |
| 326 |
\newcount\psfc@j |
| 327 |
\newcount\psscale@count |
| 328 |
\newtoks\psfigtoks@ |
| 329 |
% A dimension register for temporarily storing a dimension in |
| 330 |
% \@pDimenToSpNumber. |
| 331 |
\newdimen\psfig@dimen |
| 332 |
% |
| 333 |
%\newwrite\@unused |
| 334 |
%\def\typeout#1{{\let\protect\string\immediate\write\@unused{#1}}} |
| 335 |
|
| 336 |
% Identifying message is here. |
| 337 |
% \typeout{psfig/tex 1.4.gcg / TeXPS}\fi |
| 338 |
% |
| 339 |
% @psdo control structure -- similar to Latex @for. |
| 340 |
% I redefined these with different names so that psfig can |
| 341 |
% be used with TeX as well as LaTeX, and so that it will not |
| 342 |
% be vunerable to future changes in LaTeX's internal |
| 343 |
% control structure. |
| 344 |
\def\@nnil{\@nil} |
| 345 |
\def\@empty{} |
| 346 |
\def\@psdonoop#1\@@#2#3{} |
| 347 |
\def\@psdo#1:=#2\do#3{\edef\@psdotmp{#2}\ifx\@psdotmp\@empty \else |
| 348 |
\expandafter\@psdoloop#2,\@nil,\@nil\@@#1{#3}\fi} |
| 349 |
\def\@psdoloop#1,#2,#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else |
| 350 |
#5\def#4{#2}\ifx #4\@nnil \else#5\@ipsdoloop #3\@@#4{#5}\fi\fi} |
| 351 |
\def\@ipsdoloop#1,#2\@@#3#4{\def#3{#1}\ifx #3\@nnil |
| 352 |
\let\@nextwhile=\@psdonoop \else |
| 353 |
#4\relax\let\@nextwhile=\@ipsdoloop\fi\@nextwhile#2\@@#3{#4}} |
| 354 |
\def\@tpsdo#1:=#2\do#3{\xdef\@psdotmp{#2}\ifx\@psdotmp\@empty \else |
| 355 |
\@tpsdoloop#2\@nil\@nil\@@#1{#3}\fi} |
| 356 |
\def\@tpsdoloop#1#2\@@#3#4{\def#3{#1}\ifx #3\@nnil |
| 357 |
\let\@nextwhile=\@psdonoop \else |
| 358 |
#4\relax\let\@nextwhile=\@tpsdoloop\fi\@nextwhile#2\@@#3{#4}} |
| 359 |
% |
| 360 |
\def\psdraft{% |
| 361 |
\def\@psdraft{0} |
| 362 |
%\typeout{draft level now is \@psdraft \space.} |
| 363 |
} |
| 364 |
\def\psfull{% |
| 365 |
\def\@psdraft{100} |
| 366 |
%\typeout{draft level now is \@psdraft \space.} |
| 367 |
} |
| 368 |
\psfull |
| 369 |
\newif\if@prologfile |
| 370 |
\newif\if@postlogfile |
| 371 |
\newif\if@noisy |
| 372 |
\def\pssilent{% |
| 373 |
\@noisyfalse |
| 374 |
} |
| 375 |
\def\psnoisy{% |
| 376 |
\@noisytrue |
| 377 |
} |
| 378 |
%\psnoisy |
| 379 |
\pssilent |
| 380 |
% These are for the option list: |
| 381 |
% a specification of the form a = b maps to calling \@p@@sa{b}. |
| 382 |
\newif\if@bbllx |
| 383 |
\newif\if@bblly |
| 384 |
\newif\if@bburx |
| 385 |
\newif\if@bbury |
| 386 |
\newif\if@height |
| 387 |
\newif\if@width |
| 388 |
\newif\if@rheight |
| 389 |
\newif\if@rwidth |
| 390 |
\newif\if@clip |
| 391 |
\newif\if@proportional |
| 392 |
\newif\if@scale |
| 393 |
\newif\if@verbose |
| 394 |
\def\@p@@sclip#1{\@cliptrue} |
| 395 |
\def\@p@@sproportional#1{\@proportionaltrue} |
| 396 |
\def\@p@@sfile#1{% |
| 397 |
%\typeout{file is #1} |
| 398 |
\def\@filestem{#1}% |
| 399 |
\def\@p@dffile{#1.pdf}% |
| 400 |
\def\@labfile{#1.lab}% |
| 401 |
} |
| 402 |
\let\@p@@sfigure\@p@@sfile |
| 403 |
% \@pDimenToSpNumber |
| 404 |
% ================== |
| 405 |
% Convert a dimension into scaled points. |
| 406 |
% #1: the name of macro which will expand to the dimension in |
| 407 |
% scaled points, without the unit 'sp' though, i.e. as a pure |
| 408 |
% integer. |
| 409 |
% #2: the dimension (not a dimension register, use |
| 410 |
% \the if dimension is stored in a dimension register). |
| 411 |
\def\@pDimenToSpNumber #1#2{% |
| 412 |
\psfig@dimen = #2\relax |
| 413 |
\edef#1{\number\psfig@dimen}% |
| 414 |
} |
| 415 |
\def\@p@@sbbllx#1{% |
| 416 |
%\typeout{bbllx is #1} |
| 417 |
\@bbllxtrue |
| 418 |
\@pDimenToSpNumber{\@p@sbbllx}{#1}% |
| 419 |
} |
| 420 |
\def\@p@@sbblly#1{% |
| 421 |
%\typeout{bblly is #1} |
| 422 |
\@bbllytrue |
| 423 |
\@pDimenToSpNumber{\@p@sbblly}{#1}% |
| 424 |
} |
| 425 |
\def\@p@@sbburx#1{% |
| 426 |
%\typeout{bburx is #1} |
| 427 |
\@bburxtrue |
| 428 |
\@pDimenToSpNumber{\@p@sbburx}{#1}% |
| 429 |
} |
| 430 |
\def\@p@@sbbury#1{% |
| 431 |
%\typeout{bbury is #1} |
| 432 |
\@bburytrue |
| 433 |
\@pDimenToSpNumber{\@p@sbbury}{#1}% |
| 434 |
} |
| 435 |
\def\@p@@sheight#1{% |
| 436 |
\@heighttrue |
| 437 |
\@pDimenToSpNumber{\@p@sheight}{#1}% |
| 438 |
%\typeout{Height is \@p@sheight} |
| 439 |
} |
| 440 |
\def\@p@@swidth#1{% |
| 441 |
%\typeout{Width is #1} |
| 442 |
\@widthtrue |
| 443 |
\@pDimenToSpNumber{\@p@swidth}{#1}% |
| 444 |
} |
| 445 |
\def\@p@@srheight#1{% |
| 446 |
%\typeout{Reserved height is #1} |
| 447 |
\@rheighttrue |
| 448 |
\@pDimenToSpNumber{\@p@srheight}{#1}% |
| 449 |
} |
| 450 |
\def\@p@@srwidth#1{% |
| 451 |
%\typeout{Reserved width is #1} |
| 452 |
\@rwidthtrue |
| 453 |
\@pDimenToSpNumber{\@p@srwidth}{#1}% |
| 454 |
} |
| 455 |
\def\@p@@ssilent#1{% |
| 456 |
\@verbosefalse |
| 457 |
} |
| 458 |
\def\@p@@sscale #1{% |
| 459 |
\def\@p@scale{#1}% |
| 460 |
\@scaletrue |
| 461 |
} |
| 462 |
|
| 463 |
\def\@p@@sprolog#1{\@prologfiletrue\def\@prologfileval{#1}} |
| 464 |
\def\@p@@spostlog#1{\@postlogfiletrue\def\@postlogfileval{#1}} |
| 465 |
\def\@cs@name#1{\csname #1\endcsname} |
| 466 |
\def\@setparms#1=#2,{\def\@tempa{#2}\ifx\@tempa\@empty |
| 467 |
\@warning{bad syntax (missing = or extra comma) in argument of \string\psfig}% |
| 468 |
\else\@@setparms#1=#2,\fi} |
| 469 |
\def\@@setparms#1=#2=,{\@cs@name{@p@@s#1}{#2}} |
| 470 |
% |
| 471 |
% Initialize the defaults. |
| 472 |
% |
| 473 |
\def\ps@init@parms{% |
| 474 |
\@bbllxfalse \@bbllyfalse |
| 475 |
\@bburxfalse \@bburyfalse |
| 476 |
\@heightfalse \@widthfalse |
| 477 |
\@rheightfalse \@rwidthfalse |
| 478 |
\@scalefalse |
| 479 |
\def\@p@sbbllx{}\def\@p@sbblly{}% |
| 480 |
\def\@p@sbburx{}\def\@p@sbbury{}% |
| 481 |
\def\@p@sheight{}\def\@p@swidth{}% |
| 482 |
\def\@p@srheight{}\def\@p@srwidth{}% |
| 483 |
\def\@p@sfile{}% |
| 484 |
\def\@labfile{}% |
| 485 |
\def\@p@scost{10}% |
| 486 |
\def\@sc{}% |
| 487 |
\@prologfiletrue |
| 488 |
\@postlogfilefalse |
| 489 |
\@clipfalse |
| 490 |
\@proportionalfalse |
| 491 |
\if@noisy |
| 492 |
\@verbosetrue |
| 493 |
\else |
| 494 |
\@verbosefalse |
| 495 |
\fi |
| 496 |
} |
| 497 |
|
| 498 |
%%%% space bug fixes |
| 499 |
\expandafter\let\csname @p@@s scale \endcsname\@p@@sscale |
| 500 |
\expandafter\let\csname @p@@sscale \endcsname\@p@@sscale |
| 501 |
\expandafter\let\csname @p@@s scale\endcsname\@p@@sscale |
| 502 |
|
| 503 |
\expandafter\let\csname @p@@s file \endcsname\@p@@sfile |
| 504 |
\expandafter\let\csname @p@@sfile \endcsname\@p@@sfile |
| 505 |
\expandafter\let\csname @p@@s file\endcsname\@p@@sfile |
| 506 |
|
| 507 |
\expandafter\let\csname @p@@s width \endcsname\@p@@swidth |
| 508 |
\expandafter\let\csname @p@@swidth \endcsname\@p@@swidth |
| 509 |
\expandafter\let\csname @p@@s width\endcsname\@p@@swidth |
| 510 |
|
| 511 |
\expandafter\let\csname @p@@s rwidth \endcsname\@p@@srwidth |
| 512 |
\expandafter\let\csname @p@@srwidth \endcsname\@p@@srwidth |
| 513 |
\expandafter\let\csname @p@@s rwidth\endcsname\@p@@srwidth |
| 514 |
|
| 515 |
\expandafter\let\csname @p@@s height \endcsname\@p@@sheight |
| 516 |
\expandafter\let\csname @p@@sheight \endcsname\@p@@sheight |
| 517 |
\expandafter\let\csname @p@@s height\endcsname\@p@@sheight |
| 518 |
|
| 519 |
\expandafter\let\csname @p@@s rheight \endcsname\@p@@srheight |
| 520 |
\expandafter\let\csname @p@@srheight \endcsname\@p@@srheight |
| 521 |
\expandafter\let\csname @p@@s rheight\endcsname\@p@@srheight |
| 522 |
|
| 523 |
\expandafter\let\csname @p@@s bbllx \endcsname\@p@@sbbllx |
| 524 |
\expandafter\let\csname @p@@sbbllx \endcsname\@p@@sbbllx |
| 525 |
\expandafter\let\csname @p@@s bbllx\endcsname\@p@@sbbllx |
| 526 |
|
| 527 |
\expandafter\let\csname @p@@s bblly \endcsname\@p@@sbblly |
| 528 |
\expandafter\let\csname @p@@sbblly \endcsname\@p@@sbblly |
| 529 |
\expandafter\let\csname @p@@s bblly\endcsname\@p@@sbblly |
| 530 |
|
| 531 |
\expandafter\let\csname @p@@s bburx \endcsname\@p@@sbburx |
| 532 |
\expandafter\let\csname @p@@sbburx \endcsname\@p@@sbburx |
| 533 |
\expandafter\let\csname @p@@s bburx\endcsname\@p@@sbburx |
| 534 |
|
| 535 |
\expandafter\let\csname @p@@s clip \endcsname\@p@@sclip |
| 536 |
\expandafter\let\csname @p@@sclip \endcsname\@p@@sclip |
| 537 |
\expandafter\let\csname @p@@s clip\endcsname\@p@@sclip |
| 538 |
|
| 539 |
\expandafter\let\csname @p@@s proportional \endcsname\@p@@sproportional |
| 540 |
\expandafter\let\csname @p@@sproportional \endcsname\@p@@sproportional |
| 541 |
\expandafter\let\csname @p@@s proportional\endcsname\@p@@sproportional |
| 542 |
|
| 543 |
% |
| 544 |
% Go through the options setting things up. |
| 545 |
% |
| 546 |
\def\parse@ps@parms#1{% |
| 547 |
\@psdo\@psfiga:=#1\do |
| 548 |
{\expandafter\@setparms\@psfiga=,}% |
| 549 |
} |
| 550 |
|
| 551 |
\newif\ifno@file |
| 552 |
\newif\ifno@psfile |
| 553 |
\newif\ifno@bb |
| 554 |
\newif\ifnot@eof |
| 555 |
\newif\if@bbmatch |
| 556 |
\newread\ps@stream |
| 557 |
\newread\lab@stream |
| 558 |
\newcount\@linecount |
| 559 |
\newcount\maxheaderlines |
| 560 |
\maxheaderlines=100 |
| 561 |
|
| 562 |
% |
| 563 |
% Scan header of file, looking for ``BoundingBox'' line |
| 564 |
% |
| 565 |
\def\scan@header{% |
| 566 |
\openin\lab@stream=\@labfile |
| 567 |
\openin\ps@stream=\@filestem.ps |
| 568 |
\ifeof\ps@stream |
| 569 |
\relax\closein\ps@stream |
| 570 |
\openin\ps@stream=\@filestem.eps |
| 571 |
\ifeof\ps@stream |
| 572 |
\relax\closein\ps@stream\no@psfiletrue |
| 573 |
\openin\ps@stream=\@filestem.pdf |
| 574 |
\ifeof\ps@stream |
| 575 |
\relax %needed here so the \@warning won't cause trouble |
| 576 |
\@warning{cannot open \@filestem.ps or .eps or .pdf} |
| 577 |
\closein\ps@stream |
| 578 |
\no@filetrue |
| 579 |
\else |
| 580 |
\edef\@p@sfile{\@filestem.pdf} |
| 581 |
\relax\closein\ps@stream |
| 582 |
\ifno@bb |
| 583 |
% |
| 584 |
% Next five lines of code supplied by Mark Petelier |
| 585 |
% |
| 586 |
% Read BB from pdf file: |
| 587 |
% |
| 588 |
\pdfximage cropbox {\@filestem.pdf} |
| 589 |
\@p@@sbbllx{\pdfximagebbox\pdflastximage 1} |
| 590 |
\@p@@sbblly{\pdfximagebbox\pdflastximage 2} |
| 591 |
\@p@@sbburx{\pdfximagebbox\pdflastximage 3} |
| 592 |
\@p@@sbbury{\pdfximagebbox\pdflastximage 4} |
| 593 |
\no@bbfalse |
| 594 |
\if@bbllx \else \no@bbtrue \fi |
| 595 |
\if@bblly \else \no@bbtrue \fi |
| 596 |
\if@bburx \else \no@bbtrue \fi |
| 597 |
\if@bbury \else \no@bbtrue \fi |
| 598 |
\fi\fi |
| 599 |
\else |
| 600 |
\relax |
| 601 |
\edef\@p@sfile{\@filestem.eps} |
| 602 |
\fi |
| 603 |
\else |
| 604 |
\relax |
| 605 |
\edef\@p@sfile{\@filestem.ps} |
| 606 |
\fi |
| 607 |
\ifno@psfile\else |
| 608 |
\not@eoftrue |
| 609 |
\ifno@bb \@bbmatchfalse \else \@bbmatchtrue \fi |
| 610 |
\catcode`\%=12 |
| 611 |
\catcode`\:=12 % in case punctuation is active (e.g., under french.sty) |
| 612 |
\@linecount=\maxheaderlines |
| 613 |
\loop |
| 614 |
\read\ps@stream to \line@in |
| 615 |
\global\psfigtoks@=\expandafter{\line@in} |
| 616 |
\ifeof\ps@stream \not@eoffalse \fi |
| 617 |
%\typeout{ looking at :: \the\psfigtoks@ } |
| 618 |
\if@bbmatch \else \@bbtest{\psfigtoks@} \fi |
| 619 |
\if@bbmatch \not@eoffalse \fi |
| 620 |
\advance\@linecount-1 |
| 621 |
\ifnum\@linecount=0 \not@eoffalse \fi |
| 622 |
\ifnot@eof \repeat |
| 623 |
\fi |
| 624 |
\catcode`\%=14 |
| 625 |
} |
| 626 |
|
| 627 |
% '% ' becomes a regular character for a very short time. |
| 628 |
{ |
| 629 |
\catcode`\%=12 |
| 630 |
\catcode`\:=12 |
| 631 |
\gdef\@bbtest#1{\expandafter\@bb@\the#1%%BoundingBox:\@bbtest\@bb@} |
| 632 |
\global\long\def\@bb@#1%%BoundingBox:#2#3\@bb@{\ifx\@bbtest#2 |
| 633 |
\else\@bbmatchtrue\expandafter\bb@cull\the\psfigtoks@\fi} |
| 634 |
} |
| 635 |
|
| 636 |
\def\bb@cull#1:{\expandafter\bb@@cull\@iden} |
| 637 |
\long\def\bb@@cull#1 #2 #3 #4 {% |
| 638 |
\@pDimenToSpNumber{\@p@sbbllx}{#1bp}% |
| 639 |
\@pDimenToSpNumber{\@p@sbblly}{#2bp}% |
| 640 |
\@pDimenToSpNumber{\@p@sbburx}{#3bp}% |
| 641 |
\@pDimenToSpNumber{\@p@sbbury}{#4bp}% |
| 642 |
\no@bbfalse |
| 643 |
} |
| 644 |
|
| 645 |
% Compute \@bbw and \@bbh, the width and height of the |
| 646 |
% bounding box. |
| 647 |
\def\compute@bb{% |
| 648 |
\no@bbfalse |
| 649 |
\if@bbllx \else \no@bbtrue \fi |
| 650 |
\if@bblly \else \no@bbtrue \fi |
| 651 |
\if@bburx \else \no@bbtrue \fi |
| 652 |
\if@bbury \else \no@bbtrue \fi |
| 653 |
\scan@header |
| 654 |
\ifno@file |
| 655 |
\else |
| 656 |
\ifno@bb |
| 657 |
\@warning{no bounding box found in \@p@sfile} |
| 658 |
\no@filetrue |
| 659 |
\else |
| 660 |
% Now compute the size of the bounding box. |
| 661 |
\psfc@c=\@p@sbburx |
| 662 |
\psfc@b=\@p@sbbury |
| 663 |
\advance\psfc@c by -\@p@sbbllx |
| 664 |
\advance\psfc@b by -\@p@sbblly |
| 665 |
\edef\@bbw{\number\psfc@c} |
| 666 |
\edef\@bbh{\number\psfc@b} |
| 667 |
%\typeout{\string\compute@bb: bbh = \@bbh, bbw = \@bbw} |
| 668 |
\fi |
| 669 |
\fi |
| 670 |
} |
| 671 |
|
| 672 |
% |
| 673 |
% \in@hundreds performs #1 * (#2 / #3) correct to the hundreds, |
| 674 |
% then leaves the result in \@result. |
| 675 |
% |
| 676 |
% note: #3 should be a big number, or a multiple of 10. |
| 677 |
% |
| 678 |
\def\in@hundreds #1#2#3{% |
| 679 |
\psfc@g=#2 |
| 680 |
\psfc@d=#3 |
| 681 |
\divide\psfc@d 10 |
| 682 |
\psfc@a=\psfc@g % First two digits #2/#3. |
| 683 |
\divide\psfc@a by \psfc@d |
| 684 |
\psfc@f=\psfc@a |
| 685 |
\multiply\psfc@f by \psfc@d |
| 686 |
\advance\psfc@g by -\psfc@f |
| 687 |
\multiply\psfc@g by 10 |
| 688 |
\psfc@f=\psfc@g % Third digit of #2/#3. |
| 689 |
\divide\psfc@f by \psfc@d |
| 690 |
\psfc@j=\psfc@f |
| 691 |
\multiply\psfc@j by \psfc@d |
| 692 |
\advance\psfc@g by -\psfc@j |
| 693 |
\multiply\psfc@g by 10 |
| 694 |
\psfc@j=\psfc@g % Third digit. |
| 695 |
\divide\psfc@j by \psfc@d |
| 696 |
\psfc@h=#1\psfc@i=0 |
| 697 |
\psfc@e=\psfc@h |
| 698 |
\multiply\psfc@e by \psfc@a |
| 699 |
\advance\psfc@i by \psfc@e |
| 700 |
\psfc@e=\psfc@h |
| 701 |
\divide\psfc@e by 10 |
| 702 |
\multiply\psfc@e by \psfc@f |
| 703 |
\advance\psfc@i by \psfc@e |
| 704 |
% |
| 705 |
\psfc@e=\psfc@h |
| 706 |
\divide\psfc@e by 100 |
| 707 |
\multiply\psfc@e by \psfc@j |
| 708 |
\advance\psfc@i by \psfc@e |
| 709 |
\divide\psfc@i 10 |
| 710 |
% |
| 711 |
\edef\@result{\number\psfc@i} |
| 712 |
} |
| 713 |
% Scale a value #1 by the current scaling factor and reassign the new |
| 714 |
% scaled value. |
| 715 |
\def\@ScaleInHundreds #1{% |
| 716 |
\in@hundreds{#1}{\@p@scale}{100}% |
| 717 |
\edef#1{\@result}% |
| 718 |
} |
| 719 |
% |
| 720 |
% |
| 721 |
% Compute width from height. |
| 722 |
\def\compute@wfromh{% |
| 723 |
% computing : width = height * (bbw / bbh) |
| 724 |
\in@hundreds{\@p@sheight}{\@bbw}{\@bbh}% |
| 725 |
%\typeout{ \@p@sheight * \@bbw / \@bbh, = \@result } |
| 726 |
\edef\@p@swidth{\@result}% |
| 727 |
%\typeout{w from h: width is \@p@swidth}% |
| 728 |
} |
| 729 |
% |
| 730 |
% Compute height from width. |
| 731 |
% |
| 732 |
\def\compute@hfromw{% |
| 733 |
% computing : height = width * (bbh / bbw) |
| 734 |
\in@hundreds{\@p@swidth}{\@bbh}{\@bbw}% |
| 735 |
%\typeout{ \@p@swidth * \@bbh / \@bbw = \@result } |
| 736 |
\edef\@p@sheight{\@result}% |
| 737 |
%\typeout{h from w : height is \@p@sheight}% |
| 738 |
} |
| 739 |
% |
| 740 |
% Compute height and width when both are given and proportionality |
| 741 |
% must be preserved. |
| 742 |
% |
| 743 |
\def\compute@minhw{% |
| 744 |
\in@hundreds{\@p@swidth}{\@bbh}{\@bbw}% |
| 745 |
\ifnum\@p@sheight<\@result |
| 746 |
\in@hundreds{\@p@sheight}{\@bbw}{\@bbh}% |
| 747 |
\edef\@p@swidth{\@result}% |
| 748 |
\else |
| 749 |
\edef\@p@sheight{\@result}% |
| 750 |
\fi |
| 751 |
} |
| 752 |
% |
| 753 |
% Compute height and width, i.e. \@p@sheight and \@p@swidth. |
| 754 |
% |
| 755 |
\def\compute@handw{% |
| 756 |
% If height is given. |
| 757 |
\if@height |
| 758 |
% If width is given |
| 759 |
\if@width |
| 760 |
\if@proportional |
| 761 |
\compute@minhw |
| 762 |
\fi |
| 763 |
\else |
| 764 |
% Height, no width: compute width. |
| 765 |
\compute@wfromh |
| 766 |
\fi |
| 767 |
\else |
| 768 |
% No height. |
| 769 |
\if@width |
| 770 |
% Width is given, no height though: compute it. |
| 771 |
\compute@hfromw |
| 772 |
\else |
| 773 |
% Neither width no height is give. |
| 774 |
\edef\@p@sheight{\@bbh} |
| 775 |
\edef\@p@swidth{\@bbw} |
| 776 |
\fi |
| 777 |
\fi |
| 778 |
} |
| 779 |
% Compute the amount of space to reserve. Unless defined |
| 780 |
% using rheight and rwidth when \psfig is called, these values |
| 781 |
% default to \@p@sheight and \@p@swidth. |
| 782 |
\def\compute@resv{% |
| 783 |
\if@rheight \else \edef\@p@srheight{\@p@sheight} \fi |
| 784 |
\if@rwidth \else \edef\@p@srwidth{\@p@swidth} \fi |
| 785 |
} |
| 786 |
% |
| 787 |
% |
| 788 |
% \psfig |
| 789 |
% ====== |
| 790 |
% usage: \psfig{file=, height=, width=, bbllx=, bblly=, bburx=, bbury=, |
| 791 |
% rheight=, rwidth=, clip=, scale=, proportional=} |
| 792 |
% |
| 793 |
% "clip=" and "proportional=" are switches and take no value, |
| 794 |
% but the `=' must be present. |
| 795 |
% |
| 796 |
\def\partest{\par} |
| 797 |
\def\psfig#1{% |
| 798 |
\vbox {% |
| 799 |
\offinterlineskip |
| 800 |
\ps@init@parms |
| 801 |
\parse@ps@parms{#1}% |
| 802 |
% Compute any missing sizes. |
| 803 |
\compute@bb |
| 804 |
\ifno@file\vbox{\hbox{\footnotesize{\tt\@filestem.\{ps,eps,pdf\}} |
| 805 |
not found (or no BBox)}}% |
| 806 |
\else |
| 807 |
\compute@handw |
| 808 |
\compute@resv |
| 809 |
\if@scale |
| 810 |
\ifx\inc@graph@flag\relax\else %% \graphicx syntax used so |
| 811 |
\psfig@dimen=100sp %% multiply scale by 100 |
| 812 |
\psfig@dimen=\@p@scale\psfig@dimen |
| 813 |
\def\@p@scale{\number\psfig@dimen} |
| 814 |
\let\inc@graph@flag\relax %% reset |
| 815 |
\fi |
| 816 |
%\if@verbose \typeout{psfig: scaling by \@p@scale}\fi |
| 817 |
%\if@verbose \typeout{psfig: scaling by \@p@scale}\fi |
| 818 |
% We now scale the width and height as reported to the PS printer. |
| 819 |
\@ScaleInHundreds{\@p@swidth}% |
| 820 |
\@ScaleInHundreds{\@p@sheight}% |
| 821 |
\@ScaleInHundreds{\@p@srwidth}% |
| 822 |
\@ScaleInHundreds{\@p@srheight}% |
| 823 |
\fi |
| 824 |
% |
| 825 |
\ifnum\@p@scost<\@psdraft |
| 826 |
%\if@verbose \typeout{psfig: including \@p@sfile \space}\fi |
| 827 |
\if@topspecials\do@specials\fi |
| 828 |
% Create a vbox to reserve the proper amount of space for the figure. |
| 829 |
\vbox to \@p@srheight sp{% |
| 830 |
\hbox to \@p@srwidth sp{}% |
| 831 |
\vss |
| 832 |
}% |
| 833 |
\if@topspecials\else\do@specials\fi |
| 834 |
\ifx\thelabellist\relax %%% no labellist so look for .lab file |
| 835 |
\ifeof\lab@stream |
| 836 |
\else{% |
| 837 |
\hyperactivelabels |
| 838 |
\not@eoftrue |
| 839 |
\loop |
| 840 |
\read\lab@stream to \line@in \ifx\line@in\partest\else\line@in\fi |
| 841 |
\ifeof\lab@stream \not@eoffalse \fi |
| 842 |
\ifnot@eof \repeat |
| 843 |
}\fi |
| 844 |
\else |
| 845 |
\hyperactivelabels\thelabellist %%% use labellist and |
| 846 |
\global\let\thelabellist\relax %%% reset for next figure |
| 847 |
\ifeof\lab@stream |
| 848 |
\else{ |
| 849 |
\@message{} |
| 850 |
\@message{I have found both a labellist AND a .lab file for \@p@sfile.} |
| 851 |
\@message{I am using the labellist.} |
| 852 |
\@message{If this is not what you want, then edit out the labellist.} |
| 853 |
\@message{} |
| 854 |
}\fi |
| 855 |
\fi |
| 856 |
\else |
| 857 |
% Draft mode: reserve the space for the figure and print the path name. |
| 858 |
\vbox to \@p@srheight sp{% |
| 859 |
\hbox to \@p@srwidth sp{% |
| 860 |
\if@verbose |
| 861 |
\@p@sfile |
| 862 |
\fi |
| 863 |
}% |
| 864 |
\vss |
| 865 |
}% |
| 866 |
\fi |
| 867 |
\fi |
| 868 |
}% |
| 869 |
} |
| 870 |
|
| 871 |
\def\do@specials{\ps@init\ps@begin |
| 872 |
\if@clip |
| 873 |
%\if@verbose \typeout{(clip)} \fi |
| 874 |
\ps@clip \fi |
| 875 |
\if@prologfile \ps@prolog \fi \ps@include \if@postlogfile \ps@postlog \fi |
| 876 |
\ps@end} |
| 877 |
|
| 878 |
\newbox\label@box |
| 879 |
\newdimen\x@lab \newdimen\y@lab |
| 880 |
\newdimen\x@aux \newdimen\y@aux |
| 881 |
\newdimen\hair\hair=3pt |
| 882 |
|
| 883 |
%%%%% version without math mode, with \mathsurround set to 0pt |
| 884 |
%%%%% and final manual adjustment <#6,#7> |
| 885 |
\def\@setlabel@#1#2#3#4#5#6#7{% |
| 886 |
\setbox\label@box\hbox{\mathsurround 0pt\ignorespaces#1}% |
| 887 |
\[email protected]\wd\label@box \x@lab#4\x@lab |
| 888 |
\[email protected]\ht\label@box\advance\[email protected]\dp\label@box \y@lab#5\y@lab |
| 889 |
% rotate lab clockwise by 22.5 degrees to get aux |
| 890 |
\[email protected]\x@lab \advance\[email protected]\y@lab |
| 891 |
\[email protected]\x@lab \advance\[email protected]\y@lab |
| 892 |
% choose |
| 893 |
\ifdim\x@aux>0pt |
| 894 |
\ifdim\y@aux>0pt |
| 895 |
\ifdim\x@aux>\y@aux\advance\[email protected]\hair\advance\[email protected]\hair |
| 896 |
\else\advance\y@lab\hair\fi |
| 897 |
\else |
| 898 |
\ifdim\x@aux>-\y@aux\advance\x@lab\hair |
| 899 |
\else\advance\[email protected]\hair\advance\[email protected]\hair\fi |
| 900 |
\fi |
| 901 |
\else |
| 902 |
\ifdim\y@aux>0pt |
| 903 |
\ifdim\x@aux>-\y@aux\advance\[email protected]\hair\advance\[email protected]\hair |
| 904 |
\else\advance\x@lab-\hair\fi |
| 905 |
\else |
| 906 |
\ifdim\x@aux>\y@aux\advance\y@lab-\hair |
| 907 |
\else |
| 908 |
\ifdim\x@aux<0pt |
| 909 |
\advance\[email protected]\hair\advance\[email protected]\hair\fi |
| 910 |
\fi |
| 911 |
\fi |
| 912 |
\fi |
| 913 |
\advance\[email protected]\wd\label@box |
| 914 |
\advance\[email protected]\ht\label@box\advance\[email protected]\dp\label@box |
| 915 |
\x@aux=#2bp \ifoldlabels \else \advance\x@aux by -\@p@sbbllx sp \fi |
| 916 |
\y@aux=#3bp \ifoldlabels \else \advance\y@aux by -\@p@sbblly sp \fi |
| 917 |
\in@hundreds{\x@aux}{\@p@swidth}{\@bbw} |
| 918 |
\edef\@xpos{\@result} |
| 919 |
\in@hundreds{\y@aux}{\@p@sheight}{\@bbh} |
| 920 |
\edef\@ypos{\@result} |
| 921 |
\vbox to 0pt{% |
| 922 |
\vss\hbox to\@p@srwidth sp{\hskip \@xpos sp \hskip-\x@lab \hskip #6 |
| 923 |
\box\label@box\hss}\vskip \@ypos sp \vskip-\y@lab \vskip #7}} |
| 924 |
|
| 925 |
|
| 926 |
%%%% old syntax: \setlabel and variant \setlabel* (\hair set 0pt) |
| 927 |
%%%% both start in math mode for back-compatibility: |
| 928 |
\def\setlabel{\@ifnextchar*{\setlabel@nohair}{\setlabel@hair}} |
| 929 |
|
| 930 |
%%%% manual adjustment added? |
| 931 |
\def\setlabel@nohair*% |
| 932 |
{\@ifnextchar<{\setlabel@nohair@adj}{\setlabel@nohair@noadj}} |
| 933 |
\def\setlabel@hair% |
| 934 |
{\@ifnextchar<{\setlabel@hair@adj}{\setlabel@hair@noadj}} |
| 935 |
|
| 936 |
\def\setlabel@nohair@noadj#1#2#3#4#5% |
| 937 |
{{\hair 0pt\@setlabel@{$#1$}{#2}{#3}{#4}{#5}{0pt}{0pt}}} |
| 938 |
\def\setlabel@nohair@adj<#1,#2>#3#4#5#6#7% |
| 939 |
{{\hair 0pt\@setlabel@{$#3$}{#4}{#5}{#6}{#7}{#1}{#2}}} |
| 940 |
|
| 941 |
\def\setlabel@hair@noadj#1#2#3#4#5% |
| 942 |
{\@setlabel@{$#1$}{#2}{#3}{#4}{#5}{0pt}{0pt}} |
| 943 |
\def\setlabel@hair@adj<#1,#2>#3#4#5#6#7% |
| 944 |
{\@setlabel@{$#3$}{#4}{#5}{#6}{#7}{#1}{#2}} |
| 945 |
|
| 946 |
|
| 947 |
%%% \pinlabel macro starts here |
| 948 |
|
| 949 |
%%% set up two flags for killing autospacing and using baseline |
| 950 |
%%% and initialise: |
| 951 |
%%% \relax is default ie \hair used but baseline not used |
| 952 |
%%% any other value means \hair not used but baseline used |
| 953 |
\let\hair@flag\relax\let\baseline@flag\relax |
| 954 |
|
| 955 |
%%% define four control sequences to carry the auxiliary information |
| 956 |
%%% and set to default values |
| 957 |
\def\@labxpos@{0}\def\@labypos@{0}% |
| 958 |
\def\@xadj@{0pt}\def\@yadj@{0pt} |
| 959 |
|
| 960 |
%%%% endgame |
| 961 |
\def\finally@pinlabel #1 {\@ifnextchar a% |
| 962 |
{\finally@pinlabel@ {#1} }{\@message{}% |
| 963 |
\@message{There is something wrong with your syntax for label #1;} |
| 964 |
\@message{you must finish with " at XXX YYY " : the "at" and spaces are important!} |
| 965 |
\@message{I'm going to try to ignore this label: don't blame me if there are some} |
| 966 |
\@message{funny numbers in your diagram and later labels are out-of-position.} |
| 967 |
\@message{}}} |
| 968 |
|
| 969 |
\def\finally@pinlabel@ #1 at #2 #3 {% |
| 970 |
\ifx\hair@flag\relax% |
| 971 |
\@setlabel@{\ifx\baseline@flag\relax\the@label\else\smash{\the@label}\fi}% |
| 972 |
{#2}{#3}{\@labxpos@}{\@labypos@}{\@xadj@}{\@yadj@}% |
| 973 |
\else |
| 974 |
{\hair 0pt \@setlabel@{\ifx\baseline@flag\relax\the@label\else\smash{\the@label}\fi}% |
| 975 |
{#2}{#3}{\@labxpos@}{\@labypos@}{\@xadj@}{\@yadj@}} |
| 976 |
\fi |
| 977 |
%%%% don't forget to reset the flags etc to default values |
| 978 |
\let\hair@flag\relax\let\baseline@flag\relax% |
| 979 |
\def\@labxpos@{0}\def\@labypos@{0}% |
| 980 |
\def\@xadj@{0pt}\def\@yadj@{0pt}} |
| 981 |
|
| 982 |
%%%% start to parse the argument |
| 983 |
%%%% is this a starred form or not? |
| 984 |
\def\pinlabel{\@ifnextchar*% |
| 985 |
{\pin@nohair}{\@pinlabel@}} |
| 986 |
\def\pin@nohair* #1 {\def\hair@flag{0}\@pinlabel@ {#1} } |
| 987 |
|
| 988 |
%%%% store the label for safety then |
| 989 |
%%%% is there any label position information? |
| 990 |
\def\@pinlabel@ #1 {\def\the@label{#1}\@ifnextchar a% |
| 991 |
{\finally@pinlabel {#1} }{\@pinlabel@@ {#1} }} |
| 992 |
|
| 993 |
%%%% are we using "by" or [ or going directly to <..,..> |
| 994 |
\def\@pinlabel@@ #1 {\@ifnextchar [% |
| 995 |
{\pin@by@letters {#1} }{\@@pinlabel@@ {#1} }} |
| 996 |
|
| 997 |
\def\@@pinlabel@@ #1 {\@ifnextchar b |
| 998 |
{\pin@by@numbers {#1} }{\@@pinlabel@@@ {#1} }} |
| 999 |
|
| 1000 |
\def\@@pinlabel@@@ #1 {\@ifnextchar <% |
| 1001 |
{\pin@with@adj {#1} }{\@message{}% |
| 1002 |
\@message{I don't understand your positioning information for label #1 and shall} |
| 1003 |
\@message{ignore it; or perhaps your label has a space and needs braces.} |
| 1004 |
\finally@pinlabel {#1} }} |
| 1005 |
|
| 1006 |
%%%% pin@with@adj recycles from the top (to allow <Xpt,Ypt> to come first) |
| 1007 |
\def\pin@with@adj #1 <#2,#3> {% |
| 1008 |
\def\@xadj@{#2}\def\@yadj@{#3} |
| 1009 |
\@pinlabel@ {#1} } |
| 1010 |
|
| 1011 |
%%%% we are using letters, is there adjustment? |
| 1012 |
\def\pin@by@letters #1 [#2] {\@ifnextchar <% |
| 1013 |
{\pin@by@letters@with@adj {#1} [#2] }{\pin@by@letters@no@adj {#1} [#2] }} |
| 1014 |
|
| 1015 |
%%%% we are using numbers, is there adjustment? |
| 1016 |
\def\pin@by@numbers #1 by #2 #3 {\@ifnextchar <% |
| 1017 |
{\pin@by@numbers@with@adj {#1} by #2 #3 }{\pin@by@numbers@no@adj {#1} by #2 #3 }} |
| 1018 |
|
| 1019 |
\def\pin@by@numbers@with@adj #1 by #2 #3 <#4,#5> at #6 #7{% |
| 1020 |
\def\@labxpos@{#2}\def\@labypos@{#3}% |
| 1021 |
\def\@xadj@{#4}\def\@yadj@{#5} |
| 1022 |
\finally@pinlabel {#1} at #6 #7} |
| 1023 |
|
| 1024 |
\def\pin@by@numbers@no@adj #1 by #2 #3 at #4 #5{% |
| 1025 |
\def\@labxpos@{#2}\def\@labypos@{#3}% |
| 1026 |
\def\@xadj@{0pt}\def\@yadj@{0pt} |
| 1027 |
\finally@pinlabel {#1} at #4 #5} |
| 1028 |
|
| 1029 |
%%% read the letter pin positions to a control sequence |
| 1030 |
\def\pin@by@letters@no@adj #1 [#2] {% |
| 1031 |
\expandafter\ifx\csname position@#2\endcsname\relax |
| 1032 |
\@message{} |
| 1033 |
\@message{Unknown position code [#2]; I shall ignore it.} |
| 1034 |
\@message{}\else |
| 1035 |
\csname position@#2\endcsname\fi |
| 1036 |
\finally@pinlabel {#1} } |
| 1037 |
|
| 1038 |
\def\pin@by@letters@with@adj #1 [#2] <#3,#4> {% |
| 1039 |
\expandafter\ifx\csname position@#2\endcsname\relax |
| 1040 |
\@message{} |
| 1041 |
\@message{Unknown position code [#2]; I shall ignore it.} |
| 1042 |
\@message{}\else |
| 1043 |
\csname position@#2\endcsname\fi |
| 1044 |
\def\@xadj@{#3}\def\@yadj@{#4} |
| 1045 |
\finally@pinlabel {#1} } |
| 1046 |
|
| 1047 |
|
| 1048 |
%%%% final task: parse the letter pin positions |
| 1049 |
\def\position@t{\def\@labxpos@{0}\def\@labypos@{1}} |
| 1050 |
\def\position@b{\def\@labxpos@{0}\def\@labypos@{-1}} |
| 1051 |
\def\position@l{\square@left\def\@labxpos@{-1}\def\@labypos@{0}} |
| 1052 |
\def\position@r{\square@right\def\@labxpos@{1}\def\@labypos@{0}} |
| 1053 |
\def\position@B{\def\baseline@flag{1}\def\@labxpos@{0}\def\@labypos@{0}} |
| 1054 |
\def\position@rt{\square@right\def\@labxpos@{1}\def\@labypos@{1}} |
| 1055 |
\def\position@tr{\square@right\def\@labxpos@{1}\def\@labypos@{1}} |
| 1056 |
\def\position@br{\square@right\def\@labxpos@{1}\def\@labypos@{-1}} |
| 1057 |
\def\position@rb{\square@right\def\@labxpos@{1}\def\@labypos@{-1}} |
| 1058 |
\def\position@lt{\square@left\def\@labxpos@{-1}\def\@labypos@{1}} |
| 1059 |
\def\position@tl{\square@left\def\@labxpos@{-1}\def\@labypos@{1}} |
| 1060 |
\def\position@bl{\square@left\def\@labxpos@{-1}\def\@labypos@{-1}} |
| 1061 |
\def\position@lb{\square@left\def\@labxpos@{-1}\def\@labypos@{-1}} |
| 1062 |
\def\position@lB{\square@left\def\baseline@flag{1}% |
| 1063 |
\def\@labxpos@{-1}\def\@labypos@{0}} |
| 1064 |
\def\position@Bl{\square@left\def\baseline@flag{1}% |
| 1065 |
\def\@labxpos@{-1}\def\@labypos@{0}} |
| 1066 |
\def\position@rB{\square@right\def\baseline@flag{1}% |
| 1067 |
\def\@labxpos@{1}\def\@labypos@{0}} |
| 1068 |
\def\position@Br{\square@right\def\baseline@flag{1}% |
| 1069 |
\def\@labxpos@{1}\def\@labypos@{0}} |
| 1070 |
|
| 1071 |
%%%% \square@left and \square@right are hacks to force diagonal |
| 1072 |
%%%% autospacing for the corner letter pin positions |
| 1073 |
|
| 1074 |
\def\square@left{% |
| 1075 |
\setbox\label@box\hbox{\mathsurround 0pt\ignorespaces\the@label}% |
| 1076 |
\y@lab\ht\label@box\advance\y@lab\dp\label@box\let\old@label\the@label |
| 1077 |
\def\the@label{\hbox to \y@lab{\old@label\hss}}} |
| 1078 |
|
| 1079 |
\def\square@right{% |
| 1080 |
\setbox\label@box\hbox{\mathsurround 0pt\ignorespaces\the@label}% |
| 1081 |
\y@lab\ht\label@box\advance\y@lab\dp\label@box\let\old@label\the@label |
| 1082 |
\def\the@label{\hbox to \y@lab{\hss \old@label}}} |
| 1083 |
|
| 1084 |
%%%% end of \pinlabel macro |
| 1085 |
|
| 1086 |
\catcode`@=\atcatcode |
| 1087 |
|
| 1088 |
\endinput |
| 1089 |
|
| 1090 |
%%%%% History: Version 1.1 released 25 March 2006 |
| 1091 |
%%%%% 28/Mar/06: bugfixes and code to detect mathematica/illustrator deleted |
| 1092 |
%%%%% 5/Apr/06: bugfix and extra utility: <Xpt,Ypt> can come first |
| 1093 |
%%%%% 20/Apr/06: \includegraphics uses graphicx if no labellist (Naom) |
| 1094 |
%%%%% 1/May/06: bugfix to \includegraphics code |
| 1095 |
%%%%% 23/Oct/06: LPPL license added (for CTAN) |
| 1096 |
%%%%% 4/Nov/11: Version 1.2: Mark Petelier's code added to read BB from pdf file |
| 1097 |
|