Debian Codegraph @

texmf-dist/source/latex/coordsys/coordsys.dtx

raw
1 % \iffalse
2 % This is the coordsys package, coordsys.dtx
3 % Copyright 2000--06 by Mogens Lemvig Hansen.
4 %
5 % Run first coordsys.ins then this file, coordsys.dtx,
6 % through LaTeX and read the documentation in coordsys.dvi
7 %
8 % This program may be distributed and/or modified under the
9 % conditions of the LaTeX Project Public License, either version 1.2
10 % of this license or (at your option) any later version.
11 % The latest version of this license is in
12 % http://www.latex-project.org/lppl.txt
13 % and version 1.2 or later is part of all distributions of LaTeX
14 % version 2003/12/01 or later.
15 %
16 % This program consists of the files coordsys.dtx and coordsys.ins
17 %
18 %<*docdriver>
19 \documentclass{ltxdoc}[1996/01/11]
20 \usepackage{url,varioref,color,coordsys,logsys}
21 \IfFileExists{eepic.sty}{\usepackage{epic,eepic}}{\relax}
22 \CodelineIndex%\EnableCrossrefs
23 %\OnlyDescription
24 \MakeShortVerb{\"}
25 \makeatletter
26 \DoNotIndex{\@circlefnt, \@empty, \@ifpackageloaded, \@ifstar,
27 \@tempcnta, \@tempcntb, \@tempdima, \@tempdimb, \@tempdimc,
28 \@wholewidth, \\, \addtocounter, \addtolength, \advance,
29 \afterassignment, \arabic, \baselineskip, \char,
30 \color@begingroup, \color@endgroup, \colorbox, \count@,
31 \DeclareOption, \def, \divide, \edef, \ensuremath,
32 \ExecuteOptions, \fontdimen, \frac, \hbox, \hfill, \hrule, \hskip,
33 \hspace, \hss,
34 \if, \else, \fi, \ifdim, \fi, \ifnum, \fi, \ifx, \repeat,
35 \ignorespaces, \leaders, \leavevmode, \let, \line, \lineskip,
36 \loop, \makebox, \mbox, \MessageBreak, \multiply, \multiput, \n,
37 \NeedsTeXFormat, \newcommand, \newif, \next, \offinterlineskip,
38 \p@, \PackageError, \PackageWarning, \PassOptionsToPackage,
39 \phantom, \ProcessOptions, \providecommand, \ProvidesPackage,
40 \put, \raisebox, \relax, \renewcommand, \RequirePackage, \rule,
41 \scriptsize, \setcounter, \setlength, \settodepth, \settoheight,
42 \settowidth, \space, \stepcounter, \string, \t, \textfont, \the,
43 \thicklines, \thinlines, \unitlength, \value, \vbox, \vector,
44 \vee, \vfill, \vrule, \vskip, \vss, \wedge, \width, \z@}
45
46 \newcommand{\nextlinelabel}[2][1]{\@bsphack
47 \@tempcnta\c@CodelineNo
48 \advance\@tempcnta#1\relax
49 \def\@currentlabel{\the\@tempcnta}\label{#2}%
50 \@esphack}
51 \makeatother
52 \begin{filecontents*}{parabola.put}
53 -10 10
54 -9.5640569167 9.1471184705
55 -9.1847451708 8.4359543853
56 -8.7581694417 7.6705531969
57 -8.3287660917 6.936834461
58 -7.9014036208 6.2432179179
59 -7.5051839042 5.6327785435
60 -7.0949213375 5.0337908785
61 -6.6706272042 4.4497267297
62 -6.2476937875 3.9033677662
63 -5.8126547833 3.378695563
64 -5.4294721917 2.947916828
65 -4.99809935 2.4980997112
66 -4.56495525 2.0838816435
67 -4.14754065 1.7202093443
68 -3.7684882042 1.4201503345
69 -3.3177581833 1.1007519363
70 -2.9359307333 .8619689271
71 -2.4917746375 .6208940844
72 -2.0986212333 .4404211081
73 -1.6672696375 .2779788044
74 -1.2565209125 .1578844804
75 -.8279477083 .0685497408
76 -.4343837208 .0188689217
77 0 0
78 .4310767958 .0185827204
79 .8149238375 .0664100861
80 1.2294891583 .151164359
81 1.6577757 .2748220272
82 2.076770525 .4312975814
83 2.4821695625 .6161165737
84 2.932296075 .8598360271
85 3.3367547667 1.1133932373
86 3.76860075 1.4202351613
87 4.1599173958 1.730491274
88 4.58772985 2.1047265177
89 4.9902680292 2.4902775003
90 5.4110364125 2.9279315057
91 5.8224144167 3.3900509639
92 6.2530890625 3.9101122824
93 6.6678799333 4.4460622805
94 7.0920635083 5.0297364806
95 7.5127346292 5.6441181608
96 7.8992877 6.2398746167
97 8.3423211417 6.9594322031
98 8.7385755333 7.6362702352
99 9.1610653625 8.3925118576
100 9.5654420375 9.1497681373
101 10 10
102 \end{filecontents*}
103 \begin{filecontents*}{cubic.put}
104 -30.000000 -20.000000
105 -28.474199 -15.804432
106 -27.146608 -12.516116
107 -25.653593 -9.202436
108 -24.150681 -6.258297
109 -22.654913 -3.698008
110 -21.268144 -1.636385
111 -19.832225 .199365
112 -18.347195 1.796657
113 -16.866928 3.103311
114 -15.344292 4.170472
115 -14.003153 4.894524
116 -12.493348 5.486493
117 -10.977343 5.863124
118 -9.516392 6.039119
119 -8.189709 6.055876
120 -6.612154 5.918569
121 -5.275758 5.685123
122 -3.721211 5.298481
123 -2.345174 4.870173
124 -.835444 4.326615
125 .602177 3.755721
126 2.102183 3.124225
127 3.479657 2.529189
128 4.965449 1.889690
129 6.508769 1.248590
130 7.852233 .726681
131 9.303212 .218408
132 10.802215 -.227277
133 12.268697 -.565992
134 13.687593 -.784166
135 15.263036 -.879136
136 16.678642 -.813612
137 18.190103 -.566101
138 19.559711 -.166508
139 21.057054 .479871
140 22.465938 1.305413
141 23.938627 2.412189
142 25.378450 3.753353
143 26.885812 5.451531
144 28.337580 7.390383
145 29.822222 9.700301
146 31.294571 12.337014
147 32.647507 15.080062
148 34.198124 18.620739
149 35.585014 22.164125
150 37.063729 26.352494
151 38.479047 30.775514
152 40.000000 36.000000
153 \end{filecontents*}
154 \begin{filecontents*}{cardioid.put}
155 100.000000 0.000000
156 112.588564 15.516766
157 121.244557 31.750443
158 124.934677 41.835945
159 127.659260 52.494751
160 129.345482 63.695172
161 129.903543 75.248573
162 129.285785 86.969731
163 127.460693 98.778657
164 124.672157 109.684223
165 120.825477 120.432570
166 115.738369 131.275035
167 109.553790 141.702160
168 102.046822 151.919323
169 93.471064 161.432430
170 83.935655 170.093229
171 73.505467 177.822188
172 61.952700 184.694870
173 49.689167 190.381106
174 38.407582 194.343741
175 26.780487 197.281781
176 13.407329 199.324137
177 -.119421 199.999947
178 -13.700122 199.294213
179 -27.122592 197.211115
180 -39.763584 193.927228
181 -51.980365 189.433046
182 -62.599453 184.351359
183 -72.673348 178.372314
184 -83.827620 170.181864
185 -93.966999 160.931907
186 -101.680605 152.366833
187 -108.531015 143.226867
188 -115.353429 131.996377
189 -120.892496 120.269314
190 -124.697389 109.601644
191 -127.460410 98.780030
192 -129.296948 86.861074
193 -129.903806 75.032811
194 -129.373414 63.979985
195 -127.809263 53.247345
196 -121.489566 32.332819
197 -112.548072 15.455006
198 -100.309649 .311093
199 -85.706682 -11.678463
200 -72.243183 -18.910373
201 -57.735843 -23.480262
202 -43.580925 -24.999414
203 -31.218159 -23.852436
204 -21.108797 -20.873626
205 -12.318983 -16.218684
206 -6.659458 -11.563205
207 -2.788086 -6.843880
208 -.903254 -3.342623
209 -.108179 -.830565
210 -.000001 -.000467
211 .107213 -.825650
212 .848070 -3.209033
213 2.934090 -7.064121
214 6.712690 -11.616493
215 12.726954 -16.492235
216 20.994604 -20.827287
217 30.567066 -23.721204
218 43.583975 -24.999401
219 56.641796 -23.700328
220 71.394649 -19.264856
221 85.586513 -11.757441
222 100.000000 .000000
223 \end{filecontents*}
224 \begin{filecontents*}{csc1.put}
225 5.769525 100.000000
226 7.337294 78.302278
227 11.176475 51.591183
228 15.041105 38.533870
229 18.887368 30.891960
230 22.453345 26.182739
231 26.145708 22.693468
232 29.964355 20.021578
233 33.770756 17.989772
234 37.686107 16.357639
235 41.134750 15.201446
236 45.017106 14.137915
237 48.915403 13.267173
238 52.672134 12.575790
239 56.083606 12.050332
240 60.140176 11.530753
241 63.576624 11.166568
242 67.574028 10.818141
243 71.112409 10.569087
244 74.994573 10.353025
245 78.691312 10.197995
246 82.548471 10.085170
247 86.090547 10.023324
248 89.911154 10.000012
249 93.879691 10.022969
250 97.334315 10.082493
251 101.065402 10.189434
252 104.919981 10.348899
253 108.690935 10.556753
254 112.339526 10.811422
255 116.390665 11.163403
256 120.030793 11.550591
257 123.917407 12.050475
258 127.439256 12.594486
259 131.289569 13.308769
260 134.912412 14.120566
261 138.699328 15.151274
262 142.401730 16.390185
263 146.277801 18.012607
264 150.010919 20.006604
265 153.828571 22.672736
266 157.614611 26.258119
267 161.093589 30.861980
268 165.080890 38.841725
269 168.647180 50.800081
270 172.449588 76.104387
271 174.258156 100.000000
272 \end{filecontents*}
273 \begin{filecontents*}{csc2.put}
274 185.769525 -100.000000
275 187.337294 -78.302274
276 191.176476 -51.591181
277 195.041106 -38.533869
278 198.887368 -30.891960
279 202.453345 -26.182739
280 206.145708 -22.693468
281 209.964356 -20.021578
282 213.770756 -17.989772
283 217.686107 -16.357639
284 221.134751 -15.201446
285 225.017106 -14.137915
286 228.915403 -13.267173
287 232.672134 -12.575790
288 236.083606 -12.050332
289 240.140177 -11.530753
290 243.576624 -11.166568
291 247.574028 -10.818141
292 251.112409 -10.569087
293 254.994573 -10.353025
294 258.691312 -10.197995
295 262.548471 -10.085170
296 266.090547 -10.023324
297 269.911154 -10.000012
298 273.879691 -10.022969
299 277.334314 -10.082493
300 281.065402 -10.189434
301 284.919981 -10.348899
302 288.690935 -10.556753
303 292.339526 -10.811422
304 296.390664 -11.163403
305 300.030793 -11.550591
306 303.917407 -12.050475
307 307.439256 -12.594486
308 311.289568 -13.308769
309 314.912412 -14.120566
310 318.699327 -15.151274
311 322.401729 -16.390185
312 326.277801 -18.012607
313 330.010919 -20.006604
314 333.828571 -22.672736
315 337.614611 -26.258119
316 341.093589 -30.861980
317 345.080890 -38.841724
318 348.647179 -50.800079
319 352.449588 -76.104383
320 354.258156 -100.000000
321 \end{filecontents*}
322 \begin{filecontents*}{logistic.put}
323 -10.000000 -17.371858
324 -9.564057 -16.614591
325 -9.184745 -15.955715
326 -8.758169 -15.214772
327 -8.328766 -14.468968
328 -7.901404 -13.726787
329 -7.505184 -13.038795
330 -7.094921 -12.326581
331 -6.670627 -11.590267
332 -6.247694 -10.856714
333 -5.812655 -10.102801
334 -5.429472 -9.439561
335 -4.998099 -8.694276
336 -4.564955 -7.948131
337 -4.147541 -7.232254
338 -3.768488 -6.586185
339 -3.317758 -5.825368
340 -2.935931 -5.190082
341 -2.491775 -4.466789
342 -2.098621 -3.846618
343 -1.667270 -3.196723
344 -1.256521 -2.617930
345 -.827948 -2.068053
346 -.631166 -1.837450
347 -.434384 -1.622076
348 -.222128 -1.407750
349 -.009872 -1.212716
350 .210603 -1.030806
351 .431077 -.869735
352 .623000 -.745941
353 .814924 -.636672
354 1.229489 -.445644
355 1.657776 -.303009
356 2.076771 -.205126
357 2.482170 -.139415
358 2.932296 -.090166
359 3.336755 -.060688
360 3.768601 -.039646
361 4.159917 -.026906
362 4.587730 -.017588
363 4.990268 -.011779
364 5.411036 -.007743
365 5.822414 -.005135
366 6.253089 -.003340
367 6.667880 -.002207
368 7.092064 -.001444
369 7.512735 -.000948
370 7.899288 -.000644
371 8.342321 -.000414
372 8.738576 -.000278
373 9.161065 -.000182
374 9.565442 -.000122
375 10.000000 -.000079
376 \end{filecontents*}
377
378 \begin{document} \DocInput{coordsys.dtx} \end{document}
379 %</docdriver>
380 % \fi
381 % \CheckSum{2292}
382 % \CharacterTable
383 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
384 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
385 % Digits \0\1\2\3\4\5\6\7\8\9
386 % Exclamation \! Double quote \" Hash (number) \#
387 % Dollar \$ Percent \% Ampersand \&
388 % Acute accent \' Left paren \( Right paren \)
389 % Asterisk \* Plus \+ Comma \,
390 % Minus \- Point \. Solidus \/
391 % Colon \: Semicolon \; Less than \<
392 % Equals \= Greater than \> Question mark \?
393 % Commercial at \@ Left bracket \[ Backslash \\
394 % Right bracket \] Circumflex \^ Underscore \_
395 % Grave accent \` Left brace \{ Vertical bar \|
396 % Right brace \} Tilde \~}
397 %
398 % \def\fileversion{1.4} \def\filedate{2006/02/03} \def\docdate{\filedate}
399 % \title{The \textsf{coordsys} and \textsf{logsys} Packages\thanks{This
400 % file describes version \fileversion, \filedate.}}
401 % \author{\copyright\ Mogens Lemvig Hansen\thanks{%
402 % The \textsf{coordsys} and \textsf{logsys} packages are distributed under
403 % the \LaTeX\ Project
404 % Public License; please see Section~\ref{sec:license}.}\\
405 % [email protected]}
406 % \date{\docdate}
407 % \maketitle
408 % \begin{abstract}
409 % The \textsf{coordsys} package provides commands for typesetting
410 % number lines (coordinate axes), coordinate systems, and grids
411 % in the \textsf{picture} environment.
412 % The \textsf{logsys} package extends the \textsf{coordsys} package by
413 % providing logarithmic, semi-logarithmic, and double-logarithmic
414 % coordinate systems and grids.
415 % \end{abstract}
416 %
417 % \tableofcontents
418 %
419 % \section{Regular Coordinate Systems}
420 % Load the \textsf{coordsys} package with the "\usepackage" command.
421 % \begin{quote}
422 % "\usepackage"\oarg{options}"{coordsys}"
423 % \end{quote}
424 % The \textsf{coordsys} package has three \meta{options},
425 % \textsf{centred} (the default), \textsf{outside}, and \textsf{inside}, that
426 % control the
427 % appearance of tick marks; see Section~\ref{sec:tickstyle} on
428 % page~\pageref{sec:tickstyle}.
429 %
430 % \subsection{One Dimension}
431 % \DescribeMacro{\numbline}
432 % The "\numbline" command typesets a number line.\index{number line|(usage}
433 % For example,
434 % \begin{quote}
435 % \begin{verbatim}
436 % \begin{picture}(200,20)(-75,-15)
437 % \numbline{-75}{125}
438 % \end{picture}
439 % \end{verbatim}
440 % \begin{picture}(200,20)(-75,-15)
441 % \numbline{-75}{125}
442 % \end{picture}
443 % \end{quote}
444 % You should always use the "\numbline" command inside a
445 % \textsf{picture} environment.
446 % Do not forget to leave room for the labels on the number line.
447 % In the following examples I omit the "\begin{picture}"
448 % and "\end{picture}" commands to reduce clutter.
449 %
450 % The tick marks are by default separated by 10 units;
451 % give "\numbline" an optional first argument to change that.
452 % For example
453 % \begin{quote}
454 % \begin{verbatim}
455 % \numbline[7]{-75}{125}
456 % \end{verbatim}
457 % \begin{picture}(200,20)(-75,-15)
458 % \numbline[7]{-75}{125}
459 % \end{picture}
460 % \end{quote}
461 %
462 % \DescribeMacro{\numbline*}
463 % The starred version of "\numbline" omits the labels.
464 % \begin{quote}
465 % \begin{verbatim}
466 % \numbline*[7]{-75}{125}
467 % \end{verbatim}
468 % \begin{picture}(200,6)(-75,-3)
469 % \numbline*[7]{-75}{125}
470 % \end{picture}
471 % \end{quote}
472 %
473 % Thus,
474 % \begin{quote}
475 % "\numbline"\oarg{spacing}\marg{from}\marg{to}\\
476 % "\numbline*"\oarg{spacing}\marg{from}\marg{to}
477 % \end{quote}
478 % typeset\label{numblinesyntax} (horizontal) number lines
479 % from \meta{from} to \meta{to} with
480 % \meta{spacing}
481 % units between the tick marks (the default is 10);
482 % use the starred command to suppresses the labels.
483 % All the arguments must be integers.
484 %
485 % \DescribeMacro{\vnumbline}\DescribeMacro{\vnumbline*}
486 % The "\vnumbline" and "\vnumbline*" commands similarly
487 % typeset vertical number lines.
488 % \begin{quote}
489 % "\vnumbline"\oarg{spacing}\marg{from}\marg{to}\\
490 % "\vnumbline*"\oarg{spacing}\marg{from}\marg{to}
491 % \end{quote}
492 % The syntax is similar to that of the "\numbline" command
493 % \vpageref[above]{numblinesyntax}.\index{number line|)usage}
494 % \begin{quote}
495 % \begin{minipage}{.2\linewidth}
496 % \begin{picture}(20,100)(-17,20)
497 % \vnumbline{20}{120}
498 % \end{picture}
499 % \end{minipage}
500 % \qquad
501 % \begin{minipage}{.6\linewidth}
502 % \begin{verbatim}
503 % \vnumbline{20}{120}
504 % \end{verbatim}
505 % \end{minipage}
506 % \end{quote}
507 %
508 % \subsection{Two Dimensions}
509 % \DescribeMacro{\coordsys}
510 % Use the "\coordsys"\index{coordinate system>with intersecting axes|usage}
511 % command to typeset coordinate systems.
512 % \begin{quote}
513 % \begin{picture}(200,110)(-50,-50)
514 % \coordsys(-50,-50)(150,60)
515 % \put(75,25){\texttt{\textbackslash coordsys(-50,-50)(150,60)}}
516 % \end{picture}
517 % \end{quote}
518 % \DescribeMacro{\coordsys*}
519 % Thus,
520 % \begin{quote}
521 % "\coordsys"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\
522 % "\coordsys*"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}
523 % \end{quote}
524 % typeset\label{coordsyssyntax} coordinate systems where
525 % \parg{ll} is the lower-left corner
526 % and \parg{ur} is the upper-right corner.
527 % The optional argument \meta{h-spacing} gives the spacing between the
528 % tick marks on the horizontal axis; the default is 10 units.
529 % The optional argument \meta{v-spacing} gives the spacing between the
530 % tick marks on the vertical axis; the default is to use the same
531 % spacing as on the horizontal axis.
532 % The starred version omits the labels.
533 % All the arguments must be integers.
534 %
535 % Regular coordinate systems with intersecting axes are not always
536 % appropriate, for example when the point $(0,0)$ is not in the range
537 % of the coordinate system.
538 % The \textsf{coordsys} package therefore provides some alternative
539 % styles. All the coordinate-system-drawing commands have similar syntax.
540 %
541 % \DescribeMacro{\fcoordsys}\DescribeMacro{\fcoordsys*}
542 % The "\fcoordsys"\index{coordinate system>framed|usage}
543 % command typesets framed coordinate systems; that is, the
544 % axes are at the left and bottom edges of the system.
545 % \begin{quote}
546 % "\fcoordsys"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\
547 % "\fcoordsys*"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}
548 % \end{quote}
549 % The syntax is similar to that of the "\coordsys" command
550 % \vpageref[above]{coordsyssyntax}.
551 % \begin{quote}
552 % \begin{picture}(220,125)(30,35)
553 % \fcoordsys[5](50,50)(250,160)
554 % \put(155,125){\texttt{\textbackslash fcoordsys[5](-50,-50)(150,60)}}
555 % \end{picture}
556 % \end{quote}
557 %
558 % \DescribeMacro{\bcoordsys}\DescribeMacro{\bcoordsys*}
559 % The "\bcoordsys"\index{coordinate system>boxed|usage}
560 % command typesets boxed coordinate systems.
561 % \begin{quote}
562 % "\bcoordsys"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\
563 % "\bcoordsys*"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}
564 % \end{quote}
565 % The syntax is similar to that of the "\coordsys" command
566 % \vpageref[above]{coordsyssyntax}.
567 % \begin{quote}
568 % \begin{picture}(265,125)(-70,-65)
569 % \bcoordsys[15][5](-50,-50)(195,60)
570 % \put(-30,25){\texttt{\textbackslash bcoordsys[15][5](-50,-50)(195,60)}}
571 % \end{picture}
572 % \end{quote}
573 %
574 % \DescribeMacro{\window}\DescribeMacro{\window*}
575 % The "\window" command typesets a plotting window as on a graphing
576 % calculator.
577 % \begin{quote}
578 % "\window"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\
579 % "\window*"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}
580 % \end{quote}
581 % The syntax is similar to that of the "\coordsys" command
582 % \vpageref[above]{coordsyssyntax}.
583 % \begin{quote}
584 % \begin{picture}(302,127)(-107,-67)
585 % \window(-50,-50)(195,60)
586 % \put(15,25){\texttt{\textbackslash window(-50,-50)(195,60)}}
587 % \end{picture}
588 % \end{quote}
589 % The labels will look nicer if you use the \textsf{amstext} package (which is
590 % part of the \textsf{amsmath} package).
591 %
592 % \DescribeMacro{\coordgrid}
593 % The "\coordgrid"\index{grid|(usage}\index{grid>dotted|usage}
594 % command typesets a coordinate grid.
595 % \begin{quote}
596 % \begin{picture}(300, 125)
597 % \coordgrid(0,0)(300,125)
598 % \put(15,25){\texttt{\textbackslash coordgrid(0,0)(300,125)}}
599 % \end{picture}
600 % \end{quote}
601 % The "\coordgrid" command does not print any labels
602 % but you can superimpose a coordinate system.
603 % \begin{quote}
604 % \begin{verbatim}
605 % \coordgrid[15][5](-50,-50)(195,60)
606 % \coordsys[15][5](-50,-50)(195,60)
607 % \end{verbatim}
608 % \begin{picture}(245,110)(-50,-50)
609 % \coordgrid[15][5](-50,-50)(195,60)
610 % \coordsys[15][5](-50,-50)(195,60)
611 % \end{picture}
612 % \end{quote}
613 % If you load the \textsf{color} package before the \textsf{coordsys}
614 % package, the labels will be printed on a
615 % white background.\index{labels>background of|usage}
616 %
617 % Typesetting pretty grids with dotted lines is not easy.
618 % If a grid does come out ugly,\index{grid>ugly|usage}
619 % try to increase "\unitlength"
620 % to allow for more dots between the lines.
621 % You may also reduce the size of the dots;
622 % see the "\gridstyle" command \vpageref[below]{gridstyle}.
623 % \DescribeMacro{\coordgrid*}
624 % Alternatively you can use the "\coordgrid*" command which
625 % typesets a coordinate grid with solid lines.\index{grid>solid|usage}
626 % You could then use the
627 % \textsf{color} package to colour the grid, say, gray; again, see
628 % the "\gridstyle" command \vpageref[below]{gridstyle}.
629 %
630 % Thus,
631 % \begin{quote}
632 % "\coordgrid"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\
633 % "\coordgrid*"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}
634 % \end{quote}
635 % typeset coordinate grids with a syntax similar to that of
636 % the "\coordsys" command \vpageref[above]{coordsyssyntax}.
637 % The starred version uses solid lines;
638 % the un-starred version uses dotted lines.\index{grid|)usage}
639 %
640 % \DescribeMacro{\gridstyle}\label{gridstyle}
641 % The default size of the dots is the with of "\thinlines"
642 % and "\thicklines".\index{grid>size of dots|usage}\index{grid>style|(usage}
643 % If you intend to print your grids at a
644 % sufficiently high resolution, you should reduce the size of the
645 % dots by issuing a "\gridstyle" command. On my 600\,dpi printer,
646 % these sizes look nice for points:
647 % \begin{quote}
648 % \begin{verbatim}
649 % \gridstyle{\linethickness{0.24pt}}{\linethickness{0.48pt}}
650 % \end{verbatim}
651 % \gridstyle{\linethickness{0.24pt}}{\linethickness{0.48pt}}
652 % \begin{picture}(245,110)(-50,-50)
653 % \coordgrid[15][5](-50,-50)(195,60)
654 % \coordsys[15][5](-50,-50)(195,60)
655 % \end{picture}
656 % \end{quote}
657 % When I use solid lines, I can get away with half that,
658 % \begin{quote}
659 % \begin{verbatim}
660 % \gridstyle{\linethickness{0.12pt}}{\linethickness{0.24pt}}
661 % \end{verbatim}
662 % \gridstyle{\linethickness{0.12pt}}{\linethickness{0.24pt}}
663 % \begin{picture}(245,110)(-50,-50)
664 % \coordgrid*[15][5](-50,-50)(195,60)
665 % \coordsys[15][5](-50,-50)(195,60)
666 % \end{picture}
667 % \end{quote}
668 %
669 % If you make grids for the screen, I recommend using
670 % colour.\index{grid>coloured|usage} For example,
671 % \begin{quote}
672 % \begin{verbatim}
673 % \definecolor{gray}{gray}{0.5}
674 % \definecolor{lightgray}{gray}{0.75}
675 % \gridstyle{\thinlines\color{lightgray}}{\thinlines\color{gray}}
676 % \coordgrid*(-109,-65)(200,100)
677 % \coordsys(-109,-65)(200,100)
678 % \end{verbatim}
679 % \begin{picture}(245,110)(-50,-50)
680 % \definecolor{gray}{gray}{0.5}
681 % \definecolor{lightgray}{gray}{0.75}
682 % \gridstyle{\thinlines\color{lightgray}}{\thinlines\color{gray}}
683 % \coordgrid*[15][5](-50,-50)(195,60)
684 % \coordsys[15][5](-50,-50)(195,60)
685 % \end{picture}
686 % \end{quote}
687 %
688 % In general,
689 % \begin{quote}
690 % "\gridstyle"\marg{thin declaration}\marg{thick declaration}
691 % \end{quote}
692 % Note that these are \emph{declarations}: the \meta{thin declarations}
693 % apply also to the thick grid lines unless explicitly overruled by the
694 % \meta{thick declaration}.
695 % The current "\gridstyle" applies to all types of grids:
696 % dotted, solid, regular, or logarithmic.
697 % The default style is
698 % "\gridstyle{\thinlines}{\thicklines}".\label{defaultgridstyle}\index{grid>style|)usage}
699 %
700 %
701 % \subsection{Bells and Whistles}
702 % \subsubsection{Manual Labels}
703 % \DescribeMacro{\sethlabel}\DescribeMacro{\setvlabel}
704 % All the number-line and coordinate-system commands format the
705 % labels\index{labels>manual|usage}\index{manual labels|usage} using
706 % the commands "\sethlabel" (for labels on horizontal axes) and
707 % "\setvlabel" (for labels on vertical axes). If you set labels manually,
708 % you should use the same commands for a uniform appearance.
709 % \begin{quote}
710 % \begin{verbatim}
711 % \numbline{-75}{125}
712 % \put(125,0){\sethlabel{x}}
713 % \end{verbatim}
714 % \begin{picture}(200,20)(-75,-15)
715 % \numbline{-75}{125}
716 % \put(125,0){\sethlabel{x}}
717 % \end{picture}
718 % \end{quote}
719 % The syntax is
720 % \begin{quote}
721 % "\sethlabel"\oarg{alignment}\marg{label}\\
722 % "\setvlabel"\oarg{alignment}\marg{label}
723 % \end{quote}
724 % The \meta{label} is set in math mode.
725 % The default \meta{alignment} is "[t]" for "\sethlabel" and
726 % "[r]" for "\setvlabel". You may want to add to these defaults
727 % (as in "\sethlabel[tl]"); you probably do not want to replace the
728 % defaults.
729 %
730 % If you want your labels set in some other style, you must re-define
731 % "\sethlabel" and "\setvlabel".
732 %
733 % \subsubsection{Thick Tick Density}
734 % \DescribeMacro{\hthickratio}
735 % \DescribeMacro{\vthickratio}
736 % By default every fifth tick mark is
737 % thick.\index{thick ticks|usage}\index{ticks>ratio of thick|usage}
738 % You can change that by redefining
739 % the commands "\hthickratio" and "\vthickratio".
740 % \begin{quote}
741 % \begin{verbatim}
742 % \renewcommand{\hthickratio}{4}
743 % \numbline[25]{0}{350}
744 % \end{verbatim}
745 % \setlength{\unitlength}{.3pt}
746 % \begin{picture}(350,80)(0,-50)
747 % \renewcommand{\hthickratio}{4}
748 % \numbline[25]{0}{350}
749 % \end{picture}
750 % \end{quote}
751 %
752 % \subsubsection{Different Scales on the Two Axes}
753 % \DescribeMacro{\rescaleby}
754 % LaTeX\ (the \textsf{picture} environment) does not support different
755 % scales\index{labels>re-scaled|usage}\index{scaling labels|usage}
756 % on the two axes; "\unitlength" is used for both the
757 % horizontal and the vertical direction.
758 % However, you may create the \emph{appearance} of different scales by
759 % scaling the labels on the axes.
760 % Here is a coordinate system that has been rigged to contain the graph of
761 % $y=x^2$ for $x$ between $-10$ and $10$.
762 % \begin{quote}
763 % \setlength{\unitlength}{5pt}
764 % \rescaleby{10}{1}{\vlabel}
765 % \begin{picture}(22,15)(-10,-3)
766 % \coordsys[1](-10,0)(12,12)
767 % \end{picture}
768 % \begin{minipage}[b]{.5\linewidth}
769 % \begin{verbatim}
770 % \rescaleby{10}{1}{\vlabel}
771 % \coordsys[1](-10,0)(12,12)
772 % \end{verbatim}
773 % \end{minipage}
774 % \end{quote}
775 % That is,
776 % \begin{quote}
777 % "\rescaleby"\oarg{symb}\marg{num}\marg{den}\marg{cmd}
778 % \end{quote}
779 % multiplies the labels by $\frac{\meta{num}}{\meta{den}}\meta{symb}$;
780 % both \meta{num} and \meta{den} must be integers;
781 % and \meta{den} must be positive.\footnote{Multiplying the labels by
782 % a negative number does not reverse the arrows, so I suggest using
783 % boxed coordinate systems in that case.}
784 % The optional argument, if present, represents a symbolic
785 % (non-numeric) scale factor; see the example below.
786 % The last argument, \meta{cmd}, must be one of "\hlabel"
787 % or "\vlabel".
788 %
789 % The following coordinate system has been rigged for graphing $\sin$ or
790 % $\cos$. Note that only that labels have been scaled;
791 % the real coordinates of the small circle are still $(90,50)$.
792 % \begin{quote}
793 % \begin{verbatim}
794 % \renewcommand{\hthickratio}{6}
795 % \rescaleby[\pi]{1}{180}{\hlabel}
796 % \rescaleby{1}{100}{\vlabel}
797 % \coordsys[15][10](0,-100)(400,115)
798 % \put(90,50){\circle{6}}
799 % \end{verbatim}
800 % \setlength{\unitlength}{.5pt}
801 % \begin{picture}(435,215)(-35,-100)
802 % \renewcommand{\hthickratio}{6}
803 % \rescaleby[\pi]{1}{180}{\hlabel}
804 % \rescaleby{1}{100}{\vlabel}
805 % \coordsys[15][10](0,-100)(400,115)
806 % \put(90,50){\circle{6}}
807 % \end{picture}
808 % \end{quote}
809 %
810 % \subsubsection{Different Styles of Tick Marks}
811 % \label{sec:tickstyle}
812 % \DescribeMacro{\tickstyle}
813 % As you can affect the width of the dots or lines of a
814 % "\coordgrid" with a "\gridstyle" command,
815 % so you can affect the width of the tick marks with a
816 % "\tickstyle"\index{ticks>style of|usage} command:
817 % \begin{quote}
818 % "\tickstyle"\marg{thin declaration}\marg{thick declaration}
819 % \end{quote}
820 % Note that these are \emph{declarations}: the \meta{thin declarations}
821 % apply also to the thick tick marks unless explicitly overruled by the
822 % \meta{thick declaration}.\footnote{And the declarations that apply
823 % to the thick tick marks spill over to the labels which maybe they
824 % shouldn't, so let's not talk about that.}
825 % The default style is
826 % "\tickstyle{\thinlines}{\thicklines}".\footnote{When
827 % I wrote \vpageref[above]{defaultgridstyle} that the default grid style is
828 % \texttt{\textbackslash gridstyle\{\textbackslash thinlines\}\{\textbackslash
829 % thicklines\}} I lied. The default grid style is the follow the current
830 % \texttt{\textbackslash tickstyle}.}
831 %
832 % \DescribeMacro{\ticklength}
833 % The "\ticklength" command controls the length of the
834 % tick marks.\index{ticks>length of|usage}
835 % \begin{quote}
836 % \begin{verbatim}
837 % \tickstyle{\thinlines\renewcommand{\ticklength}{4pt}}
838 % {\thinlines\renewcommand{\ticklength}{8pt}}
839 % \end{verbatim}
840 % \tickstyle{\thinlines\renewcommand{\ticklength}{4pt}}
841 % {\thinlines\renewcommand{\ticklength}{8pt}}
842 % \begin{picture}(200,20)(-75,-15)
843 % \numbline{-75}{125}
844 % \end{picture}
845 % \end{quote}
846 % Note that the \emph{command} "\ticklength" must be changed with
847 % "\renewcommand".
848 %
849 % If you prefer tick marks\index{ticks>style of|usage}
850 % just on the outside of the coordinate axes, load
851 % \textsf{coordsys} with the \textsf{outside} option.
852 % \begin{quote}
853 % \begin{verbatim}
854 % \usepackage[outside]{coordsys}
855 % \end{verbatim}
856 % \makeatletter
857 % \renewcommand{\vtickmark}{\makebox(0,0)[t]{\rule{\@wholewidth}{3pt}}}
858 % \renewcommand{\htickmark}{\makebox(0,0)[r]{\rule{3pt}{\@wholewidth}}}
859 % \makeatother
860 % \begin{picture}(200,110)(-50,-50)
861 % \coordsys(-50,-50)(150,60)
862 % \end{picture}
863 % \end{quote}
864 %
865 % Similarly, the \textsf{inside} option puts the tick marks on the inside of
866 % the axes. The default option is \textsf{centred}.
867 %
868 %
869 %
870 % \section{Logarithmic Coordinate Systems}
871 % Load the \textsf{logsys} package with the "\usepackage" command.
872 % \begin{quote}
873 % "\usepackage"\oarg{options}"{coordsys,logsys}"
874 % \end{quote}
875 % The \textsf{logsys} package supports the same options, \textsf{centred},
876 % \textsf{outside}, and \textsf{inside}, as the \textsf{coordsys} package.
877 %
878 % \subsection{One Dimension}
879 % \DescribeMacro{\logline}
880 % The "\logline" command typesets a horizontal, logarithmic number
881 % line.\index{number line>logarithmic|(usage}
882 % \begin{quote}
883 % \begin{verbatim}
884 % \logline{-60}{210}
885 % \end{verbatim}
886 % \begin{picture}(270,20)(-60,-15)
887 % \logline{-60}{210}
888 % \end{picture}
889 % \end{quote}
890 % The "\logline" command typesets only whole blocks of tick marks
891 % (whole powers of $10$).
892 % Making the axis long enough that the tick marks do not
893 % collide with the arrow and yet not so long that it looks ridiculous is the
894 % users responsibility.
895 % The default distance between the thick tick marks (the powers of $10$) is
896 % 50~units.
897 % Therefore I made the axis above extend from $-60$ (a bit below $-50$ which
898 % appears as $10^{-1} = \frac1{10}$) to $210$ (a bit above $200$ which appears
899 % as $10^4$).
900 %
901 % \DescribeMacro{\logline*}
902 % Thus,\label{loglinesyntax}
903 % \begin{quote}
904 % "\logline"\oarg{spacing}\marg{from}\marg{to}\\
905 % "\logline*"\oarg{spacing}\marg{from}\marg{to}
906 % \end{quote}
907 % typeset horizontal, logarithmic number lines from \meta{from} to
908 % \meta{to} with \meta{spacing} units between the powers of $10$; the default
909 % is 50.
910 % The starred version omits the labels.
911 % All the arguments must be integers.
912 %
913 % The "\logline" command only typesets an axis; it does not change the
914 % way \LaTeX\ and the \textsf{picture} environment interprets coordinates.
915 % The equation below gives the relationship between the coordinate to
916 % "\put", $x_p$, and the apparent coordinate,
917 % $x_a$.\index{labels>logarithmic|usage}
918 % \[
919 % x_p = \meta{spacing} \log_{10} x_a.
920 % \]
921 % For example:
922 % \begin{quote}
923 % \begin{verbatim}
924 % \logline[40]{-50}{210}
925 % \put(87.04,10){\makebox(0,0)[b]{150}} % 40*log(150) = 87.04
926 % \put(87.04,10){\vector(0,-1){10}}
927 % \end{verbatim}
928 % \begin{picture}(260, 40)(-50,-15)
929 % \logline[40]{-50}{210}
930 % \put(87.04,10){\makebox(0,0)[b]{150}} ^^A% 40*log(150) = 87.04
931 % \put(87.04,10){\vector(0,-1){10}}
932 % \end{picture}
933 % \end{quote}
934 %
935 % \DescribeMacro{\vlogline}
936 % \DescribeMacro{\vlogline*}
937 % The vertical equivalent is "\vlogline":
938 % \begin{quote}
939 % "\vlogline"\oarg{spacing}\marg{from}\marg{to}\\
940 % "\vlogline*"\oarg{spacing}\marg{from}\marg{to}
941 % \end{quote}
942 % The syntax is similar to that of the "\logline" command
943 % \vpageref[above]{loglinesyntax}.\index{number line>logarithmic|)usage}
944 %
945 %
946 % \subsection{Two Dimensions}
947 % \DescribeMacro{\logsys}
948 % Use the "\logsys"\index{coordinate system>logarithmic|(usage}
949 % command to typeset logarithmic coordinate systems.
950 % \begin{quote}
951 % \begin{picture}(220,125)(-70,-65)
952 % \logsys[5](-50,-50)(150,60)
953 % \put(55,25){\texttt{\textbackslash logsys[5](-50,-50)(150,60)}}
954 % \end{picture}
955 % \end{quote}
956 % \DescribeMacro{\logsys*}
957 % Thus,
958 % \begin{quote}
959 % "\logsys"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\
960 % "\logsys*"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}
961 % \end{quote}
962 % typeset coordinate systems with logarithmic vertical axis,
963 % where \parg{ll} is the lower-left corner
964 % and \parg{ur} is the upper-right corner.
965 % The optional argument \meta{h-spacing} gives the spacing between the
966 % tick marks on the horizontal axis; the default is 10 units.
967 % The optional argument \meta{v-spacing} gives the spacing between the
968 % thick tick marks (powers of $10$) on the vertical axis;
969 % the default is 50 units.
970 % The starred version omits the labels.
971 % All the arguments must be integers.
972 %
973 % \DescribeMacro{\semilogsys}
974 % Use the "\semilogsys" command to typeset semi-logarithmic
975 % coordinate systems.
976 % \begin{quote}
977 % \begin{picture}(230,125)(-70,-65)
978 % \semilogsys[25](-50,-50)(160,60)
979 % \put(55,25){\texttt{\textbackslash semilogsys[25](-50,-50)(160,60)}}
980 % \end{picture}
981 % \end{quote}
982 % \DescribeMacro{\semilogsys*}
983 % Thus,
984 % \begin{quote}
985 % "\semilogsys"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\
986 % "\semilogsys*"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}
987 % \end{quote}
988 % typeset coordinate systems with logarithmic horizontal axis,
989 % where \parg{ll} is the lower-left corner
990 % and \parg{ur} is the upper-right corner.
991 % The optional argument \meta{h-spacing} gives the spacing between the
992 % thick tick marks (powers of $10$) on the horizontal axis;
993 % the default is 50 units.
994 % The optional argument \meta{v-spacing} gives the spacing between the
995 % tick marks on the vertical axis;
996 % the default is 10 units.
997 % The starred version omits the labels.
998 % All the arguments must be integers.
999 %
1000 % \DescribeMacro{\loglogsys}
1001 % Use the "\loglogsys" command to typeset double-logarithmic
1002 % coordinate systems.
1003 % \begin{quote}
1004 % \begin{picture}(230,125)(-70,-65)
1005 % \loglogsys(-50,-50)(160,60)
1006 % \put(55,25){\texttt{\textbackslash loglogsys(-50,-50)(150,60)}}
1007 % \end{picture}
1008 % \end{quote}
1009 % \DescribeMacro{\loglogsys*}
1010 % Thus,
1011 % \begin{quote}
1012 % "\loglogsys"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\
1013 % "\loglogsys*"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}
1014 % \end{quote}
1015 % typeset coordinate systems with two logarithmic axes,
1016 % where \parg{ll} is the lower-left corner
1017 % and \parg{ur} is the upper-right corner.
1018 % The optional argument \meta{h-spacing} gives the spacing between the
1019 % thick tick marks (powers of $10$) on the horizontal axis;
1020 % the default is 50 units.
1021 % The optional argument \meta{v-spacing} gives the spacing between the
1022 % thick tick marks (powers of $10$) on the vertical axis;
1023 % the default is 50 units.
1024 % The starred version omits the labels.
1025 % All the arguments must be
1026 % integers.\index{coordinate system>logarithmic|)usage}
1027 %
1028 % \DescribeMacro{\loggrid}
1029 % \DescribeMacro{\loggrid*}
1030 % \DescribeMacro{\semiloggrid}
1031 % \DescribeMacro{\semiloggrid*}
1032 % \DescribeMacro{\logloggrid}
1033 % \DescribeMacro{\logloggrid*}
1034 % The "\loggrid",\index{grid>logarithmic|(usage}
1035 % "\loggrid*", "\semiloggrid",
1036 % "\semiloggrid*", "\logloggrid", and "\logloggrid*" commands
1037 % typeset logarithmic grids.
1038 % \begin{quote}
1039 % \begin{verbatim}
1040 % \logloggrid*(0,0)(300,100)
1041 % \end{verbatim}
1042 % \begin{picture}(300, 100)
1043 % \logloggrid*(0,0)(300,100)
1044 % \end{picture}
1045 % \end{quote}
1046 % Thus,
1047 % \begin{quote}
1048 % "\loggrid"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\
1049 % "\loggrid*"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\
1050 % "\semiloggrid"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\
1051 % "\semiloggrid*"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\
1052 % "\logloggrid"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}\\
1053 % "\logloggrid*"\oarg{h-spacing}\oarg{v-spacing}\parg{ll}\parg{ur}
1054 % \end{quote}
1055 % typeset logarithmic, semi-logarithmic, and double-logarithmic
1056 % coordinate grids where \parg{ll} is the lower-left corner
1057 % and \parg{ur} is the upper-right corner.
1058 % The optional argument \meta{h-spacing} gives the spacing between the
1059 % vertical grid lines and
1060 % the optional argument \meta{v-spacing} gives the spacing between the
1061 % horizontal grid lines;
1062 % The default spacing is 10 units on linear axes and 50 units between the
1063 % thick tick marks (the powers of $10$) on logarithmic axes.
1064 % The starred versions use solid lines;
1065 % the un-starred versions use dotted lines.
1066 % All the arguments must be integers.\index{grid>logarithmic|)usage}
1067 %
1068 %
1069 % \section{Filling the Coordinate Systems}
1070 % The purpose of the \textsf{coordsys} and \textsf{logsys} packages
1071 % is to typeset coordinate systems, so maybe the package should end here.
1072 % However, I have had to write a bit of code to help me fill my
1073 % coordinate systems, so I'll share that.
1074 %
1075 % \subsection{Intervals}
1076 % \DescribeMacro{\interval}
1077 % The "\interval" command takes as argument an interval in standard notation
1078 % and draws it on the horizontal coordinate axis or number line.
1079 % \begin{quote}
1080 % \begin{verbatim}
1081 % \numbline{-15}{65}
1082 % \interval[-7.5,30)
1083 % \end{verbatim}
1084 % \begin{picture}(80,15)(-15,-12)
1085 % \numbline{-15}{65}
1086 % \interval[-7.5,30)
1087 % \end{picture}
1088 % \end{quote}
1089 % The interval can be open, half-open, or closed as in
1090 % $(a,b)$, $(a,b]$, $[a,b)$, and $[a,b]$\footnote{The notation
1091 % $\left]a,b\right[$ for open (or half-open) intervals is also
1092 % supported.} You can specify infinite intervals with "<" or ">".
1093 % \begin{quote}
1094 % \begin{verbatim}
1095 % \numbline{-15}{65}
1096 % \interval<-14,30[
1097 % \end{verbatim}
1098 % \begin{picture}(80,15)(-15,-12)
1099 % \numbline{-15}{65}
1100 % \interval<-14,30[
1101 % \end{picture}
1102 % \end{quote}
1103 % \DescribeMacro{\intervalthickness}
1104 % The "\intervalthickness" command sets the thickness of the fat line
1105 % that marks the interval.
1106 % An optional argument allows you to draw the fat line off centre.
1107 % \begin{quote}
1108 % \begin{verbatim}
1109 % \numbline{-15}{65}
1110 % \intervalthickness[0.5pt]{1pt}
1111 % \interval[-7.5,30]
1112 % \color{red}
1113 % \intervalthickness[-0.5pt]{1pt}
1114 % \interval(10,55>
1115 % \end{verbatim}
1116 % \begin{picture}(80,15)(-15,-12)
1117 % \numbline{-15}{65}
1118 % \intervalthickness[0.5pt]{1pt}
1119 % \interval[-7.5,30]
1120 % \color{red}
1121 % \intervalthickness[-0.5pt]{1pt}
1122 % \interval(10,55>
1123 % \end{picture}
1124 % \end{quote}
1125 % \DescribeMacro{\vinterval}
1126 % The "\vinterval" command similarly draws intervals on the vertical axis.
1127 % \begin{quote}
1128 % \begin{verbatim}
1129 % \fcoordsys[5](150,50)(350,160)
1130 % \interval[200,300]
1131 % \vinterval(75,150>
1132 % \end{verbatim}
1133 % \begin{picture}(220,125)(130,35)
1134 % \fcoordsys[5](150,50)(350,160)
1135 % \interval[200,300]
1136 % \vinterval(75,150>
1137 % \end{picture}
1138 % \end{quote}
1139 %
1140 % To sum up:
1141 % \begin{quote}
1142 % "\interval"\meta{L-delim}\meta{from}","\meta{to}\meta{R-delim}\\
1143 % "\vinterval"\meta{L-delim}\meta{from}","\meta{to}\meta{R-delim}\\
1144 % "\intervalthickness"\oarg{offset}\marg{width}
1145 % \end{quote}
1146 % Here \meta{L-delim} must be one of "[", "(", "<", or "]", and
1147 % \meta{R-delim} must be one of "]", ")", ">", or "[".
1148 % Both \meta{from} and \meta{to} are numbers, integers or
1149 % decimals\footnote{Due to implementation details, a decimal
1150 % must have at least one digit on either side of the decimal point.
1151 % Thus \texttt{0.5} is ok but \texttt{.5} is not.}
1152 % Both \meta{offset} and \meta{width} must be lengths.
1153 % The centre of the fat interval line will drawn \meta{offset} above the
1154 % horizontal axis or \meta{offset} to the right of the vertical axis.
1155 %
1156 %
1157 % \subsection{Curves}
1158 % For plotting curves\index{curves|(usage}
1159 % I recommend the \textsf{epic} and
1160 % \textsf{eepic} packages.\footnote{Both are old \LaTeX209 packages that work
1161 % fine in \LaTeXe. The \textsf{eepic} package re-implements the \textsf{epic}
1162 % package making use of \textsc{PostScript}. The \textsf{eepic} package
1163 % works well with dvips and dvipdfm but not with pdf\LaTeX.}
1164 % I especially like \textsf{(e)epic}'s "\putfile" command which allows
1165 % you to calculate your plot with some external program, export the points to
1166 % plot to a text file, and import that file to have \LaTeX\ draw the plot.
1167 % For external program I use Maple.\index{curves>with Maple|usage}
1168 % The \textsf{coordsys} package includes a piece of
1169 % Maple code that exports a Maple plot in the form "\putfile" expects.
1170 % You can therefore take advantage of Maple adaptive plotting
1171 % algorithm\footnote{Maple cleverly calculates more points where the curve
1172 % wiggles.} in your \LaTeX\ plots.
1173 %
1174 % Here is how it works:\index{putfile|usage}
1175 % In Maple, read in the file \url{putfile} which is part of the
1176 % \textsf{coordsys} package.
1177 % \begin{verbatim}
1178 % > read "/where/you/placed/putfile";
1179 % \end{verbatim}
1180 % Make your plot, here $y=\frac{x^2}{10}$.
1181 % \begin{verbatim}
1182 % > plot( x^2/10, x=-10..10, title="x^2/10");
1183 % \end{verbatim}
1184 % When you are happy with your plot, assign it to a variable.
1185 % \begin{verbatim}
1186 % > P := %:
1187 % \end{verbatim}
1188 % Then use the "putfile" command to export the curve to the file
1189 % \url{parabola.put}.
1190 % \begin{verbatim}
1191 % > putfile( "parabola.put", P );
1192 % \end{verbatim}
1193 %
1194 % In \LaTeX, use the "\putfile" command to put "\picsquare"s at each
1195 % point listed in \url{parabola.put}.
1196 % \begin{quote}
1197 % \begin{verbatim}
1198 % \coordsys[1](-10,0)(11,11)
1199 % \putfile{parabola.put}{\picsquare}
1200 % \end{verbatim}
1201 % \ifx\putfile\undefined
1202 % You do not have the \textsf{epic} and \textsf{eepic} packages,
1203 % so \LaTeX\ cannot generate the result of the above commands.
1204 % \else
1205 % \setlength{\unitlength}{7pt}
1206 % \begin{picture}(21,13)(-10,-2)
1207 % \coordsys[1](-10,0)(11,11)
1208 % \putfile{parabola.put}{\picsquare}
1209 % \end{picture}
1210 % \fi
1211 % \end{quote}
1212 %
1213 % The \textsf{(e)epic} package provides an environment,
1214 % \textsf{drawjoin}, that joins all points set with the
1215 % special "\put" command "\jput".
1216 % Thus, to draw a curve with the "\putfile" command you enter a
1217 % \textsf{drawjoin} environment, let "\put" be a synonym for
1218 % "\jput", and call "\putfile".
1219 % \begin{quote}
1220 % \begin{verbatim}
1221 % \coordsys[1](-10,0)(11,11)
1222 % \begin{drawjoin}
1223 % \let\put=\jput
1224 % \putfile{parabola.put}{\picsquare}
1225 % \end{drawjoin}
1226 % \end{verbatim}
1227 % \ifx\putfile\undefined
1228 % You do not have the \textsf{epic} and \textsf{eepic} packages,
1229 % so \LaTeX\ cannot generate the result of the above commands.
1230 % \else
1231 % \setlength{\unitlength}{7pt}
1232 % \begin{picture}(21,13)(-10,-2)
1233 % \coordsys[1](-10,0)(11,11)
1234 % \begin{drawjoin}
1235 % \let\put=\jput
1236 % \putfile{parabola.put}{\picsquare}
1237 % \end{drawjoin}
1238 % \end{picture}
1239 % \fi
1240 % \end{quote}
1241 %
1242 % To draw a curve that requires (or looks best with) different scales on
1243 % the two axes, you can use the "scale" option to
1244 % "putfile"\index{curves>scaled|(usage}\index{putfile>scale|(usage}
1245 % in Maple:
1246 % \begin{verbatim}
1247 % > plot( (x+2)*(x-1)*(x-2), x=-3..4 );
1248 % > putfile( "cubic.put", %, scale=[10, 1] );
1249 % \end{verbatim}
1250 % Now all the $x$-coordinates in "cubic.put" are $10$ times larger
1251 % than they should be. Thus re-scale the horizontal labels
1252 % by~$\frac{1}{10}$.\index{labels>re-scaled|(usage}\index{scaling labels|(usage}
1253 % \begin{quote}
1254 % \begin{verbatim}
1255 % \rescaleby{1}{10}{\hlabel}
1256 % \coordsys[2](-30,-20)(40,36)
1257 % \begin{drawjoin}
1258 % \let\put=\jput
1259 % \putfile{cubic.put}{\picsquare}
1260 % \end{drawjoin}
1261 % \end{verbatim}
1262 % \ifx\putfile\undefined
1263 % You do not have the \textsf{epic} and \textsf{eepic} packages,
1264 % so \LaTeX\ cannot generate the result of the above commands.
1265 % \else
1266 % \setlength{\unitlength}{2.3pt}
1267 % \begin{picture}(70,56)(-30,-20)
1268 % \rescaleby{1}{10}{\hlabel}
1269 % \coordsys[2](-30,-20)(40,36)
1270 % \begin{drawjoin}
1271 % \let\put=\jput
1272 % \putfile{cubic.put}{\picsquare}
1273 % \end{drawjoin}
1274 % \end{picture}
1275 % \fi
1276 % \end{quote}
1277 %
1278 % Scaling can be necessary even when the two axes do use the same
1279 % scale. Consider the graph of $r=1+\sin\theta$ in polar coordinates. The
1280 % graph is $2.6$ units wide and $2.25$ units tall. All the arguments to the
1281 % "\coordsys" command must be integers, so the smallest distance between
1282 % tick marks is $1$ unit; the coordinate system will have very few tick marks.
1283 % Instead scale up by, say, a factor $100$.
1284 % In Maple:
1285 % \begin{verbatim}
1286 % > polarplot( 1+sin(theta), theta=0..2*Pi );
1287 % > putfile( "cardioid.put", %, scale=[100,100] );
1288 % \end{verbatim}
1289 % In \LaTeX:
1290 % \begin{quote}
1291 % \begin{verbatim}
1292 % \rescaleby{1}{100}{\hlabel}
1293 % \rescaleby{1}{100}{\vlabel}
1294 % \coordsys(-130,-25)(130,215)
1295 % \begin{drawjoin}
1296 % \let\put=\jput
1297 % \putfile{cardioid.put}{\picsquare}
1298 % \end{drawjoin}
1299 % \end{verbatim}
1300 % \ifx\putfile\undefined
1301 % You do not have the \textsf{epic} and \textsf{eepic} packages,
1302 % so \LaTeX\ cannot generate the result of the above commands.
1303 % \else
1304 % \setlength{\unitlength}{0.5pt}
1305 % \begin{picture}(260,240)(-130,-25)
1306 % \rescaleby{1}{100}{\hlabel}
1307 % \rescaleby{1}{100}{\vlabel}
1308 % \coordsys(-130,-25)(130,215)
1309 % \begin{drawjoin}
1310 % \let\put=\jput
1311 % \putfile{cardioid.put}{\picsquare}
1312 % \end{drawjoin}
1313 % \end{picture}
1314 % \fi
1315 % \end{quote}
1316 %
1317 % If the plot contains more than one curve,
1318 % "putfile"\index{putfile>multiple curves|usage} generates
1319 % one file for each. You can of course specify multiple curves
1320 % directly, but they can also be the result of the "discont"
1321 % option to "plot".
1322 % \begin{verbatim}
1323 % > plot( csc(x), x=0..2*Pi, y=-10..10, discont=true );
1324 % > putfile( "csc.put", %, scale=[180/Pi, 10] );
1325 % \end{verbatim}
1326 % Here "putfile" wrote two files calling them "csc1.put"
1327 % and "csc2.put". These two curves must be drawn by different
1328 % \textsf{drawjoin} environments.
1329 % \begin{quote}
1330 % \begin{verbatim}
1331 % \renewcommand{\hthickratio}{3}
1332 % \rescaleby[\pi]{1}{180}{\hlabel}
1333 % \rescaleby{1}{10}{\vlabel}
1334 % \coordsys(0,-100)(360,115)
1335 % \begin{drawjoin}
1336 % \let\put=\jput
1337 % \putfile{csc1.put}{\picsquare}
1338 % \end{drawjoin}
1339 % \begin{drawjoin}
1340 % \let\put=\jput
1341 % \putfile{csc2.put}{\picsquare}
1342 % \end{drawjoin}
1343 % \end{verbatim}
1344 % \ifx\putfile\undefined
1345 % You do not have the \textsf{epic} and \textsf{eepic} packages,
1346 % so \LaTeX\ cannot generate the result of the above commands.
1347 % \else
1348 % \setlength{\unitlength}{0.5pt}
1349 % \begin{picture}(400,215)(-40,-100)
1350 % \renewcommand{\hthickratio}{3}
1351 % \rescaleby[\pi]{1}{180}{\hlabel}
1352 % \rescaleby{1}{10}{\vlabel}
1353 % \coordsys(0,-100)(360,115)
1354 % \begin{drawjoin}
1355 % \let\put=\jput
1356 % \putfile{csc1.put}{\picsquare}
1357 % \end{drawjoin}
1358 % \begin{drawjoin}
1359 % \let\put=\jput
1360 % \putfile{csc2.put}{\picsquare}
1361 % \end{drawjoin}
1362 % \end{picture}
1363 % \fi
1364 % \end{quote}
1365 %
1366 % For logarithmic plots
1367 % scaling\index{curves>logarithmic|usage}\index{scaling labels>logarithmic|usage}
1368 % is almost always necessary.
1369 % Consider the
1370 % graph of $y=\frac{1}{1+e^{-x}}$ for $x$ running from $-10$ to $10$.
1371 % The $y$-coordinates extend over five powers of $10$, so scale by $4$
1372 % to make it comparable to the range of $x$-coordinates.
1373 % \begin{verbatim}
1374 % > logplot(1/(1+exp(-x)), x=-10..10);
1375 % > putfile("logistic.put", %, scale=[1,4]);
1376 % \end{verbatim}
1377 % The "\rescaleby" command is not suitable for logarithmic axes.
1378 % Instead set the optional \meta{spacing} argument to the correct
1379 % distance between the powers of~$10$, in this case~$4$.
1380 % \begin{quote}
1381 % \begin{verbatim}
1382 % \logsys[1][4](-10,-20)(11,1)
1383 % \begin{drawjoin}
1384 % \let\put=\jput
1385 % \putfile{logistic.put}{\picsquare}
1386 % \end{drawjoin}
1387 % \end{verbatim}
1388 % \ifx\putfile\undefined
1389 % You do not have the \textsf{epic} and \textsf{eepic} packages,
1390 % so \LaTeX\ cannot generate the result of the above commands.
1391 % \else
1392 % \setlength{\unitlength}{7pt}
1393 % \begin{picture}(25,23)(-14,-22)
1394 % \definecolor{gray}{gray}{0.5}
1395 % \definecolor{lightgray}{gray}{0.75}
1396 % \gridstyle{\linethickness{0.12pt}\color{lightgray}}%
1397 % {\linethickness{0.12pt}\color{gray}}
1398 % \loggrid*[1][4](-10,-20)(11,1)
1399 % \logsys[1][4](-10,-20)(11,1)
1400 % \color{red}
1401 % \begin{drawjoin}
1402 % \let\put=\jput
1403 % \putfile{logistic.put}{\picsquare}
1404 % \end{drawjoin}
1405 % \end{picture}
1406 % \fi
1407 % \end{quote}
1408 % \index{curves>scaled|)usage}\index{putfile>scale|)usage}%
1409 % \index{labels>re-scaled|)usage}\index{scaling labels|)usage}
1410 %
1411 % Use the "putfile" command as follows:\index{putfile>syntax|usage}
1412 % \begin{quote}
1413 % "putfile(" \meta{filename}"," \meta{PLOT structure} [","
1414 % \meta{options} ] ");"
1415 % \end{quote}
1416 % If \meta{filename} is a string and the \meta{PLOT structure} contains
1417 % more than one curve, "putfile" will append $1, 2, 3, \dots$ as needed;
1418 % "putfile" also appends an extension of ".tex" if the \meta{filename}
1419 % has no extension.
1420 % If the \meta{filename} is a list or set of filenames, they are used
1421 % as is. (So if you do not want "putfile" to meddle with your filename,
1422 % give it in a set.)
1423 %
1424 % The only possible option is\index{putfile>scale|(usage}
1425 % \begin{quote}
1426 % "scale" "=" "[" \meta{number}"," \meta{number} "]"
1427 % \end{quote}
1428 % The "putfile" command will multiply all $x$-coordinates by the first
1429 % number and all $y$-coordinates by the second number.
1430 % Both numbers must be "evalf"able.
1431 %
1432 % If you scale the coordinates of a curve, you must
1433 % of course compensate for that to get an honest
1434 % representation of your data in \LaTeX.
1435 % \begin{itemize}
1436 % \item If you scale a regular (linear) axis by, say,
1437 % "scale=[3/5,1]", you should use "\rescaleby{5}{3}{\hlabels}"
1438 % to re-scale the labels.
1439 %
1440 % \item If you scale a logarithmic axis by, say, "scale=[1,30]"
1441 % you should use the optional \meta{spacing} argument to
1442 % the command that draws the coordinate system, say
1443 % "\logsys[30]("\dots
1444 % \end{itemize}\index{putfile>scale|)usage}\index{curves|)usage}
1445 %
1446 %
1447 % \section{Installation}
1448 % Extract\index{installation|usage} the \url{.sty} files from
1449 % the \url{.dtx} file by running \url:coordsys.ins: through \LaTeX.
1450 % Then generate the documentation for the \textsf{coordsys} and
1451 % \textsf{logsys} packages
1452 % by running the file \url:coordsys.dtx: through
1453 % \LaTeX---thrice to resolve cross references.\footnote{If you want an index,
1454 % you must run MakeIndex
1455 % (\texttt{makeindex -s gind.ist coordsys}) between the second and third
1456 % \LaTeX{} run.}
1457 %
1458 % You now have to decide what to do with several files.
1459 % \begin{itemize}
1460 % \item Move the files \url:coordsys.sty: and \url:logsys.sty: to some
1461 % directory where \LaTeX\ can find it;
1462 % \url:(local)texmf/tex/latex/misc: would be
1463 % the natural choice.
1464 % \item Move the documentation, \url:coordsys.dvi: or \url:coordsys.pdf:, to
1465 % \url:(local)texmf/doc/latex/misc:.
1466 % \item You may discard the source files, \url:coordsys.dtx: and
1467 % \url:coordsys.ins:, or store them in
1468 % \url:(local)texmf/source/latex/misc:.
1469 % \item If you ran \url{coordsys.dtx} through \LaTeX, several \url{.put}
1470 % were created. You can discard those.
1471 % \end{itemize}
1472 %
1473 %
1474 %
1475 % \section{License}\label{sec:license}
1476 % This program may be distributed and/or modified under the
1477 % conditions of the \LaTeX\ Project Public License, either version 1.3
1478 % of this license or (at your option) any later version.
1479 % The latest version of this license is in
1480 % \url;http://www.latex-project.org/lppl.txt;
1481 % and version 1.2 or later is part of all distributions of \LaTeX \
1482 % version 2003/12/01 or later.
1483 %
1484 % This program consists of the files \url:coordsys.dtx: and
1485 % \url:coordsys.ins:.
1486 %
1487 %
1488 % \section{Acknowledgements}
1489 % Thank you to Scott Pakin
1490 % for his input on the implementation of Euclid's
1491 % algorithm.
1492 %
1493 % Thank you to Svend Daugaard Pedersen
1494 % for catching an error in the logarithmic systems
1495 % and for suggestions that led to "\gridstyle".
1496 %
1497 % Thank you to Staffan Lundberg
1498 % who found an error in my understanding
1499 % of Maple's structured types and thus prompted me to polish the
1500 % Maple code for "putfile".
1501 %
1502 % Thank you to Jan Hegewald
1503 % whose questions led to an improved description and implementation
1504 % of "\rescaleby".
1505 %
1506 %
1507 % \StopEventually{
1508 % \PrintIndex
1509 % }
1510 %
1511 % \section{Implementation}
1512 %
1513 % \subsection{The \textsf{coordsys} Package}
1514 % \subsubsection{Identification}
1515 % First we must declare ourselves.
1516 % \begin{macrocode}
1517 %<*coordsys>
1518 \NeedsTeXFormat{LaTeX2e}
1519 \ProvidesPackage{coordsys}[2006/02/03 version 1.4]
1520 % \end{macrocode}
1521 %
1522 % \subsubsection{Declaration of Options}
1523 % \begin{macro}{\ticklength}
1524 % \begin{macro}{\vtickmark}
1525 % \begin{macro}{\htickmark}
1526 % The options define "\ticklength", "vtickmark", and
1527 % "\htickmark". First check that these three commands are not defined
1528 % elsewhere.
1529 % \begin{macrocode}
1530 \newcommand{\ticklength}{\relax}
1531 \newcommand{\vtickmark}{\relax}
1532 \newcommand{\htickmark}{\relax}
1533 % \end{macrocode}
1534 % The "\vtickmark" and "\htickmark" commands set the individual
1535 % ticks; "\vtickmark" sets vertical ticks on a horizontal axis,
1536 % and "\htickmark" sets horizontal ticks on a vertical axis.
1537 % "\@wholewidth" is the current line width,
1538 % that is, the width of "\thinlines" or "\thicklines".
1539 % \begin{macrocode}
1540 \DeclareOption{centred}{%
1541 \def\vtickmark{\makebox(0,0){\rule{\@wholewidth}{\ticklength}}}%
1542 \def\htickmark{\makebox(0,0){\rule{\ticklength}{\@wholewidth}}}%
1543 \def\ticklength{6\p@}%
1544 }
1545 \DeclareOption{outside}{%
1546 \def\vtickmark{\makebox(0,0)[t]{\rule{\@wholewidth}{\ticklength}}}%
1547 \def\htickmark{\makebox(0,0)[r]{\rule{\ticklength}{\@wholewidth}}}%
1548 \def\ticklength{3\p@}%
1549 }
1550 \DeclareOption{inside}{%
1551 \def\vtickmark{\makebox(0,0)[b]{\rule{\@wholewidth}{\ticklength}}}%
1552 \def\htickmark{\makebox(0,0)[l]{\rule{\ticklength}{\@wholewidth}}}%
1553 \def\ticklength{3\p@}%
1554 }
1555 % \end{macrocode}
1556 % \end{macro}\end{macro}\end{macro}
1557 %
1558 % \subsubsection{Execution of Options}
1559 % The default option is \textsf{centred}.
1560 % \begin{macrocode}
1561 \ExecuteOptions{centred}
1562 \ProcessOptions
1563 % \end{macrocode}
1564 %
1565 % \subsubsection{Main Code}
1566 % \begin{macro}{\vgridfromto}
1567 % \begin{macro}{\hgridfromto}
1568 % The "\vgridfromto" and "\hgridfromto" commands typeset vertical
1569 % and horizontal dotted lines for the dotted coordinate grids.
1570 % \begin{quote}
1571 % "\vgridfromto"\marg{from}\marg{to}\\
1572 % "\hgridfromto"\marg{from}\marg{to}
1573 % \end{quote}
1574 % The dotted line is to run from ($y$- or $x$-coordinate) \meta{from} to ($y$-
1575 % or $x$-coordinate) \meta{to}. The two commands set the lines by means of
1576 % leaders in a box. The box is set at $y$- or $x$-coordinate zero and the
1577 % leaders extend to the right length by skipping back and forth. This way the
1578 % dots line up nicely in a predictable manner. When "\vgridfromto" or
1579 % "\hgridfromto" is called, "\coordsys@w" should contain the size
1580 % (height or width) of the box containing each dot.
1581 % \begin{macrocode}
1582 \newcommand{\vgridfromto}[2]{%
1583 \vbox to \z@{\vskip -#2\unitlength
1584 \leaders\vbox to \coordsys@w{\vss\hbox{\picsquare}\vss}
1585 \vfill
1586 \vskip #1\unitlength}}
1587 \newcommand{\hgridfromto}[2]{%
1588 \hbox to \z@{\hskip #1\unitlength
1589 \leaders\hbox to \coordsys@w{\hss\picsquare\hss}\hfill
1590 \hskip-#2\unitlength}}
1591 % \end{macrocode}
1592 % \end{macro}\end{macro}
1593 % \begin{macro}{\vgridlength}
1594 % \begin{macro}{\hgridlength}
1595 % The "\vgriglength" and "\hgridlength" command typesets
1596 % solid vertical and horizontal lines.
1597 % \begin{quote}
1598 % "\vgridlength"\marg{length}\\
1599 % "\hgridlength"\marg{length}
1600 % \end{quote}
1601 % The line is to have length \meta{length} and is set at the left-hand or
1602 % bottom edge of the coordinate system.
1603 % \begin{macrocode}
1604 \newcommand{\vgridlength}[1]{\line(0,1){#1}}
1605 \newcommand{\hgridlength}[1]{\line(1,0){#1}}
1606 % \end{macrocode}
1607 % \end{macro}\end{macro}
1608 %
1609 % \begin{macro}{\setvlabel}
1610 % \begin{macro}{\sethlabel}
1611 % The "\setvlabel" and "\sethlabel" commands typeset the labels on
1612 % the vertical and horizontal axes, respectively.
1613 % The "\setvlabel" command sets 5\,pt of space between the label and the
1614 % axis, which is about right, considering that the tick marks extend 3\,pt on
1615 % either side of the axis.
1616 % The "\sethlabel" command places the labels on a baseline 3\,pt plus
1617 % the current "\baselineskip" below the axis by means of a strut (a
1618 % zero-width rule).\nextlinelabel{cl:setlabels}
1619 % \begin{macrocode}
1620 \@ifpackageloaded{color}{%
1621 \newcommand{\setvlabel}[2][r]{%
1622 \makebox(0,0)[#1]{\colorbox{white}{$#2$}\hspace{5pt}}}
1623 \newcommand{\sethlabel}[2][t]{%
1624 \makebox(0,0)[#1]{%
1625 \setlength{\@tempdimc}{3pt}%
1626 \addtolength{\@tempdimc}{\baselineskip}%
1627 \rule{0pt}{\@tempdimc}\colorbox{white}{$#2$}}}%
1628 }{% no colour
1629 \newcommand{\setvlabel}[2][r]{%
1630 \makebox(0,0)[#1]{$#2$\hspace{5\p@}}}
1631 \newcommand{\sethlabel}[2][t]{%
1632 \makebox(0,0)[#1]{%
1633 \setlength{\@tempdimc}{3\p@}%
1634 \addtolength{\@tempdimc}{\baselineskip}%
1635 \rule{\z@}{\@tempdimc}$#2$}}%
1636 }% end if color package
1637 % \end{macrocode}
1638 % You may want to redefine "\setvlabel" and "\sethlabel" to present
1639 % the labels in a different way---use a smaller font, increase the distance to
1640 % the axes,\dots. Your redefined commands must take one optional and one
1641 % mandatory argument---the "\window" command uses the optional argument.
1642 % Do not assume that the mandatory argument is always a number---the
1643 % "\window" command uses "\setvlabel" and "\sethlabel" to
1644 % typeset the min\slash max labels.
1645 % \end{macro}\end{macro}
1646 %
1647 % \begin{macro}{\hlabel}
1648 % \begin{macro}{\vlabel}
1649 % The "\hlabel" and "\vlabel" commands calculate the labels that
1650 % "\setvlabel" and "\sethlabel" typeset. The default definitions
1651 % of "\hlabel" and "\vlabel" do nothing, but you can redefine them
1652 % with the "\rescaleby" command.
1653 % \begin{macrocode}
1654 \newcommand{\hlabel}[1]{#1}%
1655 \newcommand{\vlabel}[1]{#1}%
1656 % \end{macrocode}
1657 % \end{macro}\end{macro}
1658 %
1659 % \begin{macro}{\rescaleby}
1660 % The "\rescaleby" command redefines it's fourth argument
1661 % (the third mandatory argument)
1662 % which should be either "\hlabel" or "\vlabel".
1663 % After
1664 % \begin{quote}
1665 % "\rescaleby"\oarg{symb}\marg{num}\marg{den}"{\hlabel}"
1666 % \end{quote}
1667 % the result of "\hlabel"\marg{x} should be
1668 % $\frac{\meta{num}\times \meta{x}}{\meta{den}} \meta{symb}$.
1669 % \begin{macrocode}
1670 \newcommand{\rescaleby}[4][]{\renewcommand{#4}[1]{{%
1671 \count@=##1\relax
1672 \ifnum\count@=0\relax
1673 \@tempcntb=1\relax
1674 \else
1675 \multiply\count@ #2\relax
1676 \ifnum\count@<0\count@=-\count@\fi
1677 \@EuclidGCD{\count@}{#3}%
1678 \count@=##1\relax
1679 \multiply\count@ #2\relax
1680 \divide\count@\@tempcnta
1681 \@tempcntb=#3\relax
1682 \divide\@tempcntb\@tempcnta
1683 \fi
1684 % \end{macrocode}
1685 % We have reduced the fraction. Now print it nicely.
1686 % \begin{macrocode}
1687 \ifnum\count@<0\relax
1688 -%
1689 \count@=-\count@
1690 \fi
1691 \def\coordsys@a{#1}%
1692 \ifx\coordsys@a\@empty\relax
1693 \ifnum\@tempcntb=1\relax
1694 \the\count@
1695 \else
1696 \frac{\the\count@}{\the\@tempcntb}%
1697 \fi
1698 \else
1699 \ifnum\@tempcntb=1\relax
1700 \ifnum\count@=1\relax
1701 \coordsys@a
1702 \else
1703 \the\count@\coordsys@a
1704 \fi
1705 \else
1706 \ifnum\count@=1\relax
1707 \frac{\coordsys@a}{\the\@tempcntb}%
1708 \else
1709 \frac{\the\count@}{\the\@tempcntb}\coordsys@a
1710 \fi
1711 \fi
1712 \fi
1713 }}}
1714 % \end{macrocode}
1715 % \end{macro}
1716 %
1717 % \begin{macro}{\hthickratio}
1718 % \begin{macro}{\vthickratio}
1719 % By default every fifth tick mark is thick.
1720 % \begin{macrocode}
1721 \newcommand{\hthickratio}{5}
1722 \newcommand{\vthickratio}{5}
1723 % \end{macrocode}
1724 % \end{macro}\end{macro}
1725 %
1726 % \begin{macro}{\text}
1727 % Hopefully the \textsf{amstext} package will override this very simple
1728 % "\text" command intended for subscripts only.
1729 % \begin{macrocode}
1730 \providecommand{\text}[1]{\mbox{\scriptsize #1}}
1731 % \end{macrocode}
1732 % \end{macro}
1733 % \begin{macro}{\picsquare}
1734 % The "\picsquare" command typesets a square of size the current line
1735 % width---as in the \textsf{epic} package.
1736 % \begin{macrocode}
1737 \providecommand{\picsquare}{%
1738 \makebox(0,0){\rule{\@wholewidth}{\@wholewidth}}}
1739 % \end{macrocode}
1740 % \end{macro}
1741 %
1742 % \begin{macro}{\count@}
1743 % \begin{macro}{\c@@coord}
1744 % \begin{macro}{\@tenpcnta}
1745 % \begin{macro}{\@tenpcntb}
1746 % \begin{macro}{\if@numbline}
1747 % We need three counters. \LaTeX\ inherits one, "\count@", from plain
1748 % \TeX\ and defines two more, "\@tempcnta" and "\@tempcntb".
1749 % We create a \LaTeX\ counter, "@coord",\nextlinelabel{cl:@coord} without
1750 % allocating a new counter
1751 % by making "\c@@coord" a synonym for "\count@"\footnote{I don't
1752 % quite understand why I bother do that; I copied the idea from Lamport's
1753 % \textsf{graphpap} package, which is where the \textsf{coordsys} package
1754 % began.}
1755 % The "\if" controls whether to set labels.
1756 % \begin{macrocode}
1757 \let\c@@coord\count@
1758 \newif\if@numbline
1759 % \end{macrocode}
1760 % \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
1761 %
1762 % \begin{macro}{\tickstyle}
1763 % \begin{macro}{\thin@ticks}
1764 % \begin{macro}{\thick@ticks}
1765 % The commands "\thin@ticks" and "\thick@ticks" store the style of
1766 % the tick marks. The "\tickstyle" command defines those two. The
1767 % default is "\thinlines" for the thin tick marks and "\thicklines"
1768 % for the thick tick marks.
1769 % \begin{macrocode}
1770 \newcommand{\tickstyle}[2]{%
1771 \def\thin@ticks{#1}%
1772 \def\thick@ticks{#2}}
1773 \tickstyle{\thinlines}{\thicklines}
1774 % \end{macrocode}
1775 % \end{macro}\end{macro}\end{macro}
1776 %
1777 % \begin{macro}{\@set@ticks}
1778 % The "\@set@ticks" command calculates the positions of the
1779 % tick marks.
1780 % \begin{quote}
1781 % "\@set@ticks"\marg{thickratio}\marg{spacing}^^A
1782 % \marg{from}\marg{to}\marg{tickfree}\marg{cmd}
1783 % \end{quote}
1784 % \begin{macro}{\coordsys@a}
1785 % \begin{macro}{\coordsys@b}
1786 % \begin{macro}{\coordsys@c}
1787 % The "\@set@ticks" command calculates three parameters:
1788 % "\coordsys@a" is the position of the first tick;
1789 % "\coordsys@b" is the number of ticks to set; and
1790 % "\coordsys@c" is the spacing between the ticks (that is,
1791 % \meta{spacing} for the thin ticks and $\meta{thickratio}\meta{spacing}$
1792 % for the thick ticks).
1793 % \end{macro}\end{macro}\end{macro}
1794 % Then "\@set@ticks" calls \meta{cmd} to actually set the ticks using
1795 % these parameters.\nextlinelabel{cl:BeginTickCalc}
1796 % \begin{macrocode}
1797 \newcommand{\@set@ticks}[6]{%
1798 \thin@ticks
1799 \edef\coordsys@c{#2}%
1800 % \end{macrocode}
1801 % First we must round \meta{from} up to a multiple of \meta{spacing}.
1802 % Knuth's implementation of integer division
1803 % always rounds toward zero,
1804 % so for negative \meta{from} we can simply divide and multiply
1805 % by \meta{spacing}. If \meta{from} is positive, we must play around a
1806 % little to round up instead of down.
1807 % \begin{macrocode}
1808 \@tempcnta=#3\relax
1809 \ifnum\@tempcnta>0\advance\@tempcnta -1\relax\fi
1810 \divide\@tempcnta \coordsys@c\relax
1811 \ifnum #3>0\advance\@tempcnta 1\relax\fi
1812 \multiply\@tempcnta \coordsys@c\relax
1813 \edef\coordsys@a{\the\@tempcnta}%
1814 % \end{macrocode}
1815 % Then we must calculate how many ticks to set.
1816 % To avoid collision between ticks and arrowheads,
1817 % there is to be no ticks in the last \meta{tickfree} length.
1818 % \begin{macrocode}
1819 \@tempcntb=#4\relax
1820 \advance\@tempcntb -\@tempcnta\relax
1821 \setlength{\@tempdima}{\@tempcntb\unitlength}%
1822 \addtolength{\@tempdima}{-#5}%
1823 \ifdim\@tempdima<\z@\relax
1824 \def\coordsys@b{0}%
1825 \else
1826 \divide\@tempdima\unitlength\relax
1827 \divide\@tempdima\coordsys@c\relax
1828 \@tempcntb=\@tempdima%
1829 \advance\@tempcntb 1\relax%
1830 \edef\coordsys@b{\the\@tempcntb}%
1831 \fi
1832 #6%
1833 % \end{macrocode}
1834 % \nextlinelabel[0]{cl:EndTickCalc}
1835 % Then the thick ticks.
1836 % This time the spacing is $\meta{thickratio}\meta{spacing}$, so calculate
1837 % that number
1838 % and store it in "\coordsys@c".
1839 % \begin{macrocode}
1840 \thick@ticks
1841 \@tempcntb=#1\relax
1842 \multiply\@tempcntb \coordsys@c\relax
1843 \edef\coordsys@c{\the\@tempcntb}%
1844 % \end{macrocode}
1845 % Calculate the position of the first (thick) tick as above.
1846 % \begin{macrocode}
1847 \@tempcnta=#3\relax
1848 \ifnum\@tempcnta>0\advance\@tempcnta -1\relax\fi
1849 \divide\@tempcnta \coordsys@c\relax
1850 \ifnum #3>0\advance\@tempcnta 1\relax\fi
1851 \multiply\@tempcnta \coordsys@c\relax
1852 \edef\coordsys@a{\the\@tempcnta}%
1853 % \end{macrocode}
1854 % Then calculate the number of \emph{thin} ticks
1855 % between the first thick tick ("\@tempcnta") and
1856 % \meta{to} less \meta{tickfree}, namely
1857 % $\left\lfloor\frac{\meta{to}-\meta{first}-\meta{tickless}}{\meta{spacing}}\right\rfloor+1$.
1858 % \begin{macrocode}
1859 \@tempcntb=#4\relax
1860 \advance\@tempcntb -\@tempcnta\relax
1861 \setlength{\@tempdima}{\@tempcntb\unitlength}%
1862 \addtolength{\@tempdima}{-#5}%
1863 \ifdim\@tempdima<\z@\relax
1864 \def\coordsys@b{0}%
1865 \else
1866 \divide\@tempdima\unitlength\relax
1867 \divide\@tempdima#2\relax
1868 \@tempcntb=\@tempdima%
1869 % \advance\@tempcntb 1\relax
1870 % \end{macrocode}
1871 % The number of thick ticks is then
1872 % $\left\lceil\frac{\meta{number of thin ticks}}{\meta{thickratio}}\right\rceil$.
1873 % \begin{macrocode}
1874 % \advance\@tempcntb -1\relax
1875 \divide\@tempcntb #1\relax
1876 \advance\@tempcntb 1\relax
1877 \edef\coordsys@b{\the\@tempcntb}%
1878 \fi
1879 #6%
1880 }
1881 % \end{macrocode}
1882 % \end{macro}
1883 %
1884 % \begin{macro}{\numbline}
1885 % The "\numbline" command checks for a star,
1886 % \begin{macrocode}
1887 \newcommand{\numbline}{%
1888 \@ifstar{\@numblinefalse\hnumbline@i}
1889 {\@numblinetrue \hnumbline@i}}
1890 % \end{macrocode}
1891 % \begin{macro}{\hnumbline@i}
1892 % then "\hnumbline@i" picks up the optional argument,
1893 % \begin{macrocode}
1894 \newcommand{\hnumbline@i}[1][10]{\leavevmode\hnumbline@ii{#1}}
1895 % \end{macrocode}
1896 % \end{macro}
1897 % \begin{macro}{\hnumbline@ii}
1898 % and "\hnumbline@ii" does the work:
1899 % Calculate the length of the arrow and set it, then call "\@set@ticks"
1900 % to set the tick marks. The extra set of braces localizes the
1901 % "\tickstyle" declarations.
1902 % \begin{macrocode}
1903 \newcommand{\hnumbline@ii}[3]{{\color@begingroup
1904 \thinlines
1905 \@tempcnta=#3\relax
1906 \advance\@tempcnta -#2\relax
1907 \edef\coordsys@w{\the\@tempcnta}%
1908 \put(#2,0){\vector(1,0){\coordsys@w}}%
1909 \@set@ticks{\hthickratio}{#1}{#2}{#3}{6\p@}{
1910 \multiput(\coordsys@a,0)(\coordsys@c,0)\coordsys@b\vtickmark}%
1911 % \end{macrocode}
1912 % Set the labels if we have to.
1913 % The parameters "\coordsys@a", "\coordsys@b", and
1914 % "\coordsys@c" that "\@set@ticks" calculated for the thick tick
1915 % marks are still available. In particular, "\coordsys@a" is the
1916 % position and, hence, the value of the first label.
1917 % \begin{macrocode}
1918 \if@numbline
1919 \setcounter{@coord}{\coordsys@a}%
1920 \multiput(\coordsys@a,0)(\coordsys@c,0)\coordsys@b{%
1921 \edef\coordsys@a{\arabic{@coord}}%
1922 \sethlabel{\hlabel{\coordsys@a}}%
1923 \addtocounter{@coord}{\coordsys@c}}
1924 \fi
1925 \color@endgroup}%
1926 % \end{macrocode}
1927 % Finally store the vertical coordinate of the number line in
1928 % "\coordsys@w" for the sake of the "\interval" command.
1929 % \begin{macrocode}
1930 \def\coordsys@w{0}%
1931 }
1932 % \end{macrocode}
1933 % \end{macro}\end{macro}
1934 %
1935 % \begin{macro}{\vnumbline}
1936 % \begin{macro}{\vnumbline@i}
1937 % \begin{macro}{\vnumbline@ii}
1938 % The "\vnumbline" command and friends work in much the same way.
1939 % \begin{macrocode}
1940 \newcommand{\vnumbline}{%
1941 \@ifstar{\@numblinefalse\vnumbline@i}
1942 {\@numblinetrue \vnumbline@i}}
1943 \newcommand{\vnumbline@i}[1][10]{\leavevmode\vnumbline@ii{#1}}
1944 \newcommand{\vnumbline@ii}[3]{{\color@begingroup
1945 \thinlines
1946 \@tempcnta=#3\relax
1947 \advance\@tempcnta -#2\relax
1948 \edef\coordsys@h{\the\@tempcnta}%
1949 \put(0,#2){\vector(0,1){\coordsys@h}}%
1950 \@set@ticks{\vthickratio}{#1}{#2}{#3}{6\p@}{%
1951 \multiput(0,\coordsys@a)(0,\coordsys@c)\coordsys@b\htickmark}%
1952 \if@numbline
1953 \setcounter{@coord}{\coordsys@a}%
1954 \multiput(0,\coordsys@a)(0,\coordsys@c)\coordsys@b{%
1955 \edef\coordsys@a{\arabic{@coord}}%
1956 \setvlabel{\vlabel{\coordsys@a}}%
1957 \addtocounter{@coord}{\coordsys@c}}
1958 \fi
1959 \color@endgroup}%
1960 \def\coordsys@h{0}%
1961 }
1962 % \end{macrocode}
1963 % \end{macro}\end{macro}\end{macro}
1964 %
1965 % \begin{macro}{\coordsys}
1966 % All the coordinate-system drawing command use similar syntax, so we use a
1967 % unified approach for picking up the arguments.
1968 % The "\coordsys" command defines the temporary variable
1969 % "\coordsys@c" to be the name of the command that does the real work.
1970 % Then "\coordsys" checks for the presence of a star.
1971 % \begin{macrocode}
1972 \newcommand{\coordsys}{%
1973 \def\coordsys@c{\coordsys@i}%
1974 \@ifstar{\@numblinefalse\coordsys@args@i}
1975 {\@numblinetrue \coordsys@args@i}}
1976 % \end{macrocode}
1977 % \begin{macro}{\coordsys@args@i}
1978 % \begin{macro}{\@hticksep}
1979 % The "\coordsys@args@i" command picks up the first optional argument
1980 % storing it
1981 % in "\@hticksep" so that we can use that variable as the default for the
1982 % second optional argument.
1983 % \begin{macrocode}
1984 \newcommand{\coordsys@args@i}[1][10]{\leavevmode
1985 \def\@hticksep{#1}%
1986 \coordsys@args@ii}
1987 % \end{macrocode}
1988 % \end{macro}\end{macro}
1989 % \begin{macro}{\coordsys@args@ii}
1990 % \begin{macro}{\@vticksep}
1991 % Then "\coordsys@args@ii" picks up the second optional argument,
1992 % \begin{macrocode}
1993 \newcommand{\coordsys@args@ii}[1][\@hticksep]{%
1994 \def\@vticksep{#1}%
1995 \coordsys@args@iii}
1996 % \end{macrocode}
1997 % \end{macro}\end{macro}
1998 % \begin{macro}{\coordsys@args@iii}
1999 % and the "\coordsys@args@iii" command picks up the first point and
2000 % brutally
2001 % replaces whatever the following may be with a "(". Since \TeX\ ignores
2002 % spaces when looking for an argument, this allows the user to leave a space
2003 % between the first and the second point.
2004 % \begin{macrocode}
2005 \def\coordsys@args@iii(#1,#2)#3{\coordsys@c{#1}{#2}(}
2006 % \end{macrocode}
2007 % \end{macro}
2008 % \begin{macro}{\coordsys@i}
2009 % Finally the real command, "\coordsys@c", that is "\coordsys@i",
2010 % picks up the second point (as well as the first), and gets to work:
2011 % First calculate the length of each axis and set it.
2012 % \begin{macrocode}
2013 \def\coordsys@i#1#2(#3,#4){{\color@begingroup
2014 \thinlines
2015 \@tempcnta=#3\relax
2016 \advance\@tempcnta -#1\relax
2017 \edef\coordsys@w{\the\@tempcnta}%
2018 \put(#1,0){\vector(1,0){\coordsys@w}}%
2019 \@tempcnta=#4\relax
2020 \advance\@tempcnta -#2\relax
2021 \edef\coordsys@h{\the\@tempcnta}%
2022 \put(0,#2){\vector(0,1){\coordsys@h}}%
2023 % \end{macrocode}
2024 % Then set the tick marks on the horizontal axis.
2025 % \begin{macrocode}
2026 \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{6\p@}{%
2027 \multiput(\coordsys@a,0)(\coordsys@c,0)\coordsys@b\vtickmark}%
2028 % \end{macrocode}
2029 % This style of coordinate system has intersecting axes, so we must suppress
2030 % the label ``0''.
2031 % \begin{macrocode}
2032 \if@numbline
2033 \setcounter{@coord}{\coordsys@a}%
2034 \multiput(\coordsys@a,0)(\coordsys@c,0)\coordsys@b{%
2035 \ifnum\value{@coord}=0\relax\else
2036 \edef\coordsys@a{\arabic{@coord}}%
2037 \sethlabel{\hlabel{\coordsys@a}}%
2038 \fi
2039 \addtocounter{@coord}{\coordsys@c}}%
2040 \fi
2041 % \end{macrocode}
2042 % Then do the tick marks and labels on the vertical axis.
2043 % \begin{macrocode}
2044 \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{6\p@}{%
2045 \multiput(0,\coordsys@a)(0,\coordsys@c)\coordsys@b\htickmark}%
2046 \if@numbline
2047 \setcounter{@coord}{\coordsys@a}%
2048 \multiput(0,\coordsys@a)(0,\coordsys@c)\coordsys@b{%
2049 \ifnum\value{@coord}=0\relax\else
2050 \edef\coordsys@a{\arabic{@coord}}%
2051 \setvlabel{\vlabel{\coordsys@a}}%
2052 \fi
2053 \addtocounter{@coord}{\coordsys@c}}%
2054 \fi
2055 \color@endgroup}%
2056 % \end{macrocode}
2057 % Finally store the location of the axis in "\coordsys@w" and "\coordsys@h"
2058 % for the sake of the "\interval" command.
2059 % \begin{macrocode}
2060 \def\coordsys@w{0}%
2061 \def\coordsys@h{0}%
2062 }
2063 % \end{macrocode}
2064 % \end{macro}\end{macro}
2065 %
2066 % \begin{macro}{\fcoordsys}
2067 % \begin{macro}{\fcoordsys@i}
2068 % The "\fcoordsys" and "\fcoordsys@i" commands work much like
2069 % "\coordsys" and "\coordsys@i" above.
2070 % \begin{macrocode}
2071 \newcommand{\fcoordsys}{%
2072 \def\coordsys@c{\fcoordsys@i}%
2073 \@ifstar{\@numblinefalse\coordsys@args@i}
2074 {\@numblinetrue \coordsys@args@i}}
2075 \def\fcoordsys@i#1#2(#3,#4){{\color@begingroup
2076 \thinlines
2077 \@tempcnta=#3\relax
2078 \advance\@tempcnta -#1\relax
2079 \edef\coordsys@w{\the\@tempcnta}%
2080 \put(#1,#2){\vector(1,0){\coordsys@w}}%
2081 \@tempcnta=#4\relax
2082 \advance\@tempcnta -#2\relax
2083 \edef\coordsys@h{\the\@tempcnta}%
2084 \put(#1,#2){\vector(0,1){\coordsys@h}}%
2085 \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{6\p@}{%
2086 \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b\vtickmark}%
2087 \if@numbline
2088 \setcounter{@coord}{\coordsys@a}%
2089 \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b{%
2090 \edef\coordsys@a{\arabic{@coord}}%
2091 \sethlabel{\hlabel{\coordsys@a}}%
2092 \addtocounter{@coord}{\coordsys@c}}%
2093 \fi
2094 \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{6\p@}{%
2095 \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b\htickmark}%
2096 \if@numbline
2097 \setcounter{@coord}{\coordsys@a}%
2098 \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b{%
2099 \edef\coordsys@a{\arabic{@coord}}%
2100 \setvlabel{\vlabel{\coordsys@a}}%
2101 \addtocounter{@coord}{\coordsys@c}}%
2102 \fi
2103 \color@endgroup}%
2104 \def\coordsys@h{#1}%
2105 \def\coordsys@w{#2}%
2106 }
2107 % \end{macrocode}
2108 % \end{macro}\end{macro}
2109 %
2110 % \begin{macro}{\bcoordsys}
2111 % \begin{macro}{\bcoordsys@i}
2112 % The "\bcoordsys" and "\bcoordsys@i" commands work much like
2113 % "\coordsys" and "\coordsys@i" above.
2114 % \begin{macrocode}
2115 \newcommand{\bcoordsys}{%
2116 \def\coordsys@c{\bcoordsys@i}%
2117 \@ifstar{\@numblinefalse\coordsys@args@i}
2118 {\@numblinetrue \coordsys@args@i}}
2119 \def\bcoordsys@i#1#2(#3,#4){{\color@begingroup
2120 \thinlines
2121 \@tempcnta=#3\relax
2122 \advance\@tempcnta -#1\relax
2123 \edef\coordsys@w{\the\@tempcnta}%
2124 \put(#1,#2){\line(1,0){\coordsys@w}}%
2125 \put(#1,#4){\line(1,0){\coordsys@w}}%
2126 \@tempcnta=#4\relax
2127 \advance\@tempcnta -#2\relax
2128 \edef\coordsys@h{\the\@tempcnta}%
2129 \put(#1,#2){\line(0,1){\coordsys@h}}%
2130 \put(#3,#2){\line(0,1){\coordsys@h}}%
2131 \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{\z@}{%
2132 \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b\vtickmark}%
2133 \if@numbline
2134 \setcounter{@coord}{\coordsys@a}%
2135 \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b{%
2136 \edef\coordsys@a{\arabic{@coord}}%
2137 \sethlabel{\hlabel{\coordsys@a}}%
2138 \addtocounter{@coord}{\coordsys@c}}%
2139 \fi
2140 \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{\z@}{%
2141 \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b\htickmark}%
2142 \if@numbline
2143 \setcounter{@coord}{\coordsys@a}%
2144 \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b{%
2145 \edef\coordsys@a{\arabic{@coord}}%
2146 \setvlabel{\vlabel{\coordsys@a}}%
2147 \addtocounter{@coord}{\coordsys@c}}%
2148 \fi
2149 \color@endgroup}%
2150 \def\coordsys@h{#1}%
2151 \def\coordsys@w{#2}%
2152 }
2153 % \end{macrocode}
2154 % \end{macro}\end{macro}
2155 %
2156 % \begin{macro}{\window}
2157 % \begin{macro}{\window@i}
2158 % And yet another modification of the same old thing.
2159 % \begin{macrocode}
2160 \newcommand{\window}{%
2161 \def\coordsys@c{\window@i}%
2162 \@ifstar{\let\coordsys@a\phantom\coordsys@args@i}
2163 {\let\coordsys@a\relax \coordsys@args@i}}
2164 \def\window@i#1#2(#3,#4){{%
2165 \thinlines
2166 \@tempcnta=#3\relax
2167 \advance\@tempcnta-#1\relax
2168 \edef\coordsys@w{\the\@tempcnta}%
2169 \@tempcnta=#4\relax
2170 \advance\@tempcnta-#2\relax
2171 \edef\coordsys@h{\the\@tempcnta}%
2172 \put(#1,#2){\line(1,0){\coordsys@w}}%
2173 \put(#1,#2){\line(0,1){\coordsys@h}}%
2174 \put(#3,#4){\line(-1,0){\coordsys@w}}%
2175 \put(#3,#4){\line(0,-1){\coordsys@h}}%
2176 % \end{macrocode}
2177 % Set the labels; "\ensuremath" for the sake of the
2178 % subscripts.
2179 % \begin{macrocode}
2180 \put(#1,#2){\sethlabel[tl]%
2181 {\ensuremath{x_{\text{min}}=\coordsys@a{#1}}}}%
2182 \put(#3,#2){\sethlabel[tr]%
2183 {\ensuremath{x_{\text{max}}=\coordsys@a{#3}}}}%
2184 \put(#1,#2){\setvlabel[rb]%
2185 {\ensuremath{y_{\text{min}}=\coordsys@a{#2}}}}%
2186 \put(#1,#4){\setvlabel[rt]%
2187 {\ensuremath{y_{\text{max}}=\coordsys@a{#4}}}}%
2188 % \end{macrocode}
2189 % If the axes are in the window, typeset them (without labels).
2190 % \begin{macrocode}
2191 \ifnum #1<0\relax\ifnum #3>0\relax
2192 \vnumbline*[\@vticksep]{#2}{#4}%
2193 \fi\fi
2194 \ifnum #2<0\relax\ifnum #4>0\relax
2195 \numbline*[\@hticksep]{#1}{#3}%
2196 \fi\fi
2197 }%
2198 \def\coordsys@h{#1}%
2199 \def\coordsys@w{#2}%
2200 }
2201 % \end{macrocode}
2202 % \end{macro}
2203 % \end{macro}
2204 %
2205 % \begin{macro}{\gridstyle}
2206 % \begin{macro}{\grid@style}
2207 % The "\gridstyle" command defines "\grid@style" to issue a suitable
2208 % "\tickstyle" command at the proper time. The default
2209 % "\grid@style" is to do nothing---that is, use the current
2210 % "\tickstyle" unchanged.
2211 % \begin{macrocode}
2212 \newcommand{\gridstyle}[2]{\def\grid@style{\tickstyle{#1}{#2}}}
2213 \newcommand{\grid@style}{\relax}
2214 % \end{macrocode}
2215 % \end{macro}\end{macro}
2216 %
2217 % \begin{macro}{\coordgrid}
2218 % The "\coordgrid" command chooses between the starred version,
2219 % "\coordgrid@ii", with solid lines and the un-starred version,
2220 % "\coordgrid@i", with dotted lines.
2221 % \begin{macrocode}
2222 \newcommand{\coordgrid}{%
2223 \@ifstar{\def\coordsys@c{\coordgrid@ii}\coordsys@args@i}
2224 {\def\coordsys@c{\coordgrid@i}\coordsys@args@i}}
2225 % \end{macrocode}
2226 % \begin{macro}{\coordgrid@i}
2227 % The "\coordgrid@i" command calls "\coordgrid@calc" to calculate
2228 % the size, "\coordsys@w", of the box containing each dot of the dotted
2229 % lines based on the values of "\@hticksep" and "\@vticksep". Then
2230 % set the dotted lines with "\@set@ticks".
2231 % \begin{macrocode}
2232 \def\coordgrid@i#1#2(#3,#4){{\color@begingroup
2233 \coordgrid@calc
2234 \grid@style
2235 \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{\z@}{%
2236 \multiput(\coordsys@a,0)(\coordsys@c,0)\coordsys@b
2237 {\vgridfromto{#2}{#4}}}%
2238 \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{\z@}{%
2239 \multiput(0,\coordsys@a)(0,\coordsys@c)\coordsys@b
2240 {\hgridfromto{#1}{#3}}}%
2241 \color@endgroup}}
2242 % \end{macrocode}
2243 % \end{macro}
2244 % \begin{macro}{\coordgrid@ii}
2245 % The "\coordgrid@ii" command is similar to "\fcoordsys@i" above.
2246 % \begin{macrocode}
2247 \def\coordgrid@ii#1#2(#3,#4){{\color@begingroup
2248 \grid@style
2249 \@tempcnta=#3\relax
2250 \advance\@tempcnta -#1\relax
2251 \edef\coordsys@w{\the\@tempcnta}%
2252 \@tempcnta=#4\relax
2253 \advance\@tempcnta -#2\relax
2254 \edef\coordsys@h{\the\@tempcnta}%
2255 \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{\z@}{%
2256 \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b
2257 {\vgridlength{\coordsys@h}}}%
2258 \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{\z@}{%
2259 \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b
2260 {\hgridlength{\coordsys@w}}}%
2261 \color@endgroup}}
2262 % \end{macrocode}
2263 % \end{macro}\end{macro}
2264 %
2265 % \begin{macro}{\coordgrid@calc}
2266 % To typeset pretty grids of dots the number of dots between lines must be an
2267 % integer. Thus, the number of dots must be a factor of the greatest common
2268 % divisor of "\@vticksep" and "\@hticksep". The "\@EuclidGCD"
2269 % command returns the $\gcd$ in the counter "\@tempcnta"
2270 % \begin{macrocode}
2271 \newcommand{\coordgrid@calc}{%
2272 \@EuclidGCD{\@vticksep}{\@hticksep}%
2273 \@tempdima=\unitlength
2274 \multiply\@tempdima\@tempcnta
2275 % \end{macrocode}
2276 % Now "\@tempdima" is the longest length that fits an integer number of
2277 % times between lines. The dots should not be closer than 2\,pt.
2278 % \begin{macrocode}
2279 \@tempdimb=2\p@\relax
2280 \ifdim\@tempdima<\@tempdimb
2281 \PackageWarning{coordsys}{The tick marks are too
2282 close\MessageBreak for a pretty grid}%
2283 \else
2284 % \end{macrocode}
2285 % However, "\@tempdima" may be able to contain multiple dots.
2286 % \begin{macrocode}
2287 \divide\@tempdima \@tempdimb\relax
2288 \@tempdimb=\unitlength
2289 \multiply\@tempdimb\@tempcnta
2290 \divide\@tempdimb\@tempdima
2291 \fi
2292 % \end{macrocode}
2293 % In either case store the box size in "\coordsys@w".
2294 % \begin{macrocode}
2295 \edef\coordsys@w{\the\@tempdimb}%
2296 }
2297 % \end{macrocode}
2298 % \end{macro}
2299 %
2300 % \begin{macro}{\interval}
2301 % We use "\newcommand" to check that "\interval" is not already defined;
2302 % then we need plain \TeX's "\def" because "\interval" picks up its
2303 % arguments in a non-standard way.
2304 % \begin{macrocode}
2305 \newcommand{\interval}{}
2306 \def\interval#1#2,{%
2307 \def\coordsys@a{#1}%
2308 \def\coordsys@b{#2}%
2309 \def\coordsys@c{}%
2310 % \end{macrocode}
2311 % Now "\coordsys@a" is the \meta{L-delim} and "\coordsys@b" is whatever follows
2312 % up to the first comma, that is \meta{from}.
2313 % Then define "\coordsys@a" to be the correct symbol suitably aligned
2314 % in a box. Note that the characters in \LaTeX's circle font are placed
2315 % rather peculiarly inside their bounding box.
2316 % \begin{macrocode}
2317 \if\coordsys@a]\def\coordsys@a{(}\fi
2318 \if\coordsys@a[%
2319 \def\coordsys@a{%
2320 \makebox[0.5\width][l]{\@circlefnt\char'163}}%
2321 \else\if\coordsys@a(%
2322 \def\coordsys@a{%
2323 \makebox[0.5\width][l]{\@circlefnt\char'143}}%
2324 \else\if\coordsys@a<%
2325 \def\coordsys@a{%
2326 \raisebox{-\fontdimen22\textfont2}{%
2327 \makebox[\z@]{$<$}}}%
2328 \else
2329 \PackageError{coordsys}
2330 {Bad delimiter}
2331 {\string\interval\space expects [, (, <, or ] %
2332 but got \coordsys@a}%
2333 \def\coordsys@a{}%
2334 \fi\fi\fi
2335 % \end{macrocode}
2336 % Picking up the \meta{from} was easy because we know the
2337 % number ends at the comma. But we do not know where the \meta{to} number ends.
2338 % \TeX\ knows how to read an integer, so do that and proceed with "\interv@l"
2339 % which picks up either the right-hand delimiter or a decimal point as its
2340 % first argument.
2341 % \begin{macrocode}
2342 \afterassignment\interv@l\count@=}
2343 % \end{macrocode}
2344 % \end{macro}
2345 % \begin{macro}{\interv@l}
2346 % If we got a decimal point, store the integer part of the number in
2347 % "\coordsys@c" and try again.
2348 % \begin{macrocode}
2349 \newcommand{\interv@l}[1]{%
2350 \if#1.%
2351 \edef\coordsys@c{\the\count@.}%
2352 \def\next{\afterassignment\interv@l\count@=}%
2353 % \end{macrocode}
2354 % Otherwise, append the number we just read to "\coordsys@c".
2355 % Now "\coordsys@c" contains \meta{to}. So calculate the
2356 % length (in~pt) of the interval.
2357 % \begin{macrocode}
2358 \else
2359 \edef\coordsys@c{\coordsys@c\the\count@}%
2360 \setlength{\@tempdima}{\coordsys@b\unitlength}%
2361 \setlength{\@tempdima}{-\@tempdima}%
2362 \addtolength{\@tempdima}{\coordsys@c\unitlength}%
2363 % \end{macrocode}
2364 % Define "\coordsys@c" to be the correct symbol for the \meta{R-delim}.
2365 % \begin{macrocode}
2366 \def\coordsys@c{#1}%
2367 \if\coordsys@c[\def\coordsys@c{)}\fi
2368 \if\coordsys@c]%
2369 \def\coordsys@c{\mbox{%
2370 \@circlefnt
2371 \settowidth{\@tempdima}{\char'163}%
2372 \hskip 0.5\@tempdima
2373 \char'163%
2374 \hskip -\@tempdima}%
2375 }%
2376 \else\if\coordsys@c)%
2377 \def\coordsys@c{\mbox{%
2378 \@circlefnt
2379 \settowidth{\@tempdima}{\char'143}%
2380 \hskip 0.5\@tempdima
2381 \char'143%
2382 \hskip -\@tempdima}%
2383 }%
2384 \else\if\coordsys@c>%
2385 \def\coordsys@c{%
2386 \raisebox{-\fontdimen22\textfont2}{%
2387 \makebox[\z@]{$>$}}}%
2388 \else
2389 \PackageError{coordsys}
2390 {Bad delimiter}
2391 {\string\interval\space expects ], ), <, or [ %
2392 but got \coordsys@c}%
2393 \def\coordsys@c{}%
2394 \fi\fi\fi
2395 % \end{macrocode}
2396 % \begin{macro}{\coordsys@w}\begin{macro}{\coordsys@h}
2397 % Finally, "\put" the pieces down. Here "\coordsys@w" is the vertical
2398 % coordinate of the last typeset horizontal axis (usually~$0$),
2399 % and "\interval@line" is defined by "\intervalthickness" below.
2400 % \begin{macrocode}
2401 \put(\coordsys@b,\coordsys@w){\makebox[\@tempdima][s]{%
2402 \coordsys@a
2403 \interval@line
2404 \coordsys@c
2405 }}%
2406 \let\next=\ignorespaces
2407 \fi
2408 \next}
2409 % \end{macrocode}
2410 % \end{macro}\end{macro}\end{macro}
2411 %
2412 % \begin{macro}{\vinterval}
2413 % \begin{macro}{\vinterv@l}
2414 % The "\vinterval" and "\vinterv@l" commands work as their horizontal cousins.
2415 % \begin{macrocode}
2416 \newcommand{\vinterval}{}
2417 \def\vinterval#1#2,{%
2418 \def\coordsys@a{#1}%
2419 \def\coordsys@b{#2}%
2420 \def\coordsys@c{}%
2421 \if\coordsys@a]\def\coordsys@a{(}\fi
2422 \if\coordsys@a[%
2423 \def\coordsys@a{\hbox to\z@{%
2424 \@circlefnt
2425 \settowidth{\@tempdima}{\char'163}%
2426 \hskip 0.5\@tempdima minus 1fil
2427 \char'163%
2428 \hskip -0.5\@tempdima minus 1fil
2429 \vrule width \z@ depth \z@ height 0.5\@tempdima
2430 }}%
2431 \else\if\coordsys@a(%
2432 \def\coordsys@a{\hbox to\z@{%
2433 \@circlefnt
2434 \settowidth{\@tempdima}{\char'143}%
2435 \hskip 0.5\@tempdima minus 1fil
2436 \char'143%
2437 \hskip -0.5\@tempdima minus 1fil
2438 \vrule width \z@ depth \z@ height 0.5\@tempdima
2439 }}%
2440 \else\if\coordsys@a<%
2441 \def\coordsys@a{\hbox to\z@{\hss
2442 \raisebox{-\fontdimen22\textfont2}[\z@][\z@]{%
2443 $\vee$}\hss}}%
2444 \else
2445 \PackageError{coordsys}
2446 {Bad delimiter}
2447 {\string\vinterval\space expects [, (, <, or ] %
2448 but got \coordsys@a}%
2449 \def\coordsys@a{}%
2450 \fi\fi\fi
2451 \afterassignment\vinterv@l\count@=}
2452 \newcommand{\vinterv@l}[1]{%
2453 \if#1.%
2454 \edef\coordsys@c{\the\count@.}%
2455 \def\next{\afterassignment\interv@l\count@=}%
2456 \else
2457 \edef\coordsys@c{\coordsys@c\the\count@}%
2458 \setlength{\@tempdima}{\coordsys@b\unitlength}%
2459 \setlength{\@tempdima}{-\@tempdima}%
2460 \addtolength{\@tempdima}{\coordsys@c\unitlength}%
2461 \def\coordsys@c{#1}%
2462 \if\coordsys@c[\def\coordsys@c{)}\fi
2463 \if\coordsys@c]%
2464 \def\coordsys@c{\hbox to\z@{%
2465 \@circlefnt
2466 \settowidth{\@tempdima}{\char'163}%
2467 \hskip 0.5\@tempdima minus 1fil
2468 \char'163%
2469 \hskip -0.5\@tempdima minus 1fil
2470 \vrule width \z@ depth 0.5\@tempdima height \z@
2471 }}%
2472 \else\if\coordsys@c)%
2473 \def\coordsys@c{\hbox to\z@{%
2474 \@circlefnt
2475 \settowidth{\@tempdima}{\char'143}%
2476 \hskip 0.5\@tempdima minus 1fil
2477 \char'143%
2478 \hskip -0.5\@tempdima minus 1fil
2479 \vrule width \z@ depth 0.5\@tempdima height \z@
2480 }}%
2481 \else\if\coordsys@c>%
2482 \def\coordsys@c{\hbox to\z@{\hss%
2483 \raisebox{-\fontdimen22\textfont2}[\z@][\z@]{%
2484 $\wedge$}\hss}}%
2485 \else
2486 \PackageError{coordsys}
2487 {Bad delimiter}
2488 {\string\vinterval\space expects ], ), <, or [ %
2489 but got \coordsys@c}%
2490 \def\coordsys@c{}%
2491 \fi\fi\fi
2492 \put(\coordsys@h,\coordsys@b){\vbox{%
2493 \setlength{\baselineskip}{\z@}%
2494 \setlength{\lineskip}{\z@}%
2495 \settoheight{\@tempdimb}{\coordsys@a}%
2496 \addtolength{\@tempdima}{-\@tempdimb}%
2497 \settodepth {\@tempdimb}{\coordsys@c}%
2498 \addtolength{\@tempdima}{-\@tempdimb}%
2499 \coordsys@c
2500 \vinterval@line
2501 \coordsys@a
2502 }}%
2503 \let\next=\ignorespaces
2504 \fi
2505 \next}
2506 % \end{macrocode}
2507 % \end{macro}\end{macro}
2508 %
2509 % \begin{macro}{\intervalthickness}
2510 % \begin{macro}{interval@line}\begin{macro}{\vinterval@line}
2511 % The "\intervalthickness" command defines the two commands "\interval@line"
2512 % and "\vinterval@line" that draw the thick line indicating the interval.
2513 % \begin{macrocode}
2514 \newcommand{\intervalthickness}[2][\z@]{%
2515 \setlength{\@tempdima}{#2}%
2516 \setlength{\@tempdima}{0.5\@tempdima}%
2517 \setlength{\@tempdimb}{-\@tempdima}%
2518 \addtolength{\@tempdima}{#1}%
2519 \addtolength{\@tempdimb}{#1}%
2520 \edef\coordsys@a{\the\@tempdima}%
2521 \edef\coordsys@b{-\the\@tempdimb}%
2522 \edef\interval@line{%
2523 \leaders\hrule depth \coordsys@b height \coordsys@a\hss}%
2524 \setlength{\@tempdima}{#2}%
2525 \setlength{\@tempdima}{-0.5\@tempdima}%
2526 \addtolength{\@tempdima}{#1}%
2527 \edef\coordsys@a{\the\@tempdima}%
2528 \edef\vinterval@line{%
2529 \hbox to\z@{%
2530 \hskip \coordsys@a
2531 \vrule height\@tempdima width #2%
2532 \hss
2533 }%
2534 }%
2535 }
2536 % \end{macrocode}
2537 % \end{macro}\end{macro}\end{macro}
2538 %
2539 % Then a few defaults for "\interval" and "\vinterval".
2540 % \begin{macrocode}
2541 \intervalthickness{1.6\p@}
2542 \def\coordsys@w{0}
2543 \def\coordsys@h{0}
2544 %</coordsys>
2545 % \end{macrocode}
2546 %
2547 % \iffalse Don't document this fragment of code.
2548 % \begin{macrocode}
2549 %<*euclid>
2550 \NeedsTeXFormat{LaTeX2e}
2551 \ProvidesPackage{euclidgcd}[2006/02/03 version 1.4]
2552 \newcommand{\EuclidGCD}[2]{%
2553 \@EuclidGCD{#1}{#2}%
2554 \the\@tempcnta}
2555 %</euclid>
2556 % \end{macrocode}
2557 % \fi
2558 %
2559 % \begin{macro}{\@EuclidGCD}
2560 % The "\@EuclidGCD" command calculates the greatest common divisor
2561 % of two positive integers using Euclid's algorithm.\footnote{Euclid's
2562 % algorithm uses the fact that $\gcd(n, d) = \gcd(d, r)$, where $r$ is
2563 % the remainder after dividing $n$ by $d$. Since $r<d$, the second
2564 % $\gcd$ is easier to find. Repeat.}
2565 % After calling "\@EuclidGCD", the counter "\@tempcnta" contains the
2566 % $\gcd$.
2567 % \begin{macrocode}
2568 %<*coordsys|euclid>
2569 \newcommand{\@EuclidGCD}[2]{%
2570 \@tempcnta=#1\relax
2571 \@tempcntb=#2\relax
2572 \loop
2573 \count@=\@tempcntb
2574 \divide\count@\@tempcnta
2575 \multiply\count@\@tempcnta
2576 \advance\count@ -\@tempcntb
2577 % \end{macrocode}
2578 % Now "\count@" is $-r$, where $r$ is the remainder after dividing
2579 % "\@tempcntb" by "\@tempcnta".
2580 % \begin{macrocode}
2581 \ifnum\count@<0\relax
2582 \@tempcntb=\@tempcnta
2583 \@tempcnta=-\count@
2584 \repeat
2585 }
2586 %</coordsys|euclid>
2587 % \end{macrocode}
2588 % \end{macro}
2589 %
2590 %
2591 % \subsection{The \textsf{logsys} Package}
2592 % \subsubsection{Identification}
2593 % First we must declare ourselves.
2594 % \begin{macrocode}
2595 %<*logsys>
2596 \NeedsTeXFormat{LaTeX2e}
2597 \ProvidesPackage{logsys}[2006/02/03 version 1.4]
2598 % \end{macrocode}
2599 %
2600 % \subsubsection{Options}
2601 % Pass all options to \textsf{coordsys}.
2602 % \begin{macrocode}
2603 \DeclareOption{centred}{\PassOptionsToPackage{centred}{coordsys}}
2604 \DeclareOption{outside}{\PassOptionsToPackage{outside}{coordsys}}
2605 \DeclareOption{inside}{\PassOptionsToPackage{inside}{coordsys}}
2606 \ProcessOptions
2607 % \end{macrocode}
2608 %
2609 % \subsubsection{Package Loading}
2610 % The \textsf{logsys} package extends the \textsf{coordsys} package.
2611 % \begin{macrocode}
2612 \RequirePackage{coordsys}[2006/02/03]
2613 % \end{macrocode}
2614 %
2615 % \subsubsection{Main Code}
2616 % \begin{macro}{\loglabel}
2617 % The "\loglabel" command typesets logarithmic labels.
2618 % \begin{macrocode}
2619 \newcommand{\loglabel}[1]{%
2620 \ifnum #1=-2\relax \frac{1}{100}%
2621 \else\ifnum #1=-1\relax \frac{1}{10}%
2622 \else\ifnum #1= 0\relax 1%
2623 \else\ifnum #1= 1\relax 10%
2624 \else\ifnum #1= 2\relax 100%
2625 \else 10^{#1}%
2626 \fi\fi\fi\fi\fi}
2627 % \end{macrocode}
2628 % \end{macro}
2629 %
2630 % \begin{macro}{\v@logbox}
2631 % \begin{macro}{\h@logbox}
2632 % The "\v@logbox" and "\h@logbox" commands each typeset one block
2633 % of logarithmic tick marks. Each take two arguments: the size of a block and
2634 % the tick mark to typeset.
2635 % The glue in the boxes is (10000 times) $\log10-\log9$, $\log9-\log8$,
2636 % $\log8-\log7$, \dots, and $\log2-\log1$.
2637 % \begin{macrocode}
2638 \newcommand{\v@logbox}[2]{%
2639 \vbox to #1\unitlength{%
2640 \offinterlineskip
2641 \vskip \z@ plus 458fil\relax
2642 \vbox to \z@{\vss\hbox{#2}\vss}% 9
2643 \vskip \z@ plus 512fil\relax
2644 \vbox to \z@{\vss\hbox{#2}\vss}% 8
2645 \vskip \z@ plus 580fil\relax
2646 \vbox to \z@{\vss\hbox{#2}\vss}% 7
2647 \vskip \z@ plus 669fil\relax
2648 \vbox to \z@{\vss\hbox{#2}\vss}% 6
2649 \vskip \z@ plus 792fil\relax
2650 \vbox to \z@{\vss\hbox{#2}\vss}% 5
2651 \vskip \z@ plus 969fil\relax
2652 \vbox to \z@{\vss\hbox{#2}\vss}% 4
2653 \vskip \z@ plus 1249fil\relax
2654 \vbox to \z@{\vss\hbox{#2}\vss}% 3
2655 \vskip \z@ plus 1761fil\relax
2656 \vbox to \z@{\vss\hbox{#2}\vss}% 2
2657 \vskip \z@ plus 3010fil\relax
2658 }}
2659 \newcommand{\h@logbox}[2]{%
2660 \hbox to #1\unitlength{%
2661 \hskip \z@ plus 3010fill\relax
2662 \hbox to \z@{\hss #2\hss}% 2
2663 \hskip \z@ plus 1761fill\relax
2664 \hbox to \z@{\hss #2\hss}% 3
2665 \hskip \z@ plus 1249fill\relax
2666 \hbox to \z@{\hss #2\hss}% 4
2667 \hskip \z@ plus 969fill\relax
2668 \hbox to \z@{\hss #2\hss}% 5
2669 \hskip \z@ plus 792fill\relax
2670 \hbox to \z@{\hss #2\hss}% 6
2671 \hskip \z@ plus 669fill\relax
2672 \hbox to \z@{\hss #2\hss}% 7
2673 \hskip \z@ plus 580fill\relax
2674 \hbox to \z@{\hss #2\hss}% 8
2675 \hskip \z@ plus 512fill\relax
2676 \hbox to \z@{\hss #2\hss}% 9
2677 \hskip \z@ plus 458fill\relax
2678 }}
2679 % \end{macrocode}
2680 % \end{macro}\end{macro}
2681 %
2682 % \begin{macro}{\@sethlogticks}
2683 % In the linear case we got away with using one command, "\@set@ticks",
2684 % to calculate the positions of the tick marks on both horizontal and vertical
2685 % axes. The logarithmic case is more complicated, so we create separate
2686 % command for the horizontal and vertical case. This split then allows the
2687 % logarithmic commands to do more than just calculate the positions of the
2688 % ticks:
2689 % \begin{quote}
2690 % "\@sethlogticks"\marg{spacing}\marg{from}\marg{to}^^A
2691 % \marg{y0}\marg{tick}
2692 % \end{quote}
2693 % \emph{typesets} the logarithmic tick marks on a horizontal axis at
2694 % $y$-coordinate \meta{y0}. Moreover, it typesets the labels.
2695 %
2696 % The calculation is much like the calculation for thin tick marks in the
2697 % linear case; compare with code
2698 % lines~\ref{cl:BeginTickCalc}--\ref{cl:EndTickCalc}.
2699 % \begin{macrocode}
2700 \newcommand{\@sethlogticks}[5]{%
2701 \thin@ticks
2702 \@tempcnta=#2\relax
2703 \ifnum\@tempcnta>0\advance\@tempcnta -1\relax\fi
2704 \divide\@tempcnta #1\relax
2705 \ifnum #2>0\advance\@tempcnta 1\relax\fi
2706 \multiply\@tempcnta #1\relax
2707 \edef\coordsys@a{\the\@tempcnta}%
2708 \@tempcntb=#3\relax
2709 \ifnum\@tempcnta<\@tempcntb\relax
2710 \advance\@tempcntb -\@tempcnta\relax
2711 \divide\@tempcntb #1\relax
2712 \edef\coordsys@b{\the\@tempcntb}%
2713 \multiput(\coordsys@a,#4)(#1,0)\coordsys@b
2714 {\h@logbox{#1}{#5}}%
2715 % \end{macrocode}
2716 % In the linear case we took some measure against colliding tick marks and
2717 % arrow heads; in
2718 % the logarithmic case we leave that worry to the user\footnote{Because
2719 % calculating the position of individual logarithmic tick mark is difficult;
2720 % this code works by setting blocks of tick marks.}. Therefore we can (and
2721 % should) set one more thick tick mark than we have blocks.
2722 % \begin{macrocode}
2723 \thick@ticks
2724 \@tempcntb=\coordsys@b\relax
2725 \advance\@tempcntb 1\relax
2726 \edef\coordsys@b{\the\@tempcntb}%
2727 \multiput(\coordsys@a,#4)(#1,0)\coordsys@b
2728 {#5}%
2729 % \end{macrocode}
2730 % Then set the labels: First set the counter "@coord" to\footnote{The
2731 % calculation uses a horrible mixture of \LaTeX\ syntax and plain \TeX\ since
2732 % \LaTeX\ does not provide a division command. Maybe I should avoid the
2733 % \LaTeX\ style counter and just use plain \TeX. See the note to code
2734 % line~\ref{cl:@coord}.}
2735 % $\frac{\meta{from}}{\meta{spacing}}$, then step that counter by one.
2736 % \begin{macrocode}
2737 \if@numbline
2738 \setcounter{@coord}{\coordsys@a}%
2739 \divide\c@@coord #1\relax
2740 \multiput(\coordsys@a,#4)(#1,0)\coordsys@b{%
2741 \sethlabel{\loglabel{\arabic{@coord}}}%
2742 \stepcounter{@coord}}%
2743 \fi
2744 \fi
2745 }
2746 % \end{macrocode}
2747 % \end{macro}
2748 % \begin{macro}{\@setvlogticks}
2749 % The vertical version works in much the same way.
2750 % \begin{macrocode}
2751 \newcommand{\@setvlogticks}[5]{%
2752 \thin@ticks
2753 \@tempcnta=#2\relax
2754 \ifnum\@tempcnta>0\advance\@tempcnta -1\relax\fi
2755 \divide\@tempcnta #1\relax
2756 \ifnum #2>0\advance\@tempcnta 1\relax\fi
2757 \multiply\@tempcnta #1\relax
2758 \edef\coordsys@a{\the\@tempcnta}%
2759 \@tempcntb=#3\relax
2760 \ifnum\@tempcnta<\@tempcntb\relax
2761 \advance\@tempcntb -\@tempcnta\relax
2762 \divide\@tempcntb #1\relax
2763 \edef\coordsys@b{\the\@tempcntb}%
2764 \multiput(#4,\coordsys@a)(0,#1)\coordsys@b
2765 {\v@logbox{#1}{#5}}%
2766 \thick@ticks
2767 \@tempcntb=\coordsys@b\relax
2768 \advance\@tempcntb 1\relax
2769 \edef\coordsys@b{\the\@tempcntb}%
2770 \multiput(#4,\coordsys@a)(0,#1)\coordsys@b
2771 {#5}%
2772 \if@numbline
2773 \setcounter{@coord}{\coordsys@a}%
2774 \divide\c@@coord #1\relax
2775 \multiput(#4,\coordsys@a)(0,#1)\coordsys@b{%
2776 \setvlabel{\loglabel{\arabic{@coord}}}%
2777 \stepcounter{@coord}}%
2778 \fi
2779 \fi
2780 }
2781 % \end{macrocode}
2782 % \end{macro}
2783 %
2784 % \begin{macro}{\logline}
2785 % The "\logline" command checks for a star,
2786 % \begin{macrocode}
2787 \newcommand{\logline}{%
2788 \@ifstar{\@numblinefalse\hlogline@i}
2789 {\@numblinetrue \hlogline@i}}
2790 % \end{macrocode}
2791 % \begin{macro}{\hlogline@i}
2792 % then "\hlogline@i" picks up the optional argument,
2793 % \begin{macrocode}
2794 \newcommand{\hlogline@i}[1][50]{\leavevmode\hlogline@ii{#1}}
2795 % \end{macrocode}
2796 % \begin{macro}{\hlogline@ii}
2797 % and "\hlogline@ii" does the work---which isn't much since
2798 % "\@sethlogticks" does almost everything.
2799 % \begin{macrocode}
2800 \newcommand{\hlogline@ii}[3]{{\color@begingroup
2801 \thinlines
2802 \@tempcnta=#3\relax
2803 \advance\@tempcnta -#2\relax
2804 \edef\coordsys@w{\the\@tempcnta}%
2805 \put(#2,0){\vector(1,0){\coordsys@w}}%
2806 \@sethlogticks{#1}{#2}{#3}{0}{\vtickmark}
2807 \color@endgroup}%
2808 \def\coordsys@w{0}%
2809 }
2810 % \end{macrocode}
2811 % \end{macro}\end{macro}\end{macro}
2812 %
2813 % \begin{macro}{\vlogline}
2814 % \begin{macro}{\vlogline@i}
2815 % \begin{macro}{\vlogline@ii}
2816 % The "\vlogline" command and friends work in much the same way.
2817 % \begin{macrocode}
2818 \newcommand{\vlogline}{%
2819 \@ifstar{\@numblinefalse\vlogline@i}
2820 {\@numblinetrue \vlogline@i}}
2821 \newcommand{\vlogline@i}[1][50]{\leavevmode\vlogline@ii{#1}}
2822 \newcommand{\vlogline@ii}[3]{{\color@begingroup
2823 \thinlines
2824 \@tempcnta=#3\relax
2825 \advance\@tempcnta -#2\relax
2826 \edef\coordsys@h{\the\@tempcnta}%
2827 \put(0,#2){\vector(0,1){\coordsys@h}}%
2828 \@setvlogticks{#1}{#2}{#3}{0}{\htickmark}
2829 \color@endgroup}%
2830 \def\coordsys@h{0}%
2831 }
2832 % \end{macrocode}
2833 % \end{macro}\end{macro}\end{macro}
2834 %
2835 % \begin{macro}{\logsys}
2836 % The logarithmic coordinate system commands have different default values for
2837 % the optional arguments than their linear cousins. We therefore need a new
2838 % approach for picking up optional arguments.
2839 %
2840 % The "\logsys" command defines "\coordsys@c" to be the command that
2841 % eventually sets the coordinate system. Then "\logsys" define
2842 % "\@hticksep" and "\@vticksep" to be the default values for the
2843 % optional arguments. (Each logarithmic coordinate system type has a different
2844 % set of default values.) Then "\logsys" checks for a star and calls
2845 % "\logsys@args@i".
2846 % \begin{macrocode}
2847 \newcommand{\logsys}{%
2848 \def\coordsys@c{\logsys@i}%
2849 \def\@hticksep{10}%
2850 \def\@vticksep{50}%
2851 \@ifstar{\@numblinefalse\logsys@args@i}
2852 {\@numblinetrue \logsys@args@i}}
2853 % \end{macrocode}
2854 % \begin{macro}{\logsys@args@i}
2855 % The "\logsys@args@i" command picks up the first optional argument
2856 % storing it in "\@hticksep" for later processing.
2857 % \begin{macrocode}
2858 \newcommand{\logsys@args@i}[1][\@hticksep]{\leavevmode
2859 \edef\@hticksep{#1}%
2860 \logsys@args@ii}
2861 % \end{macrocode}
2862 % \end{macro}
2863 % \begin{macro}{\logsys@args@ii}
2864 % Then "\logsys@args@ii" picks up the second optional argument and calls
2865 % the good old "\coordsys@args@iii" command to pick up (some of) the
2866 % remaining arguments.
2867 % \begin{macrocode}
2868 \newcommand{\logsys@args@ii}[1][\@vticksep]{%
2869 \edef\@vticksep{#1}%
2870 \coordsys@args@iii}
2871 % \end{macrocode}
2872 % \end{macro}
2873 % \begin{macro}{\logsys@i}
2874 % Finally "\logsys@i" sets the coordinate system:
2875 % First calculate the width and height of the system, then set the axes
2876 % and the tick marks and labels on the linear (horizontal) axis---all of it
2877 % much like "\fcoordsys@i" above.
2878 % \begin{macrocode}
2879 \def\logsys@i#1#2(#3,#4){{\color@begingroup
2880 \thinlines
2881 \@tempcnta=#3\relax
2882 \advance\@tempcnta -#1\relax
2883 \edef\coordsys@w{\the\@tempcnta}%
2884 \put(#1,#2){\vector(1,0){\coordsys@w}}%
2885 \@tempcnta=#4\relax
2886 \advance\@tempcnta -#2\relax
2887 \edef\coordsys@h{\the\@tempcnta}%
2888 \put(#1,#2){\vector(0,1){\coordsys@h}}%
2889 \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{6\p@}{%
2890 \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b\vtickmark}%
2891 \if@numbline
2892 \setcounter{@coord}{\coordsys@a}%
2893 \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b{%
2894 \edef\coordsys@a{\arabic{@coord}}%
2895 \sethlabel{\hlabel{\coordsys@a}}%
2896 \addtocounter{@coord}{\coordsys@c}}%
2897 \fi
2898 % \end{macrocode}
2899 % Finally call "\@setvlogticks" to set the tick marks and labels on the
2900 % logarithmic (vertical) axis.
2901 % \begin{macrocode}
2902 \@setvlogticks{\@vticksep}{#2}{#4}{#1}{\htickmark}%
2903 \color@endgroup}%
2904 \def\coordsys@h{#1}%
2905 \def\coordsys@w{#2}%
2906 }
2907 % \end{macrocode}
2908 % \end{macro}\end{macro}
2909 %
2910 % \begin{macro}{\semilogsys}
2911 % \begin{macro}{\semilogsys@i}
2912 % The "\semilogsys" and "\semilogsys@i" commands work in much the
2913 % same manner.
2914 % \begin{macrocode}
2915 \newcommand{\semilogsys}{%
2916 \def\coordsys@c{\semilogsys@i}%
2917 \def\@hticksep{50}%
2918 \def\@vticksep{10}%
2919 \@ifstar{\@numblinefalse\logsys@args@i}
2920 {\@numblinetrue \logsys@args@i}}
2921 \def\semilogsys@i#1#2(#3,#4){{\color@begingroup
2922 \thinlines
2923 \@tempcnta=#3\relax
2924 \advance\@tempcnta -#1\relax
2925 \edef\coordsys@w{\the\@tempcnta}%
2926 \put(#1,#2){\vector(1,0){\coordsys@w}}%
2927 \@tempcnta=#4\relax
2928 \advance\@tempcnta -#2\relax
2929 \edef\coordsys@h{\the\@tempcnta}%
2930 \put(#1,#2){\vector(0,1){\coordsys@h}}%
2931 \@sethlogticks{\@hticksep}{#1}{#3}{#2}{\vtickmark}%
2932 \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{6\p@}{%
2933 \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b\htickmark}%
2934 \if@numbline
2935 \setcounter{@coord}{\coordsys@a}%
2936 \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b{%
2937 \edef\coordsys@a{\arabic{@coord}}%
2938 \setvlabel{\vlabel{\coordsys@a}}%
2939 \addtocounter{@coord}{\coordsys@c}}%
2940 \fi
2941 \color@endgroup}%
2942 \def\coordsys@h{#1}%
2943 \def\coordsys@w{#2}%
2944 }
2945 % \end{macrocode}
2946 % \end{macro}\end{macro}
2947 %
2948 % \begin{macro}{\loglogsys}
2949 % \begin{macro}{\loglogsys@i}
2950 % The "\loglogsys" and "\loglogsys@i" commands work in much the
2951 % same manner.
2952 % \begin{macrocode}
2953 \newcommand{\loglogsys}{%
2954 \def\coordsys@c{\loglogsys@i}%
2955 \def\@hticksep{50}%
2956 \def\@vticksep{50}%
2957 \@ifstar{\@numblinefalse\logsys@args@i}
2958 {\@numblinetrue \logsys@args@i}}
2959 \def\loglogsys@i#1#2(#3,#4){{\color@begingroup
2960 \thinlines
2961 \@tempcnta=#3\relax
2962 \advance\@tempcnta -#1\relax
2963 \edef\coordsys@w{\the\@tempcnta}%
2964 \put(#1,#2){\vector(1,0){\coordsys@w}}%
2965 \@tempcnta=#4\relax
2966 \advance\@tempcnta -#2\relax
2967 \edef\coordsys@h{\the\@tempcnta}%
2968 \put(#1,#2){\vector(0,1){\coordsys@h}}%
2969 \@sethlogticks{\@hticksep}{#1}{#3}{#2}{\vtickmark}%
2970 \@setvlogticks{\@vticksep}{#2}{#4}{#1}{\htickmark}%
2971 \color@endgroup}%
2972 \def\coordsys@h{#1}%
2973 \def\coordsys@w{#2}%
2974 }
2975 % \end{macrocode}
2976 % \end{macro}\end{macro}
2977 %
2978 % \begin{macro}{\loggrid}
2979 % The "\loggrid" command is the obvious cross between "\logsys" and
2980 % "\coordgrid".
2981 % \begin{macrocode}
2982 \newcommand{\loggrid}{%
2983 \def\@hticksep{10}%
2984 \def\@vticksep{50}%
2985 \@numblinefalse
2986 \@ifstar{\def\coordsys@c{\loggrid@ii}\logsys@args@i}
2987 {\def\coordsys@c{\loggrid@i}\logsys@args@i}}
2988 % \end{macrocode}
2989 % \begin{macro}{\loggrid@i}
2990 % Similarly, "\loggrid@i" is a cross between "\logsys@i" and
2991 % "\coordgrid@i",
2992 % \begin{macrocode}
2993 \def\loggrid@i#1#2(#3,#4){{\color@begingroup
2994 \coordgrid@calc
2995 \grid@style
2996 \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{\z@}{%
2997 \multiput(\coordsys@a,0)(\coordsys@c,0)\coordsys@b
2998 {\vgridfromto{#2}{#4}}}%
2999 \@setvlogticks{\@vticksep}{#2}{#4}{0}{\hgridfromto{#1}{#3}}%
3000 \color@endgroup}}
3001 % \end{macrocode}
3002 % \end{macro}
3003 % \begin{macro}{\loggrid@ii}
3004 % and "\loggrid@ii" is a cross between "\logsys@i" and
3005 % "\coordgrid@ii".
3006 % \begin{macrocode}
3007 \def\loggrid@ii#1#2(#3,#4){{\color@begingroup
3008 \grid@style
3009 \@tempcnta=#3\relax
3010 \advance\@tempcnta -#1\relax
3011 \edef\coordsys@w{\the\@tempcnta}%
3012 \@tempcnta=#4\relax
3013 \advance\@tempcnta -#2\relax
3014 \edef\coordsys@h{\the\@tempcnta}%
3015 \@set@ticks{\hthickratio}{\@hticksep}{#1}{#3}{\z@}{%
3016 \multiput(\coordsys@a,#2)(\coordsys@c,0)\coordsys@b
3017 {\vgridlength{\coordsys@h}}}%
3018 \@setvlogticks{\@vticksep}{#2}{#4}{#1}{\hgridlength{\coordsys@w}}%
3019 \color@endgroup}}
3020 % \end{macrocode}
3021 % \end{macro}\end{macro}
3022 %
3023 % \begin{macro}{\semiloggrid}
3024 % \begin{macro}{\semiloggrid@i}
3025 % \begin{macro}{\semiloggrid@ii}
3026 % Semi-logarithmic grids provide no surprises,
3027 % \begin{macrocode}
3028 \newcommand{\semiloggrid}{%
3029 \def\@hticksep{50}%
3030 \def\@vticksep{10}%
3031 \@numblinefalse
3032 \@ifstar{\def\coordsys@c{\semiloggrid@ii}\logsys@args@i}
3033 {\def\coordsys@c{\semiloggrid@i}\logsys@args@i}}
3034 \def\semiloggrid@i#1#2(#3,#4){{\color@begingroup
3035 \coordgrid@calc
3036 \grid@style
3037 \@sethlogticks{\@hticksep}{#1}{#3}{0}{\vgridfromto{#2}{#4}}%
3038 \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{\z@}{%
3039 \multiput(0,\coordsys@a)(0,\coordsys@c)\coordsys@b
3040 {\hgridfromto{#1}{#3}}}%
3041 \color@endgroup}}
3042 \def\semiloggrid@ii#1#2(#3,#4){{\color@begingroup
3043 \grid@style
3044 \@tempcnta=#3\relax
3045 \advance\@tempcnta -#1\relax
3046 \edef\coordsys@w{\the\@tempcnta}%
3047 \@tempcnta=#4\relax
3048 \advance\@tempcnta -#2\relax
3049 \edef\coordsys@h{\the\@tempcnta}%
3050 \@sethlogticks{\@hticksep}{#1}{#3}{#2}{\vgridlength{\coordsys@h}}%
3051 \@set@ticks{\vthickratio}{\@vticksep}{#2}{#4}{\z@}{%
3052 \multiput(#1,\coordsys@a)(0,\coordsys@c)\coordsys@b
3053 {\hgridlength{\coordsys@w}}}%
3054 \color@endgroup}}
3055 % \end{macrocode}
3056 % \end{macro}\end{macro}\end{macro}
3057 % \begin{macro}{\logloggrid}
3058 % \begin{macro}{\logloggrid@i}
3059 % \begin{macro}{\logloggrid@ii}
3060 % and nor do double-logarithmic grids.
3061 % \begin{macrocode}
3062 \newcommand{\logloggrid}{%
3063 \def\@hticksep{50}%
3064 \def\@vticksep{50}%
3065 \@numblinefalse
3066 \@ifstar{\def\coordsys@c{\logloggrid@ii}\logsys@args@i}
3067 {\def\coordsys@c{\logloggrid@i}\logsys@args@i}}
3068 \def\logloggrid@i#1#2(#3,#4){{\color@begingroup
3069 \coordgrid@calc
3070 \grid@style
3071 \@sethlogticks{\@hticksep}{#1}{#3}{0}{\vgridfromto{#2}{#4}}%
3072 \@setvlogticks{\@vticksep}{#2}{#4}{0}{\hgridfromto{#1}{#3}}%
3073 \color@endgroup}}
3074 \def\logloggrid@ii#1#2(#3,#4){{\color@begingroup
3075 \grid@style
3076 \@tempcnta=#3\relax
3077 \advance\@tempcnta -#1\relax
3078 \edef\coordsys@w{\the\@tempcnta}%
3079 \@tempcnta=#4\relax
3080 \advance\@tempcnta -#2\relax
3081 \edef\coordsys@h{\the\@tempcnta}%
3082 \@sethlogticks{\@hticksep}{#1}{#3}{#2}{\vgridlength{\coordsys@h}}%
3083 \@setvlogticks{\@vticksep}{#2}{#4}{#1}{\hgridlength{\coordsys@w}}%
3084 \color@endgroup}}
3085 %</logsys>
3086 % \end{macrocode}
3087 % \end{macro}\end{macro}\end{macro}
3088 %
3089 %
3090 % \subsection{The \texttt{putfile} Maple Code}
3091 % \begin{macrocode}
3092 %<*putfile>
3093 putfile := proc(fn::{string, list(string), set(string)},
3094 P::specfunc(anything, PLOT) )
3095 option `Copyright 2000-06 by Mogens Lemvig Hansen`;
3096 description "version 1.1";
3097 local L, fns, i, V, scl, FH, ttl, pt, path, ext;
3098 global StringTools;
3099 % \end{macrocode}
3100 % Process the options.
3101 % \begin{macrocode}
3102 L := [args[3..-1]];
3103 if hasoption(L, 'scale', scl, 'L') then
3104 scl := evalf(scl);
3105 if not type(scl, ['numeric', 'numeric']) then
3106 error "the scale option must be [numeric, numeric] but got %1",
3107 scl;
3108 fi;
3109 else
3110 scl := [1,1];
3111 fi;
3112 if L <> [] then
3113 error "unknown options: %1", L;
3114 fi;
3115 % \end{macrocode}
3116 % Pull the "CURVES" from the "PLOT" structure.
3117 % \begin{macrocode}
3118 L := map( `putfile/grabcurves`, [op(P)] );
3119 % \end{macrocode}
3120 % If a single filename is given, we can construct a suitable list of filenames:
3121 % The path ends with the last backslash, slash, or colon in "fn";
3122 % the extension begins with the last period after that.
3123 % \begin{macrocode}
3124 if type(fn, 'string') then
3125 path := map(StringTools:-FirstFromRight, ["\\", "/", ":"], fn);
3126 path := max(op(path));
3127 ext := StringTools:-FirstFromRight(".", fn[path+1..-1]);
3128 % \end{macrocode}
3129 % If there is not extension, prepare to append
3130 % ".tex";\footnote{The extension \texttt{.tex} for these data files
3131 % may not be logical, but it is what \TeX\ assumes in the
3132 % \texttt{\bslash putfile} command, so at least we have consistent
3133 % assumptions.}
3134 % otherwise save and strip the extension.
3135 % \begin{macrocode}
3136 if ext = 0 then
3137 ext := ".tex";
3138 fns := fn;
3139 else
3140 ext := fn[path+ext..-1];
3141 fns := fn[1..-length(ext)-1]
3142 fi;
3143 % \end{macrocode}
3144 % Multiply the filename if necessary, and append the extension.
3145 % \begin{macrocode}
3146 if nops(L) = 1 then
3147 fns := [fns];
3148 else
3149 fns := [ seq(cat(fns, i), i=1..nops(L)) ];
3150 fi;
3151 fns := map(cat, fns, ext);
3152 % \end{macrocode}
3153 % If we have a set or list or filenames, their number must match the number of
3154 % "CURVES".
3155 % \begin{macrocode}
3156 else
3157 fns := fn;
3158 if nops(fns) <> nops(L) then
3159 error "the number of filenames must match "
3160 "the number of curves, "
3161 "received %1 names but %2 curves.",
3162 nops(fns), nops(L);
3163 fi;
3164 fi;
3165 % \end{macrocode}
3166 % Extract the view-port from the "PLOT" structure.
3167 % \begin{macrocode}
3168 V := select(type, [op(P)], 'specfunc'('anything', 'VIEW'));
3169 if nops(V) <> 1 then
3170 V := ['DEFAULT', 'DEFAULT'];
3171 else
3172 V := [ op([1,1], V), op([1,2], V) ];
3173 fi;
3174 V := subs('DEFAULT'=Float(-infinity)..Float(infinity), V);
3175 % \end{macrocode}
3176 % Finally, extract the title, if any.
3177 % The title will be included as a comment.
3178 % Since the title could be a multi-line string, we must insert "%" characters
3179 % after any new-lines.
3180 % \begin{macrocode}
3181 ttl := select(type, [op(P)], 'specfunc'('anything', 'TITLE'));
3182 if nops(ttl) = 1 then
3183 ttl := op([1,1], ttl);
3184 ttl := StringTools:-SubstituteAll(ttl, "\n", "\n%% ");
3185 fi;
3186 % \end{macrocode}
3187 % Fit the curves to the view-port, and scale as requested.
3188 % \begin{macrocode}
3189 L := map( `putfile/cleancurve`, L, V);
3190 L := map2( map, u->[scl[1]*u[1], scl[2]*u[2]], L );
3191 % \end{macrocode}
3192 % For each curve, write the title (if any), the view-port, and all the points to
3193 % the file.
3194 % \begin{macrocode}
3195 for i from 1 to nops(L) do try
3196 FH := fopen(fns[i], 'WRITE', 'TEXT');
3197 if type(ttl, 'string') then fprintf(FH, "%%%% %s\n", ttl) fi;
3198 if scl <> [1,1] then fprintf(FH, "%% scaled %a\n", scl) fi;
3199 V := [ map2(op, 1, L[i]), map2(op, 2, L[i]) ];
3200 V := map( u-> min(op(u))..max(op(u)), V );
3201 fprintf(FH, "%% horizontal range: %f .. %f\n", op(V[1]));
3202 fprintf(FH, "%% vertical range: %f .. %f\n", op(V[2]));
3203 for pt in L[i] do
3204 fprintf(FH, "%f \t%f\n", op(pt));
3205 od;
3206 finally fclose(FH);
3207 end try end do;
3208 end;
3209 % \end{macrocode}
3210 %
3211 % The sub-routines that follow use Maple's naming convention for such.
3212 %
3213 % We are interested in "CURVES" objects in a "PLOT" structure.
3214 % A "CURVES" object contains options (which we ignore) and lists of
3215 % \meta{curve}s, where a \meta{curve} is a list of \meta{point}s and a
3216 % \meta{point} is a list of length two usually containing two numeric values.
3217 % If "x" is not a "CURVES", return nothing. If "x" is a
3218 % "CURVES", extract the list of \meta{curve}s and return the
3219 % corresponding sequence of \meta{curve}s. If the "PLOT" structure
3220 % contains more than one "CURVES" object, the sequences returned by
3221 % "putfile/grabcurves" will flatten to one sequence of \meta{curve}s
3222 % \begin{macrocode}
3223 `putfile/grabcurves` := proc(x)
3224 option `Copyright 2000-06 by Mogens Lemvig Hansen`;
3225 description "version 1.1";
3226 local L;
3227 if op(0, x) = 'CURVES' then
3228 L := [ op(x) ];
3229 L := select(type, L, 'list');
3230 RETURN(op(L));
3231 else
3232 RETURN(NULL);
3233 fi;
3234 end;
3235 % \end{macrocode}
3236 % Each curve has to be fitted inside the view-port.
3237 % The curve, "CC", is a list of points.
3238 % The view-port, "V", is a list of the form
3239 % \texttt{[numeric..numeric, numeric..numeric]}.
3240 % \begin{macrocode}
3241 `putfile/cleancurve` := proc(CC::list, V::list)
3242 local C, B, pts, pt, m, i;
3243 option `Copyright 2004-06 by Mogens Lemvig Hansen`;
3244 description "version 1.1";
3245 % \end{macrocode}
3246 % Remove any non-numeric points.
3247 % \begin{macrocode}
3248 C := select(type, CC, ['numeric', 'numeric']);
3249 if nops(C) < 1 then error "no numeric points in %1", C fi;
3250 % \end{macrocode}
3251 % Then build a new list of point: each time a consecutive pair of points in
3252 % "C" straddles a boundary of the view-port, add the point of intersection
3253 % between the line through the two points and the view-port.
3254 % \begin{macrocode}
3255 B := C[1];
3256 for i from 2 to nops(C) do
3257 if C[i] = C[i-1] then next fi;
3258 pts := NULL;
3259 if ( C[i-1][1] < lhs(V[1]) and C[i][1] > lhs(V[1]) )
3260 or ( C[i-1][1] > lhs(V[1]) and C[i][1] < lhs(V[1]) ) then
3261 m := ( C[i-1][2] - C[i][2] ) / ( C[i-1][1] - C[i][1] );
3262 pt := lhs(V[1]);
3263 pt := [ pt, m*(pt-C[i][1]) + C[i][2] ];
3264 pts := pts, pt;
3265 fi;
3266 if ( C[i-1][1] < rhs(V[1]) and C[i][1] > rhs(V[1]) )
3267 or ( C[i-1][1] > rhs(V[1]) and C[i][1] < rhs(V[1]) ) then
3268 m := ( C[i-1][2] - C[i][2] ) / ( C[i-1][1] - C[i][1] );
3269 pt := rhs(V[1]);
3270 pt := [ pt, m*(pt-C[i][1]) + C[i][2] ];
3271 pts := pts, pt;
3272 fi;
3273 if ( C[i-1][2] < lhs(V[2]) and C[i][2] > lhs(V[2]) )
3274 or ( C[i-1][2] > lhs(V[2]) and C[i][2] < lhs(V[2]) ) then
3275 m := ( C[i-1][1] - C[i][1] ) / ( C[i-1][2] - C[i][2] );
3276 pt := lhs(V[2]);
3277 pt := [ m*(pt-C[i][2]) + C[i][1], pt ];
3278 pts := pts, pt;
3279 fi;
3280 if ( C[i-1][2] < rhs(V[2]) and C[i][2] > rhs(V[2]) )
3281 or ( C[i-1][2] > rhs(V[2]) and C[i][2] < rhs(V[2]) ) then
3282 m := ( C[i-1][1] - C[i][1] ) / ( C[i-1][2] - C[i][2] );
3283 pt := rhs(V[2]);
3284 pt := [ m*(pt-C[i][2]) + C[i][1], pt ];
3285 pts := pts, pt;
3286 fi;
3287 % \end{macrocode}
3288 % If the two points straddle more than one view-port boundary, we add one point
3289 % for each boundary. The order of the added points must be in the direction
3290 % of the curve.
3291 % \begin{macrocode}
3292 pts := [pts];
3293 if C[i-1][1] < C[i][1] then
3294 pts := sort(pts, (u,v)->evalb(u[1]<v[1]));
3295 elif C[i-1][1] > C[i][1] then
3296 pts := sort(pts, (u,v)->evalb(u[1]>v[1]));
3297 elif C[i-1][2] < C[i][2] then
3298 pts := sort(pts, (u,v)->evalb(u[2]<v[2]));
3299 elif C[i-1][2] > C[i][2] then
3300 pts := sort(pts, (u,v)->evalb(u[2]>v[2]));
3301 else
3302 error "cannot happen";
3303 fi;
3304 B := B, op(pts), C[i];
3305 od;
3306 C := [B];
3307 % \end{macrocode}
3308 % Finally remove the point outside the view-port.
3309 % \begin{macrocode}
3310 C := select( u->evalb(lhs(V[1])<=u[1] and u[1] <= rhs(V[1])), C);
3311 C := select( u->evalb(lhs(V[2])<=u[2] and u[2] <= rhs(V[2])), C);
3312 C;
3313 end;
3314 %</putfile>
3315 % \end{macrocode}
3316 %
3317 % \Finale
3318 %