[Tex/LaTex] TikZ: Flow Chart

beameritemizelistsnodestikz-pgf

Kindly help this messy tikz flow chart.

\documentclass{beamer}
    \usetheme{CambridgeUS}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\tikzstyle{block} = [rectangle, draw, text width=10em, text centered, fill=yellow!80]
\tikzstyle{mycircle} = [circle, draw, text width=7em, text centered, fill=red!30]
\begin{document}
\begin{frame}
\begin{tikzpicture}[node distance=4.5cm, auto, >=stealth]
     \centering
\node [block](child){\par {Early life{\begin{itemize}
\item Genetic
\item Environmental
\end{itemize}}}};

\node [block] (psych)[right of = child]{\large {Psychoscial factors}{\begin{itemize}
\item life stress
\item Psychological stress
\item coping
\item social support
\end{itemize}}};

\node [block](physiology)[below of = psych]{Physiology {\begin{itemize}
\item Motility
\item Sensation
\item Inflammation
\item Altered bacterial
\item flora
\end{itemize}}};

\node [mycircle](FGID)[right of = physiology]{FGID};
%path
\draw[->](child)--(psych);
\draw[->] (child)--(physiology);
\draw[<->](psych)--(physiology);
\draw [<->](physiology)--(FGID);
\draw [<->](psych)--(FGID);
\end{tikzpicture}
\end{frame}
\end{document}

enter image description here

Best Answer

Besides the things I already commented on, here are a few other things I’d consider:

Setting a fixed with makes the nodes having them the same width but also creates problem for very long words in the itemize environment. In addition to that the itemize environment introduces a rather high horizontal white space in front of the bullet. (Similar things happen in Saving a list in a re-usable box.)

I would avoid itemize and reproduce the behavior with a simply tabular environment (see my answer on the linked question) which inserts the bullet on its own.

For a more pleasing output I center the first line (kind of a header, isn’t it?) and add additional vertical space. The rectangle split shape might help here.

The needed options are:

  • shape=rectangle split,
  • rectangle split parts=2: we want two parts,
  • rectangle split part align={center,left}: the first part is centered, the second part is left-aligned.
  • rectangle split draw splits=false: by default the shape has lines between the separate parts, this disables them.

In the second example, I have used my positioning-plus library to place the psych and the FGID node vertically centered to the other nodes.

The first example needs the positioning library (which is loaded by positioning-plus so it is not loaded explicitly).

Code

\documentclass{beamer}
\usepackage{tikz,array}
\usetikzlibrary{positioning-plus,arrows,shapes.multipart}
\tikzset{
  block/.style={
    shape=rectangle split,
    draw,
    rectangle split part align={center,left},
    rectangle split parts=2,
    rectangle split draw splits=false},
  Circle/.style={shape=circle, draw, align=left}}
\newcommand*{\itemizeTabular}[2][l]{%
  \begin{tabular}{!{\kern\tabcolsep\usebeamertemplate{itemize item}}#1@{}}#2\end{tabular}}
\begin{document}
\begin{frame}\centering
\begin{tikzpicture}[auto, thick, >=stealth]
\node[block] (child) {%
  Early life\nodepart{two}
  \itemizeTabular{Genetic\\Environmental}};
\node[block, right=of child] (psych) {%
  Psychoscial factors\nodepart{two}
  \itemizeTabular{life stress\\Psychological stress\\coping\\social support}};
\node[block, below=of psych] (phys) {%
  Physiology\nodepart{two}
  \itemizeTabular{Motility\\Sensation\\Inflammation\\Altered bacterial\\flora}};

\node[Circle, right=of phys](FGID) {FGID};

\path[->] (child) edge (psych)
                  edge (phys);
\path[<->] (psych) edge (phys)
                   edge (FGID)
            (phys) edge (FGID);
\end{tikzpicture}
\end{frame}
\begin{frame}\centering
\begin{tikzpicture}[auto, thick, >=stealth]
\node[block] (psych) {%
  Psychoscial factors\nodepart{two}
  \itemizeTabular{life stress\\Psychological stress\\coping\\social support}};
\node[block, below=of psych] (phys) {%
  Physiology\nodepart{two}
  \itemizeTabular{Motility\\Sensation\\Inflammation\\Altered bacterial\\flora}};

\node[block,left=of (phys)(psych)] (child) {%
  Early life\nodepart{two}
  \itemizeTabular{Genetic\\Environmental}};

\node[Circle, right=of (phys)(psych)](FGID) {FGID};

\path[->] (child) edge (psych)
                  edge (phys);
\path[<->] (psych) edge (phys)
                   edge (FGID)
            (phys) edge (FGID);
\end{tikzpicture}
\end{frame}
\end{document}

Output

enter image description hereenter image description here