纠正 Tikz 中的箭头连接

纠正 Tikz 中的箭头连接

我有这个图,我想裁剪掉连接的多余线条。

在此处输入图片描述

在此处输入图片描述

以下是代码:

\documentclass{article}
\usepackage[utf8]{inputenc}  
\usepackage[a4paper,left=1.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{tikz}  
\usepackage{mathtools} 
\usetikzlibrary{shapes,arrows}  
\usepackage{float}

\title{bloques}
\author{}
\date{}

\begin{document}

\maketitle

\tikzstyle{block} = [draw, fill=white, rectangle, 
    minimum height=3em, minimum width=6em   ] 
\tikzstyle{Fi} = [coordinate] 
\tikzstyle{Wi} = [coordinate]  
\tikzstyle{Wi_aWW} = [coordinate]  
\tikzstyle{Wi_aRW} = [coordinate]  
\tikzstyle{Wi_aRW_aux} = [coordinate] 
\tikzstyle{WCHP} = [coordinate]  
\tikzstyle{WCHP_aRW} = [coordinate]  
\tikzstyle{WCHP_aWW} = [coordinate] 

\tikzstyle{QCHP} = [coordinate]  
\tikzstyle{QCHP_aQQ} = [coordinate]   
\tikzstyle{QCHP_aRQ} = [coordinate]    
\tikzstyle{QCHP_aRQ_aux_1} = [coordinate]   
\tikzstyle{QCHP_aRQ_aux_2} = [coordinate]  
\tikzstyle{QCHP_aaQ} = [coordinate]  

\tikzstyle{QAB} = [coordinate]  
\tikzstyle{QAB_aRQ} = [coordinate]   
\tikzstyle{QAB_aQQ} = [coordinate]   

\tikzstyle{RCERG} = [coordinate] 
\tikzstyle{RWARG} = [coordinate] 
\tikzstyle{QaCHP} = [coordinate] 
\tikzstyle{Wd_EDS} = [coordinate] 
\tikzstyle{Wd_CHP} = [coordinate]  

\tikzstyle{Qd_CHP} = [coordinate]  
\tikzstyle{QCHP_aux} = [coordinate]   
\tikzstyle{QCHP_aux_2} = [coordinate]  

\tikzstyle{Qd_AB} = [coordinate] 
\tikzstyle{Fi_aYF} = [coordinate]  
\tikzstyle{Fi_aQF} = [coordinate] 
 
\begin{tikzpicture}[auto, node distance=2cm,>=latex'] 
\centering

%Declara los nodos

\node [block] (EDS) {\textbf{EDS}}; 
\node [block, below of=EDS, node distance = 3.5cm] (GDS) {\textbf{GDS}}; 
\node [Wi, name=Wi, right of=EDS]{}; 
\node [Wi_aWW, name=Wi_aWW, above of=Wi, node distance=0.85cm]{}; 

\node [Wi_aRW, name=Wi_aRW, below of=Wi, node distance=0.5cm]{};  
\node [Wi_aRW_aux, name=Wi_aRW_aux, below of=Wi, node distance=0.5cm]{}; 

\node [Wd_EDS, name=Wd_EDS, right of=Wi_aWW, node distance=13.5cm]{}; 
\node [block, minimum height=4em, right of=Wi_aRW, node distance = 11cm, align=center] (CERG) {\textbf{CERG} \\ $\text{COP}^{\text{CERG}}$};  
\node [RCERG, name=RCERG, right of=CERG, node distance = 2.5cm]{}; 
\node [Fi, name=Fi, right of=GDS]{};   

\node [Fi_aYF, name=Fi_aYF, above of=Fi, node distance = 0.7cm]{};  
\node [Fi_aQF, name=Fi_aQF, below of=Fi, node distance = 3cm]{};   

\node [block, minimum height=6em , right of=Fi_aYF, node distance = 2.5cm,align=center] (CHP) {\textbf{CHP}  \\ $\eta_W,\eta_Q$};  
\node [block, right of=Fi_aQF, node distance = 2.5cm, align=center] (AB) {\textbf{AB} \\ $\eta_t$}; 

\node [WCHP, name=WCHP, right of=CHP, node distance = 2.5cm]{}; 
\node [WCHP_aRW, name=WCHP_aRW, above of=WCHP, node distance = 2.27cm]{};  
\node [WCHP_aWW, name=WCHP_aWW, below of=WCHP, node distance = 0.001cm]{};  
\node [Wd_CHP, name=Wd_CHP, right of=WCHP_aWW, node distance=8.5cm]{};   

\node[QCHP, name=QCHP, right of=CHP, node distance=2.5cm]{};  
\node[QCHP_aux, name=QCHP_aux, right of=CHP, node distance=2.5cm, below=7.5mm]{}; 
\node [Qd_CHP, name=Qd_CHP, right of=QCHP, node distance=8.5cm, below = 7.5mm]{};    

\node[QCHP_aux_2, name=QCHP_aux_2, right of=CHP, node distance=2.5cm, below=15mm]{};  
\node[QCHP_aaQ, name=QCHP_aaQ, below of =QCHP_aux_2, node distance = 3mm,label={below:$\alpha_{aQ}^{\text{CHP}} Q_^{\text{CHP}}$}]{};  

\node [QCHP_aRQ_aux_1, name=QCHP_aRQ_aux_1, right of=QCHP_aux_2, node distance = 4cm]{};
\node [QCHP_aRQ_aux_2, name=QCHP_aRQ_aux_2, below of=QCHP_aRQ_aux_1, node distance = 1.5cm]{};

\node [QAB, name=QAB, right of=AB, node distance=2.5cm]{};  
\node [QAB_aRQ, name=QAB_aRQ, above of=QAB, node distance = 0.7cm]{};   
\node [QAB_aQQ, name=QAB_aQQ, below of=QAB, node distance = 0.4cm]{};    

\node [block, right of=QAB_aRQ, node distance = 6cm,align=center] (WARG) {\textbf{WARG} \\ $\text{COP}^{\text{WARG}}$};    

\node [RWARG, name=RWARG, right of=WARG, node distance=2.5cm]{};  

\node [block,minimum height=25em ,right of=CHP,node distance = 12.16cm, align=center] (USER) {\textbf{User} \\ $\left( W_d, \, Q_d, \, R_d \right)$};  

\node [Qd_AB, name=Qd_AB, right of=QAB_aQQ, node distance=8.5cm]{}; 

%Ahora conectamos los bloques 

\draw[draw,->] (EDS) -- node {$W_i$} (Wi); 
\draw[-] (Wi) -- node {} (Wi_aWW); 
\draw[-] (Wi) -- node {} (Wi_aRW);  
\draw[->] (Wi_aWW) -- node {$\alpha_{WW}^{\text{EDS}} W_i \qquad\qquad\qquad\qquad\qquad \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad$} (Wd_EDS);  
% \draw[->] (Wi_aRW) -- node [midway, above] {$\alpha_{RW}^{\text{EDS}} W_i$} (CERG);  
\draw[->] (CERG) -- node {$R^{\text{CERG}}$} (RCERG); 
\draw[->] (GDS) -- node {$F_i$} (Fi);  
 \begin{scope}[transform canvas={yshift=+4mm}]
    \draw [->] (Wi_aRW_aux) -- (CERG) node [midway, above] {$\alpha_{RW}^{\text{EDS}} W_i \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad$};
\end{scope}  

\draw[-] (Fi) -- node {} (Fi_aYF); 
\draw[-] (Fi) -- node {} (Fi_aQF); 

\draw[->] (Fi_aYF) -- node {$\alpha_{YF}^{\text{GDS}} F_i$} (CHP);  
\draw[->] (Fi_aQF) -- node {$\alpha_{QF}^{\text{GDS}} F_i$} (AB);   

\begin{scope}[transform canvas={yshift=+7.5mm}]
    \draw[->] (CHP) -- node {$W^{\text{CHP}}$} (WCHP);    
\end{scope} 
\draw[-] (WCHP) -- node {} (WCHP_aRW);   

\begin{scope}[transform canvas={yshift=-4mm}]
    \draw [->] (WCHP_aRW) -- (CERG) node [midway, above] {$\alpha_{RW}^{\text{W}^\text{CHP}} W_i \qquad\qquad$};
\end{scope}   

\draw[-] (WCHP) -- node {} (WCHP_aWW);  
\draw[->] (WCHP_aWW) -- node {$\alpha_{WW}^{\text{CHP}} W^\text{CHP}$ \qquad\qquad\qquad\qquad\qquad\qquad\;\,\,} (Wd_CHP);  

\begin{scope}[transform canvas={yshift=-7.5mm}]
    \draw[->] (CHP) -- node {$Q^{\text{CHP}}$} (QCHP);    
\end{scope}   
\draw[->] (QCHP_aux) -- node {$\alpha_{QQ}^{\text{CHP}} Q^\text{CHP} \qquad\qquad\qquad\qquad\qquad\qquad\;\;\;$}(Qd_CHP);

\draw[->] (AB) -- node {$Q^{\text{AB}}$} (QAB); 
\draw[-] (QAB) -- node {} (QAB_aRQ); 
\draw[-] (QAB) -- node {} (QAB_aQQ);    

\draw[-] (QCHP_aux) -- node {}(QCHP_aux_2); 
\draw[->] (QCHP_aux_2) -- node {}(QCHP_aaQ); 

\begin{scope}[transform canvas={yshift=-3mm}]
    \draw[->] (QAB_aRQ) -- node {$\alpha_{RQ}^{\text{AB}} Q^\text{AB} \qquad\quad\;$} (WARG);  
\end{scope}  
\draw[-] (QCHP_aux_2) -- node{$\alpha_{RQ}^{\text{CHP}} Q^\text{CHP}$} (QCHP_aRQ_aux_1);
\draw[-] (QCHP_aRQ_aux_1) -- node{} (QCHP_aRQ_aux_2);
\begin{scope}[transform canvas={yshift=+3mm}]
    \draw[->] (QCHP_aRQ_aux_2) -- node {} (WARG);  
\end{scope}  

\draw[->] (WARG) -- node {$R^{\text{WARG}}$} (RWARG);  

\draw[->] (QAB_aQQ) -- node{$\alpha_{QQ}^{\text{AB}} Q^\text{AB} \qquad\qquad\qquad\qquad\qquad\qquad\quad\,\,$}(Qd_AB);


\end{tikzpicture}

\end{document}
 

我很感谢你的帮助。

答案1

在此处输入图片描述

我认为你的绘图不必要地复杂,所以我从头开始重新绘制。你可能会发现下面的代码很有用 :-)

\documentclass{article}
\usepackage[a4paper,
            hmargin={1.5cm,2.5cm}, vmargin=2.5cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning,
                quotes,
                shapes}
\usepackage{mathtools}
\DeclareMathOperator{\ab}{AB}
\DeclareMathOperator{\cerg}{CERG}
\DeclareMathOperator{\chp}{CHP}
\DeclareMathOperator{\cop}{COP}
\DeclareMathOperator{\eds}{EDS}
\DeclareMathOperator{\gds}{GDS}
\DeclareMathOperator{\warg}{WARG}

\title{Bloques}
\author{}
\date{}

\begin{document}

\maketitle

    \begin{tikzpicture}[auto,
node distance = 24mm and 12mm,
 block/.style = {draw, font=\bfseries,align=center,
                 minimum height=4em, minimum width=6em},
every path/.append style = {-Latex}
                        ]
%Declara los nodos
\node [block] (EDS) {EDS};
    \coordinate[right=of EDS] (Wi);
\node [block, below=of EDS] (GDS) {GDS};
    \coordinate[right=of GDS] (Fi);
%
\node [block, 
       right=of GDS.north-| Wi] (CHP) {CHP\\ $\eta_W,\eta_Q$};
    \coordinate[above right=2ex and 12mm of CHP.east] (Wchp);
    \coordinate[below right=2ex and 12mm of CHP.east] (Qchp);
\node [block, below=of CHP]      (AB)   {AB\\ $\eta_t$};
    \coordinate[right=of AB] (Qab);
%
\node [block, 
       right=7.7 of EDS.south east]         (CERG) {CERG\\ $\cop^{\cerg}$};
\node [block, 
       right=7.7 of GDS.east |- AB.north]   (WARG) {WARG\\ $\cop^{\warg}$};
%
\node [block, minimum height=27em,
       right=of CHP -| CERG.east] (USER) {User\\ $(W_d, Q_d, R_d)$};
%%%% Ahora conectamos los bloques 
    \coordinate[above=2ex of CERG.north west] (Wi_aWW);
    \draw (EDS) to ["$W_i$"] (Wi);
    \draw (Wi) |- (Wi_aWW -| CERG.west)
                        node[pos=0.6] {$\alpha_{WW}^{\eds} Wi$}
                       -- (Wi_aWW -| USER.west);
    \draw (Wi) |- ([yshift=2ex] CERG.west)
                        node[pos=0.6] {$\alpha_{RW}^{\eds} Wi$};
    \draw (CERG) to ["$R^{\cerg}$"] (CERG -| USER.west);
%
   \draw (GDS) to ["$F_i$"] (Fi);
    \draw (Fi) |- (CHP)
                        node[pos=0.6] {$\alpha_{YF}^{\gds} Fi$};
    \draw (Fi) |- (AB)
                        node[pos=0.6,swap] {$\alpha_{QF}^{\gds} Fi$};
%
    \draw (Wchp -| CHP.east) to ["$W^{\chp}$"] (Wchp);
    \draw (Wchp) |- ([yshift=-2ex] CERG.west)
                       node[pos=0.75] {$\alpha_{WW}^{\chp} W_i$};
    \draw (Wchp) |- (CERG.west |- USER)
                       node[pos=0.75] {$\alpha_{WW}^{\chp} W^{\chp}$}
                         -- (USER);
%
    \draw (Qchp -| CHP.east) to ["$W^{\chp}$"] (Qchp);
    \draw (Qchp) to["$\alpha_{QQ}^{\chp} Q^{\chp}$" '] (Qchp-| CERG.west)
                         -- (Qchp -| USER.west);
%
    \draw (Qchp) |- ([yshift=3ex] WARG.west)
                       coordinate[pos=0.25] (Qchp_WARG)
                       node[pos=0.75] {$\alpha_{RQ}^{\chp} Q^{\chp}$};
    \draw (Qchp_WARG) -| ([yshift=-3ex] Qchp_WARG -| CHP.east)
                       node[below] {$\alpha_{aQ}^{\chp} Q_{\chp}$};
    \draw (WARG) to ["$R^{\warg}$"] (WARG -| USER.west);
%
    \coordinate[below=2ex of WARG.south west] (Qab_WARG);
    \draw (AB) to ["$Q^{\ab}$"] (Qab);
    \draw (Qab) |- ([yshift=-2ex] WARG.west)
                        node[pos=0.75] {$\alpha_{RQ}^{\ab} Q^{\chp}$};
    \draw (Qab) |- (Qab_WARG)
                        node[pos=0.75,swap] {$\alpha_{QQ}^{\ab} Q^{\ab}$}
                        -- (Qab_WARG -| USER.west);
    \end{tikzpicture}
\end{document}

答案2

你不需要下面的代码transform canvas/scope

 \begin{scope}[transform canvas={yshift=+4mm}]
    \draw [->] (Wi_aRW_aux) -- (CERG) node [midway, above] {$\alpha_{RW}^{\text{EDS}} W_i \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad$};
\end{scope}  

用。。。来代替

        \draw [->] (Wi_aRW_aux) |- (CERG)   ;

要得到

在此处输入图片描述

现在您可以在箭头上方适当地插入标签/文本

该语法|-暗示了下行线和水平线的交叉

scope items/canvas code对其余节点重复相同步骤

有问题请回复

  • 根据 OP 评论进行编辑

要使箭头终止于中心以外的另一点,请使用以下语法

    \draw [->] (Wi_aRW_aux) |- ($(CERG)+(0pt,4pt)$)   ;

终止点现在4pt位于y direction

使用这样的语法,你需要使用calc序言中的库\usetikzlibrary{calc}

使用calc库的完整示例可以在这里看到——https://tex.stackexchange.com/a/603652/197451

相关内容