%% BEGIN pst-user.sty
%%
%% Macros for typesetting pst-user.tex v0.93, 0.93a.

\input tvz-user.sty
\input art12.sty
\input npsfont.sty
\input pstricks.tex
\input pst-node.tex
\input pst-coil.tex
\input pst-plot.tex

\def\thetitle{PSTricks: User's Guide}
\let\theheadertitle\thetitle  % Used with twoside option.
\let\fileversion\Version
\let\filedate\Date

% Paragraphs are marked by large space rather than indentation:
\parindent 0pt
\parskip 7pt plus 1pt minus 1pt

% These are for 8.5inx11in paper:
\oddsidemargin 5cm
\evensidemargin 5cm
\textwidth 11.5cm

% Total bottom margin 1in, text height 8.8in
\topmargin\z@
\textheight 8.8in
\footskip .625in

% No headers, 1in top margin
\headheight 0pt
\headsep 0pt

% Marginal notes always on left.
\marginparwidth 3.5cm
\marginparsep .5cm
\reversemarginpar

% Now adjust margins for different paper size:
% The a4 option sets \paperwidth and \paperheight for a4 paper:
\@ifundefined{paperwidth}%
{%
  \def\paperwidth{8.5in}
  \def\paperheight{11in}
}{%
  \@tempdima=\paperwidth\relax
  \advance\@tempdima-8.5in
  \divide\@tempdima 2
  \advance\oddsidemargin\@tempdima
  \advance\evensidemargin\@tempdima
  \@tempdima=\paperheight\relax
  \advance\@tempdima-11in
  \divide\@tempdima 2
  \advance\topmargin\@tempdima
}

% Now adjust left and right margins for twosided printing:
\if@twoside
  \advance\oddsidemargin.75cm
  \advance\evensidemargin-.75cm
\fi

%%%%%%%%%%%%%%% SECTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Section headings use customizable fonts, leave less space above
% and below, and may overhang on left.

\def\section{\@startsection{section}{1}{\sechang}%
  {-3ex plus -1ex minus -.2ex}{1.5ex plus .2ex}{\secfont}}
\def\subsection{\@startsection{subsection}{2}{\subsechang}%
  {-2.75ex plus -1ex minus -.2ex}{1.25ex plus .2ex}{\subsecfont}}
\newdimen\sechang
\newdimen\subsechang
\sechang=-.75in
\subsechang=-.375in
\def\secfont{\sf\LARGE\bf}       % Section headings
\def\subsecfont{\sf\Large\bf}    % Subsection headings


%%%%%%%%%%%%%%%%%%%% FONTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% See npsfonts.sty for the macros used below.
%% These font definitions require the NFSS.

\newpsfamily[.96]{times}{
  {m}{n}{ptmr},          %Times
  {m}{it}{ptmri},        %
  {m}{sl}{ptmri},        %
  {bx}{n}{ptmb},         %Times-Bold
  {bx}{it}{ptmbi},       %
  {bx}{sl}{ptmbi}}       %
\newpsfamily[.82]{helvetica}{
  {m}{n}{phvr},          %Helvetica
  {m}{it}{phvro},        %Helvetica-Oblique
  {m}{sl}{phvro},        %Helvetica-Oblique
  {bx}{n}{phvb},         %Helvetica-Bold
  {bx}{it}{phvbo},       %Helvetica-BoldOblique
  {bx}{sl}{phvbo}}       %Helvetica-BoldOblique
\newpsfamily[.96]{courier}{
  {m}{n}{pcrr},          %Courier
  {bx}{n}{pcrb},         %Courier-Bold
  {m}{it}{pcrr},         %Courier-Oblique
  {bx}{it}{pcrb}}        %Courier-BoldOblique
\newpsfamily[.965]{symbol}{{m}{n}{rpsyr}}         %Symbol

\renewcommand{\default@family}{times}%
\renewcommand{\rmdefault}{times}%
\renewcommand{\ttdefault}{helvetica}%
\renewcommand{\sfdefault}{helvetica}%
\family\default@family\selectfont

\define@mathgroup\mv@normal{0}{times}{m}{n}
\define@mathgroup\mv@normal{1}{times}{m}{it}
\define@mathgroup\mv@bold{0}{times}{bx}{n}
\define@mathgroup\mv@bold{1}{times}{bx}{it}

% A few tricks to avoid math fonts:
\def\AmS{AMS}

\def\symchar#1{%
  \mbox{%
    \kern .3pt
    \family{symbol}\series{m}\shape{n}\selectfont
    \char#1
    \kern .3pt}}

