Trees and psmatrix environment (from ctt)
Denis Girou
Denis.Girou at idris.fr
Thu May 7 20:33:06 CEST 1998
-----------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------
------- Start of forwarded message -------
From: Denis Girou <Denis.Girou at idris.fr>
Newsgroups: comp.text.tex
Subject: Re: PSTricks
Date: 06 May 1998 19:30:12 +0200
>>>>> "Uffe.Holst" == Uffe Holst <uhc at post6.tele.dk> writes:
Uffe.Holst> It seems my macros are a bit old. The \pstree macro was included, but not
Uffe.Holst> described in the documentation. Probably need to upgrade. The \pstree macro
Uffe.Holst> is actually quite neat.
You really need to install and use the PSTricks 97 distribution if you
haven't it already. It's on CTAN/graphics/pstricks Tree macro and relative
parameters are described in the file betadoc2.ps of the documentation.
Uffe.Holst> one of the diagrams I have to make looks like:
Uffe.Holst> +-----------------+
Uffe.Holst> | Project Manager |
Uffe.Holst> +--------+--------+
Uffe.Holst> |
Uffe.Holst> | +---------------------+
Uffe.Holst> +---+ Consulting engineer |
Uffe.Holst> | +---------------------+
Uffe.Holst> |
Uffe.Holst> +-------------+--------------+
Uffe.Holst> | |
Uffe.Holst> | |
Uffe.Holst> +-------+-------+ +-------+-------+
Uffe.Holst> | Subcontractor | | Subcontractor |
Uffe.Holst> +---------------+ +---------------+
Uffe.Holst> And as far as I can see, it isn't possible to make using tree diagrams.
Uffe.Holst> I guess I will have to use nodes and probably the psmatrix environment.
The tree macro is _very_ sophisticated and powerful. But you must know that
it is also not really simple to use and understand as soon as you want to draw
no trivial trees. It require time and work to be understood. And it is rather
the same thing for node connectors, and globally for all PSTricks usage.
Before to use it, you must be aware that, if it is a very powerful tool,
it require a good general programming experiment, and also that it learning
curve is rather long, so it is not at all for an occasional usage. But with
efforts, very good results will be there...
It is possible to draw your example as a tree, but it is not so simple...
It is clearly more straightforward and easy to understand as a grid-structured
diagram using the psmatrix environment. I give you both codes that you can
study and adapt.
Uffe.Holst> But what about:
Uffe.Holst> +-----------------+
Uffe.Holst> | Top level |
Uffe.Holst> +--------+--------+
Uffe.Holst> |
Uffe.Holst> +----------+ | +----------+
Uffe.Holst> + Left #1 +---+--+--+---+ Right #1 |
Uffe.Holst> +----------+ | | +----------+
Uffe.Holst> | |
Uffe.Holst> +----------+ | | +----------+
Uffe.Holst> + Left #2 +---+ +---+ Right #2 |
Uffe.Holst> +----------+ | | +----------+
Uffe.Holst> | |
Uffe.Holst> +----------+ | | +----------+
Uffe.Holst> + Left #3 +---+ +---+ Right #3 |
Uffe.Holst> +----------+ +----------+
Uffe.Holst> After browsing the book it seems to me, that nodes and connections can't
Uffe.Holst> accomplish that.
LGC (and the documentation itself) can't of course give examples and
solutions of the infinite number of cases. Diagrams and trees have an
infinite number of variants and specificities. Very often, we must found
special solutions to special requirements. But your example is rather easy
and can be built also as a tree or a grid-structured diagram. In the first
case, it is simple to have the tree - the only little difficulty is to have
the connections. But for this case too, the psmatrix example seems more
readable.
I give you too both solutions. But I can't do all for you. Now you have
to work and experiment by yourself!
\documentclass{article}
\usepackage{pst-tree}
% We force the boxes to be of the same size using \makebox
\newcommand{\MyNode}[1]{\Tr{\psshadowbox{\makebox[4cm]{#1}}}}
\renewcommand{\psedge}[2]{\ncangle[angleA=-90,angleB=90,armB=0.8]{#1}{#2}}
\pagestyle{empty}
\begin{document}
\psset{treesep=2.5}
\begin{center}
\pstree[thislevelsep=1]
{\MyNode{Project Manager}}
{\pstree{\pstree[treemode=R,thislevelsep=3.5]{\Tn}
{\renewcommand{\psedge}[2]{%
\ncangle[angleA=-90,angleB=180]{#1}{#2}}
\MyNode{Consulting engineer}}}
{\MyNode{Subcontractor}\MyNode{Subcontractor}}}
\end{center}
\begin{center}
\begin{psmatrix}[mnode=r,colsep=-1]
& \MyNode{Project Manager} \\[-1cm]
& & \MyNode{Consulting engineer} \\
\MyNode{Subcontractor} & & \MyNode{Subcontractor}
\end{psmatrix}
\ncangle[angleA=-90,angleB=180]{1,2}{2,3}
\psset{angleA=-90,angleB=90,armB=0.8}
\ncangle{1,2}{3,1}
\ncangle{1,2}{3,3}
\end{center}
\end{document}
---------------------------------------------------------------------------
\documentclass{article}
\usepackage{pst-tree}
% We force the boxes to be of the same size using \makebox
\newcommand{\MyNode}[1]{\Tr{\psshadowbox{\makebox[2.5cm]{#1}}}}
\pagestyle{empty}
\begin{document}
\psset{treesep=2.5}
\begin{center}
\pstree{\MyNode{Top Level}}
{\pstree{\renewcommand{\psedge}[2]{%
\ncangle[angleA=-90,angleB=0]{#1}{#2}}
\MyNode{Left \#1}}
{\renewcommand{\psedge}[2]{%
\ncangles[angle=0,armA=0.7]{#1}{#2}}
\pstree{\MyNode{Left \#2}}
{\MyNode{Left \#3}}}
\pstree{\renewcommand{\psedge}[2]{%
\ncangle[angleA=-90,angleB=180]{#1}{#2}}
\MyNode{Right \#1}}
{\renewcommand{\psedge}[2]{%
\ncangles[angle=180,armA=0.7]{#1}{#2}}
\pstree{\MyNode{Right \#2}}
{\MyNode{Right \#3}}}}
\end{center}
\begin{center}
\begin{psmatrix}[mnode=r,colsep=-0.2]
& \MyNode{Top Level} \\
\MyNode{Left \#1} & & \MyNode{Right \#1} \\
\MyNode{Left \#2} & & \MyNode{Right \#2} \\
\MyNode{Left \#3} & & \MyNode{Right \#3}
\end{psmatrix}
\ncangle[angleA=-90,angleB=0]{1,2}{2,1}
\ncangle[angleA=-90,angleB=180]{1,2}{2,3}
\psset{armA=0.7}
\ncangles[angle=0]{2,1}{3,1}
\ncangles[angle=0]{3,1}{4,1}
\ncangles[angle=180]{2,3}{3,3}
\ncangles[angle=180]{3,3}{4,3}
\end{center}
\end{document}
Denis Girou
------- End of forwarded message -------
-----------------------------------------------------------------------------
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