![使用 TikZ PGF 在框内排列数字,并带有从一个框到另一个框的交叉箭头](https://linux22.com/image/414476/%E4%BD%BF%E7%94%A8%20TikZ%20PGF%20%E5%9C%A8%E6%A1%86%E5%86%85%E6%8E%92%E5%88%97%E6%95%B0%E5%AD%97%EF%BC%8C%E5%B9%B6%E5%B8%A6%E6%9C%89%E4%BB%8E%E4%B8%80%E4%B8%AA%E6%A1%86%E5%88%B0%E5%8F%A6%E4%B8%80%E4%B8%AA%E6%A1%86%E7%9A%84%E4%BA%A4%E5%8F%89%E7%AE%AD%E5%A4%B4.png)
答案1
欢迎!矩阵是一个很好的选择,但也许下面的更简单。
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
\path coordinate (aux) foreach \X in {1,...,10}
{node[anchor=west,minimum size=1.6em,draw,
label={[name=l-\X,inner sep=0.25pt]center:{$\X$}}]
(aux) at (aux.east){}}
foreach \X in {3,4}
{(l-\X) edge[semithick,-stealth] (l-\the\numexpr\X+1)};
\end{tikzpicture}
\end{document}
答案2
厌恶matrix
:
\documentclass[tikz]{standalone}
\usetikzlibrary{matrix}
\tikzset{
numbersrow/.style={
matrix,
matrix of nodes,
nodes in empty cells,
column sep=-\pgflinewidth,
nodes={
minimum size=1.6em,
anchor=center,
draw,
node contents=\the\pgfmatrixcurrentcolumn,
}
}
}
\begin{document}
\begin{tikzpicture}
\node[numbersrow](a){&&&&&&&&&\\};
\draw[->, shorten > =5pt, shorten <=5pt] (a-1-3.center)--(a-1-4.center);
\draw[->, shorten > =5pt, shorten <=5pt] (a-1-4.center)--(a-1-5.center);
\end{tikzpicture}
\end{document}