% \iffalse 
%<*copyright>
% pawpict macros for use with LaTeX and PAW
% $Header: pawpict.dtx,v 1.0 97/12/24 14:43:14 sdc Exp $
%$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (C) 1997 Christian Holm.
%
% The pawpict package 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 of
% the License, or (at your option) any later version.
%
% The pawpict package 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.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% @LaTeX-style-file{
%%    Author     = "Christian Holm",
%%    Version    = "1.0",
%%    Date       = "1997/12/24",
%%    Time       = "14:43:14",
%%    Filename   = "pawpict.sty",
%%    Address    = "Niels Bohr Institute of Physics
%%                  University of Copenhagen
%%                  Denmark",
%%    Email      = "cholm@fys.ku.dk (Internet)",
%%    CodeTable  = "ISO/ASCII",
%%    Keywords   = "LaTeX2e, PAW, graphics",
%%    Supported  = "yes",
%%    Abstract   = "LaTeX package for providing easy inclusion of
%%                  graphics made in PAW"
%% }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%</copyright>
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\RecordChanges
\CodelineIndex
\typeout{Expect some Under- and overfull boxes}
\begin{document}
  \DocInput{pawpict.dtx}
\end{document}
% \fi
%
%\newcommand{\CERNLIB}{\textsc{cernlib}\index{CERNLIB}}
%\newcommand{\CMZ}{\textsc{cmz}\index{CMZ}}
%\newcommand{\COMIS}{\textsc{comis}\index{COMIS}}
%\newcommand{\CSPACK}{\textsc{cspack}\index{CSPACK}}
%\newcommand{\FATMEN}{\textsc{fatmen}\index{FATMEN}}
%\newcommand{\GEANT}{\textsc{geant}\index{GEANT}}
%\newcommand{\GKS}{\textsc{gks}\index{GKS}}
%\newcommand{\HBOOK}{\textsc{hbook}\index{HBOOK}}
%\newcommand{\HEPDB}{\textsc{hepdb}\index{HEPDB}}
%\newcommand{\HIGZ}{\textsc{higz}\index{HIGZ}}
%\newcommand{\HPLOT}{\textsc{hplot}\index{HPLOT}}
%\newcommand{\KUIP}{\textsc{kuip}\index{KUIP}}
%\newcommand{\MINUIT}{\textsc{minuit}\index{MINUIT}}
%\newcommand{\PATCHY}{\textsc{patchy}\index{PATCHY}}
%\newcommand{\PAW}{\textsc{paw}\index{PAW}}
%\newcommand{\SIGMA}{\textsc{sigma}\index{SIGMA}}
%\newcommand{\PAWPP}{\textsc{paw++}\index{PAW++}}
%\newcommand{\WWW}{\textsc{www}\index{WWW}}
%\newcommand{\VAXTAP}{\textsc{vaxtap}\index{VAXTAP}}
%\newcommand{\ZEBRA}{\textsc{zebra}\index{ZEBRA}}
%
%\def\fileversion{v1.0} 
%\def\filedate{97/12/24}
%\def\docdate {97/12/24}
%\def\bs{{\tt\char'134}}
%\newcommand{\Lcs}[1]{{\bs\tt#1}}
%
%\def\SpecialOptIndex#1{%
%    \index{#1\actualchar{\protect\ttfamily#1}
%           (option)\encapchar usage}%
%    \index{options:\levelchar{\protect\ttfamily#1}\encapchar
%           usage}}
%\def\DescribeOption{\leavevmode
%   \begingroup\MakePrivateLetters\DescribeOPT}
%\def\DescribeOPT#1{\endgroup
%              \marginpar{\raggedleft\PrintDescribeMacro{#1}}%
%              \SpecialOptIndex{#1}\ignorespaces}
%\def\SpecialPawIndex#1{%
%    \index{#1\actualchar{\protect\ttfamily#1}
%           (\textsc{paw} command)\encapchar usage}%
%    \index{paw\actualchar{\protect\textsc{paw} command:}%
%      \levelchar{\protect\ttfamily#1}\encapchar
%           usage}}
%\def\DescribePaw{\leavevmode
%   \begingroup\MakePrivateLetters\Describe@Paw}
%\def\Describe@Paw#1{\endgroup
%              \marginpar{\raggedleft\PrintDescribeMacro{#1}}%
%              \SpecialPawIndex{#1}\ignorespaces}
% 
% \DoNotIndex{\@ne,\advance,\begin,\char,\closein,\def,\DeclareOption}
% \DoNotIndex{\divide,\docdate,\else,\end,\fi,\filedate,\fileversion}
% \DoNotIndex{\framebox,\global,\ifdim,\ifeof,\ifnum,\ifx,\let,\loop}
% \DoNotIndex{\makebox,\mbox,\mutliply,\NeedsTeXFormat,\newcommand}
% \DoNotIndex{\newcount,\newdim,\newenvironment,\newif,\newsavebox}
% \DoNotIndex{\noindent,\openin,\PackageWarning,\par,\ProcessOptions}
% \DoNotIndex{\ProvidesPackage,\put,\relax,\repeat,\RequirePackage}
% \DoNotIndex{\rule,\savebox,\space,\tempa,\textsc,\tt,\undefined}
% \DoNotIndex{\usebox}
%
% \changes{v1.0}{97/12/24}{The creation of \textsf{pawpict}}
%
% \title{The \textsf{pawpict}--package\thanks{%
%    This package is based on output from \textsc{paw}.
%    This file has version number \fileversion{} dated \filedate{}.
%    The documentation was last revised on \docdate.
%       }}
% \author{Christian Holm\thanks{Due thancks to the creators of \textsc{paw}}}
%
% \date{\docdate}
% 
% \maketitle
% \begin{abstract}
%   This package is for use with \textsc{paw} as distributed from the
%   \textsc{cernlib}. It is intended to make it easier to include
%   pictures made in \textsc{paw} in \LaTeX{} documents. However, this
%   package is really only usefull if more then one such picture is
%   included in the document.
% \end{abstract}
%
% \tableofcontents
%
% \section{Motivation for use of \texttt{pawpict}}
%
% When you in \PAW{} create a picture for use in \LaTeX{}, you have
% the option of either making a (Encapsulated) Postscript file, and
% include this in your document by doing something like:
% \begin{verbatim}
%   \begin{figure}
%     \epsffile{example.eps}
%     \caption{Example of Encapsulated PostScript in \LaTeX{}.}
%     \label{EXAMPLE_EPS}
%     \end{figure}
% \end{verbatim}
% or you can create a Encapsulated \LaTeX{} file and include it with
% something like:
% \begin{verbatim}
%   \begin{figure}
%     \include{example.tex}
%     \caption{Example of Encapsulated \LaTeX{} in \LaTeX{}.}
%     \label{EXAMPLE_TEX}
%     \end{figure}
% \end{verbatim}
% 
% Now the \LaTeX{} version has the obvoius advantage, that they take
% up less disk space\footnote{Postscript Files are notriously big},
% and also, % you can view these files on \textit{any}
% \texttt{dvi}--previewer\footnote{Some \texttt{dvi}--previewers do
% not understand the \Lcs{special}  command needed for Postscript
% files}.
%
% However, the \LaTeX{} generated by \PAW{} tends to be rather long
% and hard to read, making it diffecult to make changes, or just get a
% clear picture of what is going on. Therefore, it would be nice to
% \textit{reduce} the size of these files, and make them easier to
% understand, as well as saving disk space.
%
% This package realizes this, by making the common commands needed for
% pictures generated by \PAW{} (actually \HIGZ{}) avaliable in one
% style file to be included by \Lcs{usepackage\{pawpict\}}
%
% \DescribeEnv{noborder}
% The option \texttt{noborder} is avaliable for the \texttt{pawpict}
% package. Pass the option \texttt{noborder} to pawpict, if you in
% \PAW{} have created the pictures without borders. Else do nothing.
%
% \section{How to use  \texttt{pawpict}}
%
% \subsection{Things to do in \PAW{}}
% To create a \LaTeX{} file containing a picture produced by \HIGZ{},
% do the following in \PAW{}:
% \begin{enumerate}
%   \item First you must open a file (in the current directory), and
%   assign it a Logical Unit Number (LUN). This is done by:
%   \DescribePaw{FORTRAN/FILE}
%   \begin{quote}
%      \texttt{FORTRAN/FILE} \textsl{LUN~FNAME} \texttt{[}
%      \textsl{STATUS} \texttt{]}
%   \end{quote}
%   where \textsl{LUN} is any integer\footnote{LUN 10 is used by
%   \PAW{} as \texttt{paw.metafile}}, \textsl{FNAME} is a valid file
%   name and \textsl{STATUS} can be any of:
%   \begin{description}
%    \item{OLD}       Open existing file for reading.
%    \item{APPEND}    Open existing file and position at EOF.
%    \item{NEW}       Create new file; error if already existing.
%    \item{UNKNOWN}   Open existing or create new file.
%    \item{DONTKNOW}  Like UNKNOWN except on VMS opens highest cycle.
%   \end{description}
%   Default is UNKNOWN.
%   \item Second, you should tell \HIGZ{} that it should create output
%   on a file and this is to be in the \LaTeX{} format. This is
%   accompliced in \PAW{} by:
%   \DescribePaw{GRAPHICS/METAFILE}
%   \begin{quote}
%     \texttt{GRAPHICS/METAFILE} [$\pm$]\textsl{LUN} -777
%     \textsl{FNAME} 
%   \end{quote}
%   where \textsl{LUN} is the Logical Unit Number, and \textsl{FNAME}
%   is the filename, used in 1. If \textsl{LUN} is provided negative,
%   then the picyures will \emph{not} be output on the display, but
%   only in the file. 
%   \item Now create what ever picture you may need, using zones,
%   superimpose, etc. However, do \emph{only} create one picture.
%   \item Lastly, you \emph{must} close the file:
%   \DescribePaw{FORTRAN/CLOSE}
%   \begin{quote}
%     \texttt{FORTRAN/CLOSE} \textsl{LUN}
%   \end{quote}
%   still using the \textsl{LUN} created in 1.
% \end{enumerate}
%
% Now you have a file in your current directory, containing \LaTeX{}
% commands to draw the picture created by \HIGZ{}. 
%
% There is an example of what might be in such a file (a lot is left
% out) in Figure~\ref{exa:higzfile} 
% \begin{figure}[htbp]\label{exa:higzfile}
% \begin{verbatim}
% HIGZ version 1.23/07 LaTeX metafile created  97/12/11   23.58
% \ifx\higzunit\undefined\unitlength=0pt{}
% \else\unitlength=\higzunit\fi
% \ifdim\unitlength=0pt\unitlength=\textwidth
% \divide\unitlength 2000\fi\par\noindent
% \begin{picture}(2000,2000)(0,0)
% \ifx\higzdraft\undefined\newcount
% \higzdraft\higzdraft=0{}\fi\ifnum\higzdraft>0
% \put(0,0){\framebox(2000,2000){}}
% \else\ifx\higzstep\undefined\newcount\higzstep\higzstep=0{}\fi
% \ifnum\higzstep<1\higzstep=2\fi
% ...
% \def\higzstroke#1,#2,#3,#4;{
% \advance\higzloffs\higzllen
% \ifnum\higzloffs>#1\advance\higzloffs-\higzllen\advance\higzloffs-#1
% \higzloffs=-\higzloffs\ifnum#2>0
% \put(\higzlx,\higzly){\line(#3,#4){\higzloffs}}\fi\
% ifnum#2<0\put(\higzlx,\higzly){\circle*{0}}\fi
% \higztemp=\higzloffs\multiply\higztemp#3
% \advance\higzlx\higztemp\higztemp=\higzloffs
% \multiply\higztemp#4\advance\higzly\higztemp
% \advance\higzllen-\higzloffs\higzloffs=#1
% \else\ifnum#2>0
% \put(\higzlx,\higzly){\line(#3,#4){\higzllen}}
% \fi\ifnum#2<0\put(\higzlx,\higzly){\circle*{0}}
% \fi\higzllen=0\fi}
% ...
% % End of Initialisation
% \let\higzline=\higzsolid
% \put(0,0){\framebox(2268,2268){}}
% \put(227,227){\framebox(1814,1814){}}
% \m1058,76;\s-1,3;\s-5,1;\r4;\s-5,-1;
% \s-1,-3;\s1,-3;\s3,-2;\s8,-1;\s3,-2;\s1,-3;
% \D1;\s-1,-4;\s-5,-1;\r4;\s-5,1;\s-1,4;
% \m1067,91;\s2,-2;\s1,2;\s-1,1;\s-2,-1;\m1069,80;
% ...
% \fi\end{picture}
% \end{verbatim}
% \caption{Example of a picture created by  \HIGZ{}} 
% \end{figure}
%
% \subsection{Things to do in an editor}
%
% The file created by \HIGZ{} contains
% \emph{all} the commands needed, but since a lot of these commands
% are also in style file \texttt{pawpict}, you need to take some of
% the definitions out of the file, created by \HIGZ{}.
%
% Open the newly created file in you favorite ASCII editor, and then
% delete up to the line saying
% \texttt{\% End of Initialisation}, and then save the file.
%
% The next step needed, is to edit your \LaTeX{} document, making
% paragraphs, text, tables, figures, etc and include the picture made
% by \HIGZ{}. More on this in the next section.
%
% \subsection{Things to do in document}
%  
% The picture should be included in some \textsc{figure}
% enviroment. To do this easely, \DescribeEnv{pawfig} use the
% \texttt{pawfig} enviroment. It takes one mandatory argument, the
% caption to put under the figure. It also has a optional
% argument. The optional argument is the width of the figure (defaults
% amounts to full page width).
%
% In any case, the \texttt{pawfig} environment, should be used as:
% \begin{quote}
% \Lcs{begin\{pawfig\}[}\textsl{option}\texttt{]\{}\textsl{caption}\texttt{\}}\\
%  \Lcs{input\{}\textsl{filename}\texttt{\}}\\
% \Lcs{end\{pawfig\}}\\
% \end{quote}
%
% \DescribeEnv{pawpict}
% Also, if you like, you can provide the figure enironment yourself,
% but then you should use the \texttt{pawpict} enviroment, wich takes
% no arguments. It is used like this:
% \begin{quote}
% \Lcs{begin\{pawpict\}}\\
%  \Lcs{input\{}\textsl{filename}\texttt{\}}\\
% \Lcs{end\{pawfig\}}\\
% \end{quote} 
%
% \DescribeEnv{pawfigure}
% This is a simple environment, that takes two mandatory arguments:
% the width and the caption. Optional argument is the placement.  
%
% \section{The User Commands}
% 
% In this part we describe the commands,
% which you have at your disposal in the present style.
% 
% \DescribeMacro{\pawdraft}
% You can use the command \Lcs{pawdraft} to control the output
% of the pictures made by \HIGZ{}. If this is set, no picture 
% will be drawn, instead, a frame of the size of the picture 
% is produced, at the place where the picture would go.
%
% \DescribeMacro{\pawfigplacement}
% This macro takes one argument, the placement of the figure
% floats. Notice this is meaningless if you use the \texttt{floatflt}
% package. The placement parameters are in the standard \LaTeX{} form.
% (\texttt{h}ere, \texttt{t}op, \texttt{b}ottom,
% or \texttt{p}age, in any combination. Default is \texttt{htbp}.)
% 
% \DescribeMacro{\pawincludepict}
% This macro includes a file, putting it in a \texttt{pawpict}
% environment. The mandaory argument is the filename, the optional is
% the width of the picture.
%
% \DescribeMacro{\pawincludefig}
% Much like above, only it is put in a \texttt{pawfig} environment,
% with to mandatory arguments, the filename, and the
% caption. Optionally the width of the figure may be specified.
%
% \DescribeMacro{\pawincludefigure}
% Much like above, only it is put in a \texttt{pawfigure} environment,
% with three mandatory arguments, the filename, the width, and the
% caption. Optionally the placement of the figure may be specified.
%
% There are also some commands for producing simple text 
% inserts. These are listed in Table~\ref{tab:short}. They are 
% basically convinient shorthand macroes for various text inserts,
% but also makes and index entry to that keyword.
%
% \begin{table}[htbp]
%   \label{tab:short}
%   \begin{tabular}{l l}
%     \textbf{Command}&\textbf{Resault}\\
%       \Lcs{CERNLIB}&  \textsc{cernlib}\\
%       \Lcs{CMZ}&      \textsc{cmz}\\
%       \Lcs{COMIS}&    \textsc{comis}  \\
%       \Lcs{CSPACK}&   \textsc{cspack}  \\
%       \Lcs{FATMEN}&   \textsc{fatmen} \\
%       \Lcs{GEANT}&    \textsc{geant}  \\
%       \Lcs{GKS}&      \textsc{gks}    \\
%       \Lcs{HBOOK}&    \textsc{hbook}  \\
%       \Lcs{HEPDB}&    \textsc{hepdb}  \\
%       \Lcs{HIGZ}&     \textsc{higz}   \\
%       \Lcs{HPLOT}&    \textsc{hplot}  \\
%       \Lcs{KUIP}&     \textsc{kuip}   \\
%       \Lcs{MINUIT}&   \textsc{minuit} \\
%       \Lcs{PATCHY}&   \textsc{patchy} \\
%       \Lcs{PAW}&      \textsc{paw}    \\
%       \Lcs{SIGMA}&    \textsc{sigma}  \\
%       \Lcs{PAWPP}&    \textsc{paw++}  \\
%       \Lcs{WWW}&      \textsc{www}    \\
%       \Lcs{VAXTAP}&   \textsc{vaxtap} \\
%       \Lcs{ZEBRA}&    \textsc{zebra}  \\
%    \end{tabular}
%    \caption{Shorthand macroes}
%  \end{table}
%
% \DescribeMacro{\bs}\DescribeMacro{\Lcs}
% Also defined are the macroes \Lcs{bs} and \Lcs{Lcs}.
% type, preceded by a backslash. \Lcs{bs} takes no argument, and produce 
% a backslash \bs{}. \Lcs{Lcs} takes one argument, and typesets this 
% argument in typewriter font, preceded by a backslash. This is usefull
% for macro descriptions etc. In fact \Lcs{Lcs} is produced by the 
% sequence \bs\texttt{Lcs\{Lcs\}}. These commands where actaully defined
% to ease the writing of this documentation, but left in the style, since
% I find them generally usefull. 
% 
% \iffalse
%<*package>
% \fi
%
% \section{Implementation}
% 
% In this section, the implementation of the \texttt{pawpict} package 
% will be described.
%
% \subsection{Style definitions}
%
% These definitions serve basically to say something about the style
% and not much else.
%
%    \begin{macrocode} 
\def\fileversion{v1.0} 
\def\filedate{97/12/12}
\def\docdate {97/12/12}
\ProvidesPackage{pawpict}[\filedate\space\fileversion\space pawpict
                          package.]
\NeedsTeXFormat{LaTeX2e}
\def\bs{{\tt\char'134}}
\newcommand{\Lcs}[1]{{\bs\tt#1}}
%    \end{macrocode}
%
% \subsection{Options}
%
% \DescribeOption{noborder}
% \DescribeOption{border}
% The Following is the avaliable options to the \texttt{pawpict}
% package.
%    \begin{macrocode}
\DeclareOption{border}{}
\DeclareOption{noborder}{\def\noborder{}}
\DeclareOption*{\PackageWarning{pawpict}{Unkown option: `\CurrentOption'}} 
\ProcessOptions\relax
%    \end{macrocode}
% Pass the option \texttt{noborder} to pawpict, if you in \PAW{} have
% created the pictures without borders. Else do nothing.
%
% \subsection{Control Commands}
%
% \begin{macro}{\pawdraft}
% This command controls wether \LaTeX{} should draw the picture, 
% or a box, the size of the picture.
%    \begin{macrocode}
\def\pawdraft{\def\higzdraft{}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pawfigplacement}
% This command tells \LaTeX{} how to place the figures, using normal
% \LaTeX{} placement syntax. It defaults to \texttt{htbp}.
%    \begin{macrocode}
\newcommand{\pawfigplacement}[1]{\def\tempa{#1}}
\ifx\tempa\undefined
  \def\figplacement{htbp}
\else
  \def\figplacement{\tempa{}}
\fi
%    \end{macrocode}
% \end{macro}
%
% \subsection{The enviroments}
%
% Next the environments are defined. 
%
% \paragraph*{Notice:} No definitions are 
% present in the environment definitions. This is not possible because
% of the way \TeX{} interpreds argumments. It would have been nice to 
% limit the use of the definitions to the enviroments, but I just don't
% know a way to do that. The reason why \TeX{} will not allow it, is
% because \TeX{} expands the possible arguments of an environment, in 
% \emph{all} subseguent uses of that argument, also in macro definitions.
% So if you have an enviroment that takes an argument, then \emph{every}
% occurence of \texttt{\#1}\footnote{\texttt{\#1} is the \textit{token} 
% \TeX{} uses for the \textit{type}: ``\textit{the first argument of a
% macro}''.} is concidered an argument to the environment. That means, 
% if you have a macro definition in the definition of the environment
% of the form \Lcs{def}\Lcs{foo\#1\{...\#1...\}}, then, the argument
% the user  gave to the environment, will be passed to the macro,
% which doesn't make sense, because you will create a new macro every
% time you use  the enviroment. For exapmle, if you gave the
% environment the argument `\texttt{foo}', then the above macro would
% be \Lcs{foobar\{...\#1...\}} wich is strictly forbidden. 
% 
% \begin{macro}{pawpict}
% This is the simple enviroment, that takes no arguments, and merely 
% provide the neccesary dimensions.
%    \begin{macrocode}
\newenvironment{pawpict}[1][\textwidth]{
  \ifx\higzunit\undefined
    \newdimen\higzunit
  \fi
  \higzunit#1
%    \end{macrocode}
% Test to see if dimension \Lcs{higzunit} is defined, then define
%  it. In any case, set it to the (optional) argument of
% \texttt{pawpict} which defaults to width of page
%    \begin{macrocode}
  \ifx\noborder\undefined
    \divide\higzunit2268
   \else
     \divide\higzunit2045
   \fi
   \unitlength\higzunit
%    \end{macrocode}
% First we check to see, if the dimension \Lcs{higzunit} is set. This
% should be set by \HIGZ{}, when it writes out the \LaTeX{} file, or 
% by some other style (maybe \texttt{cernman}?). If it isn't set, then 
% it becomes the size of the text width. In any case
% the unit lenght (\Lcs{unitlenght}) becomes one $2000^\mbox{\small th}{}$ or
% one $2268^\mbox{\small th}{}$ part of  \Lcs{higzwidth} depending on wether
% the picture was created with a border or not. \Lcs{textwidth} is
% usally defined in either a  class (such as \texttt{article}) or a
% style (such as \texttt{a4wide}). This is done to make the picture
% come out right relative to the text.
%    \begin{macrocode}
  \ifx\higzdraft\undefined
  \else
    \begin{picture}(2000,2000)
      \put(0,0){\framebox(2000,2000){}}
      \put(500,500){\mbox{Here will be a picture made by \PAW{}}}
    \end{picture}
    \unitlength=0pt{}
  \fi
%    \end{macrocode}
% This is a check to see, if the picture should be draw. This is 
% usefull if you don't want \LaTeX{} to produce the final picture, for
% example if you are preparing a draft of your document, and only want
% to see if the picture has the right  size, and comes out the right 
% place. If \Lcs{higzdraft} is set, then \LaTeX will only produce a
% frame in the size of the right size. You can control this by the 
% command \Lcs{pawdraft}.
%    \begin{macrocode}
  \ifx\higzstep\undefined
    \newcount\higzstep\higzstep=0{}
  \fi
  \ifnum\higzstep<1
    \higzstep=2
  \fi
%    \end{macrocode}
% The dimension \Lcs{higzstep} determinds in how many steps, a curve,
% line, etc should be drawn. The should \emph{not} be extarnally 
% defined, unless in some very rare cases.
%    \begin{macrocode}
  \ifx\higzxx\undefined
    \newcount\higzxx
    \newcount\higzyy
    \newcount\higzx
    \newcount\higzy
    \newcount\higzdx
    \newcount\higzdy
    \newcount\higzlx
    \newcount\higzly
    \newcount\higzslope
    \newcount\higzlen
    \newcount\higzllen
    \newcount\higzoffs
    \newcount\higzloffs
    \newcount\higzadash
    \newcount\higzbdash
    \newcount\higzcdash
    \newcount\higzddash
    \newcount\higzmsize
    \newcount\higztemp
  \fi
%    \end{macrocode}
% Define all the counters needed to draw the pictures, if they are 
% not defined\footnote{Actually, they should not be defined any where
% else, then via the \texttt{pawpict} environment.}
%    \begin{macrocode}  
  \par
  \noindent
  \ifx\noborder\undefined
    \begin{picture}(2268,2268)(0,0)
  \else
    \begin{picture}(2000,2000)(0,0)
  \fi
}
{
  \end{picture}
}
%    \end{macrocode}
% Finally, start a \texttt{picture} environment, to put the drawing 
% macroes inside. 
% \end{macro}
% 
% \begin{macro}{pawfig}
% This is the more complex environment, with one mandatory and one
% optional argument. It is set in a \texttt{floatingfigure} or 
% in a \texttt{figure} environment, depending on wether the 
% \texttt{floatflt} style is avaliable.
%
% By default the figures are treated as normal floats, but if the
% \texttt{floatflt} style is avaliable, it makes a nicer output, to
% use this package for floats (i.e.\ for figures)
% So that {\sf pawpict} can be run independently of {\tt floatflt.sty}
% we first check for its existence and set the "have@floatflt" flag
% appropriately for use below.
%    \begin{macrocode}
\newif\ifhave@floatflt
\openin\@ne floatflt.sty
\ifeof\@ne \else \have@floatflttrue \fi
\closein\@ne \relax
%    \end{macrocode}
% If we found {\tt floatflt.sty} we use it.  
%    \begin{macrocode}
\ifhave@floatflt 
  \RequirePackage{floatflt} 
\fi
%    \end{macrocode}
% Now the conditinal definition of the \texttt{pawfig} environment
%    \begin{macrocode}
\newsavebox{\pawfigcaption}
%    \end{macrocode}
% Savebox for the caption of the figure.
%    \begin{macrocode}
\ifhave@floatflt
  \newenvironment{pawfig}[2][\textwidth]{
    \savebox{\pawfigcaption}{#2}
%    \end{macrocode}
% Save the second (mandatory) argument in the save box for the
% caption.
%    \begin{macrocode} 
    \ifx\pawfigwidth\undefined
      \newdimen\pawfigwidth
    \fi
    \pawfigwidth#1
    \ifdim\pawfigwidth>\textwidth
      \pawfigwidth\textwidth
    \fi
%    \end{macrocode}
% Define the dimension \Lcs{pawfigwidth}, and set it to the first
% (optional) argument. Then test to see if this is bigger then the
% dimension \Lcs{textwidth}, if it is, then set it to that
% dimension.
%    \begin{macrocode} 
    \begin{floatingfigure}{\pawfigwidth}
      \begin{pawpict}[\pawfigwidth]
  }
  {
      \end{pawpict}
      \caption{\usebox{\pawfigcaption}}
    \end{floatingfigure}
  }
%    \end{macrocode}
% Using the \texttt{floatingfigure} environment, we make a figure in
% the width of the text, if no optional argument is given, and then 
% start the primitive \texttt{pawpict} environment. Finally the 
% caption is put under the figure. 
%    \begin{macrocode}
\else
  \newenvironment{pawfig}[2][\textwidth]{
    \savebox{\pawfigcaption}{#2}
    \ifx\pawfigwidth\undefined
      \newdimen\pawfigwidth
    \fi
    \pawfigwidth#1
    \begin{figure}[\figplacement]    
      \begin{pawpict}[\pawfigwidth]
  }
  {
      \end{pawpict}
      \caption{\usebox{\pawfigcaption}}
    \end{figure}
  }
\fi
%    \end{macrocode}
% End of the conditional definition of \texttt{pawfig} environmanent.
% \end{macro}
%
% \begin{macro}{pawfigure}
% This is a simple environment, that takes two mandatory arguments:
% the width and the caption. Optional argument is the placement.  
%    \begin{macrocode}
\newenvironment{pawfigure}[3][htbp]{%
  \savebox{\pawfigcaption}{#3}
  \ifx\pawfigwidth\undefined
      \newdimen\pawfigwidth
  \fi
  \pawfigwidth#2
  \begin{figure}[#1]    
    \begin{pawpict}[\pawfigwidth]
}
{
    \end{pawpict}
    \caption{\usebox{\pawfigcaption}}
  \end{figure}
}
%    \end{macrocode}
% \end{macro}
%  
% \subsection{Picture include commands}
%
% \begin{macro}{\pawincludepict}
% This macro includes a file, putting it in a \texttt{pawpict}
% environment. The mandaory argument is the filename, the optional is
% the width of the picture.
%    \begin{macrocode}
\newcommand{\pawincludepict}[2][\textwidth]{%
  \begin{pawpict}%
     \input{#2}%
  \end{pawpict}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\pawincludefig}
% Much like above, only it is put in a \texttt{pawfig} environment,
% with to mandatory arguments, the filename, and the
% caption. Optionally the width of the figure may be specified.
%    \begin{macrocode}
\newcommand{\pawincludefig}[3][\textwidth]{%
  \begin{pawfig}[#1]{#3}%
    \input{#2} %
  \end{pawfig}%
}
%    \end{macrocode}
% \end{macro} 
% \begin{macro}{\pawincludefigure}
% Much like above, only it is put in a \texttt{pawfigure} environment,
% with three mandatory arguments, the filename, the width, and the
% caption. Optionally the placement of the figure may be specified.
%    \begin{macrocode}
\newcommand{\pawincludefigure}[4][htbp]{%
  \begin{pawfigure}[#1]{#3}{#4}%
    \input{#2} %
  \end{pawfigure}%
}
%    \end{macrocode}
% \end{macro}
% 
% \subsection{The Drawing macroes}
%
% These macroes are not well documentated, I'm sorry \verb+:-(+.
%
% All the lines, curves, characters, etc.\ made by \HIGZ{} is made of 
% horizontal and vertical lines, or dots.
%
% In time, these maybe substuted with more efficient macros. Since the
% number of command needed to draw a picture is large, it takes some
% time to process the picture.
%
% \begin{macro}{\higzstroke}
% This defines the basic stroke of \HIGZ{}, an either vertical or 
% horizontal line.
%    \begin{macrocode}
\def\higzstroke#1,#2,#3,#4;{
  \advance\higzloffs\higzllen
  \ifnum\higzloffs>#1
    \advance\higzloffs-\higzllen
    \advance\higzloffs-#1
    \higzloffs=-\higzloffs
    \ifnum#2>0
      \put(\higzlx,\higzly){\line(#3,#4){\higzloffs}}
    \fi
    \ifnum#2<0
      \put(\higzlx,\higzly){\circle*{0}}
    \fi
    \higztemp=\higzloffs
    \multiply\higztemp#3
    \advance\higzlx\higztemp
    \higztemp=\higzloffs
    \multiply\higztemp#4
    \advance\higzly\higztemp
    \advance\higzllen-\higzloffs
    \higzloffs=#1
  \else
    \ifnum#2>0
      \put(\higzlx,\higzly){\line(#3,#4){\higzllen}}
    \fi
    \ifnum#2<0
      \put(\higzlx,\higzly){\circle*{0}}
    \fi
    \higzllen=0
  \fi
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\higzdased}
% Like above, only with spaces between the lines, to make dashed and
% punctured lines, curves etc. 
%    \begin{macrocode}
\def\higzdashed#1,#2,#3,#4,#5;{{
  \higzlx=#1
  \higzly=#2
  \higzllen=#5
  \higzloffs=\higzoffs
  \loop
  \ifnum\higzloffs<\higzadash
    \ifnum\higzadash>1
      \higzstroke\higzadash,1,#3,#4;
    \else
      \higzstroke\higzadash,-1,#3,#4;
    \fi
  \else
    \ifnum\higzloffs<\higzbdash
      \higzstroke
      \higzbdash,0,#3,#4;
    \else
      \ifnum\higzloffs<\higzcdash
        \higztemp=\higzcdash
        \advance\higztemp-\higzbdash
        \ifnum\higztemp>1
          \higzstroke\higzcdash,1,#3,#4;
        \else
          \higzstroke\higzcdash,-1,#3,#4;
        \fi
      \else
        \ifnum\higzloffs<\higzddash
          \higzstroke\higzddash,0,#3,#4;
        \else
          \higzloffs=0
        \fi
      \fi
    \fi
  \fi
  \ifnum\higzllen>0
  \repeat
  \global\higzoffs=\higzloffs
}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\higzsolid}
% This macro draws a solid line!
%    \begin{macrocode}
\def\higzsolid#1,#2,#3,#4,#5;{
  \put(#1,#2){\line(#3,#4){#5}}
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\higzhslant}
% This macro draws a slanted line made from small horizontal lines.
%    \begin{macrocode}
\def\higzhslant#1,#2,#3;{
  \higzslope=#1
  \multiply\higzslope1000
  \advance\higzslope500
  \divide\higzslope#2
  \higzlen=\higzslope
  \multiply\higzlen\higzstep
  \divide\higzlen1000
  \higzdy=0
  \loop
  \ifnum\higzdy<#2
    \higzx=\higzxx
    \higzy=\higzyy
    \higzdx=\higzslope
    \multiply\higzdx\higzdy
    \advance\higzdx500
    \divide\higzdx1000
    \advance\higzy\higzdy
    \multiply\higzdx#3
    \advance\higzx\higzdx
    \multiply\higzdx#3
    \advance\higzdx\higzlen
    \ifnum\higzdx>#1
      \advance\higzlen#1
      \advance\higzlen-\higzdx
    \fi
    \higzline\higzx,\higzy,#3,0,\higzlen;
    \advance\higzdy\higzstep
  \repeat
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\higzvslant}
% This macro draws a slanted line made from small vertical lines.
%    \begin{macrocode}
\def\higzvslant#1,#2,#3;{
  \higzslope=#2
  \multiply\higzslope1000
  \advance\higzslope500
  \divide\higzslope#1
  \higzlen=\higzslope
  \multiply\higzlen\higzstep
  \divide\higzlen1000
  \higzdx=0
  \loop
  \ifnum\higzdx<#1
    \higzx=\higzxx
    \higzy=\higzyy
    \higzdy=\higzslope
    \multiply\higzdy\higzdx
    \advance\higzdy500
    \divide\higzdy1000
    \advance\higzx\higzdx
    \multiply\higzdy#3
    \advance\higzy\higzdy
    \multiply\higzdy#3
    \advance\higzdy\higzlen
    \ifnum\higzdy>#2
      \advance\higzlen#2
      \advance\higzlen-\higzdy
    \fi
    \higzline\higzx,\higzy,0,#3,\higzlen;
    \advance\higzdx\higzstep
  \repeat
 }
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\s}
% Draws a slanted line. This calls either \Lcs{higzhslant} or 
% \Lcs{higzvslant} depending on the slope of the line.
%    \begin{macrocode}
\def\s#1,#2;{
  \higzdx=#1{}
  \ifnum\higzdx<0
    \higzdx=-\higzdx
  \fi
  \higzdy=#2{}
  \ifnum\higzdy<0
    \higzdy=-\higzdy
  \fi
  \ifnum\higzdx<\higzdy
    \ifnum#1<0
      \advance\higzxx#1
      \advance\higzyy#2
      \ifnum#2<0
        \higzvslant-#1,-#2,1;
      \else
        \higzvslant-#1,#2,-1;
      \fi
    \else
      \ifnum#2<0
        \higzvslant#1,-#2,-1;
      \else
        \higzvslant#1,#2,1;
      \fi
      \advance\higzxx#1
      \advance\higzyy#2
    \fi
  \else
    \ifnum#2<0
      \advance\higzxx#1
      \advance\higzyy#2
      \ifnum#1<0
        \higzhslant-#1,-#2,1;
      \else
        \higzhslant#1,-#2,-1;
      \fi
    \else
      \ifnum#1<0
        \higzhslant-#1,#2,-1;
      \else
        \higzhslant#1,#2,1;
      \fi
      \advance\higzxx#1
      \advance\higzyy#2
    \fi
  \fi
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\h}
% Draws a horizontal line.
%    \begin{macrocode}
\def\h#1;{
  \higzline\higzxx,\higzyy,1,0,#1;
  \advance\higzxx#1
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\r}
% Draws a horizontal line (reversed).
%    \begin{macrocode}
\def\r#1;{
  \higzline\higzxx,\higzyy,-1,0,#1;
  \advance\higzxx-#1
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\U}
% Draw an upward line.
%    \begin{macrocode}
\def\U#1;{
  \higzline\higzxx,\higzyy,0,1,#1;
  \advance\higzyy#1
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\D}
% Draws a downward line.
%    \begin{macrocode}
\def\D#1;{
  \higzline\higzxx,\higzyy,0,-1,#1;
  \advance\higzyy-#1
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\m}
% Move to the point \texttt{(\#1,\#2)}.
%    \begin{macrocode}
\def\m#1,#2;{
  \higzxx=#1
  \higzyy=#2
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\higzdot}
% Draws a dot.
%    \begin{macrocode}
\def\higzdot#1,#2;{
  \put(#1,#2){\circle*{\higzmsize}}
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\higzplus}
% A plus (+) sign.
%    \begin{macrocode}
\def\higzplus#1,#2;{
  \higzx=#1
  \multiply\higzx2
  \advance\higzx-\higzmsize
  \divide\higzx2
  \put(\higzx,#2){\line(1,0){\higzmsize}}
  \higzy=#2
  \multiply\higzy2
  \advance\higzy-\higzmsize
  \divide\higzy2
  \put(#1,\higzy){\line(0,1){\higzmsize}}
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\higzstar}
% Draws a star (an ``x'' on top of a ``+'').
%    \begin{macrocode}
\def\higzstar#1,#2;{
  \higzplus#1,#2;\higzcross#1,#2;
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\higzcircle}
% A circle.
%    \begin{macrocode}
\def\higzcircle#1,#2;{
  \put(#1,#2){\circle{\higzmsize}}
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\higzcross}
% Draws an ``x''
%    \begin{macrocode}
\def\higzcross#1,#2;{
  \let\higzsave\higzline
  \let\higzline\higzsolid
  \higzlx=#1
  \multiply\higzlx2
  \advance\higzlx-\higzmsize
  \divide\higzlx2\higzly=#2
  \multiply\higzly2
  \advance\higzly-\higzmsize
  \divide\higzly2
  \m\higzlx,\higzly;
  \s\higzmsize,\higzmsize;
  \higzly=#2
  \multiply\higzly2
  \advance\higzly\higzmsize
  \divide\higzly2
  \m\higzlx,\higzly;
  \s\higzmsize,-\higzmsize;
  \let\higzline\higzsave
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\p}
% Sets a point. \Lcs{higzmarker} is set by \HIGZ{}, to eihter 
% \Lcs{higzplus}, \Lcs{higzcross}, \Lcs{higzstar}, etc..
%    \begin{macrocode}
\def\p#1,#2;{
  \higzmarker#1,#2;
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\f}
% Draws a frame.
%    \begin{macrocode}
\def\f#1,#2;{
  \put(\higzxx,\higzyy){
    \makebox(#1,#2)[lb]{\rule{#1\unitlength}{#2\unitlength}}}
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Simple Text Producing Macroes}
%
%    \begin{macrocode}
\newcommand{\CERNLIB}{\textsc{cernlib}\index{CERNLIB}}
\newcommand{\CMZ}{\textsc{cmz}\index{CMZ}}
\newcommand{\COMIS}{\textsc{comis}\index{COMIS}}
\newcommand{\CSPACK}{\textsc{cspack}\index{CSPACK}}
\newcommand{\FATMEN}{\textsc{fatmen}\index{FATMEN}}
\newcommand{\GEANT}{\textsc{geant}\index{GEANT}}
\newcommand{\GKS}{\textsc{gks}\index{GKS}}
\newcommand{\HBOOK}{\textsc{hbook}\index{HBOOK}}
\newcommand{\HEPDB}{\textsc{hepdb}\index{HEPDB}}
\newcommand{\HIGZ}{\textsc{higz}\index{HIGZ}}
\newcommand{\HPLOT}{\textsc{hplot}\index{HPLOT}}
\newcommand{\KUIP}{\textsc{kuip}\index{KUIP}}
\newcommand{\MINUIT}{\textsc{minuit}\index{MINUIT}}
\newcommand{\PATCHY}{\textsc{patchy}\index{PATCHY}}
\newcommand{\PAW}{\textsc{paw}\index{PAW}}
\newcommand{\SIGMA}{\textsc{sigma}\index{SIGMA}}
\newcommand{\PAWPP}{\textsc{paw++}\index{PAW++}}
\newcommand{\WWW}{\textsc{www}\index{WWW}}
\newcommand{\VAXTAP}{\textsc{vaxtap}\index{VAXTAP}}
\newcommand{\ZEBRA}{\textsc{zebra}\index{ZEBRA}}
%    \end{macrocode}
% \iffalse
%</package>
% \fi
%
% \Finale
% \PrintIndex \PrintChanges
\endinput
