[pstricks] New macro addtopsstyle
Herbert Voss
Herbert.Voss at fu-berlin.de
Sun Sep 9 14:42:29 CEST 2007
Christoph Bersch wrote:
> for me it would be comfortable to have a macro which adds some
> additional settings to an existing psstyle. Something like
>
> \newpsstyle{Fiber}{linecolor=green}
> \addtopsstyle{Fiber}{linewidth=0.1}
>
> -> style Fiber contains both informations
>
> The following code seems to work, but it uses the LaTeX macro
> \g at addto@macro. As I plan to include this into a PSTricks package, the
> question is, if I should rewrite it in plain TeX (don't know how), or if
> use of a LaTeX macro is ok.
>
\documentclass{article}
\usepackage{pstricks}
\makeatletter
\def\addto at psstyle#1#2{%
\pst at toks=\expandafter{#1#2}%
\edef#1{\the\pst at toks}}
\def\addtopsstyle#1#2{%
\@ifundefined{pscs@#1}{\newpsstyle{#1}{#2}}{%
\def\pst at tempA{#2}%
\ifx\pst at tempA\@empty\else
\expandafter\addto at psstyle\csname pscs@#1\endcsname{\psset{#2}}}\fi}
\makeatother
\newpsstyle{Fiber}{linewidth=0.1}
\begin{document}
\begin{pspicture}(5,5)
\psline[style=Fiber](0,0)(5,1)
\addtopsstyle{Fiber}{linecolor=green}
\psline[style=Fiber](0,1)(5,2)
\addtopsstyle{Fiber}{linestyle=dotted}
\psline[style=Fiber](0,2)(5,3)
\addtopsstyle{Fiber}{}
\psline[style=Fiber](0,3)(5,4)
\end{pspicture}
\end{document}
Herbert
More information about the PSTricks
mailing list