3

I have drawn the following nodes:

\documentclass[tikz,border=5pt]{standalone}

\begin{document}

\begin{tikzpicture}[node distance=1.5cm]
\tikzstyle{one} = [rectangle, rounded corners, minimum width=3cm, text width=8cm, minimum height=1cm, draw=black, fill=gray!30]
\tikzstyle{two} = [rectangle, rounded corners, minimum width=3cm, text width=8cm, minimum height=1cm, draw=black, fill=gray!30]
\tikzstyle{thr} = [rectangle, rounded corners, minimum width=3cm, text width=8cm, minimum height=1cm, draw=black, fill=gray!30]
\tikzstyle{fou} = [rectangle, rounded corners, minimum width=3cm, text width=8cm, minimum height=1cm, draw=black, fill=gray!30]
\tikzstyle{fiv} = [rectangle, rounded corners, minimum width=3cm, text width=6cm, text centered, minimum height=1cm, draw=black, fill=gray!30]

\node (on) [one]{\small (1) the combination of sound macroeconomic management};
\node (tw) [two,below of=on]{\small (2) increased reliance on market mechanisms};
\node (th) [thr,below of=tw]{\small (3) a strong emphasis on the delivery of social services};
\node (fo) [fou,below of=th]{\small (4) sustained improvements in infrastructure};

\node (fv) [fiv, left of=tw, yshift=-.75cm, xshift=-4cm, rotate=90]{\small Macroeconomic reforms, \textit{\textbf{doi moi}}, implemented by the government of Vietnam, in the late 1980’s}; 


\draw (on.west) -| (tw.west);

\end{tikzpicture}

\end{document}

I am trying to connect each of the nodes to get something similar to this figure: enter image description here

How can I draw these lines? Also, is there any simpler way to create the flow chart?

2 Answers 2

4

Adaptations

  • You can use the calc tikzlibrary to calculate the middle between the left node and the nodes on the right and draw through this point: ($(n5.south)!0.5!(n5.south -| n1.west)$) where (n5.south -| n1.west) gives you the point (n1.west.X, n5.south.Y) and (A)!0.5!(B) the middle between A and B.
  • Don't write the same style/code twice: I introduce the styles basis and on that basis horizontal and vertical.
  • For the connections I use a \foreach-loop.

Code

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}[node distance=1.5cm]
    \tikzstyle{basis} = [rectangle, rounded corners, minimum width=3cm, minimum height=1cm, draw=black, fill=gray!30]
    \tikzstyle{horizontal} = [basis, text width=8cm]
    \tikzstyle{vertical} = [basis, text width=6cm, text centered]

    \node (n1) [horizontal]{\small (1) the combination of sound macroeconomic management};
    \node (n2) [horizontal,below of=n1]{\small (2) increased reliance on market mechanisms};
    \node (n3) [horizontal,below of=n2]{\small (3) a strong emphasis on the delivery of social services};
    \node (n4) [horizontal,below of=n3]{\small (4) sustained improvements in infrastructure};

    \node (n5) [vertical, left of=n2, yshift=-.75cm, xshift=-4cm, rotate=90]{\small Macroeconomic reforms, \textit{\textbf{doi moi}}, implemented by the government of Vietnam, in the late 1980’s}; 

    \draw (n5.south) -- ($(n5.south)!0.5!(n5.south -| n1.west)$) coordinate (aux);
    \foreach \n in {1,...,4}
        \draw (aux) |- (n\n.west);
\end{tikzpicture}

\end{document}

Result

enter image description here

2
  • Thank you for the simpler code. I really appreciate it. I was wondering about the \draw line. Could you please let me know what -| ($(n5.south)!0.5!(n5.south -| n1.west)$) means in the code? Nov 23, 2017 at 17:45
  • I added an explanation.
    – dexteritas
    Nov 23, 2017 at 17:50
3

like this?

enter image description here

  • nodes (1) to (4) are in chain named A
  • height (width before rotation) of rotated nodes is measured with macro veclen from tikz library calc
  • for all nodes is defined common style base
  • for nodes in chain is added option text width and on chain=A
  • for lines i defined defined auxiliary coordinate aux

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{calc, chains,
                positioning}

\begin{document}

\begin{tikzpicture}[
 node distance = 4mm and 8mm,
   start chain = A going below,
   base/.style = {rectangle, rounded corners, draw=black, fill=gray!30,
                  minimum height=1cm, font=\small},
    box/.style = {base, text width=84mm, on chain=A}
                    ]
\node   [box]   {(1) the combination of sound macroeconomic management};    % A-1
\node   [box]   {(2) increased reliance on market mechanisms};
\node   [box]   {(3) a strong emphasis on the delivery of social services};
\node   [box]   {(4) sustained improvements in infrastructure};             % A-4
%
\path   let \p1 = ($(A-1.north)-(A-4.south)$),               
            \n1 = {veclen(\y1,\x1)} in
        node [base, text width=\n1-2*\pgfkeysvalueof{/pgf/inner xsep},
              rotate=90, left=of $(A-1.north west)!0.5!(A-4.south west)$,
              anchor=south] (A-5)
              {Macroeconomic reforms, \textit{\textbf{doi moi}}, implemented by the government of Vietnam, in the late 1980’s};
\draw   (A-5.south) -- ++ (0.4,0) coordinate (aux) |- (A-1)
        (aux) |- (A-2)
        (aux) |- (A-3)
        (aux) |- (A-4);
\end{tikzpicture}

\end{document}
2
  • Zarko, please explain to the OP that the styles exsist just to avoid repeating code lines.
    – CarLaTeX
    Nov 23, 2017 at 17:23
  • Thank you Zarko, I will study your code as well. Nov 23, 2017 at 17:49

You must log in to answer this question.

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