我不知道如何製作下面給出的圖像。
看我的程式碼
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (s) at (0,0);
\foreach \num in {5,2,7,-5,16,12}{
\node[minimum size=6mm, draw, rectangle] at (s) {\num};
\coordinate (s) at ($(s) + (1,0)$);
}
\end{tikzpicture}
\end{document}
問題:如何繪製圖中給出的圖像?
答案1
以下程式碼(很大程度上受到啟發貢薩洛·梅迪納的回答)可以作為一個起點:
\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning,arrows.meta,arrows}
\tikzset{
mymat/.style={
matrix of math nodes,
text height=2.5ex,
text depth=0.75ex,
text width=3.25ex,
align=center,
row sep=-\pgflinewidth
},
}
\begin{document}
\begin{tikzpicture}[>=latex]
\matrix[mymat,anchor=west,style={nodes=draw}]
at (0,0)
(mat1)
{
1\\
2\\
3\\
4\\
5\\
6\\
7\\
};
\matrix[mymat,right=of mat1,anchor=south,style={nodes={draw}},yshift=1.5cm]
(mat2)
{
1\\
2\\
};
\matrix[mymat,right=of mat2,anchor=center,style={nodes={draw}}]
(mat3)
{
1\\
2\\
};
\matrix[mymat,right=of mat3,anchor=center,style={nodes={draw}}]
(mat4)
{
1\\
2\\
};
\matrix[mymat,right=of mat1,anchor=north,style={nodes={draw}},yshift=-1.5cm]
(mat5)
{
1\\
2\\
};
\matrix[mymat,right=of mat5,anchor=center,style={nodes={draw}}]
(mat6)
{
1\\
2\\
};
\matrix[mymat,right=of mat6,anchor=center,style={nodes={draw}}]
(mat7)
{
1\\
2\\
};
\path[->]
(mat1-1-1.center) edge[bend left=50] node [left] {} (mat2-1-1.north west);
\path[->]
(mat1-1-1.center) edge[bend left=60] node [left] {} (mat3-1-1.north west);
\path[->]
(mat1-1-1.center) edge[bend left=70] node [left] {} (mat4-1-1.north west);
\path[->]
(mat1-7-1.center) edge[bend left=50] node [left] {} (mat5-1-1.north west);
\path[->]
(mat1-7-1.center) edge[bend left=60] node [left] {} (mat6-1-1.north west);
\path[->]
(mat1-7-1.center) edge[bend left=70] node [left] {} (mat7-1-1.north west);
\end{tikzpicture}
\end{document}