[pstricks] Defining an option similar to 'dash'
Herbert Voss
Herbert.Voss at FU-Berlin.DE
Mon May 26 22:39:33 CEST 2008
Christoph Bersch schrieb:
> I am trying to define an option which is similar to 'dash' in pstricks.tex:
>
> \documentclass{article}
> \usepackage{pstricks, pst-xkey}
> \makeatletter
> %
> % a dummy option
> \define at key[psset]{}{newoption}{\edef\psk at newoption{#1}}%
in nearly every case you shoudn't use \edef
The following works without an error message
\documentclass{article}
\usepackage{pstricks, pst-xkey}
\makeatletter
% a dummy option
\define at key[psset]{}{newoption}{\def\psk at newoption{#1}}%
%
\define at key[psset]{}{lens}{%
\pst at expandafter\psset@@lens{#1} {0} {0} %
{\pst at missing} {\pst at missing} {}\@nil
}%
\def\psset@@lens#1 #2 #3 #4 #5\@nil{%
\psset{linewidth=#1,%
linewidth=#2,%
linewidth=#3,%
% linewidth=#4
newoption=#4 % <- using this does not give the correct error
}%
}%
\makeatother
\begin{document}
\psset{lens=1 2 3 4}
\psset{lens=1 2 3}
\psset{lens=1 2}
\psset{lens=1}
bar
\end{document}
Herbert
> %
> \define at key[psset]{}{lens}{%
> \pst at expandafter\psset@@lens{#1} {0} {0} %
> {\pst at missing} {\pst at missing} {}\@nil
> }%
> \def\psset@@lens#1 #2 #3 #4 #5\@nil{%
> \psset{linewidth=#1,%
> linewidth=#2,%
> linewidth=#3,%
> linewidth=#4
> % newoption=#4 % <- using this does not give the correct error
> }%
> }%
> \makeatother
> \begin{document}
> \psset{lens=1 2 3 4}
> \psset{lens=1 2 3}
> \psset{lens=1 2}
> \psset{lens=1}
> \end{document}
>
> This way it works and gives me the correct error message
>
> ! Missing number or dimension. 0 substituted.
> \@pstrickserr ... immediate help.}\errmessage {#1}
> \endgroup
> l.25 \psset{lens=1}
>
> However, when I use 'newoption' instead of the 'linewidth' in the last
> assignment, it results in an
>
> ! Undefined control sequence.
> \@pstrickserr #1#2->\begingroup \newlinechar `\
>
> \edef \pst at tempc
> {#2}\expan...
> l.25 \psset{lens=1}
>
> I suppose it has to do something with the \pssetlength which is used
> when setting 'linewidth' compared to the \edef in the 'newoption'.
> What do I have to change in order to get the correct error message using
> the 'newoption=#4' in \psset@@lens?
>
> Thank you,
> Christoph
> _______________________________________________
> PSTricks mailing list
> PSTricks at tug.org
> http://tug.org/mailman/listinfo/pstricks
>
More information about the PSTricks
mailing list