# [Problem] On trees, sons are aligned only if they are subtrees, not leaves

Denis Girou Denis.Girou at idris.fr
Fri Oct 17 23:34:02 CEST 1997

-----------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------

On trees, the sons are aligned only if they are subtrees. If they are leaves
they are not aligned. The result is clearly different if the material on the
nodes is not a single line.

It is a case where it is difficult to say if it is "a bug or a feature",
even if I don't think that this is the expected result. Nevertheless, I will
not change the source code (and also I have no definitive correction...)

We can obtain the coherent result changing the leaves concerned by a tree
with a null subtree (so changing XXXX to \pstree{XXXX}{\Tn}), but it is not
pleasant. I have found a correction for most cases, but it is not always
convenient (sometimes the level number to add is greater than 1). I just give
this solution in case it can be useful.

My test case is:

% This file must be compiled twice

\documentclass{article}

\usepackage{pst-tree}

\newcommand{\MyNode}[3][]{%
\TR[#1]{\tabcolsep=0mm\begin{tabular}[t]{#2}#3\end{tabular}}}

\newcommand{\PA}{\MyNode{c}{AA\\AAAA\\AA}}
\newcommand{\PB}{\MyNode{c}{BBBB\\BBBB\\BBBB\\BBBB\\BBBB\\BBBB\\
BBBB\\BBBB\\BBBB\\BBBB\\BBBB\\BBBB}}
\newcommand{\PC}{\MyNode{c}{CC}}
\newcommand{\PD}{\MyNode{c}{DDDD\\DDDD\\DDDD\\DDDD\\DDDD\\DDDD\\DDDD\\DDDD}}

\renewcommand{\psedge}{\ncangle[angleA=-90,angleB=90,nodesep=0]}

\pagestyle{empty}
\begin{document}

\pagestyle{empty}

\LARGE

\pstree[levelsep=*\baselineskip]
{\PA}
{\PB
\pstree{\PA}{\PC}}

\pstree[levelsep=*\baselineskip]
{\PA}
{\pstree{\PB}{\Tn}
\pstree{\PA}{\PC}}

\makeatletter
% To align subtrees according of length of all the leaves at a level,
% and not only to the ones of the relevant subtree
\def\pstree at node@v{%
\edef\pstree at leftprofile{\psk at thistreenodesize\pst at dima,\pstree at stop,}%
\edef\pstree at rightprofile{\psk at thistreenodesize\pst at dimb,\pstree at stop,}%
% DG modification begin - Sep. 25, 1997
%\pssubtree at vertical}
\pssubtree at vertical
\def\pst at tempc{\number\pst at dimc}%
\def\pst at tempd{\number\pst at dimd}%
% DG modification end
\makeatother

\pstree[levelsep=*\baselineskip]
{\PA}
{\PB
\pstree{\PA}{\PC}}

\end{document}

D.G.

-----------------------------------------------------------------------------