pstricks-Zeichnung überlappt sich mit Text

pstricks-Zeichnung überlappt sich mit Text

Der folgende Code erzeugt eine Abbildung, die sich mit meinem Text in LaTeX überschneidet. Es scheint, als ob Latex keinen Platz für diese Abbildung schafft. Kann mir jemand dabei helfen?

\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}

Antwort1

Dies scheint dem Problem sehr ähnlich zu sein inDie pspicture-Umgebung überlagert Text im Figure-Float

Ich habe ein paar Änderungen an Ihrem Code vorgenommen; insbesondere habe ich die Befehle align*und entfernt psmatrixund stattdessen ein verwendet, pspicturedas verwendet werden kann als

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

Der \psgridBefehl ist während der Konstruktion hilfreich, um geeignete Werte von xmin, xmax, ymin, und zu bestimmen ymax.

Bildschirmfoto

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}

Antwort2

Fast alle PSTricks-Objekte haben standardmäßig eine Breite und Höhe von 0pt, um das Überschreiben zu ermöglichen. Sie müssen etwas Platz reservieren (horizontalUndvertikal – eine Box), wenn Sie andere Objekte darum herum platzieren möchten. Dies geschieht standardmäßig durch die Verwendung der pspictureUmgebung oder eines \parboxoder … irgendetwas anderes, das Platz reserviert. Sie verwenden in Ihrem Beispiel absolute Koordinaten, weshalb Sie es nicht verwenden können, ohne eine Box zu definieren. Hier ist ein Beispiel, das einen Standard verwendet \parbox(die Verwendung eines pspictureist die bessere Wahl – siehe Antwort von 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}

verwandte Informationen