框图/流程图

框图/流程图

我想制作一个允许多个箭头指向/来自不同框的图表。我正在使用流程图(这可能是一个糟糕的选择,我根本不是专家,我正在寻找一些易于理解和实施的东西)。

目前我有以下内容

\begin{tikzpicture}[->,>=stealth']


\node[state] (A) 
{
    \textbf{A}

};
\node[state,        
text width=3cm, 
yshift=2cm,     
left of=A,  
node distance=6 cm, 
] (B)   
{
    \textbf{B}

};
\node[state,        
text width=3cm,     
yshift=2cm,         
right of=A, 
node distance=6 cm, 
] (D)   
{
    \textbf{D}
};
\node[state,    
text width=7cm,     
%yshift=2cm,        
below of=A,     
node distance=4 cm,     
] (C)   
{
    \textbf{C}
};
\path (A)   edge   (B)
(A)         edge      (D)
(A)         edge       (C)
(C)         edge       (A)
(D)     edge         (A)
(D)     edge           (C)      
(D)     edge   (B)
(C)     edge  (B)   
(C)         edge       (D)   
;

\end{tikzpicture}

这样,我得到了从(例如)D 到 C 的双向箭头,但我希望有两个方向相反的箭头。我该怎么做?

另外,我怎样才能使框 A 相对于文本居中?

多谢!

答案1

这是一份双线方案,您似乎想要这种类型。我还加载并使用该positioning库,以便更好地定位。

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{arrows,automata}
\usetikzlibrary{decorations.markings,positioning}
\tikzset{double line with arrow/.style args={#1,#2}{decorate,decoration={markings,%
mark=at position 0 with {\coordinate (ta-base-1) at (0,2pt);
\coordinate (ta-base-2) at (0,-2pt);},
mark=at position 1 with {\draw[#1] (ta-base-1) -- (0,2pt);
\draw[#2] (ta-base-2) -- (0,-2pt);
}}}}
\begin{document}

\tikzset{every node/.append style={align=center}}
\begin{tikzpicture}[>=stealth']


\node[state] (A) 
{
    \textbf{A}

};
\node[state,        
text width=3cm, 
yshift=2cm,     
left=of A,  
] (B)   
{
    \textbf{B}

};
\node[state,        
text width=3cm,     
yshift=2cm,         
right=of A, 
] (D)   
{
    \textbf{D}
};
\node[state,    
text width=7cm,     
below=1cm of A,     
] (C)   
{
    \textbf{C}
};
\path (A)   edge[->]   (B)
(A)         edge[double line with arrow={->,<-}]      (D)
(A)         edge[double line with arrow={->,<-}]       (C)
(D)     edge[double line with arrow={->,<-}]           (C)      
(D)     edge[double line with arrow={->,<-}]   (B)
(C)     edge[double line with arrow={->,<-}]  (B)   
;

\end{tikzpicture}
\end{document}

在此处输入图片描述

编辑:具有较小的节点。

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.markings,positioning,arrows.meta}
\tikzset{double line with arrow/.style args={#1,#2}{decorate,decoration={markings,%
mark=at position 0 with {\coordinate (ta-base-1) at (0,2pt);
\coordinate (ta-base-2) at (0,-2pt);},
mark=at position 1 with {\draw[#1] (ta-base-1) -- (0,2pt);
\draw[#2] (ta-base-2) -- (0,-2pt);
}}},
mystate/.style={circle,draw,font=\bfseries}}
\begin{document}

\tikzset{every node/.append style={align=center}}
\begin{tikzpicture}[>={Stealth[]}]


\node[mystate] (A) {A};
\node[mystate,        
above left=of A,  
] (B)   {B};
\node[mystate,        
above right=of A, 
] (D)  {D};
\node[mystate,    
below=1cm of A,     
] (C)   {C};
\path (A)   edge[->]   (B)
(A)         edge[double line with arrow={->,<-}]      (D)
(A)         edge[double line with arrow={->,<-}]       (C)
(D)     edge[double line with arrow={->,<-}]           (C)      
(D)     edge[double line with arrow={->,<-}]   (B)
(C)     edge[double line with arrow={->,<-}]  (B)   
;

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容