1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054
|
% \iffalse % egplot.dtx - Encapsulated gnuplot for LaTeX(2e)
% Copyright (C) 1998 by Axel.Probst@bam.de
%
% Egplot is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2, or (at your option)
% any later version.
%
% Egp is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
%
% \fi
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%% \CheckSum{449}
%% \CharacterTable
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%% Digits \0\1\2\3\4\5\6\7\8\9
%% Exclamation \! Double quote \" Hash (number) \#
%% Dollar \$ Percent \% Ampersand \&
%% Acute accent \' Left paren \( Right paren \)
%% Asterisk \* Plus \+ Comma \,
%% Minus \- Point \. Solidus \/
%% Colon \: Semicolon \; Less than \<
%% Equals \= Greater than \> Question mark \?
%% Commercial at \@ Left bracket \[ Backslash \\
%% Right bracket \] Circumflex \^ Underscore \_
%% Grave accent \` Left brace \{ Vertical bar \|
%% Right brace \} Tilde \~}
%%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \changes{v1.00}{1998/06/17}{First released version}
% \changes{v1.01}{1998/06/25}{Fixed bug with \texttt{german} option and
% negative tic mark values}
% \changes{v1.02}{1998/07/08}{Added options \texttt{gnuplot35} and
% \texttt{gnuplot36beta} to allow output of
% syntax of \GP{}-3.5.\\
% Added numbering of \GP{} files to allow multiple
% \texttt{egpfile} environments w/o explicitly
% defined names in one document.}
%
% \MakeShortVerb{\|}
%
%
% \title{%
% \EGP: \\
% Encapsulated \GP{} for \LaTeX\thanks{%
% This is \texttt{\filename}, version \fileversion, date \filedate.}}
%
% \author{%
% Axel Probst\thanks{e-mail:
% \texttt{Axel.Probst@bam.de}}\\
% \hfil \\
% c/o\\
% Federal Institute for Materials Research and Testing\\
% Unter den Eichen 87\\
% D-12205 Berlin \\
% Germany}
%
% \maketitle
% \begin{abstract}
% The \EGP{} package allows to encapsulate \GP{} commands in \LaTeX{}
% sources. This is very useful for keeping illustrations in sync
% with the text. It also frees the user from inventing descriptive
% names for PostScript files. Additionally the package provides commands that
% enable the user to let \GP{} do calculations and insert the result values
% into the generated output.
% \end{abstract}
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \begin{multicols}{2}
% \tableofcontents
% \end{multicols}
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \vfill
% \section*{Copying}
%
% \EGP{} is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2, or (at your option)
% any later version.
%
% \EGP{} is distributed in the hope that it will be useful, but
% \emph{without any warranty}; without even the implied warranty of
% \emph{merchantability} or \emph{fitness for a particular purpose}.
% See the GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \def\topfraction{0.9}
% \def\bottomfraction{0.9}
% \def\textfraction{0.1}
% \egpfigprelude{set terminal postscript eps monochrome dashed "Helvetica" 17^^J
% set title ""; set grid^^J}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Introduction}
% \label{sec:intro}
%
% When adding illustrations to documents, one faces two bookkeeping
% problems:
% \begin{enumerate}
% \item How to encourage oneself to keep the illustrations in sync
% with the text, when the document is updated?
% \item How to make sure that the illustrations appear on the right
% spot?
% \end{enumerate}
% For both problems, the best solution is to encapsulate the figures
% in the \LaTeX{} source:
% \begin{enumerate}
% \item It is much easier to remember to update an illustration if
% one doesn't have to switch files in the editor.
% \item One does not have to invent illustrative filenames, if
% the computer keeps track of them.
% \end{enumerate}
% This concept of integrating the image generating commands into the \LaTeX{}
% source was implemented for \MF{} by Thorsten
% Ohl\footnote{e-mail:\texttt{Thorsten.Ohl@Physik.TU-Darmstadt.de}} in the
% \EMP-package.
% The \EGP{} package now allows the encapsulation of \GP~\cite{GP} into
% \LaTeX~\cite{LaTeX-Graphics-Companion,LaTeX,LaTeX-Companion}. Although \GP{}
% provides several output formats that are suitable for the inclusion into
% \LaTeX{} the \EGP{} package is only intended for use with the Postscript
% terminal of \GP{} so far.
%
% In addition to the image inclusion commands \EGP{} provides the user with
% commands to let \GP{} do calculations and include the results into the
% document. Unfortunately these features are implemented with the UN*X text utils
% and so they are only usable if these are installed on the system. If the user
% does not provide a name for the \GP{} file the
% names for the PostScript and the result values files are built by appending
% the number of the \GP{} file, the figure/calculation number and a three
% letter extension (|.eps| or |.val|) to |\jobname|. So the user has to
% choose a |\jobname| that is short enough so that the generated
% filenames fit into the conventions of certain operating systems.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Usage}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Options}
% \label{sec:options}
%
% \DescribeMacro{Options}
% Besides the options of the |graphicx| package \EGP{} recognizes the following
% options:
% \begin{description}
% \item[|german|:] If |german| is specified the calculated values and the tic labels of the
% diagrams are changed to show a `,' as decimal point
% character. The default is a `.'. This feature is also
% implemented with UN*X text utils and is only available if
% they are installed on the system.
% \item[|gnuplot35|:] If |gnuplot35|~(default) is specified the \GP{} commands
% generated by |egplot| will be compatible with the syntax
% of the official \GP{} version~3.5. Of course the user
% has to look for the right syntax in his \GP{} code
% himself. Special care has to be taken for the
% |\egpprelude{|\dots|}| and the |\egpfigepilog{|\dots|}|
% commands since these are used to implement the missing
% |reset| command of \GP{}-3.5.
% \item[|gnuplot36beta|:] If |gnuplot36beta| is specified the \GP{} commands
% generated by |egplot| will use the features of the
% beta version \GP{}~3.6beta. As mentioned above the user
% has to look for the right syntax in his \GP{} code
% himself.
% \end{description}
%
% \subsection{Commands and Environments}
% \label{sec:commands}
%
% \subsubsection{Miscellaneous}
% \label{sec:misc}
%
% \DescribeEnv{egpfile}
% All descriptions that should go into one \GP{} file are placed
% inside a |egpfile| environment which takes the name of the \GP{}
% file as an optional argument:
% \begin{quote}
% \begin{flushleft}
% |\begin{egpfile}[|\meta{\GP-file}|]|\\
% \qquad\ldots\\
% |\end{egpfile}|
% \end{flushleft}
% \end{quote}
% The default \GP-filename is |\jobname.gp|.
%
% \DescribeEnv{egpcmds}
% \DescribeMacro{\egpwrite}
% Write \GP{} commands to the current file outside of a figure.
% The |\egpwrite| command is intended for short one line commands.
% \begin{quote}
% \begin{flushleft}
% |\begin{egpcmds}|\\
% \qquad\meta{\GP-commands}\\
% |\end{egpcmds}|
% \end{flushleft}
% \end{quote}
%
% \DescribeMacro{\egpprelude}
% \DescribeMacro{\egpaddtoprelude}
% Define and add to the set of commands that are prepended to the top of
% every \GP{} file. It is intended for the global definition of variables
% or functions.
%
% The default is empty.
%
% \subsubsection{Figures}
% \label{sec:images}
%
% \DescribeEnv{egp}
% \DescribeEnv{egpx}
% \DescribeEnv{egpdef}
% The |egp| as the |egpx| environment contains the description of a single
% figure that will be placed at the location of the environment.
% The |egpdef| environment only defines a figure but does not include it into
% the document. This is useful, because these environments use the
% |verbatim| package and can therefore \emph{not} be used as an
% argument to other macros. The \meta{name} that is assigned to the figure is
% used for later inclusion with the |\egpuse{|\meta{name}|}| command.
% For the |egp| and |egpx| environment the assignment of the \meta{name} is
% optional.
% The required argument of the |egpx| environment accepts any set of keys
% accepted by the |\includegraphics| command of the |graphicx| package.
% \begin{quote}
% \begin{flushleft}
% |\begin{egp}[|\meta{name}|]|\\
% \qquad\meta{\GP-commands}\\
% |\end{egp}|
% \end{flushleft}
% \end{quote}
% \begin{quote}
% \begin{flushleft}
% |\begin{egpx}[|\meta{name}|]{|\meta{key val list}|}|\\
% \qquad\meta{\GP-commands}\\
% |\end{egpx}|
% \end{flushleft}
% \end{quote}
% \begin{quote}
% \begin{flushleft}
% |\begin{egpdef}{|\meta{name}|}|\\
% \qquad\meta{\GP-commands}\\
% |\end{egpdef}|
% \end{flushleft}
% \end{quote}
%
% \DescribeMacro{\egpuse}
% Reuse a previously defined figure.
% The optional argument of the |\egpuse| command accepts any set of the keys
% that is accepted by the |\includegraphics| command of the |graphicx| package.
% \begin{quote}
% \begin{flushleft}
% |\egpuse[|\meta{key val list}|]{|\meta{name}|}|\\
% \end{flushleft}
% \end{quote}
%
% \DescribeMacro{\egpfigprelude}
% \DescribeMacro{\egpaddtofigprelude}
% Define and add to a \GP{} prelude that is prepended to the output of
% every |egp|, |egpx| or |egpdef| environment.
% The default is:
% \begin{quote}
% \qquad{}|set terminal postscript eps monochrome dashed "Helvetica" 17|
% \end{quote}
% In fact this is the command where the terminal for the \GP{}-|plot| command
% is set. So the user has to take care that (Encapsulated) PostScript output is
% generated.
%
% \DescribeMacro{\egpfigepilog}
% \DescribeMacro{\egpaddtofigepilog}
% Define and add to a \GP{} epilog that is appended to the output of
% every |egp|, |egpx| or |egpdef| environment.
% This command can be used for e.g. |replot|ting the figure to the screen or
% |reset|ing to the defaults after every figure.
%
% The defaults are as follows:
% \begin{quote}
% \begin{tabular}{lll}
% Option: & none, |gnuplot35| & |gnuplot36beta| \\
% & |load "reset.gp"| & |reset| \\
% \end{tabular}
% \end{quote}
%
% \subsubsection{Calculating}
% \label{sec:calculations}
%
% In addition to the commands and environments to generate and include \GP{}
% figures the \EGP{}-package provides commands to use \GP{} for the
% calculation of arbitrary arithmetic expressions. Since the \GP{}-|plot|
% command is used for this feature every expression that is accepted by this
% command is possible. But this may also lead to unexpected results if the
% expression contains the variable~$x$ which is used as the independent
% variable of the \GP{}-|plot| command. As stated
% above~(cf.~p.~\pageref{sec:intro}) the UN*X text utils are used for the
% implementation and so the calculation commands can only be used on systems
% where these are installed.
%
% \DescribeMacro{\egpcalc}
% Let \GP{} calculate the value of a \meta{\GP-expression}. The result is written to a
% file.
% The optional argument assigns a name to be used with |\egpuseval{|\meta{name}|}|.
% \begin{quote}
% \begin{flushleft}
% |\egpcalc[|\meta{name}|]{|\meta{\GP-expression}|}|\\
% \end{flushleft}
% \end{quote}
%
% \DescribeMacro{\egpuseval}
% Insert a previously defined calculation result.
%
% \DescribeMacro{\egpshowval}
% Does the same as the |\egpcalc|-command but additionally the result is placed
% in the output at the position of the |\egpshowval|-command.
%
% \DescribeMacro{\egpassign}
% The first argument is the name of a \meta{\GP-variable} or \meta{\GP-user
% function} which is assigned the second argument which is a
% \meta{\GP-expression}. The result is placed in the output as for the
% |\egpshowval| command.
%
% \subsection{Procedure}
% \label{sec:procedure}
%
% After \LaTeX{} has done it's job for the first time you have to invoke \GP{}
% on the generated file~(default: |\jobnameX.gp|, where |X| is a number). Then
% another \LaTeX{} run is necessary to include the figures and the results into
% the output.
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Examples}
% \label{sec:examples}
%
% For a simple example, let's draw the function
% $f(x)=\sin({\sqrt{x^2+y^2}})/\sqrt{x^2+y^2}$.
% \begin{macrocode}
%<*sample>
\begin{egpfile}
\begin{center}
\begin{egpx}[sombrero]{width=0.8\linewidth}
set hidden3d
set nogrid
set samples 1000
set isosamples 35
splot [-10:10] [-10:10] sin(sqrt(x*x+y*y))/sqrt(x*x+y*y)
\end{egpx}
\end{center}
% \end{macrocode}
\begin{egpfile}
\begin{center}
\begin{egpx}[sombrero]{width=0.8\linewidth}
set hidden3d
set nogrid
set samples 1000
set isosamples 35
splot [-10:10] [-10:10] sin(sqrt(x*x+y*y))/sqrt(x*x+y*y)
\end{egpx}
\end{center}
%
% Additionally we define a figure that will not be shown here but at the place
% of the appropriate |\egpuse| command.
%
% \begin{macrocode}
\begin{egpdef}{kleinbottle}
set hidden3d
set parametric
set nokey
set nogrid
set noborder
set noxtics
set noytics
set noztics
set xrange [-10:10]
set yrange [-10:10]
set zrange [-3:3]
set urange [0:2*pi]
set vrange [0:2*pi]
set isosamples 39,60
set view 60,120
set title "Klein bottle"
splot (2*sin(u)*cos(v/2)-sin(2*u)*sin(v/2)+8)*cos(v), \
(2*sin(u)*cos(v/2)-sin(2*u)*sin(v/2)+8)*sin(v), \
2*sin(u)*sin(v/2)+sin(2*u)*cos(v/2)
\end{egpdef}
% \end{macrocode}
\begin{egpdef}{kleinbottle}
set hidden3d
set parametric
set nokey
set nogrid
set noborder
set noxtics
set noytics
set noztics
set xrange [-10:10]
set yrange [-10:10]
set zrange [-3:3]
set urange [0:2*pi]
set vrange [0:2*pi]
set isosamples 39,60
set view 60,120
set title "Klein bottle"
splot (2*sin(u)*cos(v/2)-sin(2*u)*sin(v/2)+8)*cos(v), \
(2*sin(u)*cos(v/2)-sin(2*u)*sin(v/2)+8)*sin(v), \
2*sin(u)*sin(v/2)+sin(2*u)*cos(v/2)
\end{egpdef}
%
% Since we have given a name to each diagram, we can now use them with
% \begin{macrocode}
\begin{figure}
\begin{center}
\fbox{\egpuse[scale=0.4]{sombrero}}
\fbox{\egpuse[scale=0.4]{kleinbottle}}
\caption{Two examples taken from the \GP{} demo}\label{fig:demo}
\end{center}
\end{figure}
% \end{macrocode}
%
% and the result is shown in figure~\ref{fig:demo}.
%
\begin{figure}
\begin{center}
\fbox{\egpuse[scale=0.4]{sombrero}}
\fbox{\egpuse[scale=0.4]{kleinbottle}}
\caption{Two examples taken from the \GP{} demo}\label{fig:demo}
\end{center}
\end{figure}
%
% To calculate the value of $f(\pi/4)$ we issue the command
%
% $f(\pi/4)=\egpshowval[sin_quarter_pi]{sin(pi/4)}$
% \begin{macrocode}
$f(\pi/4)=\egpshowval[sin_quarter_pi]{sin(pi/4)}$
% \end{macrocode}
% and get $\frac{\sqrt{2}}{2}=\fbox{\egpuseval{sin_quarter_pi}}\footnote{I
% couldn't figure out how to remove the trailing space, yet. Any hints ?}$
% \begin{macrocode}
and get $\frac{\sqrt{2}}{2}=\fbox{\egpuseval{sin_quarter_pi}}$.
\end{egpfile}
% \end{macrocode}
%
\end{egpfile}
% \begin{macrocode}
%</sample>
% \end{macrocode}
%
% \section{Acknowledgements}
% I would like to thank Thorsten Ohl for submitting the \EMP{} package to CTAN.
% By using it as a template I managed it to adapt the idea of integrating the
% image generating commands into \LaTeX{} for \GP{}. A lot of code of the
% \EMP{} package was reused with only marginal changes. This is also caused by
% the fact that I am far away from understanding all of the code of \EMP{}.
%
% \section{Todo}
% In additon to optimising \EGP{} it would be nice if the features that are
% provided through the use of UN*X text utils were implemented in
% \TeX{}/\LaTeX{}. Another interesting feature to implement in following
% versions of \EGP{} is the possibility to use other output formats
% provided by \GP{}, especially the |pslatex| and |pstricks| terminals but also
% the |png| terminal for inclusion into PDF could be useful.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \begin{thebibliography}{99}
% \bibitem{LaTeX-Graphics-Companion} Michel Goossens, Sebastian
% Rahtz, and Frank Mittelbach, \textit{The \LaTeX{} Graphics
% Companion}, Addison-Wesley, Reading MA, 1997.
% \bibitem{LaTeX} Leslie Lamport, \textit{\LaTeX{} --- A
% Documentation Preparation System},
% Addison-Wesley, Reading MA, 1985.
% \bibitem{LaTeX-Companion} Michel Goossens, Frank Mittelbach, and
% Alexander Samarin, \textit{The \LaTeX{} Companion},
% Addison-Wesley, Reading MA, 1994.
% \bibitem{EMP} Thorsten Ohl, \texttt{emp}, available from
% CTAN (cf.~p.~\pageref{pg:CTAN}), in the \texttt{macros/latex/contrib/supported/emp}
% directory.
% \bibitem{GP} Thomas Williams and Colin Kelley, \textit{gnuplot}, available
% from \texttt{ftp.dartmouth.edu} in the \texttt{/pub/gnuplot} directory.
% \end{thebibliography}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section*{Distribution}
% \label{sec:distribution}
%
% \EGP{} is available by anonymous internet ftp from any of the
% Comprehensive \TeX{} Archive Network (CTAN) hosts
% \label{pg:CTAN}
% \begin{quote}
% |ftp.tex.ac.uk|, |ftp.dante.de|
% \end{quote}
% in the directory
% \begin{quote}
% |macros/latex/contrib/supported/egplot|
% \end{quote}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \StopEventually{\PrintIndex\PrintChanges}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Implementation}
%
% \begin{macrocode}
%<*style>
\def\fileversion{v1.02a}
\NeedsTeXFormat{LaTeX2e}
\gdef\filename{egplot.sty}%
\gdef\filedate{1998/07/08}%
\gdef\filemaintainer{Axel Probst}%
% \end{macrocode}
%
% And now the standard procedure:
% \begin{macrocode}
\ProvidesPackage{egplot}[\filedate\space\fileversion\space
Encapsulated gnuplot LaTeX Package (\filemaintainer)]
% \end{macrocode}
%
% Load the required packages:
% \begin{macrocode}
\RequirePackage{verbatim}
\RequirePackage{ifthen}
% \end{macrocode}
%
% Now the options are specified:
% \begin{macrocode}
\newboolean{egp@german}
\setboolean{egp@german}{false}
\DeclareOption{german}{%
\setboolean{egp@german}{true}}
\newboolean{egp@oldgp}
\setboolean{egp@oldgp}{true}
\DeclareOption{gnuplot35}{%
\setboolean{egp@oldgp}{true}}
\DeclareOption{gnuplot36beta}{%
\setboolean{egp@oldgp}{false}}
% \end{macrocode}
%
% Every option we don't understand is sent down to |graphicx|:
% \begin{macrocode}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{graphicx}}
\ProcessOptions
\RequirePackage{graphicx}[1994/12/15]
% \end{macrocode}
%
% \begin{macro}{\egpwrite}
% Write out the argument to the \GP{} file.
% \begin{macrocode}
{\catcode`\#=11\gdef\egpcomment{#}}
\def\egpwrite#1{%
\if@egpio
\immediate\write\@outegp{#1}%
\fi
\ignorespaces}
\newif\if@egpio
\@egpiotrue
\newwrite\@outegp
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\egpfile}
% This environment encloses each \GP{} input file. The single optional
% argument gives the name of the file.
% \begin{macrocode}
\newcounter{egpfilenum} % 1998-03-07
\setcounter{egpfilenum}{0} % 1998-03-07
\newcommand{\egpfile}[1][\jobname\theegpfilenum_]{%
\def\theegpfile{#1}%
\ifthenelse{\equal{\theegpfile}{\jobname\theegpfilenum_}}{%
\stepcounter{egpfilenum}%
\def\theegpfilename{\jobname\theegpfilenum.gp}}{%
\def\theegpfilename{\theegpfile.gp}}
% \end{macrocode}
% Open the \GP{} file.
% \begin{macrocode}
\if@egpio
\immediate\openout\@outegp=\theegpfilename\relax
\egpwrite{\egpcomment\space \theegpfilename -- %
do not edit, generated automatically by \jobname.tex^^J}
% \end{macrocode}
% append the defined prelude and write it out:
% \begin{macrocode}
\expandafter\ifx\expandafter*\the\egp@prelude*\else
\egpwrite{\the\egp@prelude;}%
\fi
\fi
% \end{macrocode}
% Count the figures and the calculations
% \begin{macrocode}
\setcounter{egpfig}{0}
\setcounter{egpcalc}{0}}
\let\theegpfile\relax
\newcounter{egpfig}
\newcounter{egpcalc}
% \end{macrocode}
% Standard preludes for the whole file and for every figure and the per figure
% epilog:
% \begin{macrocode}
\newtoks\egp@prelude
\newtoks\egp@figprelude
\newtoks\egp@figepilog
%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\egpprelude}
% \begin{macro}{\egpfigprelude}
% \begin{macro}{\egpfigepilog}
% \begin{macro}{\egpaddtoprelude}
% \begin{macro}{\egpaddtofigprelude}
% \begin{macro}{\egpaddtofigepilog}
% Define and add to the file or figure prelude and the figure epilog.
% \begin{macrocode}
\def\egpprelude#1{\egp@prelude={#1}}
\def\egpfigprelude#1{\egp@figprelude={#1}}
\def\egpfigepilog#1{\egp@figepilog={#1}}
\def\egpaddtoprelude#1{\egp@prelude=\expandafter{\the\egp@prelude^^J#1}}
\def\egpaddtofigprelude#1{\egp@figprelude=\expandafter{\the\egp@figprelude^^J#1}}
\def\egpaddtofigepilog#1{\egp@figepilog=\expandafter{\the\egp@figepilog^^J#1}}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\endegpfile}
% And here is how we close the |egpfile| environment:
% \begin{macrocode}
\def\endegpfile{%
\egpwrite{\egpcomment\space the end.}%
\let\theegpfile\relax
\if@egpio
\immediate\closeout\@outegp
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\egp}
% \begin{macro}{\egpx}
% \begin{macro}{\egpdef}
% Here are the environments to define and to define and include the \GP{} diagrams.
% \begin{macrocode}
\newcommand{\egp}[1][*]{%
\def\egp@@name{#1}%
\egp@}
\newcommand{\egpx}[2][*]{%
\def\egp@@name{#1}%
\egp@x{#2}}
\newcommand{\egpdef}[1]{%
\def\egp@@name{#1}%
\egp@def}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\egp@}
% \begin{macro}{\egp@x}
% \begin{macro}{\egp@def}
% And here the real work is done.
% \begin{macrocode}
\def\egp@{%
\egp@start%
\ifthenelse{\boolean{egp@oldgp}}
{\egpwrite{\egpcomment\space --- \theegpfile\theegpfig.eps ---}}
{\egpwrite{print 'generating picture ---- \theegpfile\theegpfig.eps'}}
\egpwrite{set output '\theegpfile\theegpfig.eps'}
\egp@includegraphics{\theegpfile}{\theegpfig}%
\egpcmds}
\def\egp@x#1{%
\egp@start%
\ifthenelse{\boolean{egp@oldgp}}
{\egpwrite{\egpcomment\space --- \theegpfile\theegpfig.eps ---}}
{\egpwrite{print 'generating picture ---- \theegpfile\theegpfig.eps'}}
\egpwrite{set output '\theegpfile\theegpfig.eps'}
\egp@includegraphicx[#1]{\theegpfile}{\theegpfig}%
\egpcmds}
\def\egp@def{%
\egp@start%
\ifthenelse{\boolean{egp@oldgp}}
{\egpwrite{\egpcomment\space --- \theegpfile\theegpfig.eps ---}}
{\egpwrite{print 'generating picture ---- \theegpfile\theegpfig.eps'}}
\egpwrite{set output '\theegpfile\theegpfig.eps'}
\egpcmds}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\egp@start}
% \begin{macrocode}
\def\egp@start{%
\egp@checkfile
% \end{macrocode}
% We can't use |\stepcounter| because of the |amstext| option of
% AMS-\LaTeX{} disables it sometimes.
% \begin{macrocode}
\global\expandafter\advance\csname c@egpfig\endcsname \@ne
\egp@@def{\egp@@name}%
% \end{macrocode}
% Start the \GP{} figure:
% \begin{macrocode}
\expandafter\ifx\expandafter*\the\egp@figprelude*\else
\egpwrite{\the\egp@figprelude}%
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\egp@checkfile}
% Make sure that a \GP{} file is open, otherwise \emph{really}
% obscure error messages are possible:
% \begin{macrocode}
\def\egp@checkfile{%
\ifx\theegpfile\relax
\errhelp={Outside an egpfile environment, I have no clue as to where^^J%
the gnuplot commands should go. I will use egpdefault.gp^^J%
for this graph, but you'd better fix your code!}%
\errmessage{I detected a egp environment outside of egpfile}%
\egpfile[egpdefault]
\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\egp@includegraphics}
% \begin{macro}{\egp@includegraphicx}
% Include the Postscript files that were generated by \GP{}
% \begin{macrocode}
\def\egp@includegraphics#1#2{%
\leavevmode
\IfFileExists{#1#2.eps}%
{\includegraphics{#1#2.eps}}%
{\typeout{%
egp: File #1#2.eps\space not found:^^J%
egp: Process \theegpfilename\space with gnuplot and then %
reprocess this file.}}}
\newcommand{\egp@includegraphicx}[3][scale=1]{%
\leavevmode
\IfFileExists{#2#3.eps}%
{\includegraphics[#1]{#2#3.eps}}%
{\typeout{%
egp: File #2#3.eps\space not found:^^J%
egp: Process \theegpfilename\space with gnuplot and then %
reprocess this file.}}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\egpcmds}
% Write to the file:
% \begin{macrocode}
\def\egpcmds{%
\begingroup
\@bsphack
\let\do\@makeother\dospecials
\catcode`\^^M\active
\def\verbatim@processline{\egpwrite{\the\verbatim@line}}%
\verbatim@start}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endegpcmds}
% \begin{macrocode}
\def\endegpcmds{%
\@esphack
\endgroup}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endegp}
% \begin{macro}{\endegpx}
% \begin{macro}{\endegpdef}
% If the |german| option is used the decimal point character is changed to be
% |{,}|. This is done to avoid the additional space \LaTeX{} inserts after the
% `,' in math mode. This is implemented by using some of the UN*X text utils
% and therefore these have to be availlable on the system to benefit from this
% feature.
% \begin{macrocode}
\def\endegp{%
\endegpcmds
\ifthenelse{\boolean{egp@german}}{%
\egpwrite{!sed -e '/[0-9]*[.][0-9]*)\ .show/s/[.]/,/' %
\theegpfile\theegpfig.eps >\theegpfile\theegpfig.tmp}
\egpwrite{!cp \theegpfile\theegpfig.tmp \theegpfile\theegpfig.eps}
\egpwrite{!rm -f \theegpfile\theegpfig.tmp}}
{}
\expandafter\ifx\expandafter*\the\egp@figepilog*\else
\egpwrite{\the\egp@figepilog}%
\fi
\egpwrite{}}
\def\endegpx{\endegp}
\def\endegpdef{\endegp}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\egp@@def}
% \begin{macrocode}
\def\egp@@def#1{%
\global\e@namedef{egp@k:f:#1}{\theegpfile}%
\global\e@namedef{egp@k:c:#1}{\theegpfig}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\e@namedef}
% \begin{macrocode}
\def\e@namedef#1{\expandafter\edef\csname #1\endcsname}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\egpuse}
% Reuse a previously defined figure. The figure is referred to by the name
% given on the |egp|, |egpx| or |egpdef| environment.
% \begin{macrocode}
\newcommand{\egpuse}[2][scale=1]{%
\@ifundefined{egp@k:f:#2}%
{\typeout{egp: \string\egpuse: `#2' undefined!}}%
{\egp@includegraphicx[#1]{\@nameuse{egp@k:f:#2}}{\@nameuse{egp@k:c:#2}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\egpcalc}
% Calculate the expression in the required argument.
% \begin{macrocode}
\newcommand{\egpcalc}[2][*]{%
\def\egp@@name{#1}%
\def\egp@expression{#2}
\egp@calc}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\egp@calc}
% Write the commands to the \GP{} file.
% To get the calculated results in a file the \GP{} |table| terminal is used.
% The number of samples is set to the lowest possible value and the |zero|
% tolerance is set to 0.
% \begin{macrocode}
\def\egp@calc{%
\egp@checkfile
\global\expandafter\advance\csname c@egpcalc\endcsname \@ne
\egpc@@def{\egp@@name}%
\ifthenelse{\boolean{egp@oldgp}}
{\egpwrite{\egpcomment\space --- \theegpfile\theegpcalc.val ---}}
{\egpwrite{print 'calculating value ----- \theegpfile\theegpcalc.val'}}
\egpwrite{set term table; set output '\theegpfile\theegpcalc.tmp'^^J%
set samples 2^^J%
set zero 0^^J%
plot [0:0] \egp@expression}
% \end{macrocode}
%
% Here intensive usage of UN*X text utils is made to extract the calculated
% value out of the file \GP{} generated.
%
% If the |german| option is used the decimal point character is changed to be
% `|{,}|'. This is done to avoid the additional space \LaTeX{} inserts after the
% `,' in math mode.
%
% Maybe someone is able to implement all this in \TeX{} what would make this
% package much more portable.
%
% \begin{macrocode}
\ifthenelse{\boolean{egp@german}}{%
\egpwrite{!tail -3 \theegpfile\theegpcalc.tmp | head -1 |%
cut -f 2 -d' ' | sed -e 's/[.]/{,}/' %
>\theegpfile\theegpcalc.val}}
{\egpwrite{!tail -3 \theegpfile\theegpcalc.tmp | head -1 |%
cut -f 2 -d' ' >\theegpfile\theegpcalc.val}}
\egpwrite{!rm -f \theegpfile\theegpcalc.tmp}
% \ifthenelse{\boolean{egp@oldgp}}{%
% \egpwrite{load "reset.gp"}}{%
% \egpwrite{reset}}
\egpwrite{}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\egpc@@def}
% \begin{macrocode}
\def\egpc@@def#1{%
\global\e@namedef{egp@k:f:#1}{\theegpfile}%
\global\e@namedef{egp@k:v:#1}{\theegpcalc}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\egp@includevalue}
% With this command the generated result is read into the \LaTeX{} file.
% Unfortunately a trailing \verb*+\ + is shown after the included value what is
% caused --- as I think --- by the |\input| command. There should be a way to
% avoid this but I don't know how. Any wizards out there?
% \begin{macrocode}
\newcommand{\egp@includevalue}[2]{%
% \InputIfFileExists{#1#2.val}{\ignorespaces}%
\IfFileExists{#1#2.val}%
{\input{#1#2.val}}%
{\typeout{%
egp: File #1#2.val\space not found:^^J%
egp: Process \theegpfilename\space with gnuplot and then %
reprocess this file.}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\egpshowval}
% Calculate and include the result during the \LaTeX{} run.
% \begin{macrocode}
\newcommand{\egpshowval}[2][*]{%
\def\egp@@name{#1}%
\def\egp@expression{#2}%
\egp@calc%
\egp@includevalue{\theegpfile}{\theegpcalc}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\egpuseval}
% Include a previously defined value.
% \begin{macrocode}
\newcommand{\egpuseval}[1]{%
\@ifundefined{egp@k:f:#1}%
{\typeout{egp: \string\egpuseval: `#1' undefined!}}%
{\egp@includevalue{\@nameuse{egp@k:f:#1}}{\@nameuse{egp@k:v:#1}}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\egpassign}
% \begin{macrocode}
\newcommand{\egpassign}[2]{%
\egpwrite{#1=#2}\egpshowval{#1}}
% \end{macrocode}
% \end{macro}
%
% Define the file prelude:
% If the user specifies that the official version \GP{}-3.5 is used a file with
% the name |reset.gp| is generated at the start of the \GP{} run. Wherever a
% |reset| is done in the \GP{}-3.6 file this file is |load|ed instead.
% \begin{macrocode}
\ifthenelse{\boolean{egp@oldgp}}
{\egpprelude{save "reset.gp"}}
{\relax}
% \end{macrocode}
%
% Define the default prelude for the figures:
% \begin{macrocode}
\egpfigprelude{set terminal postscript eps monochrome dashed "Helvetica" 17}
% \end{macrocode}
% To get e.g. Computer Modern as font for the axis tics you can specify the
% name of a CM-Type-1 font file as fontname option of the \GP{} postscript
% terminal.
% For example:
% \begin{quote}
% \begin{flushleft}
% |\egpfigprelude{set terminal postscript eps monochrome dashed "CMSS17" 20}|
% \end{flushleft}
% \end{quote}
% To see the correct font in the Postscript file you have to use the
% appropriate fontmap when calling dvips or you have to download the file
% |cmss17.pfb| as header file. The error message of dvips can then be
% ignored.\\
%
%
%
% Reset all options to their default values after every |egp|, |egpx| and
% |egpdef| environment.
% As mentioned above the file |reset.gp| that is generated at the start of the
% \GP{} run is |load|ed to implement the new |reset| command of \GP{}-3.6beta
% if the user didn't specify |gnuplot36beta| as package option.
% \begin{macrocode}
\ifthenelse{\boolean{egp@oldgp}}{%
\egpfigepilog{load "reset.gp"}}{%
\egpfigepilog{reset}}
% \end{macrocode}
%
% You can configure \EGP{} by putting the appropriate commands in the file
% egplot.cfg that has to be located where \TeX{} can find it.
% \begin{macrocode}
\InputIfFileExists{egplot.cfg}
{\typeout{egp: Using configuration file 'egplot.cfg'}}
{}
%</style>
% \end{macrocode}
%
% \Finale
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \appendix
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \section{Driver File}
%
% \begin{macrocode}
%<*driver>
\documentclass[a4paper]{article}
\usepackage{doc}
\usepackage{multicol}
% \end{macrocode}
%
% \begin{macrocode}
\IfFileExists{mflogo.sty}%
{\usepackage{mflogo}%
\def\GP{\textsf{gnuplot}}%
\def\EGP{\textsf{egplot}}%
\def\EMP{\textlogo{EMP}}}%
{\def\GP{\textsf{gnuplot}}%
\def\EMP{\textsf{EMP}}%
\def\EGP{\textsf{egplot}}}
% \end{macrocode}
%
% \begin{macrocode}
\usepackage[gnuplot35]{egplot}
%\usepackage[gnuplot36beta]{egplot}
% \end{macrocode}
% \begin{macrocode}
\setlength{\parindent}{0pt}
\def\manindex#1{\SortIndex{#1}{#1}}
%<manual>\OnlyDescription
\EnableCrossrefs
\RecordChanges
\CodelineIndex
\DoNotIndex{\def,\gdef,\long,\let,\begin,\end,\if,\ifx,\else,\fi}
\DoNotIndex{\immediate,\write,\newwrite,\openout,\closeout,\typeout}
\DoNotIndex{\font,\jobname,\documentclass,\char,\catcode,\ }
\DoNotIndex{\CodelineIndex,\DocInput,\DoNotIndex,\EnableCrossrefs}
\DoNotIndex{\filedate,\filename,\fileversion,\logo,\manfnt}
\DoNotIndex{\NeedsTeXFormat,\ProvidesPackage,\RecordChanges,\space}
\DoNotIndex{\begingroup,\csname,\edef,\endcsname,\expandafter}
\DoNotIndex{\usepackage,\@ifundefined,\ignorespaces,\item,\leavevmode}
\DoNotIndex{\newcounter,\newif,\par,\parindent}
\DoNotIndex{\relax,\setcounter,\stepcounter,\the,\advance}
\DoNotIndex{\CurrentOption,\DeclareOption,\documentstyle}
\DoNotIndex{\endgroup,\global,\hfuzz,\LaTeX,\LaTeXe}
\DoNotIndex{\macrocode,\@makeother,\OnlyDescription,\PassOptionsToPackage}
\DoNotIndex{\ProcessOptions,\RequirePackage,\string,\textsf,\unitlength}
\DoNotIndex{\@bsphack,\@esphack,\@nameuse,\@ne,\active,\do,\dospecials}
\DoNotIndex{\errhelp,\errmessage,\ifcase,\IfFileExists,\includegraphics}
\DoNotIndex{\manindex,\SortIndex,\newcommand,\newtoks,\or,\origmacrocode}
\DoNotIndex{\alpha,\displaystyle,\frac,\sin,\texttt}
% \end{macrocode}
% Cut the line breaking some slack for macro code which might contain
% long lines (it doesn't really hurt if they stick out a bit).
% \begin{macrocode}
\let\origmacrocode\macrocode
\def\macrocode{\hfuzz 5em\origmacrocode}
\begin{document}
\DocInput{egplot.dtx}
\end{document}
%</driver>
% \end{macrocode}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|