我有许多节点,想要连接其中两个,但是路径不会被划掉,就像下面的例子中的这两个节点之间的节点所覆盖(我想要连接L_0
和R_0
):
为了创建此路径,我使用了以下命令:
\path [line,dashed] (l0) edge [] node {} (r0);
答案1
像这样?
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node (a) {a};
\node[right=1cm of a] (b) {B};
\node[right=1cm of b] (c) {C};
\node[right=1cm of c] (d) {D};
\node[right=1cm of d] (e) {E};
\node[right=1cm of e] (f) {F};
\draw [dashed] (a) to[bend left] node {} (f);
\draw [red,dashed] (a) -- ++(0,5mm) -| node {} (f);
\end{tikzpicture}
\end{document}
答案2
我建议您使用to
语法并指定out
和in
角度。以下是一些示例,也许可以调整distance
:
代码:
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[thick, dashed]
\foreach [count=\i] \x in {$L_0$, $R_3$, $R_1$, $L_2$, $R_0$} {
\node (\i) at (\i,0) {\x};
}
\draw [olive ] (1.north) to[out=50, in=100] (5.north);
\draw [red ] (1.north) to[out=30, in=150] (5.north);
\draw [blue ] (1.south) to[out=-30, in=-150] (5.south);
\draw [magenta] (1.south) to[out=-30, in=-150, distance=2.5cm] (5.south);
\draw [orange ] (1.south) to[out=-70, in=-110] (5.south);
\end{tikzpicture}
\end{document}