# How to display array nodes with tikz?

I need to display arrays (vertically, not latex ones, basically a consecutive sequence of values) with their implicit positions and use the result as a node within a TikZ picture (or more precisely I want to draw lines to and from it that don't overlap anything of that node). So basically what I want is something like:

array2{<mynodename>}{23}{42}


which should produce the following:

   .----.
0 | 23 |
1 | 42 |
'----'


I guess the first part should be easily doable with node parts, but I have no idea for the rest and my knowledge of TikZ is rusty and limited.

• Welcome to TeX.SE. What should lines connected? Can you provide a sketch of this? numbers in array or complete array? About this you are not clear. Regardless that your temporary knowledge is limited, you should tray do draw yourself at list nonworking example ... the best way to learn TikZ is "learning by doing" :-) – Zarko Aug 26 '16 at 16:19
• You can also just post an example of the bit you know how to do and ask how to do the second bit you're stuck on. There's no point people spending time telling their grandmothers how to suck eggs, after all. – cfr Aug 26 '16 at 16:36
• To be honest, I have no idea what you are trying to do or how you are trying to do it. – cfr Aug 26 '16 at 20:50

So is this something like you're after?

\documentclass[border=4mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{fit}
\newcommand\arraynode[2]{%
\node[coordinate] (#1-0-1) at (0,0) {};
\foreach [count=\i,evaluate=\i as \j using int(\i-1)] \x in {#2} {
\node [below] (#1-\i-1) at (#1-\j-1.south) {\j};
\node [right=1em,anchor=center] (#1-\i-2) at (#1-\i-1.east) {\x};
}
\node [draw,fit=(#1-1-2)(#1-\i-2)] (#1) {};
}
\begin{document}

\begin{tikzpicture}
\arraynode{a}{3,42,7}
\end{tikzpicture}

\end{document}