2

I don't know how to make the image given below.

enter image description here

see my code

\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}

Question : How to draw the image given in the diagram?

nice guy
  • 411

1 Answers1

2

The following code (that is heavily inspired by Gonzalo Medina's answer) might serve as a starting point:

enter image description here

\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}
leandriis
  • 62,593
  • Instead of column sep=-\pgflinewidth I would use row sep=-\pgflinewidth. – CarLaTeX Feb 27 '19 at 06:54
  • Thanks for the answer but there are few problems with the answer. 1) pointing arrays are small 2) big arrays are is not numbered as required. – nice guy Feb 27 '19 at 09:54
  • @CarLaTeX: Thank you for your comment. Indeed using row sep for a vertical array makes much more sense than using column sep. – leandriis Feb 27 '19 at 22:23
  • 1
    @I_wil_break_wall: My answer was not intended to be a complete code that exactly replicates the sketch in your image. Instead some more finetunig is needed. Regarding the size of the arrays, you can easily add more rows following the same pattern. Adjustments regarding the alignment can be done using for example the anchor option. Regarding the numbers left of the arrays, you might want to have a closer look at the answer that I liked in my answer. This numbering scheme of a horizontal array should be easily applicable to a vertical array as well. – leandriis Feb 27 '19 at 22:27
  • @leandriis +1 for the comment! –  Feb 28 '19 at 05:21