# pstricks drawing has overlap with text

The following code produces a figure that has overlap with my text in LaTeX. It seems as if latex doesn't create a space for this figure. Can anybody help me with it?

\documentclass[12pt,oneside,english]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=3cm,rmargin=3cm}
\pagestyle{plain}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{float}
\usepackage{amsmath}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\numberwithin{equation}{section}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{qtree, amssymb, amsthm, graphicx,graphics, makeidx,esint,bm,pstricks,pst-node,pst-tree,algorithmic,algorithm}

\makeatother

\begin{document}
\begin{figure}[H]
\begin{align*}
\psmatrix
\cnodeput(0,-4){E}{ e_{n-1} }
\cnodeput(-2,-2){A}{ e_{n-2} }
\cnodeput[fillstyle=crosshatch,hatchsep=6pt](2,-2){C}{ e_{n-2}^* }
\cnodeput(-4,0){A1}{e_{n-3}}
\cnodeput[fillstyle=crosshatch,hatchsep=6pt](0,0){A2}{ e_{n-3}^* }
\cnodeput(-6,2){A11}{ \ldots }
\cnodeput[fillstyle=crosshatch,hatchsep=6pt](-2,2){A12}{ \ldots }
\psset{nodesep=3pt}
\ncarc{->}{E}{A}
\ncarc{->}{E}{C}
\ncarc{->}{A}{A1}
\ncarc{->}{A}{A2}
\ncarc{->}{A1}{A11}
\ncarc{->}{A1}{A12}
\endpsmatrix
\end{align*}\caption{\label{fig:Selection-of-edges}Selection of edges in Algorithm}
\end{figure}
this is some text in the document
\end{document}

-
have you seen pspicture-environment-overlays-text-in-figure-float? –  cmhughes Dec 11 '12 at 17:16

This seems very similar to the problem in pspicture environment overlays text in figure float

I've made a few changes to your code; in particular I've removed the align* and psmatrix commands, and instead used a pspicture which can be used as

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


The \psgrid command is helpful during construction to determine appropriate values of xmin, xmax, ymin, and ymax.

Code

\documentclass{article}

\usepackage{pstricks,pst-node}

\begin{document}
\begin{figure}
\centering
\begin{pspicture}(-7,-5)(3,3)
%\psgrid
\cnodeput(0,-4){E}{ $e_{n-1}$ }
\cnodeput(-2,-2){A}{ $e_{n-2}$ }
\cnodeput[fillstyle=crosshatch,hatchsep=6pt](2,-2){C}{ $e_{n-2}^*$ }
\cnodeput(-4,0){A1}{$e_{n-3}$}
\cnodeput[fillstyle=crosshatch,hatchsep=6pt](0,0){A2}{$e_{n-3}^*$}
\cnodeput(-6,2){A11}{ \ldots }
\cnodeput[fillstyle=crosshatch,hatchsep=6pt](-2,2){A12}{ \ldots }
\psset{nodesep=3pt}
\ncarc{->}{E}{A}
\ncarc{->}{E}{C}
\ncarc{->}{A}{A1}
\ncarc{->}{A}{A2}
\ncarc{->}{A1}{A11}
\ncarc{->}{A1}{A12}
\end{pspicture}
\caption{\label{fig:Selection-of-edges}Selection of edges in Algorithm}
\end{figure}
this is some text in the document
\end{document}

-

Nearly all PSTricks objects have a width and height of 0pt to allow overwriting by default. You have to reserve some space (horizontally and vertically -- a box) if you want to place other objects around it. This is done by default by using the pspicture environment or a \parbox or .... anything else which reserves space. You are using absolute coordinates in your example, the reason why you cannot use it without defining a box. Here is an example which uses a default \parbox ( using a pspicture is the better choice -- see answer of cmhughes!)

\documentclass[12pt]{book}

\usepackage{pst-node}

\begin{document}
\begin{figure}[!htb]
\centering
\psframebox{\parbox[b][8cm][r]{0.7\linewidth}{%
\rput[rt](0.7\linewidth,5cm){$\psmatrix \cnodeput(0,-4){E}{ e_{n-1} } \cnodeput(-2,-2){A}{ e_{n-2} } \cnodeput[fillstyle=crosshatch,hatchsep=6pt](2,-2){C}{ e_{n-2}^* } \cnodeput(-4,0){A1}{e_{n-3}} \cnodeput[fillstyle=crosshatch,hatchsep=6pt](0,0){A2}{ e_{n-3}^* } \cnodeput(-6,2){A11}{ \ldots } \cnodeput[fillstyle=crosshatch,hatchsep=6pt](-2,2){A12}{ \ldots } \psset{nodesep=3pt} \ncarc{->}{E}{A} \ncarc{->}{E}{C} \ncarc{->}{A}{A1} \ncarc{->}{A}{A2} \ncarc{->}{A1}{A11} \ncarc{->}{A1}{A12} \endpsmatrix$}}}

\caption{\label{fig:Selection-of-edges}Selection of edges in Algorithm}
\end{figure}
this is some text in the document
\end{document}

-