如何在框前添加箭头

如何在框前添加箭头

我想在2条短线外面添加线作为T^-1框的输入,见附图。在此处输入图片描述

代码如下:

\documentclass[tikz,border=2mm]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{chains,fit,positioning,shapes.multipart}
\begin{document}
% Version 3t
\begin{tikzpicture}[
 node distance = 20mm and 5mm,
 start chain = going right,
  block/.style = {draw, minimum height=20mm, minimum width=5mm,
                 font=\boldmath,on chain},
  block4/.style={block,rectangle split,rectangle split parts=4}]
% upper blocks
\node (ht1)   [block,draw=none]
{\hphantom{$\boldmath(H)^+$}};
\node (f1)    [block,right=6mm of ht1]     {$T^{-1}_{1}$};
\node (y1)    [block,right=39mm of ht1]     {$T_1$};
\node (adc1)  [block4] {ADC\nodepart{two}ADC\nodepart{three}ADC\nodepart{four}ADC};
% lower blocks
\node (ht2)   [block,draw=none,below=of ht1]
{\hphantom{$\boldmath(H)^+$}};
\node (f2)    [block,right=6mm of ht2]     {$T^{-1}_L$};
\node (y2)    [block,right=39mm of ht2]     {$T_L$};
\node (adc2)  [block4] {ADC\nodepart{two}ADC\nodepart{three}ADC\nodepart{four}ADC};
% common input nodes
\node (in2)   [draw,inner sep=0pt, fit=(ht1)  (ht2),label=center:$\boldmath H^+$] {};
% top blocks
    \node (cpu) [above=15mm of in2]     {CPU};
    \node (rf)  [above=15mm of y1]      {RF-chain};

% Math symbols
    %\node at (42mm,15mm) (g1) {$\boldmath Y_1$};

    \node (Y) at (53mm,18mm) {$\boldmath y_1$};
    \draw [->] (Y) -- (53mm,10mm);

    \node (Y2) at (53mm,-23mm) {$\boldmath y_L$    
};
    \draw [->] (Y2) -- (53mm,-30mm);

    \node (Z) at (41mm,6mm) {$\boldmath z_1$};
    \node (Z2) at (41mm,-34mm) {$\boldmath z_L$};

    \node (x) at (-12mm,11mm) {$\boldmath \hat{x}$};

\draw[densely dotted] ([xshift=29mm] cpu.north -| in2.east) coordinate (in3)
                    -- (in3 |- in2.south);
% lines between blocks
    \foreach \y in {-0.75, -0.25, 0.25, 0.75}
{
% 8 input lines
    \draw [->]  ([yshift=\y cm +2 cm] in2.west)--++(180:1cm);
    \draw [->]  ([yshift=\y cm -2 cm] in2.west)--++(180:1cm);
}
% 2 lines between other blocks
    \foreach \j in {1,2}
{
        \foreach \y/\anchor  in {-0.25/two east, 0.25/three east, 0.75/four east, -0.75/text east}
        {
            \foreach \i [remember=\i as \lasti (initially y\j)] in {adc\j}
    \draw [<-] ([yshift= \y cm ]\lasti.east)--([yshift=\y cm]\i.west);
    \draw (-1,-2.0) circle [radius=0.7pt,yshift=-0 cm -\y cm];
    \draw (3.95,-2.0) circle [radius=0.7pt,yshift=-0 cm -\y cm];
    %\draw (0,-1) -- (4,-1);
    %\draw ([yshift= 0.5 cm -\y cm] adc\j.east)--++(0:1+1.5*\y)   node[antenna] {};
    \draw ([yshift=-0 cm -\y cm] adc\j.east)--++([xshift=1.5cm] 0:1+1.5*\y)   node[antenna] {};
    }

    \foreach \y  in {-0.25, 0.25}
        {
            \foreach \i [remember=\i as \lasti (initially f\j)] in { y\j}
    \draw [<-] ([yshift= \y cm ]\lasti.east)--([yshift=\y cm]\i.west);
    }

    \foreach \y  in {-0.25, 0.25, 0.75, -0.75}
        {
            \foreach \i [remember=\i as \lasti (initially ht\j)] in { f\j}
    \draw [<-] ([yshift= \y cm ]\lasti.east)--([yshift=\y cm]\i.west);
    }
}
\end{tikzpicture}
\end{document}

答案1

这是使用calc库的一种方法。坐标($(a.south east)!0.2!(a.north east)$)是从节点右下角a到右上角的直线的 20%。+表示坐标+(1cm,0)相对于前一个坐标,因此向右一厘米。

我使用了一个较短的例子来关注方法本身。

在此处输入图片描述

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\node [draw,minimum height=3cm] (a) {};
\draw [<-] ($(a.south east)!0.2!(a.north east)$) -- +(1cm,0) node[right]{0};
\draw [<-] ($(a.south east)!0.8!(a.north east)$) -- +(1cm,0) node[right]{0};
\end{tikzpicture}
\end{document}

为了达到更好的效果,我们使用了一种不使用calc库的方法,但是依赖于定义两个辅助坐标:

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node [draw,minimum height=3cm] (a) {};
\path (a.south east) -- (a.north east)
      coordinate [pos=0.2] (p1)
      coordinate [pos=0.8] (p2);
\draw [<-] (p1) -- +(1cm,0) node[right]{0};
\draw [<-] (p2) -- +(1cm,0) node[right]{0};
\end{tikzpicture}
\end{document}

相关内容