我想要制作下图。
感谢以下评论和一个例子TeXample.net,我编写了以下代码。存在一些问题。我该如何修复它们?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\tikzstyle{frame} = [
rectangle, draw,
text width=2em, text centered,
minimum height=4em
]
\tikzstyle{line} = [draw, -latex']
\begin{document}
\begin{tikzpicture}[node distance = 3cm]
\node [frame] (pop) {Population};
\node [above of=pop, left of=pop] (init) {Initialisation};
\node [below of=pop, left of=pop] (term) {Termination};
\node [frame, above of=pop, right of=pop] (parents) {Parents};
\node [frame, below of=pop, right of=pop] (off) {Offspring};
\path [line] (parents) -- node[right,pos=.4] {Recombination} node[right,pos=.6] {Mutation} (off);
\path [line] (init) |- (pop);
\path [line] (pop) -| (term);
\path [line] (off) -| node[below,pos=.25] {Survivor selection}(pop);
\path [line] (pop) |- node[above,pos=.75] {Parents selection} (parents);
\end{tikzpicture}
\end{document}
这是我的拥抱输出!
答案1
我对您的示例中的文本宽度和节点距离设置做了一些调整,已经达到了几乎相同的效果,但您可能想将箭头放大一点?
我使用以下方式在线更新写LaTeX, 看这里:
https://www.writelatex.com/37459xjfzxh
附有屏幕截图 更新:感谢对 wL 文档进行编辑的人,他们得到了下面显示的更新图像,这非常接近所需的结果
\documentclass[margin=3pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{arrows,shadows,positioning}
\tikzset{
frame/.style={
rectangle, draw,
text width=6em, text centered,
minimum height=4em,drop shadow,fill=lime!40,
rounded corners,
},
line/.style={
draw, -latex',rounded corners=3mm,
}
}
\begin{document}
\begin{tikzpicture}[font=\small\sffamily\bfseries,very thick,node distance = 4cm]
\node [frame] (pop) {Population};
\node [above=2cm, left of=pop] (init) {Initialisation};
\node [below=2cm, left of=pop] (term) {Termination};
\node [frame, above=2cm, right of=pop] (parents) {Parents};
\node [frame, below=2cm, right of=pop] (off) {Offspring};
\path [line] (parents)
-- node[right,align=left,pos=.5] {Recombination\\[3mm]Mutation}
(off);
\path [line] (init) |- (pop.170);
\path [line] (pop.190) -| (term);
\path [line] (off) -| node[below,pos=.25, align=center] {Survivor\\ selection}(pop);
\path [line] (pop) |- node[above,pos=.75, align=center] {Parents\\ selection}(parents);
\end{tikzpicture}
\end{document}