1

I want to make a diagram which allows multiple arrows to/from different boxes. I am using flow charts (it may be a bad choice, I'm not at all an expert, I was looking for something easy to understand and implement).

Right now I have the following

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

In this way I get a two headed arrow from (e.g.) D to C, but I would like to have TWO arrows in opposite senses. How can I do this?

Also, how can I center the box A with respect to the text?

Thanks a lot!

1 Answer 1

2

Here is a proposal with a double line of the type you seem to want. I also load and use the positioning library for better 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}

enter image description here

EDIT: with smaller nodes.

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

enter image description here

4
  • Excellent! Thanks a lot, this solves the issue :)
    – Ana
    Commented Jul 19, 2018 at 5:30
  • Hi! Sorry, actually this remains too rigid. I want to change the text more flexibly, and having round boxes makes the diagram too big as soon as I want to insert longer text. Could you tell me how to get back to square boxes? Thanks :)
    – Ana
    Commented Jul 26, 2018 at 15:53
  • 1
    @Ana The size of the nodes comes merely from the large textwidth. I added a version, in which I fixed that. If you really want boxes, remove circle from mystate/.style.
    – user121799
    Commented Jul 27, 2018 at 5:59
  • Thanks again, marmot! Sorry for the beginner's questions...
    – Ana
    Commented Aug 3, 2018 at 8:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .