TikZ:流程图

TikZ:流程图

请帮助整理这个混乱的 tikz 流程图。

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

在此处输入图片描述

答案1

除了我已经评论过的内容之外,我还需要考虑以下几点:

设置固定宽度会使节点具有相同的宽度,但也会在环境中产生非常长的单词问题itemize。除此之外itemize环境还会在项目符号前面引入一个相当高的水平空白。(类似的事情发生在将列表保存在可重复使用的框中

我会避免itemize并在一个简单的环境中重现这种行为tabular(参见我对链接问题的回答),它会自行插入子弹。

为了获得更令人满意的输出,我将第一行居中(有点像标题,不是吗?)并添加额外的垂直空间。形状rectangle split可能在这里有帮助。

所需的选项包括:

  • shape=rectangle split
  • rectangle split parts=2:我们需要两个部分,
  • rectangle split part align={center,left}:第一部分居中,第二部分左对齐。
  • rectangle split draw splits=false:默认情况下,形状的各个部分之间有线,此选项可禁用它们。

在第二个例子中,我使用了我的positioning-plus图书馆psychFGID节点垂直放置在其他节点的中心。

第一个例子需要positioning库(由加载,positioning-plus因此不需要明确加载)。

代码

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

输出

在此处输入图片描述在此处输入图片描述

相关内容