tabular / pstree problem

Denis Girou Denis.Girou at idris.fr
Fri Nov 26 21:00:36 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> Hi!

    Anthony.Doggett> I have a strange problem to do with putting a \pstree inside
    Anthony.Doggett> the tabular environment.

    Anthony.Doggett> If I have a table with two columns, then the top of the pstree
    Anthony.Doggett> turns out to be level with the baseline of whatever is in the
    Anthony.Doggett> other box.  (The center of tables or the bottom of other pstricks
    Anthony.Doggett> objects).

    Anthony.Doggett> How do I stop this happening?

    Anthony.Doggett> Thanks!
    Anthony.Doggett>   Anthony.

    Anthony.Doggett> (I'm using a pretty recent unix version of latex w/pstricks)

  I'm afraid that you must consider it more than a feature than a bug...
In any case, you can verify that when you put "complex" material in a tabular
cell, you loose often the exact spacing. See for instance the first next
example with a simple \shortstack macro.

  Nevertheless:

    - it is often not difficult to bypass this kind of problems by simple
add-ons introduced by hands, even if this is unpleasant to do,
    - with \pstree, there is a very simple solution, using the xbbh and xbbd
parameters (and possibly xbbl and xbbd),
    - in fact, with \pstree, the result is different according the kind of
nodes you use: you could see in the following examples that the upper position
is correct with \Tcircle but not with \Tr (but the bottom spacing is always
the same),
    - this is due to the \nodealign command which is called by some node
macros. I do not know the reason of this choice for some definitions and not
others. You can change this behaviour hacking the relevant macro definition
(see the last examples). Nevertheless, I globally do not encourage you to such
hacking... Better use the xbbh and xbbd parameters. If you have a lot of such
trees, you can of course set these parameters globally.


\documentclass[a4paper]{article}

\usepackage{a4wide}
\usepackage{pst-tree}
\usepackage{multirow}

\newcommand{\TreeX}[1][]{%
\pstree[#1]{\Tr{X}}{\Tr{Y}}}

\newcommand{\TreeY}[1][]{%
\pstree[#1]{\Tcircle{X}}{\Tcircle{Y}}}

\newcommand{\TreeZ}[1][]{%
\pstree[#1]{\Tcircle{WWW}}
           {\pstree{\Tcircle{X1}}{\Tcircle{X2}}
            \pstree{\Tcircle{Y1}}{\Tcircle{Y2}}
            \pstree{\Tcircle{Z1}}{\Tcircle{Z2}}}}

\pagestyle{empty}

\begin{document}

\LARGE

\begin{tabular}[b]{|c|c|}
  \hline
  AAAA & \shortstack{BBBB\\BBBB\\BBBB\\BBBB} \\ \hline
\end{tabular}
\hfill
\begin{tabular}[b]{|c|c|}
  \hline
  AAAA & \TreeX \\ \hline
\end{tabular}
\hfill
\begin{tabular}[b]{|c|c|}
  \hline
  AAAA & \TreeY \\ \hline
\end{tabular}

\vspace{1cm}
\begin{tabular}[b]{|c|c|}
  \hline
  AAAA   & \TreeX \\ \hline
  \TreeY & BBBB   \\ \hline
\end{tabular}
\hfill
\begingroup
\psset{showbbox=true}
\begin{tabular}[b]{|c|c|}
  \hline
  AAAA   & \TreeX \\ \hline
  \TreeY & BBBB   \\ \hline
\end{tabular}
\endgroup

\vspace{1cm}
\begin{tabular}[b]{|c|c|}
  \hline
  AAAA                      & \TreeX[xbbd=0.5] \\ \hline
  \TreeZ[xbbh=0.5,xbbd=0.5] & BBBB             \\ \hline
\end{tabular}
\hfill
\begin{tabular}[b]{|c|c|}
  \hline
  \multirow{4}*{AAAA}       & \TreeX[xbbd=0.5]    \\ \hline
  \TreeZ[xbbh=0.5,xbbd=0.5] & \multirow{7}*{BBBB} \\ \hline
\end{tabular}

\verb+___+\TreeX\verb+___+
\hfill
\begin{tabular}[b]{|c|c|}
  \hline
  AAAA & \TreeX \\ \hline
\end{tabular}
%
\makeatletter
\def\Tr at ii#1{%
\begin at treenode
\def\pstree at nodehook{%
\xdef\pstree at next{\pst at dima=\number\pst at dima sp\relax}}%
% D.G. modification begin - Nov. 26, 1999
%\nodealigntrue
% D.G. modification end
\setbox\pstree at box\hbox{#1\pssucc}%
\pstree at next
\pst at dimb=\wd\pstree at box
\advance\pst at dimb-\pst at dima
\pst at dimc=\ht\pstree at box
\pst at dimd=\dp\pstree at box
\setbox\pstree at box\hbox to\z@{\kern-\pst at dima\unhbox\pstree at box\hss}%
\ht\pstree at box=\z@
\dp\pstree at box=\z@
\end at treenode}
\makeatother
%
\hfill
\verb+___+\TreeX\verb+___+
\hfill
\begin{tabular}[b]{|c|c|}
  \hline
  AAAA & \TreeX \\ \hline
\end{tabular}

\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