我有两对节点,它们由括号分组,即带有括号修饰的路径。我想从第一个括号向第二个括号画一个箭头,垂直地从相应的括号出发并到达相应的括号。这是我尝试过的:
\begin{tikzpicture}[x=.45cm,y=.4cm, baseline=(Fb.base),every node/.append style={font=\scriptsize}]
\node at (0,0) {$L(ts)$};
\node at (2,0) {$L(tsut)$};
\node at (4,0) {$L(tu)$};
\node at (2,1) {$L(t)$};
\node at (2,-1) {$L(tsu)$};
\node (Aa) at (6,0) {$L(tsu)$};
\node (Ab) at (6,1) {$L(ts)$};
\draw[decoration={brace}, decorate] ($(Aa)+(1,1.4)$) to node(Pa){} ($(Ab)+(1,-1.4)$);
%
\node (Ba) at (10,0) {$L(ts)$};
\node at (12,0) {$L(tsut)$};
\node at (14,0) {$L(tu)$};
\node at (12,1) {$L(t)$};
\node (Bb) at (12,-1) {$L(tsu)$};
\node at (16,0) {$L(tsu)$};
\node at (16,1) {$L(ts)$};
\draw[decoration={brace, mirror}, decorate] ($(Ba)-(1,-.0)$) to node(Pb){} ($(Bb)-(0.7,.3)$);
\draw[->] (Pa) to[out=0,in=235] (Pb);
\end{tikzpicture}
最后一条路径draw
生成了所需的路径。但是,in
角度是手动设置的,但您可以看到它不是垂直的。如何让 TikZ 自动计算所需的角度?
答案1
let
你可以用库中的语法来计算calc
。我在括号的开始和结束处添加了两个辅助坐标。
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calc}
\begin{document}
\begin{tikzpicture}[x=.45cm,y=.4cm, every node/.append style={font=\scriptsize}]
\node at (0,0) {$L(ts)$};
\node at (2,0) {$L(tsut)$};
\node at (4,0) {$L(tu)$};
\node at (2,1) {$L(t)$};
\node at (2,-1) {$L(tsu)$};
\node (Aa) at (6,0) {$L(tsu)$};
\node (Ab) at (6,1) {$L(ts)$};
\draw[decoration={brace}, decorate] ($(Aa)+(1,1.4)$) to node(Pa){} ($(Ab)+(1,-1.4)$);
%
\node (Ba) at (10,0) {$L(ts)$};
\node at (12,0) {$L(tsut)$};
\node at (14,0) {$L(tu)$};
\node at (12,1) {$L(t)$};
\node (Bb) at (12,-1) {$L(tsu)$};
\node at (16,0) {$L(tsu)$};
\node at (16,1) {$L(ts)$};
\draw[decoration={brace, mirror}, decorate] ($(Ba)-(1,-.0)$) coordinate (c1) to node(Pb){} ($(Bb)-(0.7,.3)$) coordinate (c2);
\draw[->]
let
\p1=(c1),\p2=(c2),\n1={atan2(\y2-\y1,\x2-\x1)}
in
(Pa) to[out=0,in=\n1-90] (Pb);
\end{tikzpicture}
\end{document}