\def\lt{\symchar{'074}}
\def\gt{\symchar{'076}}
\def\leq{\symchar{'243}}
\def\geq{\symchar{'263}}
\def\bullet{\symchar{'267}}
\def\ldots{\symchar{'274}}
\mathcode`\-="20B1

% The font commands:
\def\MainFont{\tt\bf\large}            % For macro definitions.
\def\UsageFont{\tt\bf}                 % For in-line macro names.
\def\InlineFont{\tt}                   % For other in-line snipets of code.
\def\MetaFont{\sf\sl}                  % For meta arguments.
\def\OpArgFont{\series{m}\selectfont}  % For optional arguments.

% <foo> is short for {\MetaFont foo}.
% Works with \Verb command and LVerb* environment,
% but is disabled in LVerb environment.
\catcode`\<=13
\def<#1>{{\MetaFont #1\/}}

% Short-cuts for coordinates:
\def\x#1{{\MetaFont x#1\/}}
\def\y#1{{\MetaFont y#1\/}}
\def\c#1{{\InlineFont(\x{#1},\kern 1pt\y{#1})}}
\def\cn{\c{n}}

%%%%%%%%%%%%%%%%%%%%%%%% VERBATIM %%%%%%%%%%%%%%%%%%%%%%%%%%%%

\renewcommand{\EveryVerbatimLine}[2]{}

\renewcommand{\EveryVerbOutLine}[2]{}

\renewcommand{\VerbatimSpace}{\ \ }

\renewcommand{\VerbSpace}{\ \ }

\renewcommand{\EveryVerbatimCodes}{%
  \catcode`\"=14
  \catcode`\<=12}

\newenvironment{LVerb*}%
  {\VerbatimEnvironment
    \renewcommand{\ThisVerbCodes}{\catcode`\<=13}%
    \LVerbatim}%
  {\endLVerbatim}

\newenvironment{LVerb}{\VerbatimEnvironment\LVerbatim}{\endLVerbatim}

\renewcommand{\EveryVerbOutCodes}{%
  \catcode`\"=12
  \catcode`\<=12}

% Verbatim items:

\newcommand{\vitem}{\SaveVerb[{\item[\UseVerb{\MyTemp}]}]{\MyTemp}}

%%%%%%%%%%%%%%%%%%%%%%% EXAMPLE ENVIRONMENTS %%%%%%%%%%%%%%%%%%%%

% The Example environment uses the fancybox.sty macros
% 1. Save example verbatim to \jobname.tmp,
% 2. Input verbatim with \catcode`\"=14 (" is a comment).
% 3. Input again with \catcode\`"=9 (" is ignored).

% There are 5 example environments:
% 1. example   : center output
% 2. example*  : process output with no special formatting.
% 3. example** : Place on left side of verbatim input.
% 4. MEx       : Like example**, but contents put in picture environment.
% 5. MEx*      : Like MEx, but with grid.
\newcommand{\BeginExample}{%
  \VerbatimEnvironment
  \catcode`\<=12
  \begin{VerbatimOut}{\jobname.tmp}}

\newcommand{\EndExample}{%
  \end{VerbatimOut}%.
  \renewcommand{\EveryVerbatimLine}{}%
  \catcode`\"=9\relax}

\newenvironment{example}{\BeginExample}%
  {\EndExample\LVerbatimInput{\jobname.tmp}%
  \begin{center}\leavevmode\input{\jobname.tmp}\end{center}}

\newenvironment{example*}{\BeginExample}%
  {\EndExample\LVerbatimInput{\jobname.tmp}\input{\jobname.tmp}}

\newenvironment{example**}{\BeginExample}
  {\EndExample\SideBySideEx{\input{\jobname.tmp}}}

\newif\ifgrid
\newpsobject{usergrid}{psgrid}{subgriddiv=1,griddots=10,gridlabels=7pt}

\def\MEx{\@ifnextchar[{\@MEx}{\@MEx[0,0]}}
\def\@MEx[#1,#2](#3,#4){%
  \def\PictureSize{(#1,#2)(#3,#4)}%
  \BeginExample}
\def\endMEx{%
  \EndExample
  \SideBySideEx{%
    \expandafter\pspicture\PictureSize
    \ifgrid\usergrid\fi\relax
    \input{\jobname.tmp}%
    \endpspicture}}

\def\SideBySideEx#1{%
  \trivlist\item[]%
  \leavevmode\kern-\@totalleftmargin
  \hbox{\valign{%
    \vfil##\vfil\cr
    \hbox to \z@{\hss#1}\cr
    \hbox to \leftmargini{\hss}\cr
    \hbox{\BVerbatimInput{\jobname.tmp}}\cr}}%
  \endtrivlist}

\@namedef{MEx*}{\gridtrue\MEx}
\@namedef{endMEx*}{\endMEx}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% QUICK REFERENCE
%% The macro definitions are stored in in the command sequence
%% \quickref as they appear in the text. This is much easier
%% than trying to output the stuff to an auxiliary file and having
%% to worry about catcodes.

% An entry in \quickref is of the form: \qentry{type}{entry}
\def\quickref{}
\long\def\addtoquickref#1#2{%
  \expandafter\gdef\expandafter\quickref\expandafter{%
  \quickref\qentry{#1}{#2}}}
\def\qentry#1{\@nameuse{qr@#1}}

%% For switching into landscape mode for the Quick Reference:
\let\NormalShipout\shipout
\newbox\OutputBox
\def\LandscapeMode{%
  \long\def\shipout##1##2{%
    \setbox\OutputBox=\hbox{\rput[tl]{90}{\vbox{##2}}}%
    \NormalShipout\box\OutputBox}%
  \voffset 9in}

% This makes the Quick Reference:
\def\QuickReference{%
  \begin{Landscape}{\paperwidth}{\paperheight}{\rotateleft}
    \oddsidemargin 0pt
    \evensidemargin 0pt
    \topmargin -.5in
    \textheight 6.5in
    \textwidth 9in
    \columnsep 60pt
    \footskip 0pt
    \footheight 0pt
    \headheight 15pt
    \headsep 40pt
    \parskip 4pt plus 1pt minus 1pt
    \UsePageParameters
    \twocolumn
    \def\label##1{}
    \subsechang=-.25in
    \pagenumbering{Roman}
    \pagestyle{quickref}
    \MacroDefCodes
    \let\Main\string
    \let\MainFont\UsageFont
    \MainFont
    \quickref
  \end{Landscape}}

\def\ps@quickref{%
  \def\@oddhead{%
    \large\bf\sf
    \hbox to .5\textwidth{PSTricks\hfill}%
    \hbox to \z@{\hss Quick Reference\hss}%
    \hbox to .5\textwidth{\hfill\thepage}}
  \let\@evenhead\@oddhead
  \def\@oddfoot{}\def\@evenfoot{}}

% For page numbering in the QR:
\setbox\pst@boxg=\hbox{\UsageFont 99}
\newdimen\refnumdim
\refnumdim=\wd\pst@boxg
\def\refnum#1{\hbox to \refnumdim{\hss\rm\bf\pageref{#1}}}

% Section commands that add an entry to the QR:
\def\Section#1{\addtoquickref{section}{#1}\@checksec\section{#1}}
\def\Subsection#1{\addtoquickref{section}{#1}\subsection{#1}}

% This is just an error checker:
\def\@checksec{%
  \def\@tempa{document}%
  \ifx\@tempa\@currenvir\else
    \@latexerr{\string\Section\space occurred inside
      \@currenvir\space environment}\@ehc
    \expandafter\end\expandafter{\@currenvir}%
    \expandafter\@checksec
  \fi}

% The qr@ definitions:
\def\qr@@object#1{\mbox{\begingroup\escapechar`\+%
  \refnum{\string#1}\endgroup\hskip 1em\string#1}}
\def\qr@object#1{\qr@@object#1\par}
\def\qr@@param#1=#2\@nil{\refnum{\string#1}}
\def\qr@param#1{\leavevmode\hbox to\hsize{\qr@@param#1\@nil\hskip 1em#1}\par}
\def\qr@section#1{\subsection*{#1}}
\long\def\qr@center#1{\begin{center}#1\end{center}}

%%%%%%%%%%%%%%%%%%%%% PARTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\font\bighelv=phvb at 88bp

\def\part{\clearpage\leavevmode\@ifstar{\@@part}{\@part}}
\def\@part#1{%
  \refstepcounter{part}%
  \addcontentsline{toc}{part}{\protect\pnumberline{\thepart}#1}%
  \lower 20pt\hbox to \z@{\hss{\bighelv\Roman{part}}\hskip 2em}%
  \@@@part{#1}}
\def\@@part#1{\addcontentsline{toc}{part}{#1}\@@@part{#1}}
\def\@@@part#1{\markright{#1}{\sf\Huge\bf#1}\par\vskip 2cm\@afterheading}
\def\thepart{\Roman{part}}
\def\pnumberline#1{\hbox to\z@{\hss#1\hskip\@tempdima}}
\def\pnumberline#1{\hbox to2cm{Part #1\hfill}}

\def\l@part#1#2{%
  \addpenalty{\@secpenalty}%
  \addvspace{\lpartskip}%
  \begingroup
    \@tempdima 1em
    \parindent \z@ \rightskip \@pnumwidth
    \parfillskip -\@pnumwidth
    {\large\bf\leavevmode#1\hfil \hbox to\@pnumwidth{\hss #2}}\par
    \nobreak
  \endgroup}
\newskip\lpartskip
\lpartskip 1.25em plus 1pt minus 1pt


%%%%%%%%%%%%%%%%%% PARAMETER DEFINITIONS AND INDEXING %%%%%%%%%%%%%%%

% Like \MainEnvIndex, etc., but for parameters:
\def\MainParIndex{\SpecialIndex{parameter}{main}}
\def\UsageParIndex{\SpecialIndex{parameter}{usage}}

% Like \MainPar, but for parameters. Can optionally include =foo.
\def\MainPar#1{\@MainPar#1==\@nil}
\def\@MainPar#1=#2=#3\@nil{%
  \MainParIndex{#1}%
  \label{#1}%
  {\MainFont #1\ifx#3=\relax=\MetaFont#2\fi}}

% Analogous to \n, but optionally argument can include =foo.
\def\p#1{\@p#1==\@nil}
\def\@p#1=#2=#3\@nil{%
  \UsageParIndex{#1}%
  {\UsageFont #1\ifx#3=\relax=#2\fi}}

% For listing parameter definitions in a {description} environment:
\def\pitem[#1]{\@ifnextchar({\@pitem#1}{\@@pitem#1\@nil}}
\def\@pitem#1=#2(#3){%
  \item[\MainFont#1=\MetaFont#2]%    % Set the definition in \MainFont
  \MainParIndex{#1}%
  \label{#1}%
  \addtoquickref{param}{#1={\MetaFont #2}\hfill {\rm Default:} #3}%
  \hfill {\MainFont {\rm Default:} #3}\par}
\def\@@pitem#1=#2\@nil{%
  \@ifundefined{default@#1}%
    {\@warning{Parameter `#1' default not defined.}\@eha\@pitem#1=#2()}
    {\@pitem#1=#2(\csname default@#1\endcsname)}}

% Read in a list of defaults extracted from pstricks.doc:
\begingroup
  \catcode`\@=12
  \catcode`\{=12
  \catcode`\}=12
  \catcode`\&=1
  \catcode`\^=2
  \def\psset@&%
    \begingroup
    \catcode`\\=12
    \pssetxx^
  \def\pssetxx#1{#2}&%
    \expandafter\gdef\csname default@#1\endcsname&#2^%
    \endgroup^
  \csname @input\endcsname&defaults.pst^
\endgroup

% For putting parameter definitions in an Ex environment:
\def\Par#1{\@ifnextchar({\@Par#1}{\@@Par#1\@nil}}
\def\@Par#1=#2(#3){%
  \leavevmode
  \MainParIndex{#1}%
  \label{#1}%
  \addtoquickref{param}{#1={\MetaFont #2}\hfill {\rm Default:} #3}%
  \hbox to\linewidth{%
    \MainFont #1={\MetaFont#2}\hfill {\rm Default:} #3}\par}
\def\@@Par#1=#2\@nil{%
  \@ifundefined{default@#1}%
    {\@warning{Parameter `#1' default not defined.}\@Par#1=#2()}
    {\@Par#1=#2(\csname default@#1\endcsname)}}


%%%%%%%%%%%%%%%%%% MACRO DEFINITIONS AND INDEXING %%%%%%%%%%%%%%%

% There are four commands for listing macro definitions:
%  1. \mitem   : List in a description environment
%  2. \oitem   : Like \mitem, but optional *[par] automatically inserted.
%  3. \object  : List in a description environment.
%  4. \Mac     : Short for \begin{Ex}\object foo\end{Ex}.
%
% In each case:
%  1. definition is delimited only by end-of-line.
%  2. {}, () and [] are literal, with contents set in \MetaFont
%  3. = and , are literal.
%  4. `foo' is for optional arguments.
%  5. <foo> is meta, as usual.

\begingroup
  \catcode`\(=13
  \catcode`\,=13
  \catcode`\==13
  \gdef\MacroDefCodes{%
    \@MD
    \catcode`\(13
    \catcode`\^^M12
    \catcode`\`13
    \catcode`\,13
    \catcode`\!1
    \catcode`\@2
    \def~{}%
    \def={{\fontshape{n}\selectfont\string=}}%
    \def,{{\fontshape{n}\selectfont\string,}}%
    \def(##1){\string({\MetaFont ##1})}}
\endgroup

\begingroup
  \catcode`\`=13 \gdef`#1'{{\OpArgFont #1}}
\endgroup

\begingroup
  \catcode`\^^M=12\relax%
  \gdef\GetMacroDef#1{\begingroup\MacroDefCodes\@GetMacroDef{#1}}%
  \gdef\@GetMacroDef#1#2^^M{#1{#2}\endgroup}%
\endgroup

% For listing macro definitions in a "description" environment:
\def\mitem{\GetMacroDef\@mitem}
\def\@mitem#1{%
  \item[{\MainFont\Main#1}]%
  \addtoquickref{object}{#1}%
  \leavevmode\par}

% For listing graphics object definitions in a {description} environment:
% The optional *[par] is inserted automatically.
\def\oitem{\GetMacroDef\@oitem}
\def\@oitem#1{\@@oitem#1\@nil}
\def\@@oitem#1#2\@nil{\@mitem{#1{\OpArgFont*[{\MetaFont par}]}#2}}

% For generic macro definition, usually to be put in a displayed env.
\def\object{\GetMacroDef\@object}
\def\@object#1{\addtoquickref{object}{#1}{\MainFont\Main#1\@@par}}

% For a single displayed macro definition:
\def\Mac{\GetMacroDef\@Mac}
\def\@Mac#1{\begin{Ex}\@object{#1}\end{Ex}}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%]
%% INDEX:
%%
\def\PrintUserIndex{%
  \clearpage
  \columnsep=20pt
  \advance\oddsidemargin\sechang
  \advance\evensidemargin\sechang
  \advance\textwidth-\sechang
  \sechang=0pt
  \onecolumn
  \@input{\jobname.ind}}


%%%%%%%%%%% FRAMED WARNINGS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newbox\bombbox
\setbox\bombbox=\hbox to\z@{%
  \hss
  \rput[r](-1.5cm,0){%
    \psset{unit=7pt}
    \begin{pspicture}(-4,-4)(4,4)
      \pscircle[fillcolor=gray,fillstyle=solid]{4}
      \rput{45}{\scaleboxto(6,0){PS\kern-1pt}}
      \psellipse*(0,3.8)(1,.2)
      \psellipse*(0,5.5)(1,.2)
      \psframe*(-1,3.8)(1,5.5)
      \psbezier(0,5.5)(0,7)(1,8)(3.5,8)
      \multido{\r=-0+40}{9}{\rput{\r}(3.5,8){\psline(0,0)(.4,0)}}
    \end{pspicture}}}

\def\Warning{%
  \trivlist\item[]
  \leavevmode\kern\@totalleftmargin
  \valign\bgroup%
    \vfil##\vfil\cr
    \copy\bombbox\cr
    \minipage{\textwidth}
    \quote
    \em Warning:\hskip 1em
    \ignorespaces}
\def\endWarning{\endquote\endminipage\cr\egroup\endtrivlist}

\newbox\filebox
\setbox\filebox=\hbox{%
  \pspicture(-1,-.5)(1,.7)
  \pspolygon[linearc=2pt,shadow=true,shadowangle=45,xunit=1.1]%
    (-1,-.55)(-1,.5)(-.8,.5)(-.8,.65)(-.2,.65)(-.2,.5)(1,.5)(1,-.55)
   \endpspicture}
\def\File#1{%
  \leavevmode
  \marginpar{%
    \leavevmode\lower 20pt\hbox{%
      \hbox to0pt{\hbox to \linewidth{\hss\copy\filebox\hss}\hss}%
      \raise 10pt\hbox to \linewidth{\hss\large\bf\sf #1\hss}}}%
   \ignorespaces}


%%%%%%%%%%%%%%%%%%%%  MISCELLANEOUS  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Driver notes:
\def\drivers{\noindent\small Driver notes:\hskip 1em\ignorespaces}

% This makes " a short verb. E.g., "\foo" instead of \verb+\foo+.
\catcode`\"=\active
\def"{\verb"}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\endinput

%% END pst-user.sty