[pstricks] Question about unit in pstricks

Herbert Voss LaTeX at zedat.fu-berlin.de
Sat Oct 15 19:17:12 CEST 2005


Peter Staab wrote:
> I ran into a problem converting the ps to pdf in a latex file using 
> vectors fields and have finally nailed down the problem.
> 
> The following problem is closely related to the vector field code on the 
> pstricks web site.  If I set the parameter unit using:
> \pset{unit=0.5cm}
> where the unit is 0.5cm I get a error: "/invalidrestore in --restore-- " 
> (see below).  If I set the unit to 1cm or larger it is fine.  A guess of 
> the problem is the following:  since the code uses raw postscript, there 
> might be an issue in scaling. 
> 
> I should also mention that there must be two pspicture environments for 
> this to fail.  If I run the code on just one pspicture environment, 
> there is no error in converting the ps to pdf. 

> \begin{pspicture}(-6,-6)(6,6)
>   \psaxes{<->}(0,0)(-6,-6)(6,6)
>   \psset{arrows=->}
>   \multido{\ia=-5+1}{11}{%
>     \multido{\ib=-5+1}{11}{%
>       \pstVerb{/x \ia\space def

often \code inside of \pscuston is a better choice.
Try the following, it avoids the problem with gsave ... grestore

Herbert


\documentclass[a4paper]{article}
\usepackage{pst-plot}
\SpecialCoor% importanmt for all examples

\begin{document}
\psset{unit=0.5cm}
\begin{pspicture}(-6,-6)(6,6)
   \psaxes{<->}(0,0)(-6,-6)(6,6)
   \psset{arrows=->}
   \multido{\ia=-5+1}{11}{%
     \multido{\ib=-5+1}{11}{%
       \pscustom{%
       \code{/x \ia\space def
                /y \ib\space def
                y 0 eq
                  {/ValueTempA 0 def
                   /ValueTempB 0.5 def}
                  {/ValueTempZ 10 def
                   /ValueTempA y ValueTempZ div def
                   /ValueTempB x neg ValueTempZ div def}
                  ifelse}
       \psline(! x ValueTempA sub y ValueTempB sub)
              (! x ValueTempA add y ValueTempB add)}}
       }
\end{pspicture}

\begin{pspicture}(-6,-6)(6,6)
   \psaxes{<->}(0,0)(-6,-6)(6,6)
   \psset{arrows=->}
   \multido{\ia=-5+1}{11}{%
     \multido{\ib=-5+1}{11}{%
       \pscustom{%
          \code{/x \ia\space def
                /y \ib\space def
                y 0 eq
                  {/ValueTempA 0 def
                   /ValueTempB 0.5 def}
                  {/ValueTempZ 2 1 x x mul y y mul div add sqrt mul def
                   /ValueTempA 1 ValueTempZ div def
                   /ValueTempB x neg y ValueTempZ mul div def}
                  ifelse}
       \psline(! x ValueTempA sub y ValueTempB sub)
              (! x ValueTempA add y ValueTempB add)}}
       }
\end{pspicture}

\end{document}




More information about the PSTricks mailing list