[pstricks] Bookkeeping in pspicture environment

Herbert Voss Herbert.Voss at FU-Berlin.DE
Tue Jul 22 17:00:12 CEST 2008


Christoph Bersch schrieb:

> in the next pst-optexp version I want to integrate some kind of 
> bookkeeping for named objects. The names are defined with a parameter 
> 'compname'. The names are registered in a global list and before every 
> new definition it is checked if the name was already used.
> 
> Now this bookkeeping should be local in every pspicture environment. I 
> thought of doing this by redefining \pspicture as follows:
> 
> \let\old at pspicture\pspicture
> \def\pspicture{\let\@complist\@empty\old at pspicture}%
> 
> A working example would then be

[ ... ]

> This seems to work... The problem does not raise any PackageWarning, 
> only when uncommenting the last \psset{...} it is raised, as expected.
> 
> Are there any problems to be expected with my solution or do you have a 
> better suggestion how to solve this issue?

everything inside the pspicture environment is local. If
I understand well, then you want the list also be local.

\documentclass{article}
\usepackage{pst-xkey}
\usepackage{pstricks}
\makeatletter
\def\@complist{}
\define at key[psset]{}{compname}{%
     \def\pst at temp{#1}%
     \ifx\pst at temp\@empty\else
        \@expandtwoargs\in@{,#1,}{,\@complist,}%
        \ifin@
           \PackageWarning{}%
              {^^Jcompname '#1' already used.^^J}%
        \else
           \edef\@complist{\@complist\ifx\@complist\@empty\else,\fi#1}%
        \fi
     \fi
}%
\makeatother
\begin{document}

\begin{pspicture}(5,5)
    \psset{compname=Name}
\end{pspicture}
\begin{pspicture}(5,5)
    \psset{compname=Name}
   \psset{compname=Name}
\end{pspicture}

\end{document}

Herbert




More information about the PSTricks mailing list