[pstricks] Bookkeeping in pspicture environment

Christoph Bersch usenet at bersch.net
Tue Jul 22 17:12:41 CEST 2008


Herbert Voss schrieb:
> 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.
> 
[same code]
>            \edef\@complist{\@complist\ifx\@complist\@empty\else,\fi#1}%
[same code]

Sorry, I see, that my example was too minimal to show the issue.
The point is, that the parameter 'compname' is set only within an object 
(i.e. in a surrounding  group). Therefore, I need the \xdef\@complist in 
order to change \@complist outside of the group.
The following example should now reproduce more exactly the problem:

\documentclass{article}
\usepackage{pst-xkey}
\usepackage{pstricks}
\makeatletter
\let\old at pspicture\pspicture
\def\pspicture{\let\@complist\@empty\old at pspicture}%
\define at key[psset]{}{compname}{%
     \edef\pst at temp{#1}%
     \ifx\pst at temp\@empty\else
        \@expandtwoargs\in@{,#1,}{,\@complist,}%
        \ifin@
           \PackageWarning{}%
              {^^Jcompname '#1' already used.^^J}%
        \else
	 % Use definition of \XKV at addtolist@x with an \xdef instead
	 % of \edef in order to keep the bookkeeping global
           \xdef\@complist{\@complist\ifx\@complist\@empty\else,\fi#1}%
        \fi
     \fi
}%
\makeatother
\begin{document}
\begin{pspicture}(5,5)
    \begingroup
       \psset{compname=Name}
    \endgroup
\end{pspicture}
\begin{pspicture}(5,5)
    \begingroup
       \psset{compname=Name}
    \endgroup
    \begingroup
%     \psset{compname=Name}
    \endgroup
\end{pspicture}
\end{document}

Thank you,
Christoph



More information about the PSTricks mailing list