10
\documentclass[preview,border=2cm]{standalone}
\usepackage{pst-tools}
\usepackage{pst-node}
\psset{saveNodeCoors}


\begin{document}
\section*{With pnode}

\begin{pspicture}(3,3)
    \pnode(1,1){A}
    \rput(0,3){\psPrintValue{N-A.x}}
    \rput(0,0){\psPrintValue{N-A.y}}
\end{pspicture}

\section*{With nodexn}

\begin{pspicture}(3,3)
    \nodexn{(1,1)}{A}
    \rput(0,3){\psPrintValue{N-A.x}}
    \rput(0,0){\psPrintValue{N-A.y}}
\end{pspicture}
\end{document}

enter image description here

Edit

I strongly believe by inspection that \nodexn does not respect the existence of saveNodeCoors so the variable N-<node_name>.x and N-<node_name>.y are left uninitialized.

\documentclass[preview,border=1cm]{standalone}
\usepackage{pst-tools}
\usepackage{pst-node}
\psset{saveNodeCoors}


\begin{document}
\psLoop{5}{%
\begin{pspicture}(3,3)
    \pnode(1,1){A}
    \rput(0,2){\psPrintValue{N-A.x}}
    \rput(0,1){\psPrintValue{N-A.y}}
    %
    \nodexn{(1,1)}{B}
    \rput(2,2){\psPrintValue{N-B.x}}
    \rput(2,1){\psPrintValue{N-B.y}}
\end{pspicture}
\qquad}
\end{document}

enter image description here

  • What I find interesting is that the node generated by \nodexn seems to have the correct coordinates, not only in the displayed output, but also when you use \shownode. However, things seem to go awry when you apply N-<node_name>.x and N-<node_name>.y to a node generated via \nodexn – A.Ellett Dec 30 '13 at 20:03
  • I've been mucking around with this since you posted similar questions yesterday. Very bizarre and hard to debug. Other than \shownode do you know of other tools to help see what's happening inside the ps part of pstricks? – A.Ellett Dec 30 '13 at 20:05
  • It is absolutely a bug! – kiss my armpit Dec 30 '13 at 21:03
  • I will give 10 bounties of 500 each to a person who can prove that my assumption (i.e., there is a bug in \nodexn causing this issue) is wrong. – kiss my armpit Dec 31 '13 at 10:33
6
+200

That is not a bug in \nodexn, but could be regarded as a bug in saveNodeCoors. You can see the same behaviour when using e.g. \pnode(1,1){A}\pnode(A){C}. The error happens also with \nodexn, because that macro defines an internal node, which value is loaded in order to save its coordinates in N-<node>.x and N-<node>.y:

\documentclass[preview,border=1cm]{standalone}
\usepackage{pst-tools}
\usepackage{pst-node}
\psset{saveNodeCoors}

\begin{document}
\begin{pspicture}(5,3)
    \pnode(1,1){A}
    \rput(0,2){\psPrintValue{N-A.x}}
    \rput(0,1){\psPrintValue{N-A.y}}
    %
    \nodexn{(1,1)}{B}
    \rput(2,2){\psPrintValue{N-B.x}}
    \rput(2,1){\psPrintValue{N-B.y}}
    % 
    \pnode(A){C}
    \rput(4,2){\psPrintValue{N-C.x}}
    \rput(4,1){\psPrintValue{N-C.y}}
\end{pspicture}
\end{document}

That gives:

enter image description here

That happens, because the Postscript transformation matrix when saving N-<node>.x and N-<node>.y is not the same as the one when saving the new node. And this error appears only when loading the coordinates from a previous node, which happens e.g. with \pnode(A){C} or with \nodexn, which internally uses a temporary node from which the coordinates are loaded.

The following changes to \pst@newnode fixes the error:

Replace the lines

\ifPst@saveNodeCoors
    \ifx\relax#3\relax 0 0 \else #3 \tx@UserCoor \fi 

with

\ifPst@saveNodeCoors
    \ifx\relax#3\relax 
      0 0 
    \else 
      gsave 
        tx@Dict begin 
          STV CP T
        end
        #3 \tx@UserCoor
      grestore
    \fi

The following example, which has these changes, give the correct results:

\documentclass[preview,border=1cm]{standalone}
\usepackage{pst-tools}
\usepackage{pst-node}
\makeatletter
% the following is the definition from pst-node.tex v 1.30, with the mentioned changes
\def\pst@newnode#1#2#3#4{%
\pst@killglue
\leavevmode
\pst@getnode{#1}\pst@thenode
\pst@Verb{
  \ifPst@saveNodeCoors
    \ifx\relax#3\relax 
      0 0 
    \else 
      gsave 
        tx@Dict begin 
          STV CP T
        end
        #3 \tx@UserCoor
      grestore
    \fi 
%  startGlobal
%  \tx@UserCoor
  /N-#1.y\space exch def
  /N-#1.x\space exch def
%  endGlobal
  \fi
  \pst@nodedict
  {#3}
  \ifx\psk@name\relax false \else \psk@name true \fi
  \pst@thenode
  #2
  {#4}
  \tx@NewNode
  end 
}%
%
\global\let\psk@name\relax%
\pstree@nodehook%
\global\let\pstree@nodehook\relax}
\makeatother

\psset{saveNodeCoors}

\begin{document}
\begin{pspicture}(5,3)
    \pnode(1,1){A}
    \rput(0,2){\psPrintValue{N-A.x}}
    \rput(0,1){\psPrintValue{N-A.y}}
    %
    \nodexn{(1,1)}{B}
    \rput(2,2){\psPrintValue{N-B.x}}
    \rput(2,1){\psPrintValue{N-B.y}}
    % 
    \pnode(A){C}
    \rput(4,2){\psPrintValue{N-C.x}}
    \rput(4,1){\psPrintValue{N-C.y}}
\end{pspicture}
\end{document}

enter image description here

Edit

This problem has been fixed in pst-node.tex, version 1.32 2014-02-03.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.