如何正确对齐同一块中的第二个箭头?

如何正确对齐同一块中的第二个箭头?

我有使用 tikz 获得的以下框图:

在此处输入图片描述

如何对齐从“参数自适应律”块到“控制器参数更新”块的箭头,以便不位于指向“参数自适应块”的箭头之上?这是生成框图的脚本:

\begin{tikzpicture}[auto, 
                node distance = 15mm and 10mm,
                start chain = going right,
                arr/.style = {-Latex},
                %block/.style = {draw, minimum height=3em, minimum width=4em},
                sum/.style = {circle, draw, node contents={}},    
                        ]
                \begin{scope}[nodes={on chain, join=by arr}]        
                \coordinate (in);
                \node (n1) [sum];
                \node (n2) [block, right=of n1] {\textlatin{Controller}};                      
                \node (n3) [block, right=of n2] {\textlatin{Plant}};
                \node (n4) [block,right=of n3] {\textlatin{Low Pass Filter}};
                \coordinate (out);
                \end{scope}
                \path   (in) to [pos=0.35,"$r \ \ \ \ +$"] (n1)
                        (n1) to ["$e$"{name=error}]     (n2)
                        (n2) to ["$u$"{name=control signal}] (n3)
                        (n3) to ["$y$"{name=plant output}] (n4)
                        (n4) to ["$y_f$"{name=y}]        (out);         
                \draw [->] (y) -- ++ (0,-2) -| node [pos=0.95] {$-$} (n1);
                \node (n5) [block, above=of plant output] {\textlatin{Parameters Adaptation Law}};
                \node (n6) [block, above=of n2] {\textlatin{Controller Parameters Update}};

                \draw [->] (y) |- (n5);
                \draw [->] (n6) -- node[anchor=east] {$\hat{K}$} (n2);
                \draw [->] (control signal) |- (n5);
                \draw [->] (n5) -- node[anchor=south] {$\hat{A}$} (n6);                        
\end{tikzpicture}

答案1

没有前导的代码总是需要一些猜测工作(以及不必要的工作)。我放弃了这些\textlatin{...}命令,因为我不知道babel你使用的是哪个版本。这个问题的答案可能是这样的

\draw [->] (control signal) |- ([yshift=-1em]n5.west);

但还有几个其他问题。最重要的一个是,你可以使用任何一个 chains 或者 positioning用于节点定位。因此在链的范围内,执行不是使用,right of因为这会导致节点轻微错位(这就是为什么其中一个箭头不是完全水平的原因)。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,babel,chains,quotes}
\begin{document}
\begin{tikzpicture}[auto, 
                node distance = 15mm and 10mm,
                start chain = going right,
                arr/.style = {->},>=Latex,
                block/.style = {draw, minimum height=3em, minimum
                width=4em,align=center,fill=blue!20},
                sum/.style = {circle, draw, node contents={}},    
                        ]
                \begin{scope}[nodes={on chain, join=by arr}]        
                \coordinate (in);
                \node (n1) [sum];
                \node (n2) [block] {Controller};                      
                \node (n3) [block] {Plant};
                \node (n4) [block] {Low Pass Filter};
                \coordinate (out);
                \end{scope}
                \path   (in) to [pos=0.35,"$r~~~+$"] (n1)
                        (n1) to ["$e$"{name=error}]     (n2)
                        (n2) to ["$u$"{name=control signal}] (n3)
                        (n3) to ["$y$"{name=plant output}] (n4)
                        (n4) to ["$y_f$"{name=y}]        (out);         
                \draw [->] (y) -- ++ (0,-2) -| node [pos=0.95] {$-$} (n1);
                \node (n5) [block, above=of plant output] {Parameters\\
                        Adaptation\\ Law};
                \node (n6) [block] at (n5-|n2) {Controller\\ Parameters\\ Update};

                \draw [->] (y) |- (n5);
                \draw [->] (n6) -- node[anchor=east] {$\hat{K}$} (n2);
                \draw [->] (control signal) |- ([yshift=-1em]n5.west);
                \draw [->] (n5) -- node[anchor=south] {$\hat{A}$} (n6);                        
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容