我想在代码中连接块 B 和 M,但又不想让连接线“切割”F。我怎样才能强制连接扩大连接线并避开 F?
\documentclass[11pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,shapes.geometric,arrows,positioning,intersections}
\begin{document}
\begin{tikzpicture}[auto,node distance=1cm,thick,
main node/.style={black,draw,minimum width=1.5cm,minimum height=0.75cm}]%circle,draw,font=\sffamily\Large\bfseries}]
\node[main node] (L) {L};
\node[main node] (F) [left = of L ] {F};
\node[main node] (C) [below = of F ] {M};
\node[main node] (B) [right = of L ] {B};
\node[main node] (AP) [below = of B ] {AP};
\node[main node] (A) [below = of L ] {A};
\node[main node] (H) [right = of B ] {H};
\node[main node] (G) [right = of H] {G};
\node[main node] (BR) [below = of G] {BR};
\node[main node] (LR) [below = of BR] {LR};
\node[main node] (U) [below = of AP ] {U};
\node[main node] (P) [below = of U ] {P};
\path[every node/.style={font=\sffamily\small}]
(L) edge node [right] {} (B)
(L) edge node [right] {} (F)
(L) edge node [right] {} (C)
(F) edge node [right] {} (C)
(B.north) edge [out=90,in=90] node [right] {} (F.north)
(B.north) edge [out=90,in=180] node [right] {} (C.west)
(B) edge node [right] {} (AP)
(B) edge node [right] {} (A)
(AP.east) edge [out=0,in=270] node [left] {} (H.south)
(B) edge node [right] {} (H)
(H) edge node [right] {} (G)
(U.east) edge [out=0,in=270] node [left] {} (H.south)
(P.east) edge [out=0,in=270] node [left] {} (H.south)
(U) edge node [right] {} (P)
(BR.west) edge [out=180,in=270] node [right] {} (H.south)
(LR.west) edge [out=180,in=270] node [right] {} (H.south)
(BR.east) edge [out=0,in=0] node [right] {} (G.east)
(LR.east) edge [out=0,in=0] node [right] {} (G.east);
\end{tikzpicture}
\end{document}
这就是我现在得到的
这就是我想要得到的
谢谢!
答案1
欢迎使用 TeX-SE!在这种情况下,可以引入辅助坐标来更精细地控制路径。只要 和in
相差out
180 度,结果就会看起来很平滑。
\documentclass[11pt,tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[auto,node distance=1cm,thick,
main node/.style={black,draw,minimum width=1.5cm,minimum height=0.75cm}]%circle,draw,font=\sffamily\Large\bfseries}]
\node[main node] (L) {L};
\node[main node] (F) [left = of L ] {F};
\node[main node] (C) [below = of F ] {M};
\node[main node] (B) [right = of L ] {B};
\node[main node] (AP) [below = of B ] {AP};
\node[main node] (A) [below = of L ] {A};
\node[main node] (H) [right = of B ] {H};
\node[main node] (G) [right = of H] {G};
\node[main node] (BR) [below = of G] {BR};
\node[main node] (LR) [below = of BR] {LR};
\node[main node] (U) [below = of AP ] {U};
\node[main node] (P) [below = of U ] {P};
\path[every node/.style={font=\sffamily\small}]
(L) edge node [right] {} (B)
(L) edge node [right] {} (F)
(L) edge node [right] {} (C)
(F) edge node [right] {} (C)
(B.north) edge [out=90,in=90] node [right] {} (F.north)
(B) edge node [right] {} (AP)
(B) edge node [right] {} (A)
(AP.east) edge [out=0,in=270] node [left] {} (H.south)
(B) edge node [right] {} (H)
(H) edge node [right] {} (G)
(U.east) edge [out=0,in=270] node [left] {} (H.south)
(P.east) edge [out=0,in=270] node [left] {} (H.south)
(U) edge node [right] {} (P)
(BR.west) edge [out=180,in=270] node [right] {} (H.south)
(LR.west) edge [out=180,in=270] node [right] {} (H.south)
(BR.east) edge [out=0,in=0] node [right] {} (G.east)
(LR.east) edge [out=0,in=0] node [right] {} (G.east);
\draw (B.north) to[out=90,in=70] ([xshift=-10mm,yshift=10mm]F)
to[out=-110,in=180] (C.west);
\end{tikzpicture}
\end{document}
或者
\draw (B.north) to[out=90,in=90] ([xshift=-8mm]F.north west) to[out=-90,in=180] (C.west);
而且,还可以稍微缩短代码。
\documentclass[11pt,tikz]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[auto,node distance=1cm,thick,
main node/.style={black,draw,minimum width=1.5cm,minimum
height=0.75cm}]%circle,draw,font=\sffamily\Large\bfseries}
\node[main node] (L) {L};
\node[main node] (F) [left = of L ] {F};
\node[main node] (C) [below = of F ] {M};
\node[main node] (B) [right = of L ] {B};
\node[main node] (AP) [below = of B ] {AP};
\node[main node] (A) [below = of L ] {A};
\node[main node] (H) [right = of B ] {H};
\node[main node] (G) [right = of H] {G};
\node[main node] (BR) [below = of G] {BR};
\node[main node] (LR) [below = of BR] {LR};
\node[main node] (U) [below = of AP ] {U};
\node[main node] (P) [below = of U ] {P};
\path (L) edge (B)
(L) edge (F)
(L) edge (C)
(F) edge (C)
(B) edge [out=90,in=90] (F)
(B) edge (AP)
(B) edge (A)
(AP) edge [out=0,in=270] (H)
(B) edge (H)
(H) edge (G)
(U) edge [out=0,in=270] (H)
(P) edge [out=0,in=270] (H)
(U) edge (P)
(BR) edge [out=180,in=270] (H)
(LR) edge [out=180,in=270] (H)
(BR) edge [out=0,in=0] (G)
(LR) edge [out=0,in=0] (G);
\draw (B) to[out=90,in=90] ([xshift=-8mm]F.north west)
to[out=-90,in=180] (C.west);
\end{tikzpicture}
\end{document}