PSTree node labels - Take 2

Denis Girou Denis.Girou at idris.fr
Fri Dec 3 23:30:16 CET 1999


-----------------------------------------------------------------------------
This is the PSTricks mailing list, devoted to discussions about computational
graphics in (La)TeX using the PSTricks package from Timothy van Zandt.
For help using this mailing list, see instructions at the end of message.
-----------------------------------------------------------------------------

The following message is a courtesy copy of an article
that has been posted to comp.text.tex as well.

>>>>> "Anthony.Doggett" == adoggett  <adoggett at uiuc.edu> writes:

    Anthony.Doggett> OK.  I've been working on this labels problem, and in the process
    Anthony.Doggett> have changed the way that labels appear.  My problem however is still
    Anthony.Doggett> the same:  When I try to have two of my "labels" on the same PSTricks
    Anthony.Doggett> line, the second one falls to the point at the end of the line instead 
    Anthony.Doggett> of being in the middle where it should be.

    Anthony.Doggett> If my "labels" were just text then things would be fine, but I am
    Anthony.Doggett> wanting the fancy little arrow with a label of its own as my
    Anthony.Doggett> "label"s.  I believe that it is this "little arrow" that is
    Anthony.Doggett> causing the problem, but I don't understand why or how to fix it:(

  This was a complex bug, due to the conjonction of usage of two labels
on the same edge of a tree _and_ of node commands in these labels themselves.
So, you use nodes inside nodes, and the context was not properly restored
after the external one, which had the bad side effect you saw if you require
later another label on the same edge.

  In fact, it didn't affect only the \naput and \nbput macros, but the serie
of \tlput, \trput, \thput, \tvput as well.

  Here is a correction (I verify that it correct too the two test cases you
sent - and I can hope that it haven't another bad side effect...).

  Thanks for the report.

\documentclass{article}

\usepackage{pst-tree}

\newcommand{\arrowbit}{%
\cnode(0,0){.1}{A}
\pnode(0.6,0){B}
\ncline{->}{A}{B}}

\pagestyle{empty}

\begin{document}

\pstree{\Tr{A}}
       {\Tr{B}\nbput[nrot=:U]{\arrowbit}\naput[nrot=:D]{\arrowbit}}
\hfill
\pstree{\Tr{A}}
       {\Tr{B}\tlput{\pcline{<-}(-1,0)(0,0)\naput{left}}
              \trput{\pcline{->}(0,0)(1,0)\naput{right}}}
\hfill
\pstree{\Tr{A}}
       {\Tr{B}\thput{\pcline{<-}(-1,0)(0,0)\naput{left}}
              \tvput{\pcline{->}(0,0)(1,0)\naput{right}}}

\makeatletter

\def\ncput at iii{%
\leavevmode
\hbox{%
\pst at Verb{%
% DG/SR modification begin - December 3, 1999 - Patch 10
save
% DG/SR modification end
\pst at nodedict
/t \psk at npos def
\tx at LPut
end
\tx at PutBegin}%
\box\pst at hbox
% DG/SR modification begin - December 3, 1999 - Patch 10
%\pst at Verb{\tx at PutEnd}}}
\pst at Verb{\tx at PutEnd restore}}}
% DG/SR modification end

\def\psput at tput#1#2{%
\begingroup
\use at par
\pst at tputmakesmall
\leavevmode
\hbox{%
\pst at Verb{%
% DG/SR modification begin - December 3, 1999 - Patch 10
save
% DG/SR modification end
\pst at nodedict
/t \psk at tpos \pst at tposflip def
tx at NodeDict /HPutPos known
{ #1PutPos }
{ CP /Y ED /X ED /NAngle 0 def /NCLW 0 def }
ifelse
/Sin NAngle sin def
/Cos NAngle cos def
/s \pst at number\pslabelsep NCLW add def
/l \pst at number\pst at dima def
/r \pst at number\pst at dimb def
/h \pst at number\pst at dimc def
/d \pst at number\pst at dimd def
% DG/SR modification begin - Sep. 26, 1997 - Patch 4
%\ifnum1=0#2\else
\ifnum1=0#2 \else
% DG/SR modification end
/flag #2 def
\csname tx@#1PutAdjust\endcsname
\fi
\tx at LPutCoor
end
\tx at PutBegin}%
\box\pst at hbox
% DG/SR modification begin - December 3, 1999 - Patch 10
%\pst at Verb{\tx at PutEnd}}%
\pst at Verb{\tx at PutEnd restore}}%
% DG/SR modification end
\endgroup
\pst at shortput}

\makeatother

\vspace{1cm}

\pstree{\Tr{A}}
       {\Tr{B}\nbput[nrot=:U]{\arrowbit}\naput[nrot=:D]{\arrowbit}}
\hfill
\pstree{\Tr{A}}
       {\Tr{B}\tlput{\pcline{<-}(-1,0)(0,0)\naput{left}}
              \trput{\pcline{->}(0,0)(1,0)\naput{right}}}
\hfill
\pstree{\Tr{A}}
       {\Tr{B}\thput{\pcline{<-}(-1,0)(0,0)\naput{left}}
              \tvput{\pcline{->}(0,0)(1,0)\naput{right}}}

\end{document}


Denis Girou
-- 
--------------------------------------------------------------------------
Institut du Développement et des Ressources en Informatique Scientifique |
Centre National de la Recherche Scientifique                             |
Bâtiment 506 - B.P. 167 - 91403 Orsay Cedex - France                     |
--------------------------------------------------------------------------

-----------------------------------------------------------------------------
The list interface (subscription, information, access to the archives) is on:
http://www.tug.org/cgi-bin/lwgate/pstricks
Otherway to unsubscribe, send mail to pstricks-request at mail.tug.org
with a blank subject and in body the line unsubscribe <email-address>
-----------------------------------------------------------------------------



More information about the PSTricks mailing list