考虑以下 MWE:
\documentclass{memoir}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
% Nodes
\node[draw] (node1) {1};
\node[draw, below left=of node1] (node2) {2};
\node[draw, below right=of node1] (node3) {3};
% Arrows
\draw[->] (node1.south) -| (node2.north);
\draw[->] (node1.south) -| (node3.north);
\end{tikzpicture}
\end{document}
例如,我希望箭头弯曲两次,方法是写类似|-|
而不是 的内容-|
。这样简单的解决方案可行吗?还是我需要更复杂的东西?
(我在网上搜索过答案,但显然使用了错误的关键词。任何有关 TikZ 手册有用部分的帮助都将不胜感激。)
答案1
像这样:
\documentclass{memoir}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
% Nodes
\node[draw] (node1) {1};
\node[draw, below left=of node1] (node2) {2};
\node[draw, below right=of node1] (node3) {3};
% Arrows
\draw[->] (node1.south) |- ($(node1.south) - (0,5mm)$) -| (node2.north);
\draw[->] (node1.south) |- ($(node1.south) - (0,5mm)$) -| (node3.north);
\end{tikzpicture}
\begin{tikzpicture}
% Nodes
\node[draw] (node1) {1};
\node[draw, below left=of node1] (node2) {2};
\node[draw, below right=of node1] (node3) {3};
% Arrows
\draw[->] (node1.south) |- ++(0,-5mm) -| (node2.north);
\draw[->] (node1.south) |- ++(0,-8mm) -| (node3.north);
\end{tikzpicture}
\end{document}