两个表格之间的箭头

两个表格之间的箭头

我想使用箭头连接不同表格中的两个单元格。如何实现?

在此处输入链接描述

答案1

以下是使用 TikZ 实现此目的的几种不同方法:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart,matrix,positioning}
\begin{document}
\begin{tikzpicture}
\node[rectangle split, rectangle split parts=3,draw,inner sep=1ex] (A) at (0,1)
{minus\nodepart{two}times\nodepart{three}transpose};

\node[rectangle split, rectangle split parts=5,draw,inner sep=1ex] (B) at (3,1)
{mmul\nodepart{two}mmuli\nodepart{three}sub\nodepart{four}subi\nodepart{five}transpose};
\draw[->] (A.text east) -- (B.three west);
\draw[->] (A.text east) -- (B.four west);
\draw[->] (A.two east) -- (B.text west);
\draw[->] (A.two east) -- (B.two west);
\draw[->] (A.three east) -- (B.five west);
\node (C) [below=of A]{Matrix Class};
\node[below= .5cm of B,text width=2cm,align=center]{Double Matrix\\ Class};
\end{tikzpicture}

\bigskip
\begin{tikzpicture}
\matrix (A) [matrix of nodes,nodes={draw, minimum size=.65cm, text width=2cm,align=center}] at (0,1)
{
minus\\
times\\
transpose\\
};
\matrix (B) [matrix of nodes,nodes={draw, minimum size=.65cm, text width=2cm,align=center}] at (4,1)
{
mmul\\
mmuli\\
sub\\
subi\\
transpose\\
};

\draw[->] (A-1-1.east) -- (B-3-1.west);
\draw[->] (A-1-1.east) -- (B-4-1.west);
\draw[->] (A-2-1.east) -- (B-1-1.west);
\draw[->] (A-2-1.east) -- (B-2-1.west);
\draw[->] (A-3-1.east) -- (B-5-1.west);

\node (C) [below=of A]{Matrix Class};
\node[below= .25cm of B,text width=2cm,align=center]{Double Matrix\\ Class};
\end{tikzpicture}

\end{document}

代码输出

答案2

{NiceTabular}这是使用nicematrix和 TikZ 绘制箭头的解决方案。

\documentclass{article}
\usepackage{nicematrix,tikz}
\usetikzlibrary{arrows.meta}

\begin{document}

\sffamily 

\renewcommand{\arraystretch}{1.5}
\begin{NiceTabular}{cw{c}{8mm}c}[cell-space-limits=4pt]
            && \Block[hvlines]{5-1}{} mmul \\
            && mmuli \\
  \Block[hvlines]{3-1}{}
  minus     && sub \\
  times     && subi \\
  transpose && transpose \\
  \Block{}{Matrix\\ class} 
            && \Block{}{DoubleMatrix\\ class}
\CodeAfter
  \begin{tikzpicture} [->, > = LaTeX]
    \draw (4.5-|2) -- (1.5-|3) ; 
    \draw (3.5-|2) -- (3.5-|3) ; 
    \draw (3.5-|2) -- (4.5-|3) ; 
    \draw (5.5-|2) -- (5.5-|3) ; 
  \end{tikzpicture}
\end{NiceTabular}

\end{document}

上述代码的输出

相关内容