[pstricks] Using \@ifnextchar in node definition
Christoph Bersch
usenet at bersch.net
Wed Nov 11 16:42:25 CET 2009
Herbert Voss schrieb:
> Am 11.11.2009 13:37, schrieb Christoph Bersch:
>
>> how can I use commands that use \@ifnextchar to build node names? The
>> following does not work:
>
> PSTricks checks the first character of the coordinates to decide what
> kind of values are present. For nodes it compares the catcode of "a"
> with the first character of the argument. If it is the same catcode, it
> must be a node. This doesn't work with your \mynode, because it has
> another catcode than "a"
But then using raw coordinates or constructing the trailing part of the
name should work, but it does not:
\documentclass{article}
\usepackage{pst-node}
\SpecialCoor
\makeatletter
\def\mynode{%
\@ifnextchar[{\mynode at i}{\mynode at i[]}
}%
\def\mynode at i[#1]#2{%
#2%
}%
\makeatother
\begin{document}
\begin{pspicture}(5,5)
\pnode(2,2){A}
\makeatletter
\psdot(! \pst at nodedict N@\mynode{A} GetCenter \tx at UserCoor end)
\makeatother
%
\pnode(1,1){AA}
\psdot(A\mynode{A})
\end{pspicture}
\end{document}
Both variants give me the error
! Use of \psdot at ii doesn't match its definition.
Thank you,
Christoph
More information about the PSTricks
mailing list