4

I used the sample https://texample.net/tikz/examples/consort-flowchart/ to build a flowchart. I have some problems, that it looks good.

  1. Text 1 - The shape has to move up, that there is no konflict with the arrows. The shape should have the width of the hole page and the text should be centered. I can change the size but then the other shapes below moving as well to the left.
  2. The other arrows should move from the middle to the the next shape.

What can I do to solve it?

\documentclass[border=10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}

\begin{document} \centering

\begin{tikzpicture}[auto, block_top/.style ={rectangle, draw=black, thick, fill=white, text width=10em, text centered, minimum height=2em, inner sep=6pt}, block_middle/.style ={rectangle, draw=black, thick, fill=white, text width=15em, text centered, minimum height=2em, inner sep=6pt}, block_center/.style ={rectangle, draw=black, thick, fill=white, text width=8em, text centered, minimum height=4em},
block_left/.style ={rectangle, draw=black, thick, fill=white, text width=16em, text ragged, minimum height=4em, inner sep=6pt}, block_lost/.style ={rectangle, draw=black, thick, fill=white, text width=16em, text ragged, minimum height=3em, inner sep=6pt}, line/.style ={draw, thick, -latex', shorten >=0pt}] % outlining the flowchart using the PGF/TikZ matrix funtion

\matrix [column sep=5mm,row sep=3mm] {
  % enrollment - row 1
  \node [block_top] (D) {TEXT 1};\\
  % enrollment - row 2
  \node [block_center] (DL) {TEXT 2}; 
  & \node [block_center] (DC) {TEXT 3};
  & \node [block_center] (DB) {TEXT 4};\\
  % follow-up - row 3
  \node [block_middle] (I) {TEXT 5}; 
  & \node [block_middle] (L) {TEXT 6}; \\
  % follow-up - row 4
  \node [block_center] (IG) {TEXT 7) }; 
  & \node [block_center] (IS) {TEXT 8)}; 
  & \node [block_center] (LS) {TEXT 9}; 
  & \node [block_center] (LO) {TEXT 10};\\
 };% end matrix

% connecting nodes with paths
\begin{scope}[every path/.style=line]
  \path (D) -| (DL);
  \path (D) -| (DC);
  \path (D) -| (DB);
  \path (DL) -- (I);
  \path (DB) -- (L);
  \path (DC) -- (L);
  \path (DC) -- (I);
  \path (DL) -- (I);
  \path (I)  -- (IG);
  \path (I)  -- (IS);
  \path (L)  -- (LS);
  \path (L)  -- (LO);
\end{scope}

\end{tikzpicture}

\end{document}

Cheers

koleygr
  • 20,105
Kopi
  • 65
  • Thanks for the link. – Kopi Jan 25 '21 at 18:06
  • Welcome to TeX.SE! This not seems to be flowchart, rather some ornigram (with some degree of tree structure). It design is opinion based. If you like to have three nodes styles, structured in matrix, than is there is no much to do. – Zarko Jan 25 '21 at 18:20

2 Answers2

4

I don't see a matrix structure, rather levels of nodes depending on the position of the nodes below. Therefore I start bottom up.

  • Equally space out the nodes at the bottom.
  • Position the nodes in the row above between the nodes below it.
  • Position the center node in the second row above the middle between the nodes below, and the nodes to the left and right of the center node.
  • Position the top node above the center node of the second row.

enter image description here

\documentclass[border=10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,arrows,calc}
\begin{document}
\begin{tikzpicture}[auto,
  block/.style={rectangle, draw=black, thick, fill=white,
      text width=#1, text centered,
      minimum height=2em, inner sep=6pt},
  block_top/.style = {block=40em},
  block_middle/.style = {block=15em},
  block_center/.style = {block=8em,minimum height=4em},
  block_left/.style ={block=16em,text ragged,minimum height=4em},
  block_lost/.style ={block=16em,text ragged,minimum height=3em},
  line/.style ={draw, thick, -latex', shorten >=0pt, rounded corners}
  ]
  % follow-up - row 4
  \node [block_center] (IG) {TEXT 7}; 
  \node [block_center,right=of IG] (IS) {TEXT 8}; 
  \node [block_center,right=of IS] (LS) {TEXT 9}; 
  \node [block_center,right=of LS] (LO) {TEXT 10};
  % follow-up - row 3
  \coordinate (IGIS) at ($(IG.north)!0.5!(IS.north)$);
  \node [block_middle,above=of IGIS] (I) {TEXT 5}; 
  \coordinate (LSLO) at ($(LS.north)!0.5!(LO.north)$);
  \node [block_middle,above=of LSLO] (L) {TEXT 6}; \\
  % enrollment - row 2
  \coordinate (IL) at ($(I.north)!0.5!(L.north)$);
  \node [block_center,above=of IL] (DC) {TEXT 3};
  \node [block_center] (DL) at (IG|-DC) {TEXT 2};
  \node [block_center] (DB) at (LO|-DC) {TEXT 4};
  % enrollment - row 1
  \node [block_top,above=of DC] (D) {TEXT 1};
  \begin{scope}[every path/.style=line]
    \path (D) -- +(0,-0.8) -| (DL);
    \path (D) -- (DC);
    \path (D) -- +(0,-0.8) -| (DB);
    \path (DL) -- (I);
    \path (DB) -- (L);
    \path (DC) -- (L);
    \path (DC) -- (I);
    \path (DL) -- (I);
    \path (I)  -- (IG);
    \path (I)  -- (IS);
    \path (L)  -- (LS);
    \path (L)  -- (LO);
  \end{scope}
\end{tikzpicture}

\end{document}

gernot
  • 49,614
  • Thanks gernot, that's perfect. I hope I got enougth ideas to do the rest by myself. – Kopi Jan 25 '21 at 19:27
3

As forest:

\documentclass[border=3.141592]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{arrows.meta,
                shadows}

\begin{document} \begin{forest} for tree = { % nodes draw, semithick, fill=white, drop shadow, text width=6em, text badly centered, % tree grow = south, edge = {-Straight Barb, semithick}, anchor = north, forked edge, l sep = 8mm, fork sep = 3.5mm, where level = 2{s sep=2mm}{s sep=6mm}, % extry connection /tikz/arr/.style = {draw=red, -Straight Barb, semithick}, }% ed of "for tree" [ Text 1\ (root) [Tex 2 [Text 5, name=n12 [Text 7] [Text 8] ] ] [Text 3, name=n21 [Text 6, name=n22 [Text 9] [Text 10] ] ] [Tex 4, name=n31] ] \draw[arr] ([xshift=-1em] n21.south) -- ++ (0,-3.5mm) -| ([xshift=1em] n12.north); \draw[arr] (n31.south) -- ++ (0,-3.5mm) -| ([xshift=1em] n22.north);
\end{forest} \end{document}

enter image description here

Zarko
  • 296,517