[pstricks] problem with \pnode

Denis Girou Denis.Girou at idris.fr
Tue Jul 2 19:48:29 CEST 2002

>>>>> "Altheus" == altheus  <altheus at free.fr> writes:

    Altheus> i am trying to define my own electronic package with pstricks.
    Altheus> I would like to use the \pnode definition of nodes but i cannot
    Altheus> send this information trough my macro command named \resistor.
    Altheus> I give an example in order to see more precisely what the problem.

  This clearly cannot work this way. If you give node names as required
arguments of your \resistor macro, you will transmit them to the \info macro.
And in your \info macro, you wait two pairs of coordinates inside parentheses.
So, this is incoherent.

\resistor[name=$R$, pos=u](A)(B)



  First, you must change your \info macro to decode either coordinates either
node names. And for node names, you must do something completely different.
As I told you yesterday, giving the advice to read the explanations of
you cannot proceed at the TeX level, as you cannot got the coordinates of
a predefined node at the TeX level. So, you must rewrite all the content of
your \info macro in PostScript only, getting the coordinates of the nodes
with the GetCenter PostScript macro:

          \pst at nodedict
            % Points coordinates
            tx at NodeDict /N@#2 known
              {/N@#2 load GetCenter} {0 0} ifelse
            /YPa ED
            /XPa ED
            tx at NodeDict /N@#3 known
              {/N@#3 load GetCenter} {1 1} ifelse
            /YPd ED
            /XPd ED

  P.S. * For instance, you can learn these techniques studying the code of the
`pst-eucl' package, which use this kind of things:

       * Take care that you introduce a lot of spurious blanks in your code
(see the PSTricks documentation pages 3 and 4). This is why your resistor is
not at all at the horizontal (1,1)(2,3) coordinates in your first case.

       * To make tests on strings, use syntax like:

\def\comment at u{u}
\ifx\pst at pos\comment at u...

       * Avoid to use the commands \aput, \bput, \lput macros, which were
declared obsolete in 1994. See
http://tex.loria.fr/graph-pack/pstricks/pst-doc2.pdf pages 30-32. Rather use
\naput, \nbput, \ncput with the nrot parameter. 

       * Several persons have developed some specialized macros for
electronic circuits. At least Manuel Luque had given publicly his code.
You can found ideas looking at it.


More information about the PSTricks mailing list