[pstricks] Accessing key/value parameters set using \psset incustom macros?

Hendri Adriaens Hendri at uvt.nl
Wed Apr 27 09:48:06 CEST 2005


> your macro still _overwrites_ a preceeding global setting by \psset.
> This can only be changed by a local option, like your linecolor=green.

And instead of \addbefore at par, one could use the
preset system, which allows users to change variables
globally. See an example below. Notice 2 things:

1) \use at par does not execute \@psset when \pst at par
(the optional argument) is empty, but this execution
is needed for the preset system, so we execute it
even if \pst at par is empty

2) the presets for eg linecolor do not influence
other pstricks macros at this time as they overwrite
the presets locally using \addbefore at par. If pstricks
would not do that, one would preferrably use a new
family of keys for the macro at hand to avoid changing
eg the linecolor of all lines in the document.

I supply this just as a demonstration. I'm aware that
the system doesn't fit with pstricks all that well as
pstricks resets things locally again. As this is a
demonstration, I won't worry too much about that now.

-Hendri.

\documentclass{article}
\usepackage{pstricks-add}

\makeatletter
\def\rjhLine{\pst at object{rjhLine}}
\def\rjhLine at i(#1,#2){%
  \pst at killglue
  \begingroup
  \expandafter\@psset\pst at par,\@nil
  \psline(#1,#2)%
  \endgroup
}
\makeatother

\presetkeys[psset]{}{%
  linecolor=blue,linewidth=1.25pt,arrowscale=1.25,arrows=->%
}{}

\begin{document}

\begin{pspicture}(-1,0)(3,4)
  \rjhLine[linecolor=green](-1,2)
  \rjhLine(3,4)
\end{pspicture}
% Change presets
\presetkeys[psset]{}{linecolor=gray}{}
\begin{pspicture}(-1,0)(3,4)
  \rjhLine[linecolor=green](-1,2)
  \rjhLine(3,4)
\end{pspicture}

\end{document}




More information about the PSTricks mailing list