Debian Codegraph @

texmf-dist/tex/latex/lpic/lpic.sty

raw
1 %% lpic.sty
2 %% Copyright 2010 R. Matveyev
3 %
4 % This work may be distributed and/or modified under the
5 % conditions of the LaTeX Project Public License, either version 1.3
6 % of this license or (at your option) any later version.
7 % The latest version of this license is in
8 % http://www.latex-project.org/lppl.txt
9 % and version 1.3 or later is part of all distributions of LaTeX
10 % version 2005/12/01 or later.
11 %
12 % This work has the LPPL maintenance status `maintained'.
13 %
14 % The Current Maintainer of this work is R. Matveyev.
15 %
16 % This work consists of the files:
17 % lpic.sty instructions.tex
18 % instructions.pdf instructions-differential.eps
19 % instructions-differential.pdf README
20
21 % lpic.sty V0.8, 23.12.2010
22 %
23
24 \ProvidesPackage{lpic}
25 [2010/12/23, version 0.8]
26
27 \NeedsTeXFormat{LaTeX2e}
28 \RequirePackage{epsfig}
29 \RequirePackage{rotating}
30 \RequirePackage{calc}
31 \RequirePackage{ifthen}
32 \RequirePackage{color}
33
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 % debugging stuff
37 %
38
39 \newcommand{\lp@skipthis}[1]{\relax}
40 \newcommand{\lp@msg}[1]{\message{^^J! lpic message: #1^^J}}
41
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 %
44 % Counters, lengths, boxes
45 %
46
47 % Adjustable parameters
48 \newlength{\lpunitlength}\setlength{\lpunitlength}{1mm}
49
50 \newlength{\lpmarginright}\setlength{\lpmarginright}{0mm}
51 \newlength{\lpmarginleft}\setlength{\lpmarginleft}{0mm}
52 \newlength{\lpmargintop}\setlength{\lpmargintop}{0mm}
53 \newlength{\lpmarginbottom}\setlength{\lpmarginbottom}{0mm}
54
55 \newlength{\lpbgboxsep}\setlength{\lpbgboxsep}{\fboxsep}
56
57 \newlength{\lpgridthickness}\setlength{\lpgridthickness}{0.01mm}
58 \newlength{\lpframethickness}\setlength{\lpframethickness}{0.7mm}
59 \newlength{\lplblframethickness}\setlength{\lplblframethickness}{0.01mm}
60 \newlength{\lpfigframethickness}\setlength{\lpfigframethickness}{0.2mm}
61
62 \newcounter{lpgridstep}\setcounter{lpgridstep}{5}
63 \newcounter{lpcoordstep}\setcounter{lpcoordstep}{10}
64
65 % Internal parameters
66 \newlength{\lp@marginright}
67 \newlength{\lp@marginleft}
68 \newlength{\lp@margintop}
69 \newlength{\lp@marginbottom}
70 \newlength{\lp@xsizeorig}
71 \newlength{\lp@ysizeorig}
72 \newlength{\lp@xtotalsizeorig}
73 \newlength{\lp@ytotalsizeorig}
74 \newlength{\lp@gridstep}
75 \newlength{\lp@coordstep}
76 \newlength{\lp@coordx}
77 \newlength{\lp@coordy}
78
79 \newcounter{lp@xtotalsize}
80 \newcounter{lp@ytotalsize}
81 \newcounter{lp@xorigin}
82 \newcounter{lp@yorigin}
83 \newcounter{lp@coordx}
84 \newcounter{lp@coordy}
85
86 \newsavebox{\lp@pictbox} %box to save (ps or pdf)-figure
87
88 % Temp stuff
89 \newlength{\lp@tmpa}
90 \newlength{\lp@tmpb}
91 \newlength{\lp@tmpc}
92 \newlength{\lp@tmpd}
93 \newlength{\lp@tmpx}
94 \newlength{\lp@tmpy}
95 \newlength{\lp@tmpdx}
96 \newlength{\lp@tmpdy}
97
98 \newcounter{lp@tmpa}
99 \newcounter{lp@tmpb}
100 \newcounter{lp@tmpc}
101 \newcounter{lp@tmpd}
102 \newcounter{lp@tmpe}
103 \newcounter{lp@tmpf}
104 \newcounter{lp@tmpx}
105 \newcounter{lp@tmpy}
106 \newcounter{lp@tmpdx}
107 \newcounter{lp@tmpdy}
108
109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110 %
111 % Procedure to check whether argument is a number or length
112 % we need a way to check whether given argument is a number or
113 % length \lp@ifnumber{arg}{true cmds}{false cmds}
114
115 \def\lp@substring#1 in #2;%
116 {%
117 \def\lp@check##1#1##2ENDOFTHEARGS%
118 {\edef\lp@foundsubstring{\lp@foundsubstring##2}}%
119 \expandafter\lp@check#2#1ENDOFTHEARGS%
120 }
121
122 \def\lp@ifsubstring#1 in #2;#3#4%
123 {%
124 \edef\lp@foundsubstring{}%
125 \lp@substring #1 in #2;%
126 \ifthenelse{\equal{x}{x\lp@foundsubstring}}{#4}{#3}%
127 }
128
129 \newcommand{\lp@ifnumber}[3]%
130 {%
131 \edef\lp@foundsubstring{}%
132 \lp@substring pt in #1;%
133 \lp@substring pc in #1;%
134 \lp@substring in in #1;%
135 \lp@substring bp in #1;%
136 \lp@substring cm in #1;%
137 \lp@substring mm in #1;%
138 \lp@substring dd in #1;%
139 \lp@substring cc in #1;%
140 \lp@substring sp in #1;%
141 \lp@substring em in #1;%
142 \lp@substring ex in #1;%
143 \ifthenelse{\equal{\lp@foundsubstring}{}}{#2}{#3}%
144 }
145
146 %
147 %
148 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
149
150 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
151 %
152 % Save scaled picture in \lp@pictbox, calculate its sizes, calculate
153 % sizes and the origin of the whole picture box and define procedure
154 % for calculating coordinates
155 % \lp@dimens defines \lp@xtotalsize!, \lp@ytotalsize!, \lp@xorig!,
156 % \lp@yorig!, \lp@xcoord{original_length_in_\lp@units},
157 % \lp@ycoord{original_length_in_\lp@units}
158 %
159
160 \newcommand{\lp@dimens}
161 {%
162 % Save unscaled pict and calculate sizes
163 \sbox{\lp@pictbox}{\epsfig{figure=\lp@epsfile}}%
164 \settowidth{\lp@xsizeorig}{\usebox{\lp@pictbox}}% Original x-size
165 \settoheight{\lp@ysizeorig}{\usebox{\lp@pictbox}}% Original y-size
166 %
167 % Are we given absolute dimensions or scale coefficients?
168 \ifthenelse{\equal{\lp@xscale}{}}%
169 % x scale is not given
170 {%
171 %\lp@msg{x=\lp@xscale, y=\lp@yscale}
172 \ifthenelse{\equal{\lp@yscale}{}}
173 % x - no, y - no
174 {%
175 \edef\lp@xnum{1cm}\edef\lp@xdenom{1cm}%
176 \edef\lp@ynum{1cm}\edef\lp@ydenom{1cm}%
177 }%
178 % x - no, y - yes
179 {%
180 \lp@ifnumber{\lp@yscale}
181 {%
182 \edef\lp@ynum{\lp@yscale cm}\edef\lp@ydenom{1cm}%
183 \edef\lp@xnum{\lp@yscale cm}\edef\lp@xdenom{1cm}%
184 }%
185 {%
186 \edef\lp@ynum{\lp@yscale}\def\lp@ydenom{\lp@ysizeorig}%
187 \edef\lp@xnum{\lp@yscale}\def\lp@xdenom{\lp@ysizeorig}%
188 }%
189 }%
190 }%
191 % x is given
192 {%
193 \ifthenelse{\equal{\lp@yscale}{}}
194 % x - yes, y - no
195 {%
196 \lp@ifnumber{\lp@xscale}
197 {%
198 \edef\lp@ynum{\lp@xscale cm}\edef\lp@ydenom{1cm}%
199 \edef\lp@xnum{\lp@xscale cm}\edef\lp@xdenom{1cm}%
200 }%
201 {%
202 \edef\lp@ynum{\lp@xscale}\def\lp@ydenom{\lp@xsizeorig}%
203 \edef\lp@xnum{\lp@xscale}\def\lp@xdenom{\lp@xsizeorig}%
204 }%
205 }%
206 % x - yes, y - yes
207 {%
208 \lp@ifnumber{\lp@xscale}
209 {%
210 \edef\lp@xnum{\lp@xscale cm}\edef\lp@xdenom{1cm}%
211 }
212 {%
213 \edef\lp@xnum{\lp@xscale}\def\lp@xdenom{\lp@xsizeorig}%
214 }
215 \lp@ifnumber{\lp@yscale}
216 {%
217 \edef\lp@ynum{\lp@yscale cm}\edef\lp@ydenom{1cm}%
218 }
219 {%
220 \edef\lp@ynum{\lp@yscale}\def\lp@ydenom{\lp@ysizeorig}%
221 }%
222
223 }%
224 }%
225 %\lp@msg{xscale=\lp@xnum/\lp@xdenom, yscale=\lp@ynum/\lp@ydenom}
226 \setlength{\lp@tmpx}{\lp@xsizeorig * \ratio{\lp@xnum}{\lp@xdenom}}% x-size in the doc
227 \setlength{\lp@tmpy}{\lp@ysizeorig * \ratio{\lp@ynum}{\lp@ydenom}}% y-size in the doc
228 % Save scaled picture
229 \sbox{\lp@pictbox}%
230 {\epsfig{figure=\lp@epsfile, width=\lp@tmpx, height=\lp@tmpy}}%
231 % Calculate sizes and coordinates of the origin of the whole pict
232 \setlength{\lp@tmpa}{\lp@tmpx + \lpmarginleft + \lpmarginright}%
233 \setcounter{lp@xtotalsize}{\lp@tmpa / \unitlength}%
234 \def\lp@xtotalsize{\value{lp@xtotalsize}}%
235 \setlength{\lp@tmpa}{\lp@tmpy + \lpmargintop + \lpmarginbottom}%
236 \setcounter{lp@ytotalsize}{\lp@tmpa / \unitlength}%
237 \def\lp@ytotalsize{\value{lp@ytotalsize}}%
238 \setcounter{lp@xorigin}{-\lpmarginleft / \unitlength}%
239 \def\lp@xorigin{\value{lp@xorigin}}%
240 \setcounter{lp@yorigin}{-\lpmarginbottom / \unitlength}%
241 \def\lp@yorigin{\value{lp@yorigin}}%
242 % Redefine margins in units of the original
243 \setlength{\lp@marginleft}{\lpmarginleft / \ratio{\lp@xnum}{\lp@xdenom}}%
244 \setlength{\lp@marginright}{\lpmarginright / \ratio{\lp@xnum}{\lp@xdenom}}%
245 \setlength{\lp@margintop}{\lpmargintop / \ratio{\lp@ynum}{\lp@ydenom}}%
246 \setlength{\lp@marginbottom}{\lpmarginbottom / \ratio{\lp@ynum}{\lp@ydenom}}%
247 \setlength{\lp@xtotalsizeorig}%
248 {\lp@xsizeorig + \lp@marginleft + \lp@marginright}%
249 \setlength{\lp@ytotalsizeorig}%
250 {\lp@ysizeorig + \lp@margintop + \lp@marginbottom}%
251 }
252
253 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
254 %
255 % Define \lp@put(x,y)[position]{object}
256 % \lp@multiput(x,y)(deltax,deltay)[position]{count}{object}
257 % where (x,y)(deltax,deltay) are lengths in the original unscaled eps
258 % picture.
259 %
260 \def\lp@put(#1,#2)[#3]#4%
261 {{%
262 \setlength{\lp@tmpx}{( #1 ) * \ratio{\lp@xnum}{\lp@xdenom}}%
263 \setlength{\lp@tmpy}{( #2 ) * \ratio{\lp@ynum}{\lp@ydenom}}%
264 \setcounter{lp@tmpx}{\lp@tmpx / \unitlength}%
265 \setcounter{lp@tmpy}{\lp@tmpy / \unitlength}%
266 \put(\value{lp@tmpx},\value{lp@tmpy})%
267 {\makebox(0,0)[#3]{#4}}%
268 }}
269
270 \def\lp@multiput(#1,#2)(#3,#4)(#5)[#6]#7%
271 {{%
272 \setlength{\lp@tmpx}{( #1 ) * \ratio{\lp@xnum}{\lp@xdenom}}%
273 \setlength{\lp@tmpy}{( #2 ) * \ratio{\lp@ynum}{\lp@ydenom}}%
274 \setcounter{lp@tmpx}{\lp@tmpx / \unitlength}%
275 \setcounter{lp@tmpy}{\lp@tmpy / \unitlength}%
276 \setlength{\lp@tmpdx}{( #3 ) * \ratio{\lp@xnum}{\lp@xdenom}}%
277 \setlength{\lp@tmpdy}{( #4 ) * \ratio{\lp@ynum}{\lp@ydenom}}%
278 \setcounter{lp@tmpdx}{\lp@tmpdx / \unitlength}%
279 \setcounter{lp@tmpdy}{\lp@tmpdy / \unitlength}%
280 \multiput(\value{lp@tmpx},\value{lp@tmpy})%
281 (\value{lp@tmpdx},\value{lp@tmpdy})%
282 {#5}%
283 {\makebox(0,0)[#6]{#7}}%
284 }}
285
286 \def\lp@hline#1%
287 {{%
288 \setlength{\lp@tmpa}{#1}%
289 \setlength{\lp@tmpa}{\lp@tmpa * \ratio{\lp@xnum}{\lp@xdenom}}%
290 \setcounter{lp@tmpa}{\lp@tmpa / \unitlength}%
291 \line(1,0){\value{lp@tmpa}}%
292 }}
293
294 \def\lp@vline#1%
295 {{%
296 \setlength{\lp@tmpa}{#1}%
297 \setlength{\lp@tmpa}{\lp@tmpa * \ratio{\lp@ynum}{\lp@ydenom}}%
298 \setcounter{lp@tmpa}{\lp@tmpa / \unitlength}%
299 \line(0,1){\value{lp@tmpa}}%
300 }}
301
302 % \lp@put.....
303 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
304
305
306
307 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
308 % Drawing commands
309 %
310
311 % \lp@pictframecmd draws a frame around all of the picture including
312 % margins. \lpframethickness -- thickness of the lines
313 \newcommand{\lp@pictframecmd}
314 {\begingroup%
315 \linethickness{\lpframethickness}%
316 \lp@put(-\lp@marginleft,-\lp@marginbottom)[l]
317 {\lp@hline{\lp@xsizeorig+\lp@marginleft+\lp@marginright}}%
318 \lp@put(-\lp@marginleft,-\lp@marginbottom)[b]
319 {\lp@vline{\lp@ysizeorig+\lp@margintop+\lp@marginbottom}}%
320 \lp@put(\lp@xsizeorig+\lp@marginright,\lp@ysizeorig+\lp@margintop)[r]
321 {\lp@hline{\lp@xsizeorig+\lp@marginleft+\lp@marginright}}%
322 \lp@put(\lp@xsizeorig+\lp@marginright,\lp@ysizeorig+\lp@margintop)[t]
323 {\lp@vline{\lp@ysizeorig+\lp@margintop+\lp@marginbottom}}%
324 \endgroup}
325
326 % \lp@gridcmd draws a grid with the step \value{lpgridstep} x
327 % \lpunitlength wrt original and lines \lpgridthickness thick
328 \newcommand{\lp@gridcmd}
329 {%
330 \begingroup%
331 \linethickness{\lpgridthickness} %
332 \setlength{\lp@gridstep}{\lpunitlength * \value{lpgridstep}}%
333 \setcounter{lp@tmpa}{\lp@marginleft / \lp@gridstep}%
334 \setlength{\lp@tmpa}{-\lp@gridstep * \value{lp@tmpa}}%
335 \setcounter{lp@tmpb}
336 {(\lp@xsizeorig-\lp@tmpa+\lp@marginright ) / %
337 \lp@gridstep + 1}%
338 \lp@multiput(\lp@tmpa,-\lp@marginbottom)%
339 (\lp@gridstep,0mm)%
340 (\value{lp@tmpb})%
341 [b]%
342 {\lp@vline{\lp@ysizeorig+\lp@margintop+\lp@marginbottom}}%
343 \setcounter{lp@tmpa}{\lp@marginbottom / \lp@gridstep}%
344 \setlength{\lp@tmpa}{-\lp@gridstep * \value{lp@tmpa}}%
345 \setcounter{lp@tmpb}
346 {(\lp@ysizeorig-\lp@tmpa+\lp@margintop ) / %
347 \lp@gridstep + 1}%
348 \lp@multiput(-\lp@marginleft,\lp@tmpa)%
349 (0mm,\lp@gridstep)%
350 (\value{lp@tmpb})%
351 [l]%
352 {\lp@hline{\lp@xsizeorig+\lp@marginleft+\lp@marginright}}%
353 \endgroup%
354 }
355
356 % \lp@coordscmd draws coordinates on all four sides of the picture
357 % with the step \lpunitlength * \value{lpcoordstep}
358 \newcommand{\lp@coordscmd}
359 {\begingroup%
360 \setlength{\lp@coordstep}{\lpunitlength * \value{lpcoordstep}}%
361 \setcounter{lp@tmpa}{\lp@marginleft / \lp@coordstep}
362 \setlength{\lp@tmpa}{-\lp@coordstep * \value{lp@tmpa}}
363 \setcounter{lp@tmpb}
364 {(\lp@xsizeorig-\lp@tmpa+\lp@marginright) / \lp@coordstep+1}
365 \setcounter{lp@tmpc}{\lp@tmpa / \lpunitlength}
366 \lp@multiput(\lp@tmpa,-\lp@marginbottom-\lpframethickness-0.1mm)%
367 (\lp@coordstep,0mm)%
368 (\value{lp@tmpb})%
369 [t]%
370 {%
371 {\tiny\bf\arabic{lp@tmpc}}%
372 \addtocounter{lp@tmpc}{\value{lpcoordstep}}%
373 }%
374 \setcounter{lp@tmpc}{\lp@tmpa / \lpunitlength}
375 \lp@multiput(\lp@tmpa,\lp@ysizeorig+\lp@margintop+\lpframethickness)%
376 (\lp@coordstep,0mm)%
377 (\value{lp@tmpb})%
378 [b]%
379 {%
380 {\tiny\bf\arabic{lp@tmpc}}%
381 \addtocounter{lp@tmpc}{\value{lpcoordstep}}%
382 }%
383 \setcounter{lp@tmpa}{\lp@marginbottom / \lp@coordstep}
384 \setlength{\lp@tmpa}{-\lp@coordstep * \value{lp@tmpa}}
385 \setcounter{lp@tmpb}
386 {(\lp@ysizeorig-\lp@tmpa+\lp@margintop)/\lp@coordstep+1}
387 \setcounter{lp@tmpc}{\lp@tmpa / \lpunitlength}
388 \lp@multiput(-\lp@marginleft-\lpframethickness,\lp@tmpa)%
389 (0mm,\lp@coordstep)%
390 (\value{lp@tmpb})%
391 [r]%
392 {%
393 {\tiny\bf\arabic{lp@tmpc}}%
394 \addtocounter{lp@tmpc}{\value{lpcoordstep}}%
395 }%
396 \setcounter{lp@tmpc}{\lp@tmpa / \lpunitlength}
397 \lp@multiput(\lp@xsizeorig+\lp@marginright+\lpframethickness,\lp@tmpa)%
398 (0mm,\lp@coordstep)%
399 (\value{lp@tmpb})%
400 [l]%
401 {%
402 {\tiny\bf\arabic{lp@tmpc}}%
403 \addtocounter{lp@tmpc}{\value{lpcoordstep}}%
404 }%
405 \endgroup}
406
407
408 % \lp@lblframecmd draws a frame around each label \lplblframethickness
409 % thick
410 \newcommand{\lp@lblframecmd}[1]
411 {\begingroup%
412 \setlength{\linethickness}{\lplblframethickness}%
413 \frame{#1}%
414 \endgroup}
415
416 % \lp@figframecmd draws a frame around eps figure \lpfigframethickness
417 % thick
418 \newcommand{\lp@figframecmd}[1]
419 {\begingroup%
420 \setlength{\linethickness}{\lpfigframethickness}%
421 \frame{#1}%
422 \endgroup}
423
424 %
425 \newcommand{\lp@putepsfigurecmd}
426 {%
427 \put(0,0){\makebox(0,0)[bl]{\lp@figframe{\usebox{\lp@pictbox}}}}
428 }
429
430 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
431 % options
432
433 % Print nothing but the picture and labels
434 \def\lpopt@clean
435 {%
436 \let\lp@lblframe=\relax%
437 \let\lp@figframe=\relax%
438 \let\lp@pictframe=\relax%
439 \let\lp@coords=\relax%
440 \let\lp@grid=\relax%
441 \let\lbl=\lbl@cmd%
442 \let\lp@putepsfigure=\lp@putepsfigurecmd%
443 }
444
445 % Set margins
446 \def\lpopt@l#1%
447 {%
448 \ifthenelse{\not\equal{#1}{}}
449 {\setlength{\lpmarginleft}{#1}}
450 {}%
451 }
452 \def\lpopt@r#1%
453 {%
454 \ifthenelse{\not\equal{#1}{}}
455 {\setlength{\lpmarginright}{#1}}
456 {}%
457 }
458 \def\lpopt@t#1%
459 {%
460 \ifthenelse{\not\equal{#1}{}}
461 {\setlength{\lpmargintop}{#1}}
462 {}%
463 }
464 \def\lpopt@b#1%
465 {%
466 \ifthenelse{\not\equal{#1}{}}
467 {\setlength{\lpmarginbottom}{#1}}
468 {}%
469 }
470
471 % Print frame around whole picture margins included
472 \def\lpopt@frame#1%
473 {%
474 \ifthenelse{\not\equal{#1}{}}
475 {\setlength{\lpframethickness}{#1}}{}%
476 \let\lp@pictframe=\lp@pictframecmd%
477 }
478
479 % Print frame around eps figure
480 \def\lpopt@figframe#1%
481 {%
482 \ifthenelse{\not\equal{#1}{}}
483 {\setlength{\lpfigframethickness}{#1}}{}%
484 \let\lp@figframe=\lp@figframecmd%
485 }
486
487 % Draw frames around labels
488 \def\lpopt@frames#1%
489 {%
490 \ifthenelse{\not\equal{#1}{}}
491 {\setlength{\lplblframethickness}{#1}}{}%
492 \let\lp@lblframe=\lp@lblframecmd%
493 }
494
495 % Write coordinates on all four sides of the picture
496 % argument=step
497 \def\lpopt@coords#1%
498 {%
499 \ifthenelse{\not\equal{#1}{}}
500 {\setcounter{lpcoordstep}{#1}}{}%
501 \let\lp@coords=\lp@coordscmd%
502 }
503
504 % Draw a grid, argument=step
505 \def\lpopt@grid#1%
506 {%
507 \ifthenelse{\not\equal{#1}{}}
508 {\setcounter{lpgridstep}{#1}}{}%
509 \let\lp@grid=\lp@gridcmd%
510 }
511
512 % Ignore all the labels
513 \def\lpopt@nolbl{\renewcommand{\lbl}[2][]{\relax}}
514
515 % Don't insert epsfigure
516 \def\lpopt@nofigure{\let\lp@putepsfigure=\relax}
517
518 % Draw what is usually convenient for adjusting the labels
519 \def\lpopt@draft
520 {%
521 \lpopt@figframe{}\relax%
522 \lpopt@frame{}\relax%
523 \lpopt@coords{}\relax%
524 \lpopt@grid{}\relax%
525 \lpopt@frames{}\relax%
526 }
527
528 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
529 % Option processing commands
530 %
531 %
532
533 % Should be called \exec@option{name(arg)} or
534 % \exec@option{name}. It executes \name and passes
535 % arg if present as an argument.
536 % That is \name should have at most one argument.
537
538 \def\exec@optionmisc#1(#2)#3ENDOFTHEARGS%
539 {%
540 \csname#1\endcsname{#2}\relax%
541 }
542 \newcommand{\exec@option}[1]
543 {%
544 \exec@optionmisc#1()ENDOFTHEARGS%
545 }
546
547
548 % Called with a coma-separated list of options, and then executes
549 % each ``name'' prefixed with the value of \option@prefix. It passes
550 % this command the argument if present. Each option is either
551 % ``name'' or ``name(arg)''. ``arg'' should not contain comas or
552 % should be enclosed in {}.
553 \def\process@optionsmisc#1,#2ENDOFTHEARGS%
554 {%
555 %\lp@msg{1=#1, 2=#2}
556 \ifthenelse{\not\equal{#1}{}}%
557 {%
558 \exec@option{\option@prefix#1}%
559 \process@optionsmisc#2ENDOFTHEARGS%
560 }%
561 {}%
562 }
563 \newcommand\process@options[1]
564 {%
565 \process@optionsmisc#1,,ENDOFTHEARGS%
566 }
567
568
569 % Next command process ``filename'' argument.
570 % Defines \lp@epsfile, \lp@xscale, \lp@yscale
571 % Syntaxis is one of the following
572 % \lp@getscaleandfile{FILE}
573 % \lp@getscaleandfile{FILE()}
574 % \lp@getscaleandfile{FILE(,)}
575 % \lp@getscaleandfile{FILE(x)}
576 % \lp@getscaleandfile{FILE(x,)}
577 % \lp@getscaleandfile{FILE(,y)}
578 % \lp@getscaleandfile{FILE(x,y)}
579
580 \def\lp@getname#1(#2ENDOFTHEARGS{\edef\lp@epsfile{#1}\edef\lp@string{#2}}
581 \def\lp@getscales#1)#2ENDOFTHEARGS{\edef\lp@string{#1}}
582 \def\lp@getxscale#1,#2ENDOFTHEARGS{\edef\lp@xscale{#1}\edef\lp@string{#2}}
583 \def\lp@getyscale#1,#2ENDOFTHEARGS{\edef\lp@yscale{#1}\edef\lp@string{#2}}
584
585 \def\lp@getscaleandfile#1%
586 {%
587 \edef\lp@epsfile{}%
588 \edef\lp@xscale{}%
589 \edef\lp@yscale{}%
590 \edef\lp@string{#1}%
591 \expandafter\lp@getname\lp@string(ENDOFTHEARGS%
592 \expandafter\lp@getscales\lp@string)ENDOFTHEARGS%
593 \expandafter\lp@getxscale\lp@string,ENDOFTHEARGS%
594 \expandafter\lp@getyscale\lp@string,ENDOFTHEARGS%
595 %\lp@msg{file=\lp@epsfile, x=\lp@xscale, y=\lp@yscale}%
596 }
597 %
598 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
599
600
601 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
602 % \begin{lpic}[coma separated options]{filename[(xscale[,yscale])]},
603 % \lbl[position]{xcoord,ycoord;object}
604 % ....
605 % \end{lpic}
606 % Where options are clean, draft, grid, frame, frames, coords, nolbl
607 % Position is at most two of the following t,b,l,r
608 \newenvironment{lpic}[2][clean]
609 {\begingroup%
610 %Process options
611 \edef\option@prefix{lpopt@}%
612 \setlength{\unitlength}{1sp}%
613 \lpopt@clean%
614 \process@options{#1}%
615 % read scale and filename from the second argument
616 \expandafter\lp@getscaleandfile{#2}%
617 % Calculate parameters
618 \lp@dimens%
619 % Start picture environment
620 \begin{picture}(\lp@xtotalsize,\lp@ytotalsize)
621 (\lp@xorigin,\lp@yorigin)%
622 %insert picture. We do it before any LaTeX, so that white bg rectangles are on top
623 \lp@putepsfigure%
624 }
625 {%
626 %draw a frame around the whole picture
627 \lp@pictframe
628 % draw grid
629 \lp@grid
630 % draw coordinates
631 \lp@coords
632 \end{picture}%
633 \endgroup}
634 %
635 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
636
637 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
638 %
639 % \lbl[position]{<xcoord>,<ycoord>[,angle];object}
640 %
641
642 % read coordinates and the angle from the argument of \lbl
643 \def\lp@getxya#1,#2,#3,#4ENDOFTHEARGS%
644 {%
645 \setlength{\lp@tmpx}{\lpunitlength * \real{#1} * \ratio{\lp@xnum}{\lp@xdenom}}%
646 \setcounter{lp@tmpx}{\lp@tmpx / \unitlength}%
647 \setlength{\lp@tmpy}{\lpunitlength * \real{#2} * \ratio{\lp@ynum}{\lp@ydenom}}%
648 \setcounter{lp@tmpy}{\lp@tmpy / \unitlength}%
649 \def\lp@angle{#3}%
650 }
651
652 % disassemble the arg of \lbl
653 \def\lp@getdata#1;#2#3ENDOFTHEARGS%
654 {%
655 \lp@getxya#1,,,ENDOFTHEARGS%
656 \def\lp@lbldata{#2#3}%
657 }
658
659 \newcommand{\lp@getcoords}[1]
660 {%
661 \lp@getdata#1ENDOFTHEARGS%
662 }
663
664 %\setlength{\lpbgboxsep}{10mm}
665
666 \newcommand{\lbl@cmd}[2][]
667 {\begingroup%
668 % Set the defaults
669 \def\lp@lblbox{\makebox(0,0)[#1]} %
670 \def\lp@bgbox{\relax} % No background
671 \setcounter{lp@tmpdx}{0} % No shifting
672 \setcounter{lp@tmpdy}{0}
673 % Dissasemble the second argument
674 \lp@getcoords{#2}%
675 % Let's see whether angle is supplied
676 \ifthenelse{\equal{\lp@angle}{}}
677 {\let\lp@rotatelbl=\relax}
678 {\def\lp@rotatelbl{\turnbox{\lp@angle}}}%
679 % What options are given?
680 % ``W'' put white background with margins
681 \lp@ifsubstring W in #1;%
682 {%
683 \setlength{\lp@tmpa}{0.152mm}
684 \setcounter{lp@tmpdx}{( \lpbgboxsep + \lp@tmpa ) / \unitlength}%
685 \setcounter{lp@tmpdy}{( \lpbgboxsep + \lp@tmpa ) / \unitlength}%
686 \def\lp@bgbox##1{%
687 \begingroup%
688 \setlength{\fboxsep}{\lpbgboxsep}%
689 \colorbox{white}{##1}
690 \endgroup%
691 }%
692 }%
693 {}%
694 % ``w'' put white background without margins
695 \lp@ifsubstring w in #1;%
696 {%
697 \def\lp@bgbox##1{%
698 \begingroup%
699 \setlength{\fboxsep}{0mm}%
700 \colorbox{white}{##1}%
701 \endgroup%
702 }%
703 }%
704 {}%
705 % Positioning
706 \lp@ifsubstring t in #1;{\addtocounter{lp@tmpy}{\value{lp@tmpdy}}}{}%
707 \lp@ifsubstring b in #1;{\addtocounter{lp@tmpy}{-\value{lp@tmpdy}}}{}%
708 \lp@ifsubstring l in #1;{\addtocounter{lp@tmpx}{-\value{lp@tmpdx}}}{}%
709 \lp@ifsubstring r in #1;{\addtocounter{lp@tmpx}{\value{lp@tmpdx}}}{}%
710 % Put the material
711 \put(\value{lp@tmpx},\value{lp@tmpy})%
712 {\lp@rotatelbl{\lp@lblbox{\lp@bgbox{\lp@lblframe{\lp@lbldata}}}}}%
713 \endgroup}
714
715 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
716 %
717 % PS definitions for the white bg
718 %\special{! TeXDict
719 % begin
720 % /whitebgbox{% Needs : x0 y0 x1 y1.
721 % newpath 2 copy moveto 3 copy pop exch lineto 4 copy pop pop
722 % lineto 4 copy exch pop exch pop lineto closepath 1 setgray fill} bind def
723 % end
724 %}