2

So, I'm looking for the easiest way of drawing something like this. It's a simple diagram.

enter image description here

Is the picture environment the most appropiate one?

6

One possibility using TikZ and multipart rectangles:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart,shapes.arrows}

\tikzset{
mystack/.style={
  draw,
  rectangle split,
  rectangle split parts=#1,
  text width=2cm,
  align=center,
  anchor=north east,
  font=\ttfamily}
}

\begin{document}

\begin{tikzpicture}
% The stack to the left
\node[mystack=2] at (0,0) (sta1)   
  {stack\nodepart{two}\rule{0pt}{2cm}};
\draw[white,line width=3pt] (sta1.south west) -- (sta1.south east);
\node[fill=red!50,single arrow,rotate=-90,text width=10pt] at (sta1) {};

% The stack to the right
\node[mystack=3] at (5,0) (sta2) 
  {0$\times$AAA\nodepart{two}0$\times\cdots$\nodepart{three}\rule{0pt}{1.5cm}};
\draw[white,line width=3pt] (sta2.south west) -- (sta2.south east);

% The red and black arrows
\draw[line width=2pt,red,->] 
  ([xshift=1cm]sta1.east) -- ++(20pt,0);
\draw[line width=1pt,<-] 
  ([xshift=5pt]sta2.two split east) -- ++(10pt,0) node[right] {ESP};
\end{tikzpicture}

\end{document}

enter image description here

|improve this answer|||||
  • +1 for \draw[white ... at lower border and \rule{0pt}... to fix stack height. Could you explain how do you know each stack line height is 5mm? – Ignasi Jun 3 '13 at 8:55
  • @Ignasi thanks for the vote! Regarding your question, I'm a little confused; which are the stack lines you are referring to? – Gonzalo Medina Jun 3 '13 at 13:31
  • In sta1 you use \rule{0pt}{2cm} while in \sta2 rule heigth is only 1.5cm, and both stacks show same height. How did you decide this 5mm difference? – Ignasi Jun 3 '13 at 14:14
  • @Ignasi ah, now I understand. Well, the values were just found "by eye" (I'm not sure if that's the right English expression). – Gonzalo Medina Jun 3 '13 at 14:19
1

I think that a good choice is the pstricks package, or any other design/draw software.

Use graphics package to include .jpg, .eps, .png... files in the .tex file.

Here you can see some examples:

http://tug.org/PSTricks/main.cgi/

http://www.tn-home.de/Tobias/Soft/TeX/TUG040611/presentation.pdf

If you want to write me, you can do it in spanish at NOTHINGmika2ikeNOTHING@gmail.com. I'm starting learning PSTricks. If you are using it, remember to compile with xelatex or use other options like the ones you can find here:

How to use PSTricks in pdfLaTeX?

|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.