我想用以下代码绘制一个图表。但是当我对某个“节点”设置一些条件时,它要么重叠,要么没有正确对齐。我该如何解决这个问题?
\documentclass[]{amsart}
\usepackage{tikz-cd}
\usepackage{tkz-graph}
\usepackage{tkz-berge}
\usetikzlibrary{positioning,arrows,shapes.geometric,trees}
\usepackage{graphicx}
\usepackage{mathtools}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[scale=2]
\node (k1) {$\underset{(1)} {STEP1}$};
\node (k2) [right=of k1] {$ \underset{(2)} STEP2$};
\node (k3) [right=of k2] {$\underset{(3)} STEP3$};
\node (a1) [below=of k1] {$\underset{(4)} STEP4$};
\node (a2) [below=of k2] {$\underset{(5)} STEP5$};
\node (a3) [below=of k3] {$\underset{(6)} STEP6$};
\node (b1) [below=of a1] {$\underset{(7)} STEP7$};
\node (b2) [below=of a2] {$\underset{(8)} STEP8$};
\node (b3) [below=of a3] {$\underset{(9)} STEP9$};
\draw[->]
(k1) edge node[above]{Proposition 4} (k2)
(k2) edge (k3)
(a1) edge (a2)
%(a2) edge (a3)
(b1) edge (b2)
(b2) edge (b3);
\draw[->]
(k1) edge (a1)
(a1) edge (b1)
(k2) edge node[right]{proposition 1} (a2)
(a2) edge node[left]{proposition 1}(b2)
(k3) edge (a3);
\draw[->,dotted,thick]
(a2) edge[bend left=60] node[left,sloped] {Theorem 6} (k2)
(b2) edge [bend right=70] node[right,sloped] {Theorem5} (k2)
(b3) edge[bend left] node[below,sloped] {Theorem 5} (b2);
\end{tikzpicture}
\end{document}
答案1
我不确定我是否完全理解了你所说的将条件置于某个节点上的意思。但首先,标记箭头的文本对于箭头来说太宽了。您可以使用设置节点间距node distance
,我将其设置为2cm
垂直和4cm
水平。我还调整了虚线箭头的弯曲和标签。并将每行设置为单独的\draw
,因为我认为这样更具可读性。要使用将节点的小编号置于文本下方的中心\underset
,整个文本必须为{}
。
label
然后是节点条件。您可以使用作为参数来标记节点(节点外的文本) 。这是在节点k2
(STEP2)和a1
(STEP4)中完成的。但在这里我不确定这是否是你的意思。
\documentclass[]{amsart}
\usepackage{tikz-cd}
\usepackage{tkz-graph}
\usepackage{tkz-berge}
\usetikzlibrary{positioning,arrows,shapes.geometric,trees}
\usepackage{graphicx}
\usepackage{mathtools}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[scale=2,node distance=2cm and 4cm]
\node (k1) {$\underset{(1)} {STEP1}$};
\node (k2) [right=of k1,label=90:$A<B$] {$\underset{(2)} {STEP2}$};
\node (k3) [right=of k2] {$\underset{(3)} {STEP3}$};
\node (a1) [below=of k1,label=180:$A>B$] {$\underset{(4)} {STEP4}$};
\node (a2) [below=of k2] {$\underset{(5)} {STEP5}$};
\node (a3) [below=of k3] {$\underset{(6)} {STEP6}$};
\node (b1) [below=of a1] {$\underset{(7)} {STEP7}$};
\node (b2) [below=of a2] {$\underset{(8)} {STEP8}$};
\node (b3) [below=of a3] {$\underset{(9)} {STEP9}$};
\draw[->] (k1) edge node[above]{Proposition 4} (k2);
\draw[->] (k2) edge (k3);
\draw[->] (a1) edge (a2);
% \draw[->] (a2) edge (a3);
\draw[->] (b1) edge (b2);
\draw[->] (b2) edge (b3);
\draw[->] (k1) edge (a1);
\draw[->] (a1) edge (b1);
\draw[->] (k2) edge node[right]{Proposition 1} (a2);
\draw[->] (a2) edge node[left]{Proposition 1}(b2);
\draw[->] (k3) edge (a3);
\draw[->,dotted,thick] (a2) edge[bend left=60] node[left,sloped,anchor=south] {Theorem 6} (k2);
\draw[->,dotted,thick] (b2) edge [bend right=70,looseness=1.4] node[right,sloped,anchor=north] {Theorem 5} (k2);
\draw[->,dotted,thick] (b3) edge[bend left] node[below,sloped] {Theorem 5} (b2);
\end{tikzpicture}
\end{document}