diff options
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/gastex/gastex.sty | 514 |
1 files changed, 403 insertions, 111 deletions
diff --git a/Master/texmf-dist/tex/latex/gastex/gastex.sty b/Master/texmf-dist/tex/latex/gastex/gastex.sty index a9f0a8ad43b..9fbb83909b1 100644 --- a/Master/texmf-dist/tex/latex/gastex/gastex.sty +++ b/Master/texmf-dist/tex/latex/gastex/gastex.sty @@ -1,41 +1,118 @@ -\NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{gastex}[2006/11/28 v2.8] -\newif\ifgastexslide\gastexslidefalse -\DeclareOption{slide}{\global\gastexslidetrue} -\DeclareOption{paper}{\global\gastexslidefalse} -\ProcessOptions -\RequirePackage{calc,trig} -\special{header=gastex.pro} -% \input gastex.ps - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% GasTeX : Graphs and Automata Simplified in TeX %% %% Macros for drawing easily graphs and automata under the picture -%% environment of LaTeX2e. -%% See the README file +%% environment of LaTeX. +%% See the README file. %% %% Paul Gastin -%% LSV -%% ENS de Cachan -%% 61, avenue du Prˇsident Wilson -%% F-94235 CACHAN Cedex +%% LMF +%% ENS Paris-Saclay +%% 4, Avenue des Sciences +%% F-91190 Gif-sur-Yvette %% FRANCE -%% http://www.lsv.ens-cachan.fr/~gastin/ +%% mail: paul.gastin@ens-paris-saclay.fr +%% http://www.lsv.fr/~gastin/ %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% A lot of changes has been made since gastex 1.0 and as a result, -% these new macros are no longer compatible with the previous ones. -% To be able to use old pictures, a compatible mode is provided -% (see \compatiblegastexun at the end of the file). The compatibility -% is almost 100% and should be sufficient in most cases. -% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gastex}[2013/10/01 v3.0] +\RequirePackage{ifpdf} +\RequirePackage{xkeyval} +\RequirePackage{xifthen} +\RequirePackage{calc} +\RequirePackage{trig} +\RequirePackage{environ} +\RequirePackage{xcolor} +\RequirePackage{graphicx} +\newif\ifgastexslide\gastexslidefalse +\DeclareOptionX{slide}{\global\gastexslidetrue} +\DeclareOptionX{paper}{\global\gastexslidefalse} +% +\define@boolkey{gastex.sty}[gastex@]{pdflatex}[true]{} +\PassOptionsToPackage{final}{pst-pdf} +% +\newif\ifgastex@autopstpdf\gastex@autopstpdffalse +\newif\ifgastex@mdfive\gastex@mdfivefalse +\define@choicekey*{gastex.sty}{recompilepics}[\g@val\g@nr]{auto,true,false}[auto]{% + \ifcase\g@nr\relax +% During the latex+dvips+ps2pdf run, the md5 computations and checks should not +% be executed. Hence, we check whether pdftex is running in pdf mode. + \ifpdf\gastex@mdfivetrue\else\gastex@mdfivefalse\fi + \gastex@autopstpdftrue + \PassOptionsToPackage{off}{auto-pst-pdf} + \or + \ifpdf\gastex@mdfivetrue\else\gastex@mdfivefalse\fi + \gastex@autopstpdftrue + \PassOptionsToPackage{on}{auto-pst-pdf} + \or + \gastex@mdfivefalse + \gastex@autopstpdffalse + \PassOptionsToPackage{off}{auto-pst-pdf} + \fi +} +\ExecuteOptionsX{recompilepics=false} % if not set when loading gastex.sty, this option is off +% +\define@choicekey*{gastex.sty}{pst-pdf}[\g@val\g@nr]{md5,auto,final,draft,off}[md5]{% + \PackageWarning{gastex}{Option pst-pdf is depreciated. Use options pdflatex + and recompilepics instead.}{} +} +% \ExecuteOptionsX{pst-pdf=off} % if not set when loading gastex.sty, this option is off +% +\DeclareOptionX*{\PassOptionsToPackage{\CurrentOption}{auto-pst-pdf}} +\ProcessOptionsX +% if it exists, the md5 file should be read now to set the option of +% auto-pst-pdf to on if some pictures have changed +\def\g@hashfilename{\jobname-md5.txt}% +\def\g@extract@mdfive:#1:#2:#3:{\expandafter\edef\csname g@oldmdfive@#2\endcsname{#3}}% +\def\g@changed@mdfive!#1!{\PassOptionsToPackage{on}{auto-pst-pdf}}% +\def\g@read@mdfive#1{\@ifnextchar:{\g@extract@mdfive}{\g@changed@mdfive}#1}% +\def\g@process@mdfivefile{% + \newif\ifnot@eof\not@eoffalse + \IfFileExists{\g@hashfilename}{% + \openin2 = "\g@hashfilename"% + \loop% + \read 2 to \g@md% + \ifeof 2 \not@eoffalse\else\not@eoftrue\fi% + \ifnot@eof% + \expandafter\g@read@mdfive\expandafter{\g@md}% + \repeat% + \closein2}{}}% +\ifgastex@mdfive\g@process@mdfivefile\fi +% +\ifgastex@pdflatex + \ifgastex@autopstpdf + \RequirePackage{auto-pst-pdf} + \else + \RequirePackage{pst-pdf} + \fi +\else + \special{header=gastex.pro} +\fi +% \input gastex.ps %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % History since version 2.0 % +% 3.0 +% Many changes in this release. +% - Compatibility with pdflatex using auto-pst-pdf. +% - New gpicture environment and new gusepicture command. +% - New command to draw an arc of circle or a pie (See ex-gastex.tex) +% \drawarc[linecolor=black](0,10,20,0,45) +% \drawarc[arcPie=y,linecolor=blue](0,10,20,-50,-15) +% - New command to draw a snaky line (See ex-gastex.tex) +% \drawsnake[linecolor=red,snakeh=.8,snakew=.8](20,15.5)(20,8.5) +% \drawsnake[linecolor=red,snakeh=.8,snakew=.8](0,7.5)(0,0.5) +% +% 2.9: +% - added the parameters loopwidth and loopheight to be able to set +% independently the width and height of loops. loopdiam still exists and set +% both loopwidth and loopheight to the same value. +% - added the example "ex-gastex-pdflatex.tex" which contains instructions how +% to use gastex directly with pdflatex using the package auto-pst-pdf +% % 2.8: % - packaged for CTAN % @@ -131,6 +208,14 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % +% A lot of changes has been made since gastex 1.0 and as a result, +% these new macros are no longer compatible with the previous ones. +% To be able to use old pictures, a compatible mode is provided +% (see \compatiblegastexun at the end of the file). The compatibility +% is almost 100% and should be sufficient in most cases. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Known problems and (hopefully) solutions. % % 21/10/99: Frank Goertzen (frank.goertzen@unibw-muenchen.de) has @@ -279,8 +364,12 @@ % With a positive/negative value the curved edge is on the left/right % of the line joining the two nodes. % +% loopwidth=number +% width in \unitlength of (vertical) loops +% loopheight=number +% height in \unitlength of (vertical) loops % loopdiam=number -% diameters in \unitlength of loops +% width and height in \unitlength of (vertical) loops % loopangle=number % direction in degree of loops % loopCW=y or n @@ -375,57 +464,56 @@ % angle in degrees with respect to the x axis of the first vertex % of the regular polygon. % -\def\gasset#1{\gas@set#1,&}% -\def\gas@set#1=#2,{\ignorespaces% - \@ifundefined{gasset@#1} - {\PackageWarning{gastex}{Parameter #1 undefined}{}} - {\csname gasset@#1\endcsname{#2}}% - \@ifnextchar&{\gas@gobble}{\gas@set}} +\def\gasset#1{\setkeys*[]{gastex}{#1}}% -\def\gasset@Nw#1{% +\define@key[]{gastex}{Nw}{% \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} \edef\N@w{\thecnt@a}}% -\def\gasset@Nh#1{% +\define@key[]{gastex}{Nh}{% \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} \edef\N@h{\thecnt@a}}% -\def\gasset@Nmr#1{% +\define@key[]{gastex}{Nmr}{% \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} \edef\N@mr{\thecnt@a}}% \newif\if@wadjust \newif\if@hadjust \newif\if@nadjust -\def\gasset@Nadjust#1{% +\define@key[]{gastex}{Nadjust}{% \@wadjustfalse \@hadjustfalse \gasset@@Nadjust #1&} \def\gasset@@Nadjust#1{% \@ifundefined{if@#1adjust} {\PackageWarning{gastex}{Node adjust #1 undefined}{}} {\csname @#1adjusttrue\endcsname}% \@ifnextchar&{\gas@gobble}{\gasset@@Nadjust}} -\def\gasset@Nadjustdist#1{% +\define@key[]{gastex}{Nadjustdist}{% \setcounter{cnt@a}{2*\ratio{#1\unitlength}{\d@my@unit}} \edef\N@adjustdist{\thecnt@a}}% -\newif\if@frame \newif\if@fill \newif\if@ExtNL +\newif\if@frame \newif\if@fill \newif\if@ExtNL \newif\if@arcPie \def\flag@y{\relax}\def\flag@n{\relax} -\def\gasset@Nframe#1{% +\define@key[]{gastex}{Nframe}{% \@ifundefined{flag@#1} {\PackageWarning{gastex}{Nframe value should be y or n}{}} {\if#1y \@frametrue \else \@framefalse \fi}} -\def\gasset@Nfill#1{% +\define@key[]{gastex}{Nfill}{% \@ifundefined{flag@#1} {\PackageWarning{gastex}{Nfill value should be y or n}{}} {\if#1y \@filltrue \else \@fillfalse \fi}} -\def\gasset@ExtNL#1{% +\define@key[]{gastex}{ExtNL}{% \@ifundefined{flag@#1} {\PackageWarning{gastex}{ExtNL value should be y or n}{}} {\if#1y \@ExtNLtrue \else \@ExtNLfalse \fi}} +\define@key[]{gastex}{arcPie}{% + \@ifundefined{flag@#1} + {\PackageWarning{gastex}{arcPie value should be y or n}{}} + {\if#1y \@arcPietrue \else \@arcPiefalse \fi}} -\def\gasset@NLangle#1{\edef\NL@angle{#1}}% -\def\gasset@NLdist#1{% +\define@key[]{gastex}{NLangle}{\edef\NL@angle{#1}}% +\define@key[]{gastex}{NLdist}{% \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} \edef\NL@dist{\thecnt@a}}% \newif\if@imark \newif\if@fmark \newif\if@rmark \newif\if@nmark -\def\gasset@Nmarks#1{% +\define@key[]{gastex}{Nmarks}{% \@imarkfalse \@fmarkfalse \@rmarkfalse \gasset@@Nmarks #1&} \def\gasset@@Nmarks#1{% \@ifundefined{if@#1mark} @@ -433,79 +521,86 @@ {\csname @#1marktrue\endcsname}% \@ifnextchar&{\gas@gobble}{\gasset@@Nmarks}} -\def\gasset@ilength#1{% +\define@key[]{gastex}{ilength}{% \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} \edef\i@length{\thecnt@a}}% -\def\gasset@iangle#1{\edef\i@angle{#1}}% -\def\gasset@flength#1{% +\define@key[]{gastex}{iangle}{\edef\i@angle{#1}}% +\define@key[]{gastex}{flength}{% \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} \edef\f@length{\thecnt@a}}% -\def\gasset@fangle#1{\edef\f@angle{#1}}% -\def\gasset@rdist#1{% +\define@key[]{gastex}{fangle}{\edef\f@angle{#1}}% +\define@key[]{gastex}{rdist}{% \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} \edef\rep@dist{\thecnt@a}}% -\def\gasset@sxo#1{% +\define@key[]{gastex}{sxo}{% \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} \edef\E@sxo{\thecnt@a}}% -\def\gasset@syo#1{% +\define@key[]{gastex}{syo}{% \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} \edef\E@syo{\thecnt@a}}% -\def\gasset@exo#1{% +\define@key[]{gastex}{exo}{% \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} \edef\E@exo{\thecnt@a}}% -\def\gasset@eyo#1{% +\define@key[]{gastex}{eyo}{% \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} \edef\E@eyo{\thecnt@a}}% -\def\gasset@curvedepth#1{% +\define@key[]{gastex}{curvedepth}{% \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} \edef\curve@depth{\thecnt@a}}% -\def\gasset@loopdiam#1{% +\define@key[]{gastex}{loopwidth}{% + \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} + \edef\loop@width{\thecnt@a}}% +\define@key[]{gastex}{loopheight}{% \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} - \edef\loop@diam{\thecnt@a}}% -\def\gasset@loopangle#1{\edef\loop@angle{#1}}% + \edef\loop@height{\thecnt@a}}% +\define@key[]{gastex}{loopdiam}{% + \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} + \edef\loop@width{\thecnt@a}% + \edef\loop@height{\thecnt@a}}% +\define@key[]{gastex}{loopangle}{\edef\loop@angle{#1}}% \newif\if@loopCW -\def\gasset@loopCW#1{% +\define@key[]{gastex}{loopCW}{% \@ifundefined{flag@#1} {\PackageWarning{gastex}{loopCW value should be y or n}{}} {\if#1y \@loopCWtrue \else \@loopCWfalse \fi}} -\def\gasset@AHnb#1{\edef\AH@nb{#1\space}}% -\def\gasset@AHdist#1{% +\define@key[]{gastex}{AHnb}{\edef\AH@nb{#1\space}}% +\define@key[]{gastex}{AHdist}{% \dim@x=#1\unitlength \edef\AH@d{\strip@PT\dim@x}}% -\def\gasset@AHangle#1{\edef\AH@angle{#1\space}}% -\def\gasset@AHLength#1{% +\define@key[]{gastex}{AHangle}{\edef\AH@angle{#1\space}}% +\define@key[]{gastex}{AHLength}{% \dim@x=#1\unitlength \edef\AH@L{\strip@PT\dim@x}}% -\def\gasset@AHlength#1{% +\define@key[]{gastex}{AHlength}{% \dim@x=#1\unitlength \edef\AH@l{\strip@PT\dim@x}}% -\def\gasset@ATnb#1{\edef\AT@nb{#1\space}}% -\def\gasset@ATdist#1{% +\define@key[]{gastex}{ATnb}{\edef\AT@nb{#1\space}}% +\define@key[]{gastex}{ATdist}{% \dim@x=#1\unitlength \edef\AT@d{\strip@PT\dim@x}}% -\def\gasset@ATangle#1{\edef\AT@angle{#1\space}}% -\def\gasset@ATLength#1{% +\define@key[]{gastex}{ATangle}{\edef\AT@angle{#1\space}}% +\define@key[]{gastex}{ATLength}{% \dim@x=#1\unitlength \edef\AT@L{\strip@PT\dim@x}}% -\def\gasset@ATlength#1{% +\define@key[]{gastex}{ATlength}{% \dim@x=#1\unitlength \edef\AT@l{\strip@PT\dim@x}}% \def\ELside@l{\relax}\def\ELside@r{\relax} -\def\gasset@ELside#1{% +\define@key[]{gastex}{ELside}{% \@ifundefined{ELside@#1} {\PackageWarning{gastex}{ELside value should be l or r}{}} {\edef\EL@s{#1}}}% -\def\gasset@ELpos#1{ +\define@key[]{gastex}{ELpos}{ \ifnum#1>100 \PackageWarning{gastex}{ELpos value should be between 0 and 100}{} \else\ifnum#1<0 \PackageWarning{gastex}{ELpos value should be between 0 and 100}{} \else\edef\EL@p{#1}\fi\fi}% -\def\gasset@ELdist#1{% +\define@key[]{gastex}{ELdist}{% \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} \edef\EL@dist{\thecnt@a}}% \newif\if@ELdistC -\def\gasset@ELdistC#1{% +\define@key[]{gastex}{ELdistC}{% \@ifundefined{flag@#1} {\PackageWarning{gastex}{ELdistC value should be y or n}{}} {\if#1y \@ELdistCtrue \else \@ELdistCfalse \fi}} @@ -520,8 +615,8 @@ \def\gas@recode#1,{\edef\gas@tmp@col{\gas@tmp@col #1 }% \@ifnextchar&{\gas@gobble}{\gas@recode}} -\def\gasset@linegray#1{\edef\line@color{#1 setgray\space}}% -\def\gasset@linecolor#1{\@ifundefined{extractcolorspec}% +\define@key[]{gastex}{linegray}{\edef\line@color{#1 setgray\space}}% +\define@key[]{gastex}{linecolor}{\@ifundefined{extractcolorspec}% {\@ifundefined{\string\color @#1} {\PackageWarning{gastex}{Color #1 undefined}{}} {\edef\line@color{#1\space}}}% @@ -529,8 +624,8 @@ \expandafter\gas@color\gas@tmp@color% \edef\line@color{\gas@tmp@col\space}}}% -\def\gasset@fillgray#1{\@filltrue\edef\fill@color{#1 setgray\space}}% -\def\gasset@fillcolor#1{\@ifundefined{extractcolorspec}% +\define@key[]{gastex}{fillgray}{\@filltrue\edef\fill@color{#1 setgray\space}}% +\define@key[]{gastex}{fillcolor}{\@ifundefined{extractcolorspec}% {\@ifundefined{\string\color @#1} {\PackageWarning{gastex}{Color #1 undefined}{}} {\@filltrue\edef\fill@color{#1\space}}}% @@ -538,9 +633,9 @@ \expandafter\gas@color\gas@tmp@color% \@filltrue\edef\fill@color{\gas@tmp@col\space}}}% -\def\gasset@linewidth#1{% +\define@key[]{gastex}{linewidth}{% \dim@x=#1\unitlength \edef\line@width{\strip@PT\dim@x}}% -\def\gasset@dash#1{\gasset@@dash #1}% +\define@key[]{gastex}{dash}{\gasset@@dash #1}% \def\gasset@@dash#1#2{% \def\gas@dash{[}% \gas@convert 0 #1 & @@ -551,15 +646,23 @@ \ifdim\dim@x=0pt\else\edef\gas@dash{\gas@dash\strip@PT\dim@x}\fi% \@ifnextchar&{\gas@gobble}{\gas@convert}} -\def\gasset@arcradius#1{% +\define@key[]{gastex}{arcradius}{% \dim@x=#1\unitlength \edef\arc@radius{\strip@PT\dim@x}}% -\def\gasset@polyangle#1{\edef\poly@angle{#1}}% +\define@key[]{gastex}{polyangle}{\edef\poly@angle{#1}}% + +\define@key[]{gastex}{snakew}{% + \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} + \edef\snake@w{\thecnt@a}}% + +\define@key[]{gastex}{snakeh}{% + \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} + \edef\snake@h{\thecnt@a}}% %----------------------------------------------------------------------- % Default settings \unitlength=1mm \gasset{Nw=8,Nh=8,Nmr=4} % circle -\gasset{Nframe=y} +\gasset{Nframe=y,arcPie=n} \gasset{fillgray=0,Nfill=n} % Not filled but black if filled \gasset{ExtNL=n,NLangle=90,NLdist=0} \gasset{iangle=180,ilength=5} @@ -577,6 +680,7 @@ \gasset{linegray=0} % black lines \gasset{linewidth=0.14,dash={}0} % continuous path \gasset{arcradius=0,polyangle=0} % sharp angles +\gasset{snakew=2,snakeh=1} % width and height of snake waves % Settings for slides \ifgastexslide @@ -585,6 +689,84 @@ \gasset{ATdist=2.1,ATLength=2.25,ATlength=2.1} \fi +%%%%%%%%%%% NEW FOR MD5 %%%%%%%%%%%%%%%%%%%%%%%%%%% +\newif\if@picthavechanged\@picthavechangedfalse +\def\g@cstocheckmdfive#1{\expandafter\def\csname cs@#1\endcsname{\relax}}% +\def\g@check@mdfive#1#2{% #1 is the pict number, #2 is the new md5 + \@ifundefined{g@oldmdfive@#1}{\global\@picthavechangedtrue% + \immediate\write 2 {!pict #1 has changed!}}{% +% This is my way of testing whether the old and new md5 are equal + \g@cstocheckmdfive{\csname g@oldmdfive@#1\endcsname}% + \@ifundefined{cs@#2}{\global\@picthavechangedtrue% + \immediate\write 2 {!pict #1 has changed!}}{}}% +} +\def\g@mdfivemsg{\if@picthavechanged% + \PackageWarning{gastex}{Pictures have changed. Compile once more}% + \fi} +\ifgastex@mdfive + \AtBeginDocument{\immediate\openout2 = "\g@hashfilename"}% + \AtEndDocument{\immediate\closeout2 \g@mdfivemsg}% +\fi +%%%%%%%%%%% NEW FOR AUTO-PST-PDF %%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcounter{g@cnt@pict}\setcounter{g@cnt@pict}{0}% +\define@cmdkeys[]{gastex}{name} +\define@boolkey[]{gastex}{frame}[true]{\ifgastex@pdflatex\setkeys*{Gin}{frame=#1}\fi} +% +\long\def\g@normalpicture(#1)(#2)#3&g@stex&{% + \begin{picture}(#1)(#2)\nullfont% + \ifgastex@frame\put(#2){{\unitlength=1mm\gasset{linewidth=0.05}}\drawrect[Nfill=n](0,0,#1)}\fi + #3 + \end{picture}}% +% +\long\def\g@pdfpicture(#1,#2)(#3,#4)#5&g@stex&{{% + \begin{postscript}\special{header=gastex.pro}% + \begin{picture}(#1,#2)(#3,#4)\nullfont% + #5 + \end{picture}% + \end{postscript}% +}}% +% +\long\def\g@picture#1{\@ifnextchar({\g@@picture}{\g@@picture(10,10)}#1&g@stex&}% +% +\long\def\g@@picture(#1)#2&g@stex&{% + \ifgastex@pdflatex% + \@ifnextchar({\g@pdfpicture(#1)}{\g@pdfpicture(#1)(0,0)}#2&g@stex&% + \else% + \@ifnextchar({\g@normalpicture(#1)}{\g@normalpicture(#1)(0,0)}#2&g@stex&% + \fi% +}% +% +\NewEnviron{gpicture}[1][]{{% + \gasset{#1}% +% \let\g@opt@Gin=\XKV@rm% + \setrmkeys*{Gin}% + \expandafter\g@picture\expandafter{\BODY}% + \refstepcounter{g@cnt@pict}% + \ifgastex@mdfive% + \xdef\g@lastmdfive{\pdfmdfivesum{\meaning\BODY}}% + \gsavepicture{\g@lastmdfive}% + \immediate\write 2 {:md5 of pict:\theg@cnt@pict:\g@lastmdfive:}% + \g@check@mdfive{\theg@cnt@pict}{\g@lastmdfive}% + \fi% + \@ifundefined{cmdgastex@name}{}{\gsavepicture{\cmdgastex@name}}% +% \ifGin@ignore\else\gusepicture[\g@opt@Gin]{\g@lastmdfive}\fi% +}} % [\gusepicture[\g@opt@Gin]{\g@lastmdfive}\ignorespacesafterend] +% +% I define alternate versions of \savepicture and \usepicture since the ones +% from pst-pdf do not work properly (at least not as I expect). +\def\gsavepicture#1{\expandafter\xdef\csname ppf@@@#1\endcsname{\theg@cnt@pict}}% +% +\newcommand\gusepicture[2][]{% + \ifgastex@pdflatex% + \@ifundefined{ppf@@@#2}{\usepicture[#1]{#2}}{% + \usepicture[#1]{\csname ppf@@@#2\endcsname}}% + \else% + \PackageWarning{gastex}{gusepicture is not available when pdflatex option of gastex.sty is not set (to true)}\relax% + \fi} +% \tracingonline=1 +% \tracingmacros=1 +% \tracingcommands=1 + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Nodes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -607,7 +789,7 @@ % and the parameters Nframe=n,Nfill=n \def\rpnode#1(#2)(#3)(#4)#5{{% \@ifnextchar[{\process@rpnodeopt}{\rp@node}#1(#2)(#3)(#4){#5}}} -\def\process@rpnodeopt[#1]{\gas@set#1,&\rp@node}% +\def\process@rpnodeopt[#1]{\gasset{#1}\rp@node}% \def\rp@node(#1)(#2,#3)(#4,#5)#6{{% % The value -1 assigned to node@#1@w characterizes polygonal nodes \global\expandafter\edef\csname node@#1@w\endcsname{-1}% @@ -658,7 +840,7 @@ % and the parameters Nframe=n,Nfill=n \def\node#1(#2)(#3,#4)#5{{% \@ifnextchar[{\process@nodeopt}{\i@node}#1(#2)(#3,#4){#5}}} -\def\process@nodeopt[#1]{\gas@set#1,&\i@node}% +\def\process@nodeopt[#1]{\gasset{#1}\i@node}% \def\i@node(#1)(#2,#3)#4{% \let@node(#1)(#2,#3){#4}\draw@node(#1){#4}} @@ -744,7 +926,7 @@ % [parameter=value,...] \def\imark#1(#2){{% \@ifnextchar[{\process@imarkopt}{\i@mark}#1(#2)}} -\def\process@imarkopt[#1]{\gas@set#1,&\i@mark}% +\def\process@imarkopt[#1]{\gasset{#1}\i@mark}% \def\i@mark(#1){{% \dim@x=\csname node@#1@x\endcsname\d@my@unit \edef\ps@par{\strip@PT\dim@x}% \dim@x=\csname node@#1@y\endcsname\d@my@unit \edef\ps@par{\ps@par \strip@PT\dim@x}% @@ -770,7 +952,7 @@ % [parameter=value,...] \def\fmark#1(#2){{% \@ifnextchar[{\process@fmarkopt}{\f@mark}#1(#2)}} -\def\process@fmarkopt[#1]{\gas@set#1,&\f@mark}% +\def\process@fmarkopt[#1]{\gasset{#1}\f@mark}% \def\f@mark(#1){{% \dim@x=\csname node@#1@x\endcsname\d@my@unit \edef\ps@par{\strip@PT\dim@x}% \dim@x=\csname node@#1@y\endcsname\d@my@unit \edef\ps@par{\ps@par \strip@PT\dim@x}% @@ -796,7 +978,7 @@ % [parameter=value,...] \def\rmark#1(#2){{% \@ifnextchar[{\process@rmarkopt}{\r@mark}#1(#2)}} -\def\process@rmarkopt[#1]{\gas@set#1,&\r@mark}% +\def\process@rmarkopt[#1]{\gasset{#1}\r@mark}% \def\r@mark(#1){{% \ifnum\csname node@#1@w\endcsname=-1 % then it's a polygonal node \dim@x=\csname node@#1@x\endcsname\d@my@unit @@ -847,7 +1029,7 @@ \newif\if@cosneg \newif\if@sinneg \def\nodelabel#1(#2)#3{{% \@ifnextchar[{\process@nodelabelopt}{\node@label}#1(#2){#3}}} -\def\process@nodelabelopt[#1]{\gas@set#1,&\node@label}% +\def\process@nodelabelopt[#1]{\gasset{#1}\node@label}% \def\node@label(#1)#2{{% \unitlength=\d@my@unit \edef\cs@x{\csname node@#1@x\endcsname}% @@ -950,7 +1132,7 @@ % [parameter=value,...] \def\drawedge#1(#2)#3{{% \@ifnextchar[{\process@edgeopt}{\draw@edge}#1(#2){#3}}} -\def\process@edgeopt[#1]{\gas@set#1,&\draw@edge}% +\def\process@edgeopt[#1]{\gasset{#1}\draw@edge}% \def\draw@edge(#1,#2)#3{% % Control points of the cubic Bezier curve \setcounter{cnt@a}{\csname node@#1@x\endcsname + \E@sxo}% @@ -998,7 +1180,7 @@ % [parameter=value,...] \def\drawqbedge#1(#2)#3{{% \@ifnextchar[{\process@qbedgeopt}{\draw@qbedge}#1(#2){#3}}} -\def\process@qbedgeopt[#1]{\gas@set#1,&\draw@qbedge}% +\def\process@qbedgeopt[#1]{\gasset{#1}\draw@qbedge}% \def\draw@qbedge(#1,#2,#3,#4)#5{% % Control points of the cubic Bezier curve \setcounter{cnt@a}{\csname node@#1@x\endcsname + \E@sxo}% @@ -1038,7 +1220,7 @@ % [parameter=value,...] \def\drawqbpedge#1(#2)#3{{% \@ifnextchar[{\process@qbpedgeopt}{\draw@qbpedge}#1(#2){#3}}} -\def\process@qbpedgeopt[#1]{\gas@set#1,&\draw@qbpedge}% +\def\process@qbpedgeopt[#1]{\gasset{#1}\draw@qbpedge}% \def\draw@qbpedge(#1,#2,#3,#4)#5{% % Control points of the cubic Bezier curve \setcounter{cnt@a}{\csname node@#1@x\endcsname + \E@sxo}% @@ -1095,7 +1277,7 @@ % [parameter=value,...] \def\drawbpedge#1(#2)#3{{% \@ifnextchar[{\process@bpedgeopt}{\draw@bpedge}#1(#2){#3}}} -\def\process@bpedgeopt[#1]{\gas@set#1,&\draw@bpedge}% +\def\process@bpedgeopt[#1]{\gasset{#1}\draw@bpedge}% \def\draw@bpedge(#1,#2,#3,#4,#5,#6)#7{% % Control points of the cubic Bezier curve \setcounter{cnt@a}{\csname node@#1@x\endcsname + \E@sxo}% @@ -1146,7 +1328,7 @@ % [parameter=value,...] \def\drawbcedge#1(#2)#3{{% \@ifnextchar[{\process@bcedgeopt}{\draw@bcedge}#1(#2){#3}}} -\def\process@bcedgeopt[#1]{\gas@set#1,&\draw@bcedge}% +\def\process@bcedgeopt[#1]{\gasset{#1}\draw@bcedge}% \def\draw@bcedge(#1,#2,#3,#4,#5,#6)#7{% % Control points of the cubic Bezier curve \setcounter{cnt@a}{\csname node@#1@x\endcsname + \E@sxo}% @@ -1183,7 +1365,7 @@ % [parameter=value,...] \def\drawloop#1(#2)#3{{% \@ifnextchar[{\process@loopopt}{\draw@loop}#1(#2){#3}}} -\def\process@loopopt[#1]{\gas@set#1,&\draw@loop}% +\def\process@loopopt[#1]{\gasset{#1}\draw@loop}% \def\draw@loop(#1)#2{% % Control points of the cubic Bezier curve \unitlength=\d@my@unit @@ -1194,8 +1376,8 @@ \edef\cs@xd{\cs@xa}% \edef\cs@yd{\cs@ya}% \node@diam(#1,\loop@angle) - \setcounter{cnt@a}{2*(\cs@nd+2*\loop@diam)/3} - \setcounter{cnt@b}{\loop@diam*1732/1000} % approx of sqrt(3) + \setcounter{cnt@a}{2*(\cs@nd+2*\loop@height)/3} + \setcounter{cnt@b}{\loop@width*1732/1000} % approx of sqrt(3) % Rotation \setcounter{cnt@c} {\cs@xa+\thecnt@a*\real{\cs@cos}-\thecnt@b*\real{\cs@sin}} @@ -1247,7 +1429,7 @@ \def\drawline#1(#2){\begingroup% \setcounter{cnt@a}{0} \edef\ps@param{}% \@ifnextchar[{\process@drawlineopt}{\draw@line}#1(#2)} -\def\process@drawlineopt[#1]{\gas@set#1,&\draw@line}% +\def\process@drawlineopt[#1]{\gasset{#1}\draw@line}% \def\draw@line(#1,#2){% \setcounter{cnt@a}{\thecnt@a+1} \dim@x=#1\unitlength \edef\ps@param{\ps@param \strip@PT\dim@x}% @@ -1256,12 +1438,122 @@ \put(0,0){\special{" \gas@initps \line@color \gas@ATparam \gas@AHparam \ps@param \thecnt@a\space \arc@radius !pslines}} \endgroup + } +} + +%----------------------------------------------------------------------- +% Draw a line with snake waves between two points. +% width and height of the waves are controlled by parameters snakeh and snakeh +% The line may have arrowhead(s), arrowtail(s), color, ... +% depending of the current settings +% +% \drawsnake(x1,y1)(x2,y2) +% \drawsnake[parameter=value,...](x1,y1)(x2,y2) +% +% Required arguments in \unitlengh: +% (x1,y1)(x2,y2) : coordinates of the points. +% Optional argument: +% [parameter=value,...] +\def\drawsnake#1(#2)(#3){{% + \@ifnextchar[{\process@drawsnakeopt}{\draw@snake}#1(#2)(#3)}} +\def\process@drawsnakeopt[#1]{\gasset{#1}\draw@snake}% +\def\draw@snake(#1,#2)(#3,#4){% + \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}} % x1 + \edef\snake@x{\thecnt@a} + \setcounter{cnt@a}{1*\ratio{#2\unitlength}{\d@my@unit}} % x1 + \edef\snake@y{\thecnt@a} + \setcounter{cnt@a}{1*\ratio{#3\unitlength}{\d@my@unit}} % x1 + \edef\snake@X{\thecnt@a} + \setcounter{cnt@a}{1*\ratio{#4\unitlength}{\d@my@unit}} % x1 + \edef\snake@Y{\thecnt@a} + % + \edef\ps@param{} + \dim@x=\snake@x\d@my@unit \edef\ps@param{\ps@param \strip@PT\dim@x}% + \dim@x=\snake@y\d@my@unit \edef\ps@param{\ps@param \strip@PT\dim@x}% + % + \setcounter{cnt@a}{\snake@X-\snake@x} + \edef\snake@A{\thecnt@a} + \setcounter{cnt@a}{\snake@Y-\snake@y} + \edef\snake@B{\thecnt@a} + \setcounter{cnt@a}{\snake@A*\snake@A+\snake@B*\snake@B} + \gas@sqrt{\thecnt@a} + \edef\snake@L{\the@sqrt} + % + \setcounter{cnt@@a}{\snake@w/2} + \setcounter{cnt@a}{\snake@x+\snake@A*\thecnt@@a/\snake@L} + \setcounter{cnt@b}{\snake@y+\snake@B*\thecnt@@a/\snake@L} + \dim@x=\thecnt@a\d@my@unit \edef\ps@param{\ps@param \strip@PT\dim@x}% + \dim@x=\thecnt@b\d@my@unit \edef\ps@param{\ps@param \strip@PT\dim@x}% + \setcounter{cnt@@a}{\thecnt@@a+3*\snake@w/4} + \setcounter{cnt@@c}{1} + % + \setcounter{cnt@c}{(\snake@L-5*\snake@w/2)/\snake@w} % nb iteration + \@whilenum\thecnt@c>0\do{% + \setcounter{cnt@@b}{\thecnt@@c*\snake@h} + \setcounter{cnt@a}{\snake@x+(\snake@A*\thecnt@@a-\snake@B*\thecnt@@b)/\snake@L} + \setcounter{cnt@b}{\snake@y+(\snake@B*\thecnt@@a+\snake@A*\thecnt@@b)/\snake@L} + \dim@x=\thecnt@a\d@my@unit \edef\ps@param{\ps@param \strip@PT\dim@x}% + \dim@x=\thecnt@b\d@my@unit \edef\ps@param{\ps@param \strip@PT\dim@x}% + \setcounter{cnt@@a}{\thecnt@@a+\snake@w} + \setcounter{cnt@@c}{-\thecnt@@c} + \setcounter{cnt@c}{\thecnt@c-1} + } + \setcounter{cnt@@a}{\thecnt@@a-\snake@w/4} + \setcounter{cnt@a}{\snake@x+\snake@A*\thecnt@@a/\snake@L} + \setcounter{cnt@b}{\snake@y+\snake@B*\thecnt@@a/\snake@L} + \dim@x=\thecnt@a\d@my@unit \edef\ps@param{\ps@param \strip@PT\dim@x}% + \dim@x=\thecnt@b\d@my@unit \edef\ps@param{\ps@param \strip@PT\dim@x}% + \dim@x=\snake@X\d@my@unit \edef\ps@param{\ps@param \strip@PT\dim@x}% + \dim@x=\snake@Y\d@my@unit \edef\ps@param{\ps@param \strip@PT\dim@x}% + % + \setcounter{cnt@c}{4+(\snake@L-5*\snake@w/2)/\snake@w} % nb iteration + \put(0,0){\special{" \gas@initps \line@color + \gas@ATparam \gas@AHparam + \ps@param \thecnt@c\space !pscurve}} +} + +%----------------------------------------------------------------------- +% Draw an arc of a circle. +% +% \drawarc(x,y,r,a,b) +% \drawarc[parameter=value,...](x,y,r,a,b) +% +% Required arguments: +% x,y : coordinates of the circle center (in \unitlengh). +% r : radius of the circle (in \unitlengh). +% a : starting angle of the arc (in degree) +% b : ending angle of the arc (in degree) +% Optional argument: +% [parameter=value,...] +\def\drawarc#1(#2){{% + \@ifnextchar[{\process@arcopt}{\draw@arc}#1(#2)}} +\def\process@arcopt[#1]{\gasset{#1}\draw@arc}% +\def\draw@arc(#1,#2,#3,#4,#5){{% + \dim@x=#1\unitlength \edef\ps@x{\strip@PT\dim@x}% + \dim@x=#2\unitlength \edef\ps@y{\strip@PT\dim@x}% + \dim@x=#3\unitlength \edef\ps@r{\strip@PT\dim@x}% + \put(0,0){\special{" \gas@initps + \if@fill \fill@color + newpath + \if@arcPie \ps@x \ps@y moveto \fi + \ps@x \ps@y \ps@r #4 #5 arc + \if@arcPie closepath \fi + fill + \fi + \if@frame \line@color + newpath + \if@arcPie \ps@x \ps@y moveto \fi + \ps@x \ps@y \ps@r #4 #5 arc + \if@arcPie closepath \fi + stroke + \fi }} +}} %----------------------------------------------------------------------- % Draw a circle. % -% \drawcircle(x,y,r) +% \drawcircle(x,y,d) % \drawcircle[parameter=value,...](x,y,d) % % Required arguments in \unitlengh: @@ -1271,7 +1563,7 @@ % [parameter=value,...] \def\drawcircle#1(#2){{% \@ifnextchar[{\process@circleopt}{\draw@circle}#1(#2)}} -\def\process@circleopt[#1]{\gas@set#1,&\draw@circle}% +\def\process@circleopt[#1]{\gasset{#1}\draw@circle}% \def\draw@circle(#1,#2,#3){{% \dim@x=#1\unitlength \edef\ps@x{\strip@PT\dim@x}% \dim@x=#2\unitlength \edef\ps@y{\strip@PT\dim@x}% @@ -1301,7 +1593,7 @@ % [parameter=value,...] \def\drawrect#1(#2){{% \@ifnextchar[{\process@rectopt}{\draw@rect}#1(#2)}} -\def\process@rectopt[#1]{\gas@set#1,&\draw@rect}% +\def\process@rectopt[#1]{\gasset{#1}\draw@rect}% \def\draw@rect(#1,#2,#3,#4){{% \dim@x=#1\unitlength \edef\ps@x{\strip@PT\dim@x}% \dim@x=#2\unitlength \edef\ps@y{\strip@PT\dim@x}% @@ -1333,7 +1625,7 @@ % [parameter=value,...] \def\drawoval#1(#2){{% \@ifnextchar[{\process@ovalopt}{\draw@oval}#1(#2)}} -\def\process@ovalopt[#1]{\gas@set#1,&\draw@oval}% +\def\process@ovalopt[#1]{\gasset{#1}\draw@oval}% \def\draw@oval(#1,#2,#3,#4,#5){{% \dim@x=#1\unitlength \edef\ps@path{\strip@PT\dim@x}% \dim@x=#2\unitlength \edef\ps@path{\ps@path \strip@PT\dim@x}% @@ -1365,7 +1657,7 @@ \def\drawpolygon#1(#2){\begingroup% \setcounter{cnt@a}{0} \edef\ps@param{}% \@ifnextchar[{\process@polygonopt}{\draw@polygon}#1(#2)} -\def\process@polygonopt[#1]{\gas@set#1,&\draw@polygon}% +\def\process@polygonopt[#1]{\gasset{#1}\draw@polygon}% \def\draw@polygon(#1,#2){% \setcounter{cnt@a}{\thecnt@a+1} \dim@x=#1\unitlength \edef\ps@param{\ps@param \strip@PT\dim@x}% @@ -1399,7 +1691,7 @@ % [parameter=value,...] \def\drawrpolygon#1(#2)(#3){\begingroup% \@ifnextchar[{\process@rpolygonopt}{\draw@rpolygon}#1(#2)(#3)} -\def\process@rpolygonopt[#1]{\gas@set#1,&\draw@rpolygon}% +\def\process@rpolygonopt[#1]{\gasset{#1}\draw@rpolygon}% \def\draw@rpolygon(#1,#2)(#3,#4){% \dim@x=#1\unitlength \dim@y=#2\unitlength \edef\ps@path{\strip@PT\dim@x \strip@PT\dim@y #3\space}% @@ -1434,7 +1726,7 @@ \def\drawccurve#1(#2){\begingroup% \setcounter{cnt@a}{0} \edef\ps@param{}% \@ifnextchar[{\process@drawccurveopt}{\draw@c@curve}#1(#2)} -\def\process@drawccurveopt[#1]{\gas@set#1,&\draw@c@curve}% +\def\process@drawccurveopt[#1]{\gasset{#1}\draw@c@curve}% \def\draw@c@curve(#1,#2){% \setcounter{cnt@a}{\thecnt@a+1} \dim@x=#1\unitlength \edef\ps@param{\ps@param \strip@PT\dim@x}% @@ -1470,7 +1762,7 @@ \def\drawcurve#1(#2){\begingroup% \setcounter{cnt@a}{0} \edef\ps@param{}% \@ifnextchar[{\process@drawcurveopt}{\draw@curve}#1(#2)} -\def\process@drawcurveopt[#1]{\gas@set#1,&\draw@curve}% +\def\process@drawcurveopt[#1]{\gasset{#1}\draw@curve}% \def\draw@curve(#1,#2){% \setcounter{cnt@a}{\thecnt@a+1} \dim@x=#1\unitlength \edef\ps@param{\ps@param \strip@PT\dim@x}% @@ -1495,7 +1787,7 @@ % [parameter=value,...] \def\drawqbezier#1(#2){{% \@ifnextchar[{\process@drawqbezieropt}{\draw@q@bezier}#1(#2)}} -\def\process@drawqbezieropt[#1]{\gas@set#1,&\draw@q@bezier}% +\def\process@drawqbezieropt[#1]{\gasset{#1}\draw@q@bezier}% \def\draw@q@bezier(#1,#2,#3,#4,#5,#6){{% \dim@x=#1\unitlength \edef\ps@xa{\strip@PT\dim@x}% \dim@x=#2\unitlength \edef\ps@ya{\strip@PT\dim@x}% @@ -1521,7 +1813,7 @@ % [parameter=value,...] \def\drawcbezier#1(#2){{% \@ifnextchar[{\process@drawcbezieropt}{\draw@c@bezier}#1(#2)}} -\def\process@drawcbezieropt[#1]{\gas@set#1,&\draw@c@bezier}% +\def\process@drawcbezieropt[#1]{\gasset{#1}\draw@c@bezier}% \def\draw@c@bezier(#1,#2,#3,#4,#5,#6,#7,#8){{% \dim@x=#1\unitlength \edef\ps@xa{\strip@PT\dim@x}% \dim@x=#2\unitlength \edef\ps@ya{\strip@PT\dim@x}% @@ -1727,7 +2019,7 @@ \def\AH@l{\strip@PT\@wholewidth 9 mul 20 cos mul } \def\line@width{\strip@PT\@wholewidth} % - \def\setstatediam##1{\gasset@Nw{##1}\gasset@Nh{##1}\gasset@Nmr{##1}} + \def\setstatediam##1{\gasset{Nw=##1,Nh=##1,Nmr=##1}} \def\setvertexdiam{\setstatediam} \setstatediam{6} % @@ -1736,11 +2028,11 @@ \edef\repeated@diam{\thecnt@a}}% \setrepeatedstatediam{5} % - \def\setloopdiam{\gasset@loopdiam}% + \def\setloopdiam##1{\gasset{loopdiam=##1}}% \setloopdiam{6} % - \def\settranslabelskip{\gasset@ELdist}% - \def\setedgelabelskip{\gasset@ELdist} + \def\settranslabelskip##1{\gasset{ELdist=##1}}% + \def\setedgelabelskip##1{\gasset{ELdist=##1}} \settranslabelskip{1} % \def\setprofcurve##1{% @@ -1769,7 +2061,7 @@ \def\pcolor{} \def\pictcolor##1##2{} % - \def\setpsgray##1{\gasset@linegray{##1}\gasset@fillgray{##1}}% + \def\setpsgray##1{\gasset{linegray=##1,fillgray=##1}}% \setpsgray{0} % black %----------------------------------------------------------------------- % States @@ -1901,7 +2193,7 @@ \def\pcolor{} \def\pictcolor##1##2{} % - \def\setpsgray##1{\gasset@linegray{##1}\gasset@fillgray{##1}}% + \def\setpsgray##1{\gasset{linegray=##1,fillgray=##1}}% \setpsgray{0} % black % % Redefinition of latex \line(a,b){L}. |