# pspicture environment overlays text in figure float

I have a strange problem witih PSTricks, pst-tree and the pspicture environment. I use a figure float and a simple tree. When I put a pspicture environment around it, the picture is placed above the text. What am I doing wrong?

Note: when I remove the pspicture environment, everything is working fine. But without the pspicture environment, I can't use things like the psbrace.

\documentclass[english]{article}

\usepackage{pst-plot}
\usepackage{pstricks}
\usepackage{pst-node}
\usepackage{pst-tree}

\begin{document}
Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem
ipsum.

\begin{figure}
\begin{pspicture}(3,3)
\pstree{\Tcircle{ }}
{
\pstree{\Tr{ }}{\Tfan}
\pstree{\Tr{ }}{\Tfan}
}
\end{pspicture}

\caption{}
\end{figure}

Lorem ipsum. Lorem ipsum. Lorem ipsum.

\end{document}

-

This is happening because the contents of your pspicture are extending outside of its bounds.

If you add the line \psgrid immediately after your \begin{pspicture}, you'll see that you get

There are many ways to fix this- the easiest is perhaps to change the viewing window of your pspicture, to something like

\begin{pspicture}(5,-5)


The general syntax is

\begin{pspicture}(xmin,ymin)(xmax,ymax)


In addition to this, you'll probably want to add \centering to your environment. The complete code follows for your reference.

\documentclass{article}

\usepackage{pst-tree}

\begin{document}
Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem ipsum. Lorem
ipsum.

\begin{figure}
\centering
\begin{pspicture}(5,-5)
\psgrid
\pstree{\Tcircle{ }}
{
\pstree{\Tr{ }}{\Tfan}
\pstree{\Tr{ }}{\Tfan}
}
\end{pspicture}
\caption{}
\end{figure}

Lorem ipsum. Lorem ipsum. Lorem ipsum.

\end{document}


Once you're done with construction, simply comment out the \psgrid line, and you'll be finished.

-
Great answer. You'll have to wait for an up-vote. – Werner Feb 6 '12 at 22:27
@Werner Thanks, that's high praise indeed from a guru :) – cmhughes Feb 6 '12 at 22:29
Thanks a lot for your answer! I had the idea to enable the grid to see what's going on, but I didn't think of setting negative values. But this means, I have to know size of the tree in advance? – lumbric Feb 6 '12 at 23:09
@lumbric During construction, I think the answer is typically, yes. You can use pspicture* which will automatically clip the picture, but that's probably not what you want. – cmhughes Feb 7 '12 at 0:24
@lumbric I tend to think of the pspicture environment as the 'bounding box' for the picture. Without the environment, PSTricks will do its best to figure out the 'bounding box' on its own- as you've described, sometimes it will work, but you may not be able to use all commands. – cmhughes Feb 7 '12 at 16:08