我在两条水平线之间添加箭头符号时遇到了困难。我有代码来添加从一条水平线开始的箭头,但我不知道如何制作从中间开始的箭头。
我已附加一张图片来说明我想要达到的结果。
感谢@zarko,我已经获得了接近预期结果的代码,如下所示。
\begin{center}
\begin{tikzpicture}[
node distance = 3mm and 20mm,
arr/.style = {draw=blue!70!black, -{Straight Barb[scale=0.8]}, very thick},
N/.style = {font=\small, text width=60mm, align=center, inner sep=2pt},
]
% left image
\node (n1) [N] {Set \mbox{$r_1=0$}\\
Use fixed window $[0,r_2]$};
\draw[thick] (n1.west) -- ++ (0,-30mm)
(n1.east) -- ++ (0,-30mm);
%
\coordinate[below=19mm of n1.west] (aux1);
\path[arr] (n1.east |- aux1) node[right] {$r_2$} --
(aux1) node[left] {$r_2$};
% right image
\node (n2) [N, right=of n1]
{Set \mbox{$r\in[0,r_1-r_2]$}\\
Anvend fast termineringsvindue $[r_1,r_2]$};
\draw[thick] (n2.west) -- ++ (0,-30mm)
(n2.east) -- ++ (0,-30mm);
%
\coordinate[below=19mm of n2.west] (aux2);
\coordinate[above=of aux2] (aux3);
\coordinate[above=of aux3] (aux4);
\coordinate[above=of aux4] (aux5);
\path[arr] (n2.east |- aux2) --
(aux2) node[left] {$r_1$};
\path[arr] (n2.east |- aux3) node[right] {$r_2$} -- ++
(-36mm,0) node[left] {$r_1$};
\path[arr] (n2.east |- aux4) -- node[above] {$r_w=r_2-r_1$} ++
(-24mm,0) node[left] {$r_1$};
\end{tikzpicture}
\end{center}
答案1
下面的内容应该能让你了解如何做到这一点。你可以让你的箭头从任意位置开始。只要你不使用--
(或to
),\path
就不会绘制任何内容(过于简单,但在这种情况下是正确的)。因此,你可以移动到特定点(例如,(aux1)
移动到坐标aux1
,并++(2,0)
从当前位置向右移动两厘米),并在到达所需点后开始绘制。
\documentclass[tikz,border=3.14]{standalone}
\usetikzlibrary{positioning,arrows.meta}
\begin{document}
\begin{tikzpicture}[
node distance = 3mm and 20mm,
arr/.style = {draw=blue!70!black, -{Straight Barb[scale=0.8]}, very thick},
N/.style = {font=\small, text width=60mm, align=center, inner sep=2pt},
]
% left image
\node (n1) [N] {Set \mbox{$r_1=0$}\\
Use fixed window $[0,r_2]$};
\draw[thick] (n1.west) -- ++ (0,-30mm)
(n1.east) -- ++ (0,-30mm);
%
\coordinate[below=19mm of n1.west] (aux1);
\path[arr] (aux1) ++(2,0) node[right]{$r_2$} to (aux1);
\coordinate[below=of aux1] (aux1);
\path[arr] (aux1) ++(4,0) node[right]{$r_2$} -- (aux1) node[left]{$r_1$};
\coordinate[below=of aux1] (aux1);
\path[arr] (n1.east |- aux1) node[right] {$r_2$} -- (aux1);
% right image
\node (n2) [N, right=of n1]
{Set \mbox{$r\in[0,r_1-r_2]$}\\
Anvend fast termineringsvindue $[r_1,r_2]$};
\draw[thick] (n2.west) -- ++ (0,-30mm)
(n2.east) -- ++ (0,-30mm);
%
\coordinate[below=19mm of n2.west] (aux2);
\coordinate[above=of aux2] (aux3);
\coordinate[above=of aux3] (aux4);
\coordinate[above=of aux4] (aux5);
\path[arr] (n2.east |- aux2) --
(aux2) node[left] {$r_1$};
\path[arr] (n2.east |- aux3) node[right] {$r_2$} -- ++
(-36mm,0) node[left] {$r_1$};
\path[arr] (n2.east |- aux4) -- node[above] {$r_w=r_2-r_1$} ++
(-24mm,0) node[left] {$r_1$};
\end{tikzpicture}
\end{document}