![如何在 TikZ 中用箭头绘制相邻单元格?](https://linux22.com/image/428977/%E5%A6%82%E4%BD%95%E5%9C%A8%20TikZ%20%E4%B8%AD%E7%94%A8%E7%AE%AD%E5%A4%B4%E7%BB%98%E5%88%B6%E7%9B%B8%E9%82%BB%E5%8D%95%E5%85%83%E6%A0%BC%EF%BC%9F.png)
答案1
开始一些事情
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{matrix,positioning}
\tikzset{
blockline/.style={matrix of nodes, nodes in empty cells,
row sep=0pt, column sep=-\pgflinewidth,
nodes={anchor=center, minimum width=15mm, minimum height=8mm},},
}
\begin{document}
\begin{tikzpicture}
\matrix[blockline] (block1a) {
&|[draw]| &|[draw, label=block1a]| 500 &|[draw]| &\\ 0 & 1 & 2 & 3 & 4\\};
\draw ([yshift=-.5\pgflinewidth]block1a-1-1.north west)--([yshift=-.5\pgflinewidth]block1a-1-5.north east) ([yshift=.5\pgflinewidth]block1a-1-1.south west)--([yshift=.5\pgflinewidth]block1a-1-5.south east);
\matrix[blockline, below right=0mm and 10mm of block1a.south] (block2a) {
&|[draw]| &|[draw, label=block2a]| 502 &|[draw]| &\\ 23 & 24 & 25 & 26 & 27\\};
\draw ([yshift=-.5\pgflinewidth]block2a-1-1.north west)--([yshift=-.5\pgflinewidth]block2a-1-5.north east) ([yshift=.5\pgflinewidth]block2a-1-1.south west)--([yshift=.5\pgflinewidth]block2a-1-5.south east);
\draw[->] ([xshift=5mm]block1a-1-3.south) coordinate(aux)-- node[pos=.35,right]{right} (aux|-block2a.south)-|([xshift=-5mm]block2a-1-3.south);
\end{tikzpicture}
\end{document}
答案2
这是一个起点:
\documentclass[tikz,border=3.14159pt]{standalone}
\usetikzlibrary{matrix,positioning,arrows,arrows.meta,calc}
\tikzset{
mymat/.style={
matrix of nodes,
anchor=center,
row 2/.style={nodes=draw,nodes in empty cells},
text height=2.8ex,
text depth=0.75ex,
text width=7ex,
align=center,
column sep=-\pgflinewidth
},
myarrow/.style={-{Stealth[scale=1.5]},rounded corners=2pt}
}
\begin{document}
\begin{tikzpicture}
\matrix[mymat]
at (0,0)
(mat1)
{
& & \small{block1a} & & \\
& & \large{500} & & \\
0 & 1 & 2 & 3 & 4 \\
};
\matrix[mymat]
at (-4,-3)
(mat2)
{
& & \small{block3a} & & \\
& & \large{501} & & \\
11 & 12 & 13 & 14 & 15 \\
};
\draw[myarrow]
($(mat1-2-3.south)+(-.4,0)$) --++ (0,-4) node[left,pos=0.3]{left} -| ($(mat2-2-3.south)+(.4,0)$);
\end{tikzpicture}
\end{document}