答案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}