我正在绘制两个节点和这些节点之间的箭头
\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[node distance=5cm]
% nodes
\node [draw] (A) {A};
\node [draw, right=of A] (B) {B};
% arrows
\draw [->] (A) -- node [above, midway] {Some text} (B);
\end{tikzpicture}
\end{document}
使用\draw [->] (A) -- node [above, midway] {Some text} (B);
我可以在箭头上方写文字;但是,文字不遵守配置的节点距离。我可以设置箭头和文字之间的距离吗?
答案1
您必须移动标签。它们不受节点距离控制。
选择一种方法:
% arara: pdflatex
\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[node distance=5cm]
\node [draw] (A) {A};
\node [draw, right=of A] (B) {B};
\node [draw, right=of B] (C) {C};
\node [draw, right=of C] (D) {D};
\draw [->] (A) -- node [above=5cm] {Some text} (B);
\draw [->] (B) -- node [label={[yshift=5cm]Some text}] {} (C);
\draw [->] (C) -- node [label={[label distance=5cm]90:Some text}] {} (D);
\end{tikzpicture}
\end{document}
你喜欢的那个,你可以申请添加例如\begin{tikzpicture}[every label/.append style={above=5cm}]