[pstricks] Bookkeeping in pspicture environment
Christoph Bersch
usenet at bersch.net
Tue Jul 22 16:08:41 CEST 2008
Hi,
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
\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)
\psset{compname=Name}
\end{pspicture}
\begin{pspicture}(5,5)
\psset{compname=Name}
% \psset{compname=Name}
\end{pspicture}
\end{document}
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?
Thank you,
Christoph
More information about the PSTricks
mailing list