I'm looking for a way to show data structures in my slides (Beamer). My first task is to show something that looks like a C++ vector.

Something like this:

enter image description here

Note that the final arrow points "one past" the end.

Thanks in advance!

  • Since you are using Beamer, TikZ seems the right tool for the job (there are others, but TikZ is automatically loaded by Beamer). It's easy to draw arrows, create nodes with text, draw rectangles, and colour them. – Manuel Feb 14 '17 at 0:36
  • 1
    @Manuel I don't think that's true. It loads pgf but not tikz. – cfr Feb 14 '17 at 1:47

This should get you started....

enter image description here



\node[draw,fill=LightSteelBlue!60,minimum width=3cm,minimum height=1cm] (a) at (2,0) {capacity};
\node[draw,fill=LightSteelBlue!60,minimum width=3cm,minimum height=1cm] (b) at (2,1) {end};
\node[draw,rectangle, fill=LightSteelBlue!60,minimum width=3cm,minimum height=1cm] (c) at (2,2) {begin};
\foreach \x in {0,1,2,3}
 \node[draw,rectangle, fill=LightSteelBlue!60,minimum width=2cm,minimum height=1cm]  (d\x) at (10,\x-2){};
\foreach \x in {0,...,4}
\node[draw,rectangle, fill=White,minimum width=2cm,minimum height=1cm]  (e\x) at (10,\x-7){};
\node[minimum width=2cm,minimum height=1cm] (f) at (10,-8){};
\draw[->,very thick] (c.east)--(d3.west);
\draw[->,very thick] (b.east)--(e4.west);
\draw[->,very thick] (a.east)--(f.west);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.