[Tex/LaTex] How to draw stack diagram with TiKz


I want to draw a stack diagram looks like this with TiKZ.
enter image description here

I wonder is there way to draw this diagram with automatic positioning like drawing Automaton? Any idea? Thanks in advance.

Best Answer

You could use the shapes.multipart library and use nodes with parts:

\begin{tikzpicture}[stack/.style={rectangle split, rectangle split parts=#1,draw, anchor=center}]
\node[stack=5]  {


output of code

Related Question