我想创建一个流程图,其中每个节点本身都是一个 pspicture(带有节点和箭头),并且 pspicture 之间有箭头。这是一个示例(看起来很糟糕,因为我必须手动放置文本和箭头):
目前,我正在手动创建箭头,但我确信这不是正确的方法。这是我当前的代码:
\documentclass[11pt,,section]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
%\usepackage[a4paper]{geometry}
%\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
\usepackage[crop=on]{auto-pst-pdf}
\usepackage{pstricks,pst-node,pst-tree}
\usepackage{graphics,graphicx}
\usepackage[overload]{textcase}
%
\newcommand{\action}[1] {
\rput(-1.5,-.5){#1}
}
\newcommand{\goleft}[1] {
\pcline[linecolor=black]{->}(-4,-0.5)(-5,-1.5)\bput(.5){\emph{#1}}
}
\newcommand{\godown}[1] {
\pcline[linecolor=black]{->}(-1.5,-0.5)(-1.5,-1.5)\aput(.5){\emph{#1}}
}
\newcommand{\goright}[1] {
\pcline[linecolor=black]{->}(1.5,-0.5)(2.5,-1.5)\aput(.5){\emph{#1}}
}
%
\newcommand{\agent}[1]{\circlenode[linecolor=white]{#1}{\textcolor{blue}{#1}}}
\newcommand{\piece}[1]{\dianode[linecolor=white]{#1}{\textcolor{blue}{#1}}}
\newcommand{\like}[2]{\ncline[linecolor=green]{->}{#1}{#2}}
\newcommand{\likenext}[2]{\ncline[linecolor=gray,linestyle=dashed]{->}{#1}{#2}}
\newcommand{\likemaybe}[2]{\ncline[linecolor=gray,linestyle=dashed]{->}{#1}{#2}}
\newcommand{\threeagents}{
\agent{A} \agent{B} \agent{C}
\vspace{7mm}
\piece{1} \piece{2} \piece{3}
}
\newcommand{\fouragents}{
\agent{A} & \agent{B} & \agent{C} & \agent{D} \\
\piece{1} & \piece{2} & \piece{3} & \piece{4}
}
\psset{colsep=0.5cm,rowsep=1cm}
\begin{document}
\begin{psmatrix}[colsep=0,rowsep=1.7]
\makebox[5cm] {
}
&
\makebox[5cm] {
Start
\goleft{B,C,D have 3 neighbors}
\godown{2 neighbors}
\goright{1 neighbor}
}
&
\makebox[5cm] {
}
\\
\begin{psmatrix}[colsep=0cm]
\fouragents
\like{A}{1}\like{A}{2}\like{A}{3}\like{A}{4}
\like{B}{2}
\like{C}{3}
\like{D}{4}
\end{psmatrix}
\action{Done}
&
\begin{psmatrix}[colsep=0cm]
\fouragents
\like{A}{1}\like{A}{2}\like{A}{3}\like{A}{4}
\like{B}{1}
\like{C}{4}
\like{D}{4}
\end{psmatrix}
\goleft{}
\godown{}
&
\begin{psmatrix}[colsep=0cm]
\fouragents
\like{A}{1}\like{A}{2}\like{A}{3}\like{A}{4}
\like{B}{4}
\like{C}{4}
\like{D}{4}
\end{psmatrix}
\\
\begin{psmatrix}[colsep=0cm]
\fouragents
\like{A}{2}\like{A}{3}\like{A}{4}
\like{B}{1}\like{B}{2}
\like{C}{4}
\like{D}{4}
\end{psmatrix}
&
\begin{psmatrix}[colsep=0cm]
\fouragents
\like{A}{2}\like{A}{3}
\like{B}{1}\like{B}{2}
\like{C}{4}\like{C}{2}
\like{D}{4}
\end{psmatrix}
&
%%%
\end{psmatrix}
\\
\\
\end{document}
我正在尝试从“起始”psmatrix 创建指向下一行中每个 psmatrix 的箭头。但这看起来不太好。
答案1
以下示例显示您可以使用单元格的符号名称:
\documentclass[11pt,,section]{article}
\usepackage[crop=on]{auto-pst-pdf}
\usepackage{pst-node}
\def\Line{\ncline[arrows=->,linecolor=green]}
\begin{document}
\begin{psmatrix}[colsep=3cm,rowsep=1.7]
& [name=start] Start & \\[1cm]
[name=Aleft]
\begin{psmatrix}[colsep=0.5cm,rowsep=0mm]
A & B & C & D \\[12mm]
1 & 2 & 3 & 4\\
\psspan{3}Done
\Line{1,1}{2,1}\Line{1,2}{2,2}\Line{1,3}{2,3}\Line{1,4}{2,4}
\Line{1,1}{2,2}\Line{1,1}{2,3}\Line{1,1}{2,4}
\end{psmatrix}
& [name=Acenter]
\begin{psmatrix}[colsep=0.5cm,rowsep=0mm]
A & B & C & D \\[12mm]
1 & 2 & 3 & 4\\
\Line{1,1}{2,1}\Line{1,2}{2,1}\Line{1,3}{2,4}\Line{1,4}{2,4}
\Line{1,1}{2,2}\Line{1,1}{2,3}\Line{1,1}{2,4}
\end{psmatrix}
& [name=Aright]
\begin{psmatrix}[colsep=0.5cm,rowsep=0mm]
A & B & C & D \\[12mm]
1 & 2 & 3 & 4\\
\Line{1,1}{2,1}\Line{1,2}{2,4}\Line{1,3}{2,4}\Line{1,4}{2,4}
\Line{1,1}{2,2}\Line{1,1}{2,3}\Line{1,1}{2,4}
\end{psmatrix}
\end{psmatrix}
\ncline[nodesepA=2mm,offsetB=-15mm]{start}{Aleft}\nbput{B,C,D have 3 neighbors}
\ncline[nodesep=2mm]{start}{Acenter}\ncput*{2 neighbors}
\ncline[nodesepA=2mm,offsetB=10mm]{start}{Aright}\naput{1 neighbor}
\end{document}
答案2
我简化了你的代码。一个psmatrix
环境就够了。这就是你想要的吗?
\documentclass[11pt,,section]{article}
\usepackage{pst-node,pst-tree}
\usepackage[crop=off]{auto-pst-pdf}
\usepackage{graphicx}
\newcommand{\agent}[1]{\circlenode[linecolor=white]{#1}{{#1}}}%
\newcommand{\like}[2]{\ncline[linecolor=green]{->}{#1}{#2}}
\begin{document}\color{blue}
\psset{arrows=->, arrowinset=0.25, colsep=0.75cm, nodesep=2pt}
\begin{psmatrix}
& \agent{Start}\\
\agent{A} & & \agent{E}\\
\agent{B} & [mnode=oval, linecolor=white]\agent{C}\hspace{1.5cm}\agent{D} & \agent{F}
\ncline{Start}{A}
\ncline{Start}{3,2}
\ncline{Start}{E}
\psset{linecolor=green}
\ncline{A}{B}
\ncline{F}{E}
\ncline{C}{D}
\end{psmatrix}
\end{document}