[pstricks] pst-tree label position

Jonne Zutt j.zutt at ewi.tudelft.nl
Thu Sep 30 23:23:30 CEST 2004


Dear pstrickers,

I am using pst-tree to draw a binary tree diagram.
Can someone help me positioning a label correctly?

Each node has several formulas that I put in a tabular to align
formula number, formule and the rule that was applied.
There are always 0 or 2 children. If there are two, I would like
to label this branch in the center, like this:

       formula_1
       formula_2
           /\
          /  \
         /(10)\
        /      \
       /        \
      /          \
     /            \
   formula_3    formula_4
   etc.         etc.

I provided a (auto-generated) latex example below (I am not happy with
the placement of the (##) labels).

ps > reason why I set the huge page size is that I want to convert the
tree to an image file. Hence, I do not want to have multiple pages.
Another problem I have is to clip the extra whitespace out of the image
(but this might not be the correct place to ask for help on that =)

ps2 > i'm afraid my mailer will break some lines :(

Thanks in advance,
Jonne.

\documentclass{article}
\usepackage{pst-tree}
% some people might require the following line, for me it gave
% some name clash, so I removed it and that worked...
%\usepackage[dvips]{color}

\textwidth=100in
\textheight=100in
\special{papersize=100in,100in}
\thispagestyle{empty}           % no page numbers

\begin{document}
\thispagestyle{empty}           % i said no page numbers

% Three colors:
% Blue  = regular formulas
% Black = literals ( [~]p_0 )
% Red   = literal that closes tree

\Huge

\newcommand{\of}{$\vee$}
\newcommand{\en}{$\wedge$}
\newcommand{\imp}{$\rightarrow$}
\newcommand{\desda}{$\leftrightarrow$}
\newcommand{\niet}{$\neg$}

\newcommand{\MyNode}[3][]{%
  \TR[ref=t]{#1{\psframebox{\begin{tabular}[t]{#2}#3\end{tabular}}}}}

\psset{levelsep=*2cm} % nodesep=2pt,labelsep=0pt,tpos=.3

\pstree{\MyNode[{\rnode[b]{PredA}}]{rll}{%
  1. & \textcolor{black}{a\imp{}b\of{}c\imp{}d\en{}e} & (hypothese)\\
  2. & \textcolor{black}{e\of{}f\imp{}g} & (hypothese)\\
  3. & \textcolor{black}{\niet{}(a\imp{}c\imp{}g)} & (\niet{} conclusie)\\
  4. & \textcolor{black}{a\en{}\niet{}(c\imp{}g)} & (\imp{}-regel, 3)\\
  5. & \textcolor{blue}{a} & (\en{}-regel, 4)\\
  6. & \textcolor{black}{\niet{}(c\imp{}g)} & (\en{}-regel, 4)\\
  7. & \textcolor{black}{c\en{}\niet{}g} & (\imp{}-regel, 6)\\
  8. & \textcolor{blue}{c} & (\en{}-regel, 7)\\
  9. & \textcolor{blue}{\niet{}g} & (\en{}-regel, 7)\\
  10. & \textcolor{black}{\niet{}(e\of{}f)\of{}g} & (\imp{}-regel, 2)\\
  11. & \textcolor{black}{\niet{}a\of{}(b\of{}c\imp{}d\en{}e)} &
(\imp{}-regel, 1)}}{
\renewcommand{\pspred}{PredA}%
\pstree{\MyNode[{\rnode[b]{PredB}}]{rll}{%
  12. & \textcolor{black}{\niet{}(e\of{}f)} & \\
  13. & \textcolor{black}{\niet{}e\en{}\niet{}f} & (\of{}-regel, 12)\\
  14. & \textcolor{blue}{\niet{}e} & (\en{}-regel, 13)\\
  15. & \textcolor{blue}{\niet{}f} & (\en{}-regel, 13)}\thput{(10)}}{
\renewcommand{\pspred}{PredB}%
\pstree{\MyNode[{\rnode[b]{PredC}}]{rll}{%
  16. & \textcolor{blue}{\niet{}a} & \\
  & \textcolor{red}{X(5, 16)}}\thput{(11)}}{
}
\pstree{\MyNode[{\rnode[b]{PredC}}]{rll}{%
  17. & \textcolor{black}{b\of{}c\imp{}d\en{}e} & \\
  18. & \textcolor{black}{\niet{}(b\of{}c)\of{}(d\en{}e)} & (\imp{}-regel,
17)}}{
\renewcommand{\pspred}{PredC}%
\pstree{\MyNode[{\rnode[b]{PredD}}]{rll}{%
  19. & \textcolor{black}{\niet{}(b\of{}c)} & \\
  20. & \textcolor{black}{\niet{}b\en{}\niet{}c} & (\of{}-regel, 19)\\
  21. & \textcolor{blue}{\niet{}b} & (\en{}-regel, 20)\\
  22. & \textcolor{blue}{\niet{}c} & (\en{}-regel, 20)\\
  & \textcolor{red}{X(8, 22)}}\thput{(18)}}{
}
\pstree{\MyNode[{\rnode[b]{PredD}}]{rll}{%
  23. & \textcolor{black}{d\en{}e} & \\
  24. & \textcolor{blue}{d} & (\en{}-regel, 23)\\
  25. & \textcolor{blue}{e} & (\en{}-regel, 23)\\
  & \textcolor{red}{X(14, 25)}}}{
}
}
}
\pstree{\MyNode[{\rnode[b]{PredD}}]{rll}{%
  26. & \textcolor{blue}{g} & \\
  & \textcolor{red}{X(9, 26)}}}{
}
}

\end{document}




More information about the PSTricks mailing list