From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/epic/README | 1 + macros/latex/contrib/epic/epic.readme | 37 ++ macros/latex/contrib/epic/epic.sty | 559 +++++++++++++++++++ macros/latex/contrib/epic/misc.sty | 62 +++ macros/latex/contrib/epic/picman-fig1.tex | 12 + macros/latex/contrib/epic/picman-fig2.tex | 32 ++ macros/latex/contrib/epic/picman-fig3.tex | 65 +++ macros/latex/contrib/epic/picman.pdf | Bin 0 -> 181857 bytes macros/latex/contrib/epic/picman.tex | 857 ++++++++++++++++++++++++++++++ macros/latex/contrib/epic/sqrt.tex | 106 ++++ 10 files changed, 1731 insertions(+) create mode 120000 macros/latex/contrib/epic/README create mode 100644 macros/latex/contrib/epic/epic.readme create mode 100644 macros/latex/contrib/epic/epic.sty create mode 100644 macros/latex/contrib/epic/misc.sty create mode 100644 macros/latex/contrib/epic/picman-fig1.tex create mode 100644 macros/latex/contrib/epic/picman-fig2.tex create mode 100644 macros/latex/contrib/epic/picman-fig3.tex create mode 100644 macros/latex/contrib/epic/picman.pdf create mode 100644 macros/latex/contrib/epic/picman.tex create mode 100644 macros/latex/contrib/epic/sqrt.tex (limited to 'macros/latex/contrib/epic') diff --git a/macros/latex/contrib/epic/README b/macros/latex/contrib/epic/README new file mode 120000 index 0000000000..3e29c113b8 --- /dev/null +++ b/macros/latex/contrib/epic/README @@ -0,0 +1 @@ +epic.readme \ No newline at end of file diff --git a/macros/latex/contrib/epic/epic.readme b/macros/latex/contrib/epic/epic.readme new file mode 100644 index 0000000000..f6db9caca3 --- /dev/null +++ b/macros/latex/contrib/epic/epic.readme @@ -0,0 +1,37 @@ +Following stuff is contained in this package: +1. epic.sty documentstyle option for "Enhancements to Picture + Environment". In its present form, will only work + with LaTeX. +2. misc.sty documentstyle option containing miscalleneous macros. + In particular, one for printing files verbatim. + used by picman.tex; quite useful otherwise. +3. picman.tex manual for epic. +4. picman-fig*.tex manual related files. +5. sqrt.tex appendix to manual. + +Run the manual in the directory as the one where all the files are. To run +it, say "latex picman.tex". + +As is discussed on the first page of the manual, there are two ways +of going about making the macro files acessible to users via the option +mechanism of \documentstyle command: + +1. simplest is to put a copy in the directory where all such things +reside (typically /usr/lib/tex/macros). + +2. keep the files somewhere in your area, and have all the users +declare a shell environment variable TEXINPUTS (typically done in +the ~/.cshrc file); something like: + +setenv TEXINPUTS .:/usr/lilb/tex/macros:/users/yourself/texlib + +Otherwise the files can be explicitly \input with full path name +and the .sty extension: +\input{/..../epic.sty} + +You might wish to move the manual files to a subdirectory "man"; +mkdir man +mv picman* man + +Have fun. +sunil podar diff --git a/macros/latex/contrib/epic/epic.sty b/macros/latex/contrib/epic/epic.sty new file mode 100644 index 0000000000..53f0f253dd --- /dev/null +++ b/macros/latex/contrib/epic/epic.sty @@ -0,0 +1,559 @@ +\typeout{% +Enhancements to Picture Environment. Version 1.2 - Released June 1, 1986} +%---------------------------------------------------------------------- +% Copyright (C) podar@sbcs (Sunil Podar) July 14,1986. +% You may use this file in whatever way you wish. You are requested to +% leave this notice intact, and report any bugs, enhancements, comments, +% suggestions, etc. to: +% USmail: Sunil Podar,Dept. of Computer Science,SUNY at Stony Brook,NY 11794. +% CSNET: podar@sbcs.csnet +% ARPA: podar%suny-sb.csnet@csnet-relay.arpa +% UUCP: {allegra, hocsd, philabs, ogcvax}!sbcs!podar +%---------------------------------------------------------------------- +% This file contains implementation of: +% \multiputlist \matrixput \grid \picsquare +% \dottedline \dashline \drawline \jput +% \putfile +% Environments: dottedjoin, dashjoin and drawjoin +% +% For documentation, see the accompanying manual. +%---------------------------------------------------------------------- +% usage: \multiputlist(x,y)(delta-x,delta-y)[tbrl]{item1,item2,item3,.....} +% \lop and \lopoff taken from TeXbook. +%---------------------------------------------------------------------- +\def\lop#1\to#2{\expandafter\lopoff#1\lopoff#1#2} +\long\def\lopoff,#1,#2\lopoff#3#4{\def#4{#1}\def#3{,#2}} +\def\@@mlistempty{,} +\newif\iflistnonempty +\def\multiputlist(#1,#2)(#3,#4){\@ifnextchar +[{\@imultiputlist(#1,#2)(#3,#4)}{\@imultiputlist(#1,#2)(#3,#4)[]}} + +\long\def\@imultiputlist(#1,#2)(#3,#4)[#5]#6{{% +\@xdim=#1\unitlength \@ydim=#2\unitlength +\listnonemptytrue \def\@@mlist{,#6,} % need this for end condition +\loop +\lop\@@mlist\to\@@firstoflist +\@killglue\raise\@ydim\hbox to\z@{\hskip +\@xdim\@imakepicbox(0,0)[#5]{\@@firstoflist}\hss} +\advance\@xdim #3\unitlength\advance\@ydim #4\unitlength +\ifx\@@mlist\@@mlistempty \listnonemptyfalse\fi +\iflistnonempty +\repeat\relax +\ignorespaces}} +%---------------------------------------------------------------------- +% two-dimensional version of \multiput +% \matrixput(0,0)(20,0){5}(0,20){3}{\circle{2}} +%---------------------------------------------------------------------- +\newcount\@@multicnt +\def\matrixput(#1,#2)(#3,#4)#5(#6,#7)#8#9{% +\ifnum#5>#8\@matrixput(#1,#2)(#3,#4){#5}(#6,#7){#8}{#9}% +\else\@matrixput(#1,#2)(#6,#7){#8}(#3,#4){#5}{#9}\fi} + +%% here #5 >= #8 +\long\def\@matrixput(#1,#2)(#3,#4)#5(#6,#7)#8#9{{\@killglue% +\@multicnt=#5\relax\@@multicnt=#8\relax% +\@xdim=0pt% +\@ydim=0pt% +\setbox\@tempboxa\hbox{\@whilenum \@multicnt > 0\do {% +%%\typeout{\the\@multicnt, \the\@@multicnt}% +\raise\@ydim\hbox to \z@{\hskip\@xdim #9\hss}% +\advance\@multicnt \m@ne% +\advance\@xdim #3\unitlength\advance\@ydim #4\unitlength}}% +\@xdim=#1\unitlength% +\@ydim=#2\unitlength% +\@whilenum \@@multicnt > 0\do {% +\raise\@ydim\hbox to \z@{\hskip\@xdim \copy\@tempboxa\hss}% +\advance\@@multicnt \m@ne% +\advance\@xdim #6\unitlength\advance\@ydim #7\unitlength}% +\ignorespaces}} +%---------------------------------------------------------------------- +%\grid(wd,ht)(delta-wd,delta-ht)[initial-X-integer,initial-Y-integer] +% example: 1. \put(0,0){\grid(95,100)(9.5,10)} +% 2. \put(0,0){\grid(100,100)(10,5)[-10,0]} +% or \put(0,0){\tiny \grid(100,100)(5,5)[0,0]}%numbers in \tiny font +%---------------------------------------------------------------------- +\newcount\d@lta +\newdimen\@delta +\newdimen\@@delta +\newcount\@gridcnt +\def\grid(#1,#2)(#3,#4){\@ifnextchar [{\@igrid(#1,#2)(#3,#4)}% +{\@igrid(#1,#2)(#3,#4)[@,@]}} + +\long\def\@igrid(#1,#2)(#3,#4)[#5,#6]{% +\makebox(#1,#2){% +\@delta=#1pt\@@delta=#3pt\divide\@delta \@@delta\d@lta=\@delta% +\advance\d@lta \@ne\relax\message{grid=\the\d@lta\space x}% +%% copied the definition of \line(0,1){#2} for some efficiency!. +\multiput(0,0)(#3,0){\d@lta}{\hbox to\z@{\hskip -\@halfwidth \vrule + \@width \@wholewidth \@height #2\unitlength \@depth \z@\hss}}% +\ifx#5@\relax\else% +\global\@gridcnt=#5% +\multiput(0,0)(#3,0){\d@lta}{% +\makebox(0,-2)[t]{\number\@gridcnt\global\advance\@gridcnt by #3}}% +\global\@gridcnt=#5% +\multiput(0,#2)(#3,0){\d@lta}{\makebox(0,0)[b]{\number\@gridcnt\vspace{2mm}% +\global\advance\@gridcnt by #3}}% +\fi% +\@delta=#2pt\@@delta=#4pt\divide\@delta \@@delta\d@lta=\@delta% +\advance\d@lta \@ne\relax\message{\the\d@lta . }% +%% copied the definition of \line(1,0){#1} for some efficiency!. +\multiput(0,0)(0,#4){\d@lta}{\vrule \@height \@halfwidth \@depth \@halfwidth + \@width #1\unitlength}% +\ifx#6@\relax\else +\global\@gridcnt=#6% +\multiput(0,0)(0,#4){\d@lta}{% +\makebox(0,0)[r]{\number\@gridcnt\ \global\advance\@gridcnt by #4}}% +\global\@gridcnt=#6% +\multiput(#1,0)(0,#4){\d@lta}{% +\makebox(0,0)[l]{\ \number\@gridcnt\global\advance\@gridcnt by #4}}% +\fi}} +%---------------------------------------------------------------------- +% \picsquare is a centered square of dimensions governed by \thinlines, +% \thicklines or \linethickness declarations. +\def\picsquare{\hskip -0.5\@wholewidth% +\vrule height \@halfwidth depth \@halfwidth width \@wholewidth} +% +% just a square dot with reference point at bottom-left +\def\picsquare@bl{\vrule height \@wholewidth depth \z@ width \@wholewidth} +%---------------------------------------------------------------------- +% \begin{dottedjoin}{interdot-gap in units} +% ..... +% \end{dottedjoin} +% \begin{dashjoin}{dash-length in units}{interdotgap in each dash} +% ..... +% \end{dashjoin} +% \begin{drawjoin} +% ..... +% \end{drawjoin} +% \jput(x,y){character} +% \dottedline[opt. dotcharacter]{dotgap in units}(x1,y1)(x2,y2)...(xN,yN) +% \dashline[#]{dash-length}[opt. dotgap](x1,y1)(x2,y2)...(xN,yN) +% \drawline[#](x1,y1)(x2,y2)...(xN,yN) +%---------------------------------------------------------------------- +% definitions for *join environment. had to do all this mess because of +% optional arguments. +%---------------------------------------------------------------------- +\newif\if@jointhem \global\@jointhemfalse +\newif\if@firstpoint \global\@firstpointtrue +\newcount\@joinkind +%\newenvironment{dottedjoin}[1]%[opt char]{dotgap} +%{\global\@jointhemtrue \gdef\dotgap@join{#1}\global\@joinkind=0\relax}% +%{\global\@jointhemfalse \global\@firstpointtrue} +%---------------------------------------------------------------------- +\def\dottedjoin{\global\@jointhemtrue \global\@joinkind=0\relax + \bgroup\@ifnextchar[{\@idottedjoin}{\@idottedjoin[\picsquare@bl]}} +\def\@idottedjoin[#1]#2{\gdef\dotchar@join{#1}\gdef\dotgap@join{#2}} +\def\enddottedjoin{\global\@jointhemfalse \global\@firstpointtrue\egroup} +%---------------------------------------------------------------------- +\def\dashjoin{\global\@jointhemtrue \global\@joinkind=1\relax + \bgroup\@ifnextchar[{\@idashjoin}{\@idashjoin[\dashlinestretch]}} +\def\@idashjoin[#1]#2{\edef\dashlinestretch{#1}\gdef\dashlen@join{#2}% +\@ifnextchar[{\@iidashjoin}{\gdef\dotgap@join{}}} +\def\@iidashjoin[#1]{\gdef\dotgap@join{#1}} +\let\enddashjoin\enddottedjoin +%---------------------------------------------------------------------- +\def\drawjoin{\global\@jointhemtrue \global\@joinkind=2\relax + \bgroup\@ifnextchar[{\@idrawjoin}{}} +\def\@idrawjoin[#1]{\def\drawlinestretch{#1}} +\let\enddrawjoin\enddottedjoin +%---------------------------------------------------------------------- +%% this is equiv to \put(x,y){#1} when not in {dot*join} environment. +\long\def\jput(#1,#2)#3{{\@killglue\raise#2\unitlength\hbox to \z@{\hskip +#1\unitlength #3\hss}\ignorespaces} +\if@jointhem + \if@firstpoint \gdef\x@one{#1} \gdef\y@one{#2} \global\@firstpointfalse + \else\ifcase\@joinkind + \@dottedline[\dotchar@join]{\dotgap@join\unitlength}% +(\x@one\unitlength,\y@one\unitlength)(#1\unitlength,#2\unitlength) + \or\@dashline[\dashlinestretch]{\dashlen@join}[\dotgap@join]% +(\x@one,\y@one)(#1,#2) + \else\@drawline[\drawlinestretch](\x@one,\y@one)(#1,#2)\fi + \gdef\x@one{#1} \gdef\y@one{#2} + \fi +\fi} +%---------------------------------------------------------------------- +\newdimen\@dotgap +\newdimen\@ddotgap +\newcount\@x@diff +\newcount\@y@diff +\newdimen\x@diff +\newdimen\y@diff +\newbox\@dotbox +\newcount\num@segments +\newcount\num@segmentsi +\newif\ifsqrt@done +%% from sqrtandstuff func basically need \num@segments. +%% given a deltax, deltay and dotgap, it calculates \num@segments = number of +%% segments along the hypotenuse. used by \dottedline & \dashline. +%% It finishes quickly if any of deltax or deltay are zero or close to zero. +\def\sqrtandstuff#1#2#3{ +\ifdim #1 <0pt \@x@diff= -#1 \else\@x@diff=#1\fi +\ifdim #2 <0pt \@y@diff= -#2 \else\@y@diff=#2\fi +%% @diff's will be positive and diff's will retain their sign. +\@dotgap=#3 \divide\@dotgap \tw@ +\advance\@x@diff \@dotgap \advance\@y@diff \@dotgap% for round-off errors +\@dotgap=#3 +\divide\@x@diff \@dotgap \divide\@y@diff \@dotgap +\sqrt@donefalse +\ifnum\@x@diff < 2 + \ifnum\@y@diff < 2 \num@segments=\@x@diff \advance\num@segments \@y@diff + \sqrt@donetrue + \else\num@segments=\@y@diff \sqrt@donetrue\fi + \else\ifnum\@y@diff < 2 \num@segments=\@x@diff \sqrt@donetrue\fi +\fi +\ifsqrt@done \ifnum\num@segments=\z@ \num@segments=\@ne\fi\relax + \else \ifnum\@y@diff >\@x@diff + \@tempcnta=\@x@diff \@x@diff=\@y@diff \@y@diff=\@tempcnta + \fi %exchange @x@diff & @y@diff, so now @x@diff > @y@diff + \num@segments=\@y@diff + \multiply\num@segments \num@segments + \multiply\num@segments by 457 + \divide\num@segments \@x@diff + \advance\num@segments by 750 % for round-off, going to divide by 1000. + \divide\num@segments \@m + \advance\num@segments \@x@diff + %num@segments = @x@diff + (0.457*sqr(@y@diff)/@x@diff) +\fi} +%---------------------------------------------------------------------- +% \dottedline[opt. char]{interdot gap in units}(x1,y1)(x2,y2)....(xN,yN) +%---------------------------------------------------------------------- +%% Used the following construction earlier but that results in box memory +%% full much too soon although it works perfectly. +%% \setbox\@dotbox\vbox to\z@{\vss \hbox to\z@{\hss #1\hss}\vss}\relax} +%% The cenetering of characters is achieved by substracting half the ht, wd +%% of character from the (x,y) coordinates where they are to be put. We +%% chose to use a macro for the ``dot'' instead of \copy\box to save memory +%% at the expense of extra cpu, since memory becomes an issue very soon. +%% \picsquare is already centered, whereas other characters, except \circle, +%% will not be cenetered, hence to handle them all in a similar fashion, +%% used \picsquare@bl. +% +% kind of tail recursion. +\def\dottedline{\@ifnextchar [{\@idottedline}{\@idottedline[\picsquare@bl]}} +\def\@idottedline[#1]#2(#3,#4){\@ifnextchar (% +{\@iidottedline[#1]{#2}(#3,#4)}{\relax}} +\def\@iidottedline[#1]#2(#3,#4)(#5,#6){\@dottedline[#1]{#2\unitlength}% +(#3\unitlength,#4\unitlength)(#5\unitlength,#6\unitlength)% +\@idottedline[#1]{#2}(#5,#6)} +% +%% user not supposed to use this directly. arguments in absolute dimensions. +%% need to pass absolute dimens here because dashline calls dottedline and +%% can supply only absolute dimensions. +\long\def\@dottedline[#1]#2(#3,#4)(#5,#6){{% +\x@diff=#5\relax\advance\x@diff by -#3\relax +\y@diff=#6\relax\advance\y@diff by -#4\relax +\sqrtandstuff{\x@diff}{\y@diff}{#2} +\divide\x@diff \num@segments +\divide\y@diff \num@segments +\advance\num@segments \@ne % to put the last point at destination. +%%\typeout{num@segments= \the\num@segments} +\setbox\@dotbox\hbox{#1}% just to get the dimensions of the character. +\@xdim=#3 \@ydim=#4 +\ifdim\ht\@dotbox >\z@% otherwise its a circle. + \advance\@xdim -0.5\wd\@dotbox + \advance\@ydim -0.5\ht\@dotbox + \advance\@ydim .5\dp\@dotbox\fi +%%circle's have a ht=0, this is one way I could think of to catch circles. +%%following loop is equiv to +%%\multiput(\@xdim,\@ydim)(\x@diff,\y@diff){\num@segments}{#1} +%%with arguments in absolute dimensions. +\@killglue +\loop \ifnum\num@segments > 0 +\unskip\raise\@ydim\hbox to\z@{\hskip\@xdim #1\hss}% +\advance\num@segments \m@ne\advance\@xdim\x@diff\advance\@ydim\y@diff% +\repeat +\ignorespaces}} +%---------------------------------------------------------------------- +% \dashline[#]{dash-length}[optional dotgap](x1,y1)(x2,y2)...(xN,yN) +% The minimum # of dashes put is 2, one at either end point; dash-length is +% reduced accordingly if necessary. Also have to some dirty work to account +% for stretch & shrink. +% \renewcommand{\dashlinestretch}{-50} %ONLY INTEGERS PERMITTED. +%---------------------------------------------------------------------- +\def\dashlinestretch{0} %well, could have used a counter. +\def\dashline{\@ifnextchar [{\@idashline}{\@idashline[\dashlinestretch]}} +\def\@idashline[#1]#2{\@ifnextchar [{\@iidashline[#1]{#2}}% +{\@iidashline[#1]{#2}[\@empty]}} %\@empty needed-- later checked with \ifx +\def\@iidashline[#1]#2[#3](#4,#5){\@ifnextchar (% +{\@iiidashline[#1]{#2}[#3](#4,#5)}{\relax}} +% +\def\@iiidashline[#1]#2[#3](#4,#5)(#6,#7){% +\@dashline[#1]{#2}[#3](#4,#5)(#6,#7)% +\@iidashline[#1]{#2}[#3](#6,#7)} +% +\long\def\@dashline[#1]#2[#3](#4,#5)(#6,#7){{% +\x@diff=#6\unitlength \advance\x@diff by -#4\unitlength +\y@diff=#7\unitlength \advance\y@diff by -#5\unitlength +%% correction to get actual width since the dash-length as taken in arguement +%% is the center-to-center of the end-points. +\@tempdima=#2\unitlength \advance\@tempdima -\@wholewidth +\sqrtandstuff{\x@diff}{\y@diff}{\@tempdima} +\ifnum\num@segments <3 \num@segments=3\fi% min number of dashes I can plot +% is 2, 1 at either end, thus min num@segments is 3 (including 'empty dash'). +\@tempdima=\x@diff \@tempdimb=\y@diff +\divide\@tempdimb by\num@segments +\divide\@tempdima by\num@segments +%% ugly if-then-else. If optional dotgap specified, then use it otherwise +%% make a solid looking dash. +{\ifx#3\@empty \relax + \ifdim\@tempdima < 0pt \x@diff=-\@tempdima\else\x@diff=\@tempdima\fi + \ifdim\@tempdimb < 0pt \y@diff=-\@tempdimb\else\y@diff=\@tempdimb\fi + \ifdim\x@diff < 0.3pt %it's a vertical dashline + \ifdim\@tempdimb > 0pt + \global\setbox\@dotbox\hbox{\hskip -\@halfwidth \vrule + \@width \@wholewidth \@height \@tempdimb} + \else\global\setbox\@dotbox\hbox{\hskip -\@halfwidth \vrule + \@width \@wholewidth \@height\z@ \@depth -\@tempdimb}\fi + \else\ifdim\y@diff < 0.3pt %it's a horizontal dashline + \ifdim\@tempdima >0pt + \global\setbox\@dotbox\hbox{\vrule \@height \@halfwidth + \@depth \@halfwidth \@width \@tempdima} + \else\global\setbox\@dotbox\hbox{\hskip \@tempdima + \vrule \@height \@halfwidth \@depth \@halfwidth + \@width -\@tempdima \hskip \@tempdima}\fi + \else\global\setbox\@dotbox\hbox{% +\@dottedline[\picsquare]{0.98\@wholewidth}(0pt,0pt)(\@tempdima,\@tempdimb)} +\fi\fi +\else\global\setbox\@dotbox\hbox{% +\@dottedline[\picsquare]{#3\unitlength}(0pt,0pt)(\@tempdima,\@tempdimb)} +\fi} +\advance\x@diff by -\@tempdima % both have same sign +\advance\y@diff by -\@tempdimb +% +%%here we correct the number of dashes to be put by reducing them +%%appropriately. (num@segments*\@wholewidth) is in some way the slack we +%%have,and division by dash-length gives the reduction. reduction = +%%(2*num@segments*\@wholewidth)/dash-length +%% (num@segments includes empty ones) +\@tempdima=\num@segments\@wholewidth \@tempdima=2\@tempdima +\@tempcnta=\@tempdima \@tempdima=#2\unitlength \@tempdimb=0.5\@tempdima +\@tempcntb=\@tempdimb \advance\@tempcnta by \@tempcntb % round-off error +\divide\@tempcnta by\@tempdima \advance\num@segments by -\@tempcnta +% +\ifnum #1=0 \relax\else\ifnum #1 < -100 + \typeout{***dashline: reduction > -100 percent implies blankness!***} +\else\num@segmentsi=#1 \advance\num@segmentsi by 100 + \multiply\num@segments by\num@segmentsi \divide\num@segments by 100 +\fi\fi +% +\divide\num@segments by 2 % earlier num@segments included 'empty dashes' too. +\ifnum\num@segments >0 % if =0 then don't divide => \x@diff & \y@diff + \divide\x@diff by\num@segments% remain same. + \divide\y@diff by\num@segments + \advance\num@segments by\@ne %for the last segment for which I subtracted + %\@tempdima & \@tempdimb from \x@diff & \y@diff + \else\num@segments=2 % one at each end. +\fi +%%\typeout{num@segments finally = \the\num@segments} +%% equiv to \multiput(#4,#5)(\x@diff,\y@diff){\num@segments}{\copy\@dotbox} +%% with arguements in absolute dimensions. +\@xdim=#4\unitlength \@ydim=#5\unitlength +\@killglue +\loop \ifnum\num@segments > 0 +\unskip\raise\@ydim\hbox to\z@{\hskip\@xdim \copy\@dotbox\hss}% +\advance\num@segments \m@ne\advance\@xdim\x@diff\advance\@ydim\y@diff% +\repeat +\ignorespaces}} +%---------------------------------------------------------------------- +%%1.00 .833333 .80 .75 .66666 .60 .50 .40 .33333 .25 .20 .16666 +%% .916666 .816666 .775 .708333 .633333 .55 .45 .366666 .291666 .225 .183333 +%% 0.0 +%%0.083333 +%% the first line has absolute slopes corresponding to various permissible +%% integer combinations representing slopes. The second line is the midpoint +%% of all those slopes (attempted to show them in the middle of two entries). +%% +%% \lineslope(x@diff dimen, y@diff dimen) +%% Given base (x@diff) and height (y@diff) in dimensions, determines the +%% closest available slope and returns the two required integers in \@xarg +%% and \@yarg. The given base and height can be ANYTHING, -ve or +ve, or +%% even 0pt. \lineslope knows about (0,1) and (1,0) slopes too and returns +%% correct values if the conditions regarding x@diff & y@diff are obeyed +%% (see NOTE). Used by \drawline. This is the simplest and only way I could +%% figure out to accomplish it!. +%% NOTE: both the dimensions (x@diff & y@diff) must be in SAME units and the +%% larger of the two dimensions must be atleast 1pt (i.e. 65536sp). To avoid +%% dividing by 0, I make the larger dimension = 1pt if it is < 1pt. +%% will need a similar one for vectors, or maybe this can be used. For +%% vectors the range is -4, 4 unlike lines where it is -6, 6. +\newif\if@flippedargs +\def\lineslope(#1,#2){% +\ifdim #1 <0pt \@xdim= -#1 \else\@xdim=#1\fi +\ifdim #2 <0pt \@ydim= -#2 \else\@ydim=#2\fi +%%\typeout{xdim,ydim= \the\@xdim, \the\@ydim} +\ifdim\@xdim >\@ydim \@tempdima=\@xdim \@xdim=\@ydim \@ydim=\@tempdima +\@flippedargstrue\else\@flippedargsfalse\fi% x < y +\ifdim\@ydim >1pt \@tempcnta=\@ydim + \divide\@tempcnta by 65536% now \@tempcnta=integral part of #1. + \divide\@xdim \@tempcnta\fi +\ifdim\@xdim <.083333pt \@xarg=1 \@yarg=0 + \else\ifdim\@xdim <.183333pt \@xarg=6 \@yarg=1 + \else\ifdim\@xdim <.225pt \@xarg=5 \@yarg=1 + \else\ifdim\@xdim <.291666pt \@xarg=4 \@yarg=1 + \else\ifdim\@xdim <.366666pt \@xarg=3 \@yarg=1 + \else\ifdim\@xdim <.45pt \@xarg=5 \@yarg=2 + \else\ifdim\@xdim <.55pt \@xarg=2 \@yarg=1 + \else\ifdim\@xdim <.633333pt \@xarg=5 \@yarg=3 + \else\ifdim\@xdim <.708333pt \@xarg=3 \@yarg=2 + \else\ifdim\@xdim <.775pt \@xarg=4 \@yarg=3 + \else\ifdim\@xdim <.816666pt \@xarg=5 \@yarg=4 + \else\ifdim\@xdim <.916666pt \@xarg=6 \@yarg=5 + \else \@xarg=1 \@yarg=1% +\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi +\if@flippedargs\relax\else\@tempcnta=\@xarg \@xarg=\@yarg + \@yarg=\@tempcnta\fi +\ifdim #1 <0pt \@xarg= -\@xarg\fi +\ifdim #2 <0pt \@yarg= -\@yarg\fi +%%\typeout{closest slope integers = \the\@xarg, \the\@yarg} +} +%---------------------------------------------------------------------- +% usage: \drawline[#](x1,y1)(x2,y2)....(xN,yN) +% % # is an optional integer between -100 & infinity. +% \renewcommand{\drawlinestretch}{-50} %ONLY INTEGERS PERMITTED. +%---------------------------------------------------------------------- +\newif\if@toosmall +\newif\if@drawit +\newif\if@horvline +\def\drawlinestretch{0} %well, could have used a counter. +% kind of tail recursion. +\def\drawline{\@ifnextchar [{\@idrawline}{\@idrawline[\drawlinestretch]}} +\def\@idrawline[#1](#2,#3){\@ifnextchar ({\@iidrawline[#1](#2,#3)}{\relax}} +\def\@iidrawline[#1](#2,#3)(#4,#5){\@drawline[#1](#2,#3)(#4,#5)% +\@idrawline[#1](#4,#5)} +% +\def\@drawline[#1](#2,#3)(#4,#5){{% +\x@diff=#4\unitlength \advance\x@diff by -#2\unitlength +\y@diff=#5\unitlength \advance\y@diff by -#3\unitlength +%% override any linethickness declarations, and since horiz & vertical lines +%% come out thinner than the slanted ones, assign slightly larger values. +%% default values are: thinlines=0.4pt, thicklines=0.8pt +\ifx\@linefnt\tenln \linethickness{0.5pt} \else \linethickness{0.9pt}\fi +\lineslope(\x@diff,\y@diff)% returns the two integers in \@xarg & \@yarg. +%------ +\@toosmalltrue +{\ifdim\x@diff <\z@ \x@diff=-\x@diff\fi + \ifdim\y@diff <\z@ \y@diff=-\y@diff\fi + \ifdim\x@diff >10pt \global\@toosmallfalse\fi + \ifdim\y@diff >10pt \global\@toosmallfalse\fi} +%------ +%% For efficiency, if the line is horiz or vertical then we draw it in one +%% shot, only if the stretch is not -ve and the line is not too small. +\@drawitfalse\@horvlinefalse +\ifnum#1 <0 \relax\else\@horvlinetrue\fi +\if@toosmall\@horvlinetrue\fi% to get 'or' condition. We necessarily draw a +% solid line if the line is too small ignoring any -ve stretch. +\if@horvline + \ifdim\x@diff =0pt \put(#2,#3){\ifdim\y@diff >0pt \@linelen=\y@diff \@upline + \else\@linelen=-\y@diff \@downline\fi}% + \else\ifdim\y@diff =0pt + \ifdim\x@diff >0pt \put(#2,#3){\vrule \@height \@halfwidth \@depth + \@halfwidth \@width \x@diff} + \else \put(#4,#5){\vrule \@height \@halfwidth \@depth + \@halfwidth \@width -\x@diff}\fi + \else\@drawittrue\fi\fi % construct the line explicitly +\else\@drawittrue\fi +%------------------------------- +\if@drawit +\ifnum\@xarg< 0 \@negargtrue\else\@negargfalse\fi +\ifnum\@xarg =0 \setbox\@linechar% +\hbox{\hskip -\@halfwidth \vrule \@width \@wholewidth \@height 10.2pt + \@depth \z@} +\else \ifnum\@yarg =0 \setbox\@linechar% +\hbox{\vrule \@height \@halfwidth \@depth \@halfwidth \@width 10.2pt} +\else \if@negarg \@xarg -\@xarg \@yyarg -\@yarg + \else \@yyarg \@yarg\fi +\ifnum\@yyarg >0 \@tempcnta\@yyarg \else \@tempcnta -\@yyarg\fi +\setbox\@linechar\hbox{\@linefnt\@getlinechar(\@xarg,\@yyarg)}% +\fi\fi +%------ +\if@toosmall% => it isn't a horiz or vert line and is toosmall. + \@dottedline[\picsquare]{.98\@wholewidth}% +(#2\unitlength,#3\unitlength)(#4\unitlength,#5\unitlength)% +\else +%% following is neat. The last segment takes \wd\@linechar & \ht\@linechar +%% so plot the line as though it were from (#2,#3) to +%% (#4-\wd\@linechar,#5-\ht\@linechar) (i.e. for positive slope; of course, +%% signs are reversed for other slopes). For horizontal & vertical dashes we +%% don't have to subtract the ht & wd resp. since they are already centered. +\ifnum\@xarg=0\relax\else\ifdim\x@diff >\z@ \advance\x@diff -\wd\@linechar + \else\advance\x@diff \wd\@linechar\fi\fi +\ifnum\@yarg=0\relax\else\ifdim\y@diff >\z@\advance\y@diff -\ht\@linechar + \else\advance\y@diff \ht\@linechar\fi\fi +\ifdim\x@diff <\z@ \@x@diff=-\x@diff \else\@x@diff=\x@diff\fi +\ifdim\y@diff <\z@ \@y@diff=-\y@diff \else\@y@diff=\y@diff\fi +%%\typeout{x@diff,y@diff=\the\x@diff , \the\y@diff} +\num@segments=0 \num@segmentsi=0 +\ifdim\wd\@linechar >1pt + \num@segmentsi=\@x@diff \divide\num@segmentsi \wd\@linechar\fi +\ifdim\ht\@linechar >1pt + \num@segments=\@y@diff \divide\num@segments \ht\@linechar\fi +\ifnum\num@segmentsi >\num@segments \num@segments=\num@segmentsi\fi +\advance\num@segments \@ne %to account for round-off error +% +\ifnum #1=0 \relax \else\ifnum #1 < -99 + \typeout{***drawline: reduction <= -100 percent implies blankness!***} +\else\num@segmentsi=#1 \advance\num@segmentsi by 100 + \multiply\num@segments \num@segmentsi + \divide\num@segments by 100 + \ifnum \num@segments=0 \num@segments=1 \fi +\fi\fi +%%\typeout{num@segments after = \the\num@segments} +% +\divide\x@diff \num@segments +\divide\y@diff \num@segments +\advance\num@segments \@ne %for the last segment for which I subtracted + %\wd & \ht of \@linechar from \@x@diff & \@y@diff. +%%\typeout{numseg,x@diff,y@diff= \the\num@segments, \the\x@diff, \the\y@diff} +% +\@xdim=#2\unitlength \@ydim=#3\unitlength +\if@negarg \advance\@xdim -\wd\@linechar\fi +\ifnum\@yarg <0 \advance\@ydim -\ht\@linechar\fi +%%following loop equiv to \multiput@abs(\@xdim,\@ydim)% +%%(\x@diff,\y@diff){\num@segments}{\copy\@linechar} +%%with arguements in absolute dimensions. +\@killglue +\loop \ifnum\num@segments > 0 +\unskip\raise\@ydim\hbox to\z@{\hskip\@xdim \copy\@linechar\hss}% +\advance\num@segments \m@ne\advance\@xdim\x@diff\advance\@ydim\y@diff% +\repeat +\ignorespaces +\fi%the if of @toosmall +\fi}}% for \if@drawit +%---------------------------------------------------------------------- +%usage: \putfile{datafile}{OBJECT} +% The OBJECT is plotted at EACH of the coordinates read from the datafile. +% The idea of these macros is to generate (x,y) pairs using some program +% and then directly use those coordinates. Since TeX doesn't have real +% floating point calculations, it is much more efficient and accurate to do +% things this way. One can also use the unix facility 'spline' now to +% generate smooth curves with equidistant ``dots''. +% NOTE: the external file of coordinates must have x y pairs with a space +% between them. Also it is suggested that some extension such as '.put' +% be used for such datafiles to distinguish them in which case it must +% be explicitely specified in the 1st argument so that TeX doesn't look +% for a .tex extension. +% The % char remains valid as a comment char and such lines are ignored; +% however, there should be atleast one space after the second entry if a +% comment is on the same line as data since % eats up the newline. +%----------------------------------------------------------------------- +\long\def\splittwoargs#1 #2 {(#1,#2)} +% +\newif\if@stillmore +\newread\@datafile +\long\def\putfile#1#2{\openin\@datafile = #1 +\@stillmoretrue +\loop +\ifeof\@datafile\relax\else\read\@datafile to\@dataline\fi +%if file nonexistent, do nothing. +\ifeof\@datafile\@stillmorefalse +\else\ifx\@dataline\@empty \relax + \else +\expandafter\expandafter\expandafter\put\expandafter\splittwoargs% +\@dataline{#2} + \fi +\fi +\if@stillmore +\repeat +\closein\@datafile +} +%---------------------------------------------------------------------- diff --git a/macros/latex/contrib/epic/misc.sty b/macros/latex/contrib/epic/misc.sty new file mode 100644 index 0000000000..5ad7cf4189 --- /dev/null +++ b/macros/latex/contrib/epic/misc.sty @@ -0,0 +1,62 @@ +% podar@sbcs (Sunil Podar) July 14, 1986 +% following commands implemented here (see the comments below for more info): +% \pmb +% \timeofday +% \verbfile +% \listing +%---------------------------------------------------------------------------- +% poor man's bold. from pp. 386 of TeXbook. 1.732*0.025=0.0433 (the ratio of +% em to ex) +\newdimen\pmboffset +\pmboffset 0.025em +\def\pmb#1{\setbox0=\hbox{#1}% + \kern-\pmboffset\copy0\kern-\wd0 + \kern 2\pmboffset\copy0\kern-\wd0 + \kern-\pmboffset\raise 1.732\pmboffset\box0 } +%---------------------------------------------------------------------------- +% \timeofday is just like \today; it gives the current time of day in the form +% hh:mm as in the military style. It eats up a blank so normally one would +% say: \timeofday\ (i.e. a \. +\def\timeofday{{\@tempcnta=\time \divide\@tempcnta by 60 \@tempcntb=\@tempcnta +\multiply\@tempcntb by 60 \advance\@tempcntb by -\time %@tempcntb is -ve here +\ifnum\@tempcntb < -9 \number\@tempcnta:\number-\@tempcntb + \else\number\@tempcnta:0\number-\@tempcntb\fi}} +%---------------------------------------------------------------------------- +%From: Tim Morgan +%Subject: verbatim macros +%Here are some macros which I mostly stole from the TeXbook source and +%other places. You can say +% +% \verbfile{filename} +%to \input all of "filename" in verbatim mode. The end of the file is the +%only thing that gets you back out of verbatim -- no characters are special. +%\listing is the same except that each line of the file is automatically +%numbered. +%Tim +% +% Produce verbatim listings of various sorts + +\def\uncatcodespecials{\def\do##1{\catcode`##1=12 } \dospecials} + +\def\setupverbatim{% + \par \tt \spaceskip=0pt % Make sure we get fixed tt spacing + \obeylines\uncatcodespecials\obeyspaces\verbatimdefs +} +{\catcode`\^^M=13{\catcode`\ =13\gdef\verbatimdefs{\def^^M{\ \par}\let =\ }} + \gdef\verbatimgobble#1^^M{}} +% +% Input a file in verbatim mode. Sometimes useful for including +% real-life examples into a paper. +\def\verbfile#1{\begingroup\setupverbatim + \parskip=0pt plus .05\baselineskip \parindent=0pt + \input#1 \endgroup +} + +% This is the same as the above, but it adds line numbers to each +% line of the file printed. +\newcount\lineno +\def\listing#1{\lineno=0\begingroup\setupverbatim + \parskip=0pt plus .05\baselineskip \parindent=20pt + \everypar{\advance\lineno by 1 \llap{\the\lineno\ \ }}\input#1 + \endgroup +} diff --git a/macros/latex/contrib/epic/picman-fig1.tex b/macros/latex/contrib/epic/picman-fig1.tex new file mode 100644 index 0000000000..de8cf48af2 --- /dev/null +++ b/macros/latex/contrib/epic/picman-fig1.tex @@ -0,0 +1,12 @@ +%\newcommand{\plotchar}{\makebox(0,0){\large $\otimes$}} +\unitlength = 1mm +\begin{picture}(100,100)(0,0) +\put(0,0){\tiny \grid(100,100)(5,5)[0,0]} +\drawline(10,5)(60,10)(85,20)(90,60)(100,95) +\drawline[-50](10,0)(65,5)(90,15)(95,55) +\thicklines +\dottedline{1.4}(10,10)(60,20)(75,35)(95,95) +\dashline{2}(80,90)(50,80)(30,50)(10,40) +\dashline{2}[0.5](80,80)(50,70)(30,40)(10,30) +\dashline[-30]{2}[0.5](80,70)(50,60)(30,30)(10,20) +\end{picture} diff --git a/macros/latex/contrib/epic/picman-fig2.tex b/macros/latex/contrib/epic/picman-fig2.tex new file mode 100644 index 0000000000..815a8a4987 --- /dev/null +++ b/macros/latex/contrib/epic/picman-fig2.tex @@ -0,0 +1,32 @@ +\xjunk=60 \yjunk=3 +\loop +\drawline(0,0)(\xjunk,\yjunk) +\drawline(0,0)(-\xjunk,\yjunk) +\drawline(0,0)(\xjunk,-\yjunk) +\drawline(0,0)(-\xjunk,-\yjunk) +\put(\xjunk,\yjunk){\plotchar} +\put(-\xjunk,\yjunk){\plotchar} +\put(\xjunk,-\yjunk){\plotchar} +\put(-\xjunk,-\yjunk){\plotchar} +\put(\xjunk,\yjunk){\makebox(8,0)[l]{\ \ (\number\xjunk,\number\yjunk)}} +\put(-\xjunk,\yjunk){\makebox(-4,0)[r]{(\number-\xjunk,\number\yjunk)}} +\put(\xjunk,-\yjunk){\makebox(8,0)[l]{\ \ (\number\xjunk,\number-\yjunk)}} +\put(-\xjunk,-\yjunk){\makebox(-4,0)[r]{(\number-\xjunk,\number-\yjunk)}} +\ifnum\yjunk < 53 \advance\yjunk by 10 %will go till 53. +\repeat +\xjunk=3 \yjunk=60 +\loop +\drawline(0,0)(\xjunk,\yjunk) +\drawline(0,0)(-\xjunk,\yjunk) +\drawline(0,0)(\xjunk,-\yjunk) +\drawline(0,0)(-\xjunk,-\yjunk) +\put(\xjunk,\yjunk){\plotchar} +\put(-\xjunk,\yjunk){\plotchar} +\put(\xjunk,-\yjunk){\plotchar} +\put(-\xjunk,-\yjunk){\plotchar} +\put(\xjunk,\yjunk){\makebox(0,7)[t]{(\number\xjunk,\number\yjunk)}} +\put(-\xjunk,\yjunk){\makebox(0,5)[t]{(\number-\xjunk,\number\yjunk)}} +\put(\xjunk,-\yjunk){\makebox(0,-4)[t]{(\number\xjunk,\number-\yjunk)}} +\put(-\xjunk,-\yjunk){\makebox(0,-6)[t]{(\number-\xjunk,\number-\yjunk)}} +\ifnum\xjunk < 53 \advance\xjunk by 10 +\repeat diff --git a/macros/latex/contrib/epic/picman-fig3.tex b/macros/latex/contrib/epic/picman-fig3.tex new file mode 100644 index 0000000000..12a3aa97ea --- /dev/null +++ b/macros/latex/contrib/epic/picman-fig3.tex @@ -0,0 +1,65 @@ +%Following commands were used to produce the graph on the next page. + +\newcommand{\plotcharms}{\makebox(0,0){$\otimes$}} +\newcommand{\plotcharscs}{\circle{1.5}} +\newcommand{\plotcharcs}{\makebox(0,0){$\diamond$}} +\begin{figure} +\begin{center} +\begin{picture}(140,160)(-130,-10) +\linethickness{0.4mm} +\put(-130,0){\vector(1,0){140}} +\put(-130,0){\vector(0,1){150}} +\thicklines +\multiput(0,-1)(-10,0){14}{\line(0,1){2}} +\multiput(-131,0)(0,10){15}{\line(1,0){2}} +\multiputlist(0,-4)(-20,0){0,50,100,150,200,250,300} %numbers along X-axis +\multiputlist(-132,20)(0,20)[r]{10,20,30,40,50,60,70} %numbers along Y-axis +\put(-60,-10){\makebox(0,0){Interarrival Times (msec.)}} +\put(-141,75){\makebox(0,0){\shortstack{% +N\\o\\r\\m\\a\\l\\i\\z\\e\\d\\[3ex]L\\i\\f\\e\\t\\i\\m\\e\\s}}} +\thinlines +\put(-120,150){\makebox(0,0)[tl]{\fbox{\shortstack[l]{ + {\makebox(4,2)[lb]{\put(2,1){\plotcharms}}}: Message Switching\\[0.5mm] + {\makebox(4,3)[lb]{\put(2,1){\plotcharscs}}}: Staged Circuit Switching\\[0.5mm] + {\makebox(4,3)[lb]{\put(2,1){\plotcharcs}}}: Circuit Switching\\[0.5mm] + {\makebox(2,0)[b]{}} + }}}} +% +\begin{dottedjoin}{2} +\thicklines +\jput(-120.00000, 34.44896){\plotcharms} +\jput( -60.00000, 35.55244){\plotcharms} +\jput( -40.00000, 36.57292){\plotcharms} +\jput( -30.00000, 37.71716){\plotcharms} +\jput( -20.00000, 40.15218){\plotcharms} +\jput( -12.00000, 48.16034){\plotcharms} +\jput( -8.00000, 67.75840){\plotcharms} +\jput( -7.60000, 74.27934){\plotcharms} +\jput( -7.20000, 83.02326){\plotcharms} +\end{dottedjoin} +% +\begin{dashjoin}{2} +\jput(-120.00000, 15.01202){\plotcharscs} +\jput( -60.00000, 15.95818){\plotcharscs} +\jput( -40.00000, 17.15990){\plotcharscs} +\jput( -30.00000, 18.16152){\plotcharscs} +\jput( -20.00000, 20.32388){\plotcharscs} +\jput( -12.00000, 27.05212){\plotcharscs} +\jput( -8.00000, 41.58512){\plotcharscs} +\jput( -7.60000, 45.3435){\plotcharscs} +\jput( -7.20000, 51.52414){\plotcharscs} +\end{dashjoin} +% +\begin{drawjoin} +\jput(-120.00000, 15.17960){\plotcharcs} +\jput( -80.00000, 16.71960){\plotcharcs} +\jput( -60.00000, 18.29430){\plotcharcs} +\jput( -56.00000, 19.81980){\plotcharcs} +\jput( -52.00000, 20.31963){\plotcharcs} +\jput( -48.00000, 50.24912){\plotcharcs} +\jput( -44.00000, 56.96844){\plotcharcs} +\end{drawjoin} +\end{picture} +\end{center} +\caption[]{A real-life example of a graph} +\end{figure} diff --git a/macros/latex/contrib/epic/picman.pdf b/macros/latex/contrib/epic/picman.pdf new file mode 100644 index 0000000000..ea50ec2f2e Binary files /dev/null and b/macros/latex/contrib/epic/picman.pdf differ diff --git a/macros/latex/contrib/epic/picman.tex b/macros/latex/contrib/epic/picman.tex new file mode 100644 index 0000000000..3c70194005 --- /dev/null +++ b/macros/latex/contrib/epic/picman.tex @@ -0,0 +1,857 @@ +% Copyright (C) podar@sbcs (Sunil Podar) July 14,1986. +\documentstyle[11pt,fleqn,epic,misc]{article} +% Archiver's note: I commented the following out to get a standard +% page layout. You will get overfull hboxes though. [KY] +%\setlength{\topmargin}{1cm} +%\setlength{\headheight}{1cm} +%\setlength{\footskip}{2cm} +%\setlength{\oddsidemargin}{1in} +%\setlength{\textwidth}{6.5in} +%\setlength{\textheight}{8.5in} +%\setlength{\parindent}{0pt} +\setlength{\unitlength}{1mm} +\parskip=6pt plus 1pt minus 1pt +\itemsep=0pt +\renewcommand{\baselinestretch}{1.3} +\newcommand{\bs}{\char '134 } % A backslash char for \tt font +\newcommand{\lb}{\char '173 } % A left brace char for \tt font +\newcommand{\rb}{\char '175 } % A right brace char for \tt font +\newcommand{\plotchar}{\makebox(0,0){\large $\otimes$}} +\pagestyle{plain} +\begin{document} +\thispagestyle{empty} +\begin{center} +{\Large\bf Enhancements to the Picture Environment of \LaTeX} +\end{center} + +\vspace*{0.5in} +\begin{center} +\begin{it} +Sunil Podar\\ +Dept. of Computer Science\\ +S.U.N.Y. at Stony Brook\\ +Technical Report 86-17\\[3mm] +Version 1.2: July 14, 1986. +\end{it} +\end{center} + +\vspace*{1.3in} +\begin{center} +{\bf Abstract} +\end{center} + +{\renewcommand{\baselinestretch}{1.5} \small\normalsize +\begin{quote} +This document describes some new commands for the picture environment of +\LaTeX. Some of the picture drawing commands of +\LaTeX\ are very low-level. New higher-level commands are implemented and +described here. These commands enhance the graphic capabilities of +\LaTeX\ and provide a friendlier and more powerful user +interface than currently existent. Their implementation has been done +with the aim of reducing the amount of +manual calculations required to specify the layout of {\it objects}. +With the addition of the commands described in this document, it should be +possible to draw +more sophisticated pictures with lesser effort than was previously possible. +\end{quote} +} + +\newpage +\setcounter{page}{1} +\section*{Enhancements to the Picture Environment of \LaTeX} + +\bigskip +\section{Introduction} + + +\LaTeX\ provides a reasonably powerful picture drawing capability. +There are many useful commands provided although the +user-interface has room for improvement. The commands described +in this document aim to achieve a simpler and more powerful interface. + +Most picture drawing commands require explicit specification of coordinates +for every {\it object\/}. Although explicit coordinates is the basis of the +picture environment, it is possible to provide higher level commands which +reduce the amount of coordinates that need to be manually calculated. There +are basically two approaches that can be taken in designing such commands: +% +\begin{itemize} +\item providing ability to specify a set of objects such that +the entire set can be plotted by specifying one or two coordinate pairs; +\verb|\shortstack| command falls into this category. + +\item providing commands that do most of the computation internally and +require simple coordinate pairs to be specified; \verb|\multiput| command is +one example of this approach. + +\end{itemize} + +The obvious advantage of having commands that fall into the above categories +is that not only they are easier to specify initially, but any subsequent +modification to the layout requires minimal recalculations. For instance, to +modify the coordinates in a \verb|\multiput| statement plotting $n$ objects +requires recalculation of at most 4 coordinates, whereas the equivalent +\verb|\put| statements may require upto $2n$ calculations and/or +recalculations. + +Another frequently used command, \verb|\line| has severe limitations and +drawbacks. The +arguments that the \verb|\line| command expects are very non-intuitive and +requires extensive calculations --- often the thought process in writing a +\verb|\line| command involves: +\begin{enumerate} +\item calculating the coordinates of the two end-points. +\item calculating the horizontal and vertical distance. +\item figuring out if the desired slope is available and if not then +repeating steps 1 and 2 till a satisfactory slope is achieved. +\item translating above into an (x,y) pair for specifying a slope and a +horizontal distance for specifying the length of the line. +\end{enumerate} + +Above mechanism is a cumbersome way of specifying a line. It also has the +drawback that the length of the shortest line of different slopes that +can be drawn is different; for instance, assuming \verb|\unitlength=1pt|, +\verb|\line(1,6){10}| is the shortest line of the given slope that can be +drawn; it is considerably longer than the available line segment of this +slope --- 60.8pt rather than about 11pt. It should be emphasized that this +is a drawback of only the implementation of the \verb|\line| +command and is not an inherent limitation. This report describes a few line +drawing commands all of which overcome such a drawback, while providing a +simpler syntax. They all take, as arguments, only the coordinates of the +end-points, thus eliminating all other steps involved in specifying a +line; it also seems to be a natural way of perceiving a line in an +environment where all the work is done in terms of coordinates. + +A few new commands are developed and described in this report. They provide +a simpler syntax and a higher-level user-interface. Also some of the commands +permit one to plot objects that were previously cumbersome or difficult to +plot. All existing commands still remain accessible. With the new +commands it should now be possible to make pictures with less effort and +make more sophisticated pictures than was possible earlier. + +\section{Commands} + +Following commands are described here: +\begin{verbatim} + \multiputlist \dottedline dottedjoin environment \jput + \matrixput \dashline dashjoin environment \picsquare + \grid \drawline drawjoin environment \putfile +\end{verbatim} + +All the examples in the following sections have been plotted with +\verb|\unitlength = 1mm|. + +\subsection{{\tt \bs}multiputlist} + +{\tt SYNOPSIS:\\ +\hspace*{\leftmargin}% +\bs multiputlist($x$,$y$)($\Delta x$,$\Delta y$)[tbrl]% +\lb{\it item1},{\it item2},{\it item3},\ldots,{\it itemN}\rb} + +This command is a variation of the regular \LaTeX\ command \verb|\multiput|. +The \verb|\multiput| command permits one to put the {\it same\/} object +at regularly spaced coordinates. Often one wishes to put {\it different\/} +objects at coordinates that have regular increments -- \verb|\multiputlist| +command can be used in those cases. This command enables one to specify a +collection of objects with a single command thus simplifying the task of +calculating coordinates. All those objects may also be plotted separately +using \verb|\put| commands, but any future revision of those coordinates +may involve lot of manual work. This command also encourages certain +regularity and symmetry in laying out various objects in a picture. + +In the \verb|\multiputlist|, as the coordinates are incremented, the objects +to be put are picked up from the {\it list of items\/}, +i.e., first item in first position, second item in second position, and so on. +For example, numbers along the X-axis in a graph may be plotted by simply +specifying:\\[2mm] +\hspace*{\leftmargin}% +\verb|\multiputlist(0,0)(10,0){1.00,1.25,1.50,1.75,2.00}| \\[2mm] +This is almost equivalent to the sequence: +\begin{quote} +\begin{verbatim} +\put(0,0){1.00} +\put(10,0){1.25} +\put(20,0){1.50} +\put(30,0){1.75} +\put(40,0){2.00} +\end{verbatim} +\end{quote} + +The difference is that each {\it item\/} is put in a +\verb|\makebox(0,0)[tbrl]{...}| kind of construction which +allows the specification of +the reference point of the box containing the item. The \verb|[tbrl]| +is optional and its absence makes the item centered at the specified +coordinate. Note that \verb|\put| command does not have such an option. + +The objects in the {\it list\/} can be virtually anything including any +\verb|\makebox|, \verb|\framebox|, math characters, etc. This command can be +usefully employed in a situation where a variety of objects are +to be put at coordinates that have a regular increment along the x-axis and +the y-axis. + +Few comments about \verb|\multiputlist| command: + +\begin{itemize} +\item Individual items have to be grouped in \verb|{}| if they contain ``,''s. + +\item In the list of items, blanks are not ignored (of course, consecutive +blanks are coalesced into one, as always). For a list of items longer than a +line of input, put a \% at the end in order to nullify the newline if a +blank is not intended to be a part of the item. + +\item Specifying individual items in a list format provides a powerful +mechanism for specifying a variety of objects in a single command. +Moreover, often real numbers need to be plotted and +it is nontrivial to generate real numbers or otherwise +handle them in \TeX; they need to be explicitly specified as {\it objects} in +the desired format. +The \verb|\multiputlist| command somewhat simplifies such a task. + +\item The implementation of \verb|\multiputlist| uses two macros derived from +the ones given in the \TeX book, namely, \verb|\lop| and \verb|\lopoff| for +list-manipulation. +\end{itemize} + +\subsection{{\tt \bs}matrixput} +{\tt SYNOPSIS:\\ +\hspace*{\leftmargin}% +\bs matrixput($x$,$y$)($\Delta x_1$,$\Delta y_1$)\lb $n_1$\rb +($\Delta x_2$,$\Delta y_2$)\lb $n_2$\rb \lb {\it object}\rb} + +Above command is the two-dimensional equivalent of the regular \LaTeX\ command +\verb|\multiput|. The \verb|\matrixput| command is equivalent to: + +\begin{quote} +{\tt \bs multiput($x$,$y$)% +($\Delta x_2$,$\Delta y_2$)\lb $n_2$\rb\lb {\it object}\rb}\\ +{\tt \bs multiput($x + \Delta x_1$,$y + \Delta y_1$)% +($\Delta x_2$,$\Delta y_2$)\lb $n_2$\rb\lb {\it object}\rb}\\ +\ldots\\ +{\tt \bs multiput($x + n_1 \Delta x_1$,$y + n_1\Delta y_1$)% +($\Delta x_2$,$\Delta y_2$)\lb $n_2$\rb\lb {\it object}\rb} +\end{quote} + +However, it is more efficient to use \verb|\matrixput| than the equivalent +$n_1$ \verb|\multiput| statements; first the objects along the dimension with +larger index are saved in a box and subsequently the box is copied along the +other dimension, resulting in a $O(n_1 + n_2)$ execution time rather than +$O(n_1*n_2)$ which would be the case with the equivalent \verb|\multiput| +statements. This command can be useful in making pictures where a pattern is +repeated at regular intervals in two dimensions, such as certain kinds +of transition diagrams. An illustration of the \verb|\matrixput| command is +presented below. + +\begin{center} +\unitlength = 1mm +\begin{picture}(155,35)(0,-8) +\thicklines +\matrixput(0,0)(10,0){6}(0,10){3}{\circle{4}} +\matrixput(2,0)(10,0){5}(0,10){3}{\line(1,0){6}} +\matrixput(0,2)(10,0){6}(0,10){2}{\line(0,1){6}} +\put(60,10){\makebox(0,0)[l]{\tt \shortstack[l]{% +\bs matrixput(0,0)(10,0)\lb 6\rb (0,10)\lb 3\rb\lb\bs circle\lb +4\rb\rb\\[3mm] +\bs matrixput(2,0)(10,0)\lb 5\rb (0,10)\lb 3\rb\lb\bs line(1,0)\lb +6\rb\rb\\[3mm] +\bs matrixput(0,2)(10,0)\lb 6\rb (0,10)\lb 2\rb\lb\bs line(0,1)\lb 6\rb\rb +}}} +\end{picture} +\end{center} + +Note: The \verb|\matrixput| command does not restrict the $\Delta x$'s and +the $\Delta y$'s to be zero. The {\it matrix} of {\it objects} can be +``skewed'', i.e., with nonzero $\Delta x$'s and/or $\Delta y$'s. + +\subsection{{\tt \bs}grid} + +{\tt SYNOPSIS:\\ +\hspace*{\leftmargin}% +\bs grid({\it width},{\it height})($\Delta width$,$\Delta height$)% +[{\it initial-X-integer},{\it initial-Y-integer}]} + +For example, the following are all valid commands: + +\begin{quote} +\begin{verbatim} +\put(0,0){\grid(95,100)(9.5,10)} +\put(0,0){\grid(100,100)(10,5)[-10,0]} +\put(0,0){\tiny \grid(100,100)(5,5)[0,0]} % the numbers in \tiny font. +\put(50,50){\makebox(0,0){\tiny \grid(20,20)(4,4)}} +\end{verbatim} +\end{quote} + +The \verb|\grid| command makes a grid of size {\it width\/} units by {\it +height\/} units where vertical lines are drawn at intervals of $\Delta width$ +and horizontal lines at intervals of $\Delta height$. The major motivation +for this command is that making a grid in the picture initially can be +very useful when laying out pictures -- it's like having a graph underneath +the picture which can be eventually deleted or commented out. Moreover, one +might actually want a grid as an object in its own right! Figure~1 (on page +14) presents an example of this command. + +The {\it width\/} and {\it height\/} should be divisible by their respective +$\Delta$'s, otherwise the grid will not be of correct dimensions. The numbers +in \verb|[ ]| at the end are optional. Their absence makes a simple grid with +lines. Their presence makes a ``numbered'' grid with integers around the +borders where the numbers put have the starting value as specified in +\verb|[. , .]| argument and are incremented by $\Delta width$ and $\Delta +height$ respectively. If specified, then these starting numbers must be +integers. The dimensions are all in units and do not have to be integers, +although in most cases one will want integers only. There is an additional +constraint when plotting a ``numbered'' grid --- the +\mbox{``$\Delta$''-dimensions} have to be integers, since one cannot easily +generate real numbers from within \TeX. None of the errors of this kind are +caught, hence, if the grid comes out funny, one of the above-mentioned +conditions may have been violated. + +The \verb|\grid| command produces a box and thus needs to be \verb|\put| at +the required coordinates. The reference point of the grid is the bottom-left +corner and the numbers along the borders, if any, do not affect the reference +point. If it is desired to have another reference point, then the whole grid +statement may be put in a \verb|\makebox(0,0)[..]{...\grid...}| kind of +construction. + +\subsection{{\tt \bs}dottedline} + +{\tt SYNOPSIS:\\ +\hspace*{\leftmargin}% +\bs dottedline[{\it optional dotcharacter}]\lb {\it dotgap in units}\rb% +($x_1$,$y_1$)($x_2$,$y_2$)\ldots($x_n$,$y_n$)} + +The above command connects the specified points by drawing a dottedline +between each pair of coordinates. At least two points must be +specified. The dotted line is drawn with inter-dot gap as specified in the +second argument (in unitlengths). Note that since integral number of dots +have to be plotted, the interdot-gap may not necessarily be exactly as +specified, but very close. It really doesn't matter in visual appearance +except when the length of dottedline is very small. By default, a little +square (\verb|\picsquare|, described later) is used as the dot, and can be +changed by optionally specifying another character. The thickness of dots is +governed by currently effective \verb|\thinlines|, \verb|\thicklines| or +\verb|\linethickness...| declaration when the default character is used. Note +that some characters such as ``*'' in roman font do not come out centered, +although most other characters do. + +One can obtain a {\it solid line\/} by specifying a very small inter-dot gap. +Since \LaTeX\ provides for only finite number of slopes for drawing lines, +this gives a general way of making lines with arbitrary slopes. However, if +{\it solid lines\/} are made using above technique, there is a good chance +\TeX\ will run out of memory, hence it is suggested that this command be used +only for ``dotted'' lines. Another, much more efficient, way of making solid +lines is described later in the section on \verb|\drawline|. + +Each ``dot'' in the dottedline is plotted as a centered object, including +those at the end points. Thus, a dottedline with a large-sized {\it +dotcharacter\/} may appear to be longer although, technically speaking, +correct. To clarify the point, below are three lines of equal length and, in +the case of dottedlines, with equal spacing: + +\begin{center} +\begin{picture}(150,20)(0,-5) +\put(0,10){\line(1,0){70}} +\put(0,-4){\line(0,1){18}} +\put(70,-4){\line(0,1){18}} +\thicklines +\dottedline{3}(0,5)(70,5) +\dottedline[$\bullet$]{3}(0,0)(70,0) +\put(80,9){\tt \bs put(0,10)\lb \bs line(1,0)\lb 70\rb \rb } +\put(80,4){\tt \bs dottedline\lb 3\rb (0,5)(70,5)} +\put(80,-1){\tt \bs dottedline[\$\bs bullet\$]\lb 3\rb (0,0)(70,0)} +\end{picture} +\end{center} + +\subsection{{\tt \bs}dashline} + +{\tt SYNOPSIS:\\ +\hspace*{\leftmargin}% +\bs dashline[{\it stretch}]\lb{\it dash-length}\rb +[{\it inter-dot-gap for dash}]% +($x_1$,$y_1$)($x_2$,$y_2$)\ldots($x_n$,$y_n$)}\newline +where {\it stretch} is an integer between -100 and infinity. + +The above command connects the specified points by drawing a dashline +between each pair of coordinates. At least two points must be +specified. A \verb|\dashline| is a dashed line where each {\it dash\/} is +constructed using a {\it dottedline\/}% +\footnote{for efficiency, in the case of horizontal and vertical dashlines, +the dash is constructed using a rule.}. +The dash-length is the length of the {\it dash\/} and inter-dot-gap is the gap +between each dot that is used to construct the dash, both in unitlengths. + +By default, a solid looking dash is constructed, but by specifying an +inter-dot-gap in the third argument, different looking dashes may be +constructed. With a large inter-dot-gap (about $>$0.4mm), each dash will have +the appearance of a little dotted line. One can create a variety of {\it +dashlines} where each {\it dash\/} looks different. Here are a few sample +dashlines: + +\begin{center} +\begin{picture}(150,30)(0,-5) +\dashline{4}[0.7](0,18)(60,18) +\thicklines +\dashline{4}(0,11)(60,11) +\dashline[-30]{4}(0,7)(60,7) +\put(75,20){\makebox(0,0)[tl]{\tt \shortstack[l]{% +\bs dashline\lb 4\rb [0.7](0,18)(60,18)\\ +\bs thicklines \\ +\bs dashline\lb 4\rb (0,11)(60,11)\\ +\bs dashline[-30]\lb 4\rb(0,7)(60,7) +}}} +\end{picture} +\end{center} + +The {\it stretch\/} in \verb|[ ]| is an integer percentage and implies +a certain ``stretch'' for positive values and ``shrink'' for negative +values; it is optional and by default is ``0'' unless the default +itself has been changed (described later). The number ``0'' signifies +that a minimum number of dashes be put such that they are +approximately equally spaced with the empty spaces between them. A +$+$ve number means increase the number of dashes by {\it stretch} +percent, and a $-$ve number means reduce by that percent. By reducing +the number of dashes, the empty space between dashes is stretched +while maintaining the symmetry. The lower limit on {\it stretch\/} is +obviously -100 since at less than -100\% reduction one essentially +gets nothing. On the upper side, the number, theoretically, can be as +large as infinity (barring arithmetic overflows) and the macro does +not check for any upper bound; one should normally not require more +than 100 percent increase (100 $\Rightarrow$ double the number of +dashes) since that would essentially mean a ``solid line'' and it is +more efficient to use the \verb|\drawline| command for drawing such +lines, as described later. + +The idea behind the {\it stretch\/} percentage option is that if several +dashed lines of different lengths are being drawn, then all the dashed lines +with the same $-$ve or $+$ve {\it stretch\/} will have similar visual +appearance, as might be desired if one were plotting a graph --- one would +like a particular ``curve'' to look the same between all the points on that +curve. Also, it can be used to take any corrective actions, if the appearance +of the default dashline does not meet one's approval. + +The default {\it stretch\/} percentage can be changed by a +\verb|\renewcommand| on the parameter\linebreak +\verb|\dashlinestretch| any time and it takes effect immediately. The +argument is the integer percentage increase or reduction that will be +applied to all \verb|\dashline| commands except the ones in which the +percentage is explicitly given using \verb|[ ]| optional parameter. +For example, all {\it dashlines\/} could be reduced by 50 percent by +putting the following line {\it before\/} using any \verb|\dashline| +command:\\[2mm] +\hspace*{\leftmargin} +\verb|\renewcommand{\dashlinestretch}{-50} % ONLY INTEGERS PERMITTED.| + +An explicit argument to the \verb|\dashline| command in \verb|[ ]| +overrides any default values, so for instance, after the above declaration, +if a dashline with ``0'' stretch was desired, +then one would simply say:\\[2mm] +\hspace*{\leftmargin}\verb|\dashline[0]{...}(x1,y1)(x2,y2) % where "0" implies no stretch or shrink| + +A note about dashlines of small length. All dashlines always have a dash +beginning at the first coordinate and another ending at the second +coordinate, which implies that a minimum of two dashes are plotted. For small +lines (or larger lines with accordingly larger sized dashes) the dash-length +is reduced as much as necessary to meet above conditions; in such cases, if +necessary, the $-$ve stretch arguments are ignored. Such dashlines +usually do not have an acceptable appearance, and may either be omitted or be +plotted separately as a dottedline or a dashline with a small dash-length. + +\subsection{{\tt \bs}drawline} + +{\tt SYNOPSIS:\\ +\hspace*{\leftmargin}% +\bs drawline[{\it stretch}]($x_1$,$y_1$)($x_2$,$y_2$)\ldots($x_n$,$y_n$)}\\ +where {\it stretch\/} is an integer between -100 and infinity. + +The above command connects the specified points by drawing a line between +each pair of coordinates using line segments of the closest slope available +in the fonts. At the minimum two points must be specified. Since there are +only finite number of slopes available in the line segment fonts, some lines +appear jagged. A \verb|\drawline| can be thick or thin depending on the +\verb|\thinlines| or \verb|\thicklines| declaration in effect; these are the +only two thicknesses available for such lines. This is also the most +efficient, in terms of memory and cpu usage, way of drawing lines of +arbitrary slopes. + +The {\it stretch\/} parameter has properties similar to those described +earlier in the context of dashlines. It is again a percentage and implies a +certain ``stretch'' or ``shrink''; it is optional and by default is ``0'' +unless the default itself has been changed (described later). The same rules +apply to the range of the {\it stretch\/} value. In this case, the number +``0'' signifies that a minimum number of dashes be put such that the line +appears solid and each dash ``connected'' at the ends. By reducing the number +of dashes by specifying a $-$ve {\it stretch\/}, one effectively gets a +dashed line. On the other hand, by specifying a $+$ve {\it stretch\/}, more +dashes will be used in constructing the line, giving a less jagged +appearance. + +A parameter, namely, \verb|\drawlinestretch|, has been provided for +\verb|\drawline|'s and its usage is identical to \verb|\dashlinestretch| +described earlier in the context of \verb|\dashline|. + +A limitation of drawing lines using line-segment fonts is that the length of +segments is fixed and is not user-controllable. If explicit control over the +line-segment length is desired, then \verb|\dashline| may be used. +If the length of the line to be drawn is smaller than the length of available +line segment, then a solid line is constructed using \verb|\dottedline| with +dots being very close; the thickness of the {\it line\/} thus constructed is +chosen appropriately. Note that in such a case, only a solid line can be +constructed between the two points, i.e., dashed appearance can not +be given to such small lines, and any $-$ve stretch is ignored. + +\subsection{The join environments} +\begin{tt} +SYNOPSIS: +\begin{quote} +\bs jput($x$,$y$)\lb{\it object}\rb + +\bs begin\lb dottedjoin\rb[{\it optional dotcharacter}]% +\lb{\it inter-dot-gap}\rb\\ +.....\hspace*{1in} dottedlines drawn here for each \verb|\jput| statement.\\ +\bs end\lb dottedjoin\rb + +\bs begin\lb dashjoin\rb[{\it stretch}]% +\lb{\it dash-length}\rb[{\it inter-dot-gap for dash}]\\ +.....\hspace*{1in} dashlines drawn here for each \verb|\jput| statement.\\ +\bs end\lb dashjoin\rb + +\bs begin\lb drawjoin\rb[{\it stretch}]\\ +.....\hspace*{1in} drawlines drawn here for each \verb|\jput| statement.\\ +\bs end\lb drawjoin\rb + +\end{quote} +\end{tt} + +Three environments, corresponding to the three kinds of lines described +earlier, are also provided. They are {\tt dottedjoin}, {\tt dashjoin} and +{\tt drawjoin}. All the three environments use yet +another new command \verb|\jput|\footnotemark\ (join and put) which is +identical to the regular \verb|\put| command of \LaTeX\ except that it +behaves differently when in any of the three environments. + +\footnotetext{could have redefined the {\tt \bs put} statement; {\tt \bs +jput} behaves identically to {\tt \bs put} when not in any join +environment.} All {\it objects\/} put using a \verb|\jput| command within the +scope of any of the three environments are, in addition to being plotted, +joined by lines of the respective kind; in other words, a line of the +specified kind is drawn between {\it points\/} plotted using \verb|\jput| +statement in the order they are encountered; a {\it point\/} refers to the $x$ +and $y$ coordinates specified in the \verb|\jput| statement. Consecutive +\verb|\jput| statements are assumed to define adjacent points --- hence, the +input should be accordingly ordered. Moreover, the plotted point should be in +a \verb|\makebox(0,0){...}| (except, of course, centered {\it objects\/} such +as \verb|\circle| and \verb|\circle*|) if it is to be centered on the +specified coordinate; without it the object's bottom-left corner will be at +the specified coordinate. Each instance of any of the three join +environments defines a separate ``curve'' hence every set of points belonging +to different ``curves'' should be enclosed in separate join environments. + +All the parameters, optional and mandatory, other than the coordinates that +go along with the line drawing commands, may be specified after the +\verb|\begin{...join}| command as its arguments. Currently effective default +values are used when not specified in {\tt []}, and may be changed anytime +using the \verb|\renewcommand| as discussed previously. + +The primary motivation for designing the join environments is for use in +plotting graphs and joining different curves by different looking lines. +It is not necessary that the \verb|\jput| statements put some object; if +the object is null then one gets only lines --- in such a case it is much +simpler to use the respective line drawing command directly. + +\subsection{{\tt \bs}picsquare} + +\verb|\picsquare| is a simple macro that gives a little square dot with its +center as the reference point. The size of the square is dependent on the +currently effective \verb|\thinlines|, \verb|\thicklines| or +\verb|\linethickness...| declaration. Most of the commands described earlier +that plot little dots, use this macro\footnotemark. It has been provided +primarily to be used in conjunction with \verb|\putfile| command described +below. +\footnotetext{The {\tt \bs dottedline} macro actually uses another similar +macro {\tt \bs picsquare@bl}, which gives an identical square, but with the +bottom-left corner as the reference point.} +Only {\tt \bs picsquare} has been made accessible to the user. + +\subsection{{\tt \bs}putfile} + +{\tt \bs putfile\lb{\it filename}\rb\lb{\it object}\rb} + +The command \verb|\putfile| is similar to the \verb|\put| command except that +the $x$ and $y$ coordinates required by the \verb|\put| command are read from +an external file and the same {\it object} is plotted at each of those +coordinates. + +The motivation behind this command is that \TeX\ does not have the capability +to do floating point calculations which would be required if one wished +to plot any parametric curve other than straight lines. Coordinates for such +curves can be easily generated by programs in other languages and +subsequently a ``dotted'' curve can be plotted via \TeX\ or \LaTeX. Even if +coordinates for certain curves could be generated from within \TeX, it is +much more efficient to use other languages --- eventually only the +coordinates of the points are required. +For instance, one can use the Unix% +\footnote{{\it Unix} is a trademark of AT\&T.}\ facility +{\it spline\/} to generate smooth curves with equidistant ``dots''. + +{\bf Format of the External File:} The external file of coordinates must have +``$x\;y\,$'' pairs, one pair on each line, with a space between them. Also, it +is suggested that some extension such as ``{\tt .put}'' be used for such +data files to distinguish them from regular text files in which case it must +be explicitly specified in the first argument so that \TeX\ doesn't look for +a ``{\tt .tex}'' extension. + +The ``{\tt \%}'' character remains valid as a comment character and such lines +are ignored. However, there should be at least one space after the second +entry if a comment is on the same line as data since {\tt \%} eats up the +newline. + +For example, to plot a smooth curve along a set of coordinates, one may +undertake the following steps: +\begin{enumerate} +\item have a file of ``$x\;y$'' coordinates for original data points, say, +{\tt datafile}. +\item run the command (for Unix systems): {\tt spline -200 datafile $>$ +data.put} +\item in a picture environment in a \LaTeX\ file, put the command:\\ +\hspace*{20pt}\verb|\putfile{data.put}{\picsquare}|\\ +(see previous section for explanation of \verb|\picsquare|). +\end{enumerate} + +\section{General Comments} + +A few remarks about efficiency and quirks: +\begin{itemize} +\item In most of the above commands, simply typing a {\tt []} for optional +arguments with {\it nothing\/} as the value will either cause an error or will +be interpreted as a null value; hence a {\tt []} should not be typed if an +optional argument is not meant to be specified. + +\item If too many ``dots'' are to be plotted in one picture, it is suggested +that a character other than the default be used --- about 40--50\% more dots +can be plotted in a picture using a period (.) or a \verb|\bullet| +($\bullet$) in various sizes, rather than the default \verb|\picsquare|, +although the latter seems to have a better visual appearance. The +use a \verb|\picsquare| also enables one to have a better control over the +thickness of dots and lines. + +A note on efficiency: when specifying a font or a fontsize for a character +it is more efficient to say:\\ +\verb|{\tiny \dottedline[$\bullet$]{2}(0,0)(40,30)(80,10)}|,\ \ \ rather than\\ +\verb|\dottedline[\tiny $\bullet$]{2}(0,0)(40,30)(80,10)|.\\ +In the latter case, \verb|\tiny| macro gets invoked for {\it each\/} instance +of the dotcharacter \verb|$\bullet$| as the dottedline is plotted. + +\item If it is not very important as to how accurately spaced a dashed line +appears, then it is suggested that \verb|\drawline| command with a $-$ve +stretch be used instead of \verb|\dashline|, since the former is much more +cpu- and memory-efficient. + +\item \verb|\dottedline| and \verb|\dashline| come out much too thin with +\verb|\thinlines|. Moreover, the thicker the \verb|\dashline|, fewer +``dots'' are required to construct dashes resulting in lesser memory and cpu +usage. Thus, it is recommended that they be plotted with \verb|\thicklines| +in effect, or with a linethickness of about 1--2pt. + +\item In the case of \verb|\drawline|, any explicit linethickness declarations +(i.e. using \verb|\linethickness| command) are ignored. The only applicable +declarations are \verb|\thinlines| and \verb|\thicklines| since line-segment +fonts are available in only two thicknesses. +\end{itemize} + +Above commands are available in the picture environment only since they use +many of the \LaTeX 's predefined picture commands. Extensive use of some of +the internal macros and variables of \LaTeX\ has been made for efficiency +sake, even though that makes these macros vulnerable to future revisions of +\LaTeX. + +The dottedline macro gets complicated because \TeX\ does not have any builtin +facility for floating point calculations or for calculating square-roots or +trigonometric functions. The inter-dot-gap in a dottedline has to be treated +as the actual distance between two dots along the ``hypotenuse'' and not its +projected distance along x-axis or y-axis, since the latter interpretation +would result in a different {\it real\/} inter-dot-gap for different slopes; +it would be incorrect if we were joining points on a graph. The dootedline +macro treats the inter-dot-gap as the actual distance between two dots and +draws the various segments of the ``curve'' with this distance fixed. The +macro accomplishes this by estimating the actual length of the line and the +number of segments of the specified distance that will fit between the two +end-points; a macro, namely, \verb|\sqrtandstuff| calculates this +square-root. Some algebraic relations are used in estimating this square-root +and are described in appendix A. + +Beware, if far too many dots are put in one picture, \LaTeX\ will run out of +memory (box full), so be kind to it. For instance, by reducing the +inter-dot-gap to about 0.3mm in the case of a \verb|\dottedline|, one can get +essentially a solid line, but that would mean a LOT of dots and it may run +out of memory. + +If many lines using above-mentioned macros are drawn, then a +\verb|\clearpage| ought to be put at judicious places in the document so as +to tell \LaTeX\ not to keep those figures floating -- \LaTeX\ sometimes +keeps entire figures in memory while trying to figure out how and where to +lay them and it can frequently run out of memory. A \verb|\clearpage| may +prevent running out of memory and may reduce execution times. +In case of such a +memory-full error message, a \verb|\clearpage| in the region where the error +occurred should be attempted first and if that does not help then the number +of ``dots'' in the picture will have to be reduced. + +A word about \verb|\drawline| is in order. \LaTeX 's \verb|\line| command +takes an ordered pair of integers to specify the slope of the line where the +numbers are between $-$6 and 6 such that the least common divisor is 1. For +the \verb|\drawline| command, the given arbitrary slope has to be mapped to +the pair of integers representing the {\it closest\/} available slope. +Another macro, \verb|\lineslope| is used to accomplish this task. The macro +\verb|\lineslope| takes two arguments, the base and the height of the +triangle whose hypotenuse represents the line to be drawn and returns the +ordered pair of integers representing the closest slope; using a line segment +of that slope, a jagged line between the two specified end-points is then +constructed. More details can be found in the macro file {\tt epic.sty}. + +As noted earlier, the command \verb|\jput| behaves identically as \verb|\put| +when not in any of the join environments. The author considered obliterating +the \verb|\put| command too radical a step. Also, there should have been a +command \verb|\jputfile| corresponding to the \verb|\jput| command (like the +\verb|\putfile| command) but that was considered unnecessary since typically +the number of coordinates plotted in a join environment would be an order +less than what might be the case with \verb|\putfile| and can be easily +typed explicitly in the document using \verb|\jput| commands. +However, if it is desired to have all the \verb|\put| commands treated as +though they were \verb|\jput|, the following declaration may be used:\\ +\hspace*{\leftmargin}\verb|\let\put\jput| \\ +Above declaration will make all +the \verb|\put| commands be treated as \verb|\jput|; in particular, +\verb|\putfile| command would then behave as though it were a +\verb|\jputfile| when in any of the join environments. However, it is +suggested that such ``tricks'' be used with care. + +Finally, commands to plot vectors of arbitrary slopes have not been +implemented. One way to plot them is to plot a line, and subsequently plot a +\verb|\vector| of appropriate slopes and length zero at the required place. + +Following pages contain some examples. The test-sample picture for +\verb|\drawline| command (Figure~2) is also about the maximum amount of +objects that one can put in one picture. Older versions of \TeX\ and \LaTeX\ +may not be able to print pictures of this size. + +\newpage +%% FIGURES FOLLOW +\begin{figure}[t] +\begin{center} +\input{picman-fig1} +\end{center} +\caption[]{\normalsize An Example of Various Line Drawing Commands} +\end{figure} + +\begin{small} +\verbfile{picman-fig1} +\end{small} + +\newcount\xjunk +\newcount\yjunk + +\clearpage +\begin{figure} +\begin{center} +\begin{tiny} +\begin{picture}(140,140)(-70,-70) +\thinlines +\input{picman-fig2} +\end{picture} +\end{tiny} +\end{center} +\caption[]{\normalsize Test Sample: Lines of various slopes with +{\tt thinlines}} +\end{figure} + +\clearpage +\begin{figure} +\begin{center} +\begin{tiny} +\begin{picture}(140,140)(-70,-70) +\renewcommand{\drawlinestretch}{-50} +\thicklines +\input{picman-fig2} +\end{picture} +\end{tiny} +\end{center} +\caption[]{\normalsize \parbox[t]{110mm}{Test Sample: Dashed lines of various +slopes using {\tt \bs drawline} command with {\tt linethickness=1pt} and {\tt +drawlinestretch = -50}}} + +\end{figure} + +\clearpage +\renewcommand{\baselinestretch}{0.85} +\begin{footnotesize} +\verbfile{picman-fig3} +\end{footnotesize} + +\clearpage +\input{picman-fig3} + +\clearpage +\section{Installation and Usage of the Package} +This package of new commands for the picture environment has been implemented +as a documentstyle option ``{\tt epic}''. To include these commands, ``epic'' +should be added as an option in the \verb|\documentstyle| command, +e.g.:\\[1mm] +\hspace*{\leftmargin}\verb|\documentstyle[epic]{article}| + +For the above option to work, one of the following will have to be done prior +to its use: +\begin{enumerate} +\item A copy of the macro file {\tt epic.sty} be put in the standard place for +such macros (typically {\tt /usr/lib/tex/macros}), or + +\item A copy of {\tt epic.sty} be put in some other directory, and the path +declared in the environment variable TEXINPUTS; e.g.\ for C-shell on unix +systems, put a command similar to the following in the ``.cshrc'' file:\\[1mm] +\hspace*{20pt}{\tt setenv TEXINPUTS .:/usr/lib/tex/macros:/users/podar/texlib} +\end{enumerate} + +Above environment variable is the directory search path for files specified +in an \verb|\input| or an \verb|\openin| command. + +\section{Concluding Remarks} +The implementation of the new commands for the picture environment has been +done with the \LaTeX\ version 2.09 and \TeX\ version 2. They have also been +tested to work with \LaTeX\ version 2.08. These commands may not work with +earlier versions of \TeX\ and \LaTeX. + +Most of the commands have been tested fairly thoroughly. +No major revisions are anticipated in the near +future, except, of course, bug fixes. The author welcomes any comments, +constructive or otherwise, suggestions for improvements, any ideas for +possible future revisions and, of course, bugs. It is also requested that he +be informed of any significant changes or modifications made to these +macros. + +All the help and encouragement from colleagues in the Dept. of Computer +Science at SUNY at Stony Brook is gratefully acknowledged; in particular, +Soumitra Sengupta's and Divyakant Agrawal's criticisms (often constructive), +help with proofreading the numerous versions of this report and general moral +support were critical to the completion of this project and are thankfully +acknowledged. + +\bigskip\noindent% +\begin{small}% +Author's address:\\[3mm] +\begin{tabular}{@{}ll} +USMAIL:&Dept. of Computer Science, SUNY at Stony Brook, Stony Brook, +N.Y.\ 11794\\ +CSNET: &podar@sbcs.csnet\\ +ARPA: &podar\%suny-sb.csnet@csnet-relay.arpa\\ +UUCP: &\{allegra, hocsd, philabs, ogcvax\}!sbcs!podar +\end{tabular} +\end{small} + +\begin{thebibliography}{99} +\bibitem{Knu} D.\ E.\ Knuth, ``The \TeX book'', Addison-Wesley Publishing Co., +1984. +\bibitem{Lam} L.\ Lamport, ``\LaTeX: A Document Preparation System'', +Addison-Wesley Publishing Co., 1986. +\end{thebibliography} + +\input{sqrt} + +\end{document} diff --git a/macros/latex/contrib/epic/sqrt.tex b/macros/latex/contrib/epic/sqrt.tex new file mode 100644 index 0000000000..cf27036797 --- /dev/null +++ b/macros/latex/contrib/epic/sqrt.tex @@ -0,0 +1,106 @@ +\appendix +%\section{Estimating Pythagorean Square-root} +\medskip\noindent +{\Large\bf Appendix A\ \ \ Estimating Pythagorean Square-root} + +\medskip\noindent +For the line drawing commands described in the main sections of this +document, we need to estimate the Pythagorean square-root in order to +determine the length of the line (along its slope). More precisely, we need +to estimate the number of segments of a given length needed to draw a line. +\TeX\ does not provide for floating point calculations, and thus there are no +direct means of calculating the above square-root. Most standard numerical +techniques are iterative and would be too slow when used with \TeX\ for lack +of floating point calculations, and in particular, real division, since +calculation of such a square-root is needed very frequently. + +A simple non-iterative formula for estimating the square-root is derived and +described below. + +\bigskip\noindent +{\bf Problem: } Given $a$ and $b$, to find $c$ = $\sqrt{a^2 + b^2}$ using +only operations in \{$+,-,*,/$\}. + +We can get very tight bounds on the square-root as follows. +Without loss of generality, let $a \ge b$. We seek a simple $n$ +such that: +\[\sqrt{a^2 + b^2} \ge a + \frac{b}{n}\] + +Squaring both sides, we have +\[\begin{array}{lrcl} +\Leftrightarrow & a^2+b^2 &\ge& a^2 + \displaystyle\frac{b^2}{n^2} + +\displaystyle\frac{2ab}{n} \\[2mm] +\Leftrightarrow & (1 - \displaystyle\frac{1}{n^2}) b^2 &\ge& +\displaystyle\frac{2ab}{n}\\[2mm] +\Leftrightarrow & \displaystyle\frac{b}{a} &\ge& \displaystyle\frac{2n}{(n^2 +-1)}\\[2mm] +\mbox{or } & (\displaystyle\frac{b}{a})n^2 - 2n -(\displaystyle +\frac{b}{a}) &\ge& 0 +\end{array}\hfill\] + +>From the quadratic equation above, we finally get an expression for $n$, +\[ n \;=\; \frac{2 \pm \sqrt{4 + 4(\frac{b}{a})^2}}{\frac{2b}{a}} + \;=\; \frac{1 \pm \sqrt{1 + (\frac{b}{a})^2}}{\frac{b}{a}} \] + +Only the $+$ve root interests us since $n$ has to be positive. +Note that the term under the root is bounded above and below (since +$\frac{b}{a} \le 1$): +\[1 \;\le\; \sqrt{1 + (\frac{b}{a})^2} \;\le\; \sqrt{2}\] + +Hence, we have two values for $n$, +\[ n_l\;=\; \frac{1+1}{\frac{b}{a}} \;=\; \frac{2a}{b};\;\;\;\;\;\;\;\;\;\; +n_u \;=\; \frac{1+ \sqrt{2}}{\frac{b}{a}} \;=\; \frac{(1+ \sqrt{2})a}{b} +\] +% +which finally gives us a lower and an upper bound for $c$, the Pythagorean +square-root, +\[ a + \frac{b^2}{(1+ \sqrt{2})a} \;\le\; c \;\le\; a + \frac{b^2}{2a}\] + +These are very tight bounds. Denoting the lower bound as $c_l$ and upper +one $c_u$, below are some numerical results ($c$ = exact square-root): + +\begin{center} +\begin{tabular}{|c|c|c|c|c|} +\hline +a & b & c & $c_l$ & $c_u$\\ +\hline +100.0 & 100.0 & 141.4213 & 141.4213 & 150.0\ \ \ \ \ \ \\ +100.0 & \ \,80.0 & 128.0642 & 126.5096 & 132.0\ \ \ \ \ \ \\ +\ \,30.0 & \ \,20.0 & \ \,36.0555 & \ 35.5228 & \ 36.6667 \\ +\hline +\end{tabular} +\end{center} + +With the above bounds, one can do a linear interpolation to get exact values. +In our case, since it is not required to be {\it extremely\/} accurate, for +estimating the square-root in the line drawing commands, +we simply take the midpoint of the two bounds. For small +numbers, which is expected to be the case most of the time, +the error is very small. + +With some algebra, we get the mid-point estimate of $c$, +\[c = \frac{c_l+c_u}{2} = a + \frac{b^2 * (3 + \sqrt{2})}{a*4*(1 + \sqrt{2})} += a + \frac{0.457\: b^2}{a} \;\;\;\;(a \ge b) \] + +The macro \verb|\sqrtandstuff| uses the above formula for estimating the +number of points (for \verb|\dottedline| macro) and number of segments (for +\verb|\dashline| macro). The \verb|\sqrtandstuff| macro, instead of +calculating the length of the line, directly calculates the {\it number\/} of +segments of a given length. For example, to draw a dotted line from +($x_1,y_1$) to ($x_2,y_2$) with the inter-dot-gap as $d$, we estimate the +number of dots $n$ using the following expression, +\[ n= \frac{\Delta x}{d} + +\frac{0.457\:(\frac{\Delta y}{d})^2}{\frac{\Delta x}{d}} \;\;\;\;\;\;\; +\Delta x = |x_2 - x_1| \mbox{ and } \Delta y = |y_2 - y_1|\] +assuming $\Delta x \ge \Delta y$ (otherwise they may be inter-changed). + +Note that since divisions in \TeX\ are integer-divisions, it is simpler to +deal in ``number of segments'' rather than actual lengths +(e.g. in the expression above, $\frac{\Delta x}{d} = $ number of segments +along X-axis). + +\noindent +{\bf Caveat:} The approach presented here for estimation of +Pythagorean square-root is an independent effort by the author. It may +already exist in the literature --- the author is neither aware of it nor has +he made any serious attempts at uncovering it. -- cgit v1.2.3