如何将箭头从矩形 R2 中间正上方移到 R2.north(顶部中心)?
\documentclass[a4paper]{scrartcl}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{tikz}
\usepackage{tikz-uml}
\usetikzlibrary{shapes.multipart,positioning,fit}
\usepackage{pgf-umlsd}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}
\node[text width=3cm] (A) at (0,0) {\tiny AAA};
\node[anchor=north west , text width=1cm] (A1) at (A.south west) {\tiny BBB};
\node[anchor=west , text width=1cm] (A2) at (A1.east) {\tiny CCC};
\node[anchor=west , text width=1cm] (A3) at (A2.east) {\tiny DDD};
\node[anchor=north west , text width=1cm] (A4) at (A1.south west) {\tiny EEE};
\node[anchor=west , text width=1cm] (A5) at (A4.east) {\tiny FFF};
\node[anchor=west , text width=1cm] (A6) at (A5.east) {\tiny };
\node [inner sep=0pt,
draw,
rounded corners,
fit = (A)(A1)(A2)(A3)(A4)(A5)(A6)
] (A13) {};
\draw (A1.north west) -- (A3.north east)
(A1.south west) -- (A3.south east);
\node[below left = 1.0cm and 0.5cm of A13.south, text width=1cm] (B1) {\tiny GGG};
\node[below =0cm of B1, text width=1cm] (B2) {\tiny HHH};
\node [inner sep=0pt,
draw,
rounded corners,
fit = (B1)(B2)
] (B6) {};
\draw[gray,->] (A6.center) -- ++(east:1.0) -- ++(down:0.5) -- ++(west:1.5) -- ++(down:0.4);
\end{tikzpicture}
\end{document}
答案1
为此,您可以使用-|
连接器,它(与--
仅绘制连接两个节点的直线不同)先绘制一条水平线,然后绘制一条垂直线,以便两个节点以直角连接。还有一种对应物|-
首先绘制垂直线。然后,您可以使用 轻松让箭头结束在正上方B6
(这就是您在代码中命名您在图片中用 R2 表示的节点的方式)B6.north
。
完整的代码将是(我注释掉了两个不需要的包,而且我也没有第一个包):
\documentclass[a4paper]{scrartcl}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{tikz}
%\usepackage{tikz-uml}
\usetikzlibrary{shapes.multipart,positioning,fit}
%\usepackage{pgf-umlsd}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}
\node[text width=3cm] (A) at (0,0) {\tiny AAA};
\node[anchor=north west , text width=1cm] (A1) at (A.south west) {\tiny BBB};
\node[anchor=west , text width=1cm] (A2) at (A1.east) {\tiny CCC};
\node[anchor=west , text width=1cm] (A3) at (A2.east) {\tiny DDD};
\node[anchor=north west , text width=1cm] (A4) at (A1.south west) {\tiny EEE};
\node[anchor=west , text width=1cm] (A5) at (A4.east) {\tiny FFF};
\node[anchor=west , text width=1cm] (A6) at (A5.east) {\tiny };
\node [inner sep=0pt,
draw,
rounded corners,
fit = (A)(A1)(A2)(A3)(A4)(A5)(A6)
] (A13) {};
\draw (A1.north west) -- (A3.north east)
(A1.south west) -- (A3.south east);
\node[below left = 1.0cm and 0.5cm of A13.south, text width=1cm] (B1) {\tiny GGG};
\node[below =0cm of B1, text width=1cm] (B2) {\tiny HHH};
\node [inner sep=0pt,
draw,
rounded corners,
fit = (B1)(B2)
] (B6) {};
\draw[gray,->] (A6.center) -- ++(east:1.0) -- ++(down:0.5) -- ++(west:1.5) -| (B6.north);
\end{tikzpicture}
\end{document}