
下面的程式碼產生一個與我在 LaTeX 中的文字重疊的圖形。乳膠似乎無法為這個人物創造空間。有人可以幫我嗎?
\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}
答案1
這看起來與中的問題非常相似pspicture 環境覆蓋圖形浮動中的文本
我對您的程式碼做了一些更改;特別是我刪除了align*
andpsmatrix
命令,而是使用了 a pspicture
,它可以用作
\begin{pspicture}(xmin,ymin)(xmax,ymax)
此\psgrid
指令有助於在構造過程中確定xmin
、xmax
、ymin
和的適當值ymax
。
程式碼
\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}
答案2
幾乎所有 PSTricks 物件的寬度和高度均為 0pt,以允許預設覆蓋。你必須預留一些空間(水平和垂直-一個盒子),如果你想在它周圍放置其他物體。預設情況下,這是透過使用pspicture
環境或 a\parbox
或 .... 任何其他保留空間的內容來完成的。您在範例中使用絕對座標,這就是為什麼在不定義框的情況下無法使用它的原因。這是一個使用預設值的範例\parbox
(使用 apspicture
是更好的選擇 - 請參閱 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}