![具有 psmatrix 环境的流程图中的节点](https://linux22.com/image/243556/%E5%85%B7%E6%9C%89%20psmatrix%20%E7%8E%AF%E5%A2%83%E7%9A%84%E6%B5%81%E7%A8%8B%E5%9B%BE%E4%B8%AD%E7%9A%84%E8%8A%82%E7%82%B9.png)
psmatrix
我正在尝试使用该包在环境中制作如下所示的流程图pstricks
。但问题是我不知道如何在{3-1}(num<=100)
和之间创建节点{5-1}(num <- num + 2)
。我希望我的节点如下所示:
但我不知道如何与pst-nodes
任何其他包建立上述连接!我查看了几份文档,pst-nodes
但什么也没找到。代码是:
\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{pstricks}
\usepackage{pst-node}
\usepackage{pst-blur}
\definecolor{Blue}{rgb}{1.,0.75,0.8}
% ================================
% Source: http://tug.org/pipermail/pstricks/2009/006766.html
\makeatletter
\newdimen\psparallelogramsep
\def\psset@parallelogramsep#1{\pssetlength\psparallelogramsep{#1}}
\psset@parallelogramsep{3mm}
\def\psparallelogrambox{\pst@object{psparallelogrambox}}
\def\psparallelogrambox@i{\pst@makebox\psparallelogrambox@ii}
\def\psparallelogrambox@ii{%
\begingroup
\pst@useboxpar
\pst@dima=\pslinewidth
\advance\pst@dima by \psframesep
\pst@dimc=\wd\pst@hbox\advance\pst@dimc by \pst@dima
\pst@dimb=\dp\pst@hbox\advance\pst@dimb by \pst@dima
\pst@dimd=\ht\pst@hbox\advance\pst@dimd by \pst@dima
\setbox\pst@hbox=\hbox{%
\ifpsboxsep\kern\pst@dima\fi
\begin@ClosedObj
\addto@pscode{%
\psk@cornersize
\pst@number\pst@dima neg
\pst@number\pst@dimb neg
\pst@number\pst@dimc
\pst@number\pst@dimd .5
\pst@number\psparallelogramsep
\tx@Parallelogram}%
\def\pst@linetype{2}%
\showpointsfalse
\end@ClosedObj
\box\pst@hbox
\ifpsboxsep\kern\pst@dima\fi%
}%
\ifpsboxsep\dp\pst@hbox=\pst@dimb\ht\pst@hbox=\pst@dimd\fi
\leavevmode\box\pst@hbox
\endgroup%
}
% From the Frame and Rect PostScript macros
\pst@def{Parallelogram}<{%
/ParallelogramA {
x1 pgs sub y1 moveto
x1 y2 lineto
x2 pgs add y2 lineto
x2 y1 lineto
x1 pgs sub y1 lineto
closepath} def
%
/pgs ED
CLW mul
/a ED
3 -1 roll
2 copy gt { exch } if
a sub
/y2 ED
a add
/y1 ED
2 copy gt { exch } if
a sub
/x2 ED
a add
/x1 ED
1 index 0 eq {pop pop ParallelogramA } { OvalFrame } ifelse}>
\makeatother
\def\pspbox[#1]#2{\makebox[#1]{\psparallelogrambox{#2}}}
% ================================
\pagestyle{empty}
\begin{document}
\vspace{0.5cm}
\small
\psset{shadowcolor=black!70,shadowangle=-90,blur=true}
\begin{psmatrix}[rowsep=0.5,colsep=0.7]% defines the distance between two frames
%Begin
\psovalbox[fillstyle=solid, fillcolor=yellow!30]{Start} \\
%computation
\psframebox[shadow=true]{$Sum \Leftarrow 0 , Num \leftarrow 10$} \\
%Condition
\psdiabox[fillstyle=solid, fillcolor=magenta!20]{$Num \leqslant 100 $} &
%Output
\psparallelogrambox[fillstyle=solid,fillcolor=blue!20]{Print Sum} \\
%Computation
\psframebox{$Sum \leftarrow Num + Sum $} &
%End
\psovalbox[fillstyle=solid, fillcolor=yellow!30]{End}\\
%computation
\psframebox{$Num \leftarrow Num + 2$}\\
% Links
\ncline{->}{1,1}{2,1}
\ncline{->}{2,1}{3,1}
\ncline{->}{3,1}{4,1}<{\textcolor{red}{Yes}}
\ncline{->}{4,1}{5,1}
\ncline{->}{3,1}{3,2}^{\textcolor{red}{No}}
\ncline{->}{3,2}{4,2}
% I used these two but none of them were helpful
\ncdiag[angleA=-90,angleB=180, armA=1cm,armB=1cm,lineAngle=-30]{->}{5,1}{3,1}
% \nccurve[ angleA=-90,angleB=180]{->}{5,1}{3,1}
\end{psmatrix}
\end{document}
但我得到的形状是:
那么我应该使用哪个命令才能获取该流程图的正确节点?
答案1
您可以使用连接ncangles
在下面的示例中我删除了的定义\psparallelogrambom
并使用来\psframebox
简化示例。
有关此命令的更多信息,请参阅文档pst 节点。
\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{xcolor}
\usepackage{pstricks}
\usepackage{pst-node}
\usepackage{pst-blur}
\definecolor{blue}{rgb}{1,0.75,0.8}
\pagestyle{empty}
\begin{document}
\vspace{0.5cm}
\small
\psset{shadowcolor=black!70,shadowangle=-90,blur=true,fillstyle=solid}
\begin{psmatrix}[rowsep=0.5,colsep=0.7]% defines the distance between two frames
\psovalbox[fillcolor=yellow!30]{Start} \\
\psframebox[shadow=true]{$Sum \Leftarrow 0 , Num \leftarrow 10$}\\
\psdiabox[fillcolor=magenta!20]{$NUM\leqslant100$}&
\psframebox[fillcolor=blue!20]{Print Sum} \\
\psframebox{$Sum \leftarrow Num +Sum$} &
\psovalbox[fillcolor=yellow!30]{End}\\
\psframebox{$Num \leftarrow Num +2$} \\
\psset{arrows=->,fillstyle=none}
\ncline{1,1}{2,1}
\ncline{2,1}{3,1}
\ncline{3,1}{4,1}<{\textcolor{red}{Yes}}
\ncline{4,1}{5,1}
\ncline{3,1}{3,2}^{\textcolor{red}{No}}
\ncline{3,2}{4,2}
\ncangles[angleA=-90,angleB=180,armA=1cm,armB=1cm,lineAngle=-30]{5,1}{3,1}
\end{psmatrix}
\end{document}