8

I have to draw an arrow to a table like in this picture.

http://dl.dropbox.com/u/2793099/ex.png

Caramdir
  • 89,023
  • 26
  • 255
  • 291
Justus1
  • 183

4 Answers4

5

And as a LaTeX document.

\documentclass{article}
\usepackage{array}

\begin{document}

\def\arraystretch{2}
\begin{tabular}{@{}r|>{\ttfamily}c|}\cline{2-2}
    & x             \\\cline{2-2}
    & c             \\\cline{2-2}
    & control link  \\\cline{2-2}
  \noalign{\smash{\llap{\lower2pt\hbox{\tt fp$\longrightarrow$}}}}
    & return address\\\cline{2-2}
    & a[9]          \\\cline{2-2}
\end{tabular}

\end{document}
lockstep
  • 250,273
3

Here's a quick mock-up with Plain:

\vbox{
  \offinterlineskip % remove skips so that the \vrule's span the whole lineheight
  \mathsurround=3pt % consistent surrounding hspace for the arrow
  \everycr={\noalign{\hrule}}
  \halign{
    % begin preamble
      \vphantom{$\Big($}#% for every line, insert a invisible Big paren, to
                         % account for the lack of interlineskip
      &\vrule\enspace\hfil#\hfil\enspace\vrule\cr
    % end preamble
    &\tt x\cr
    &\tt c\cr
    &control link\cr
    \noalign{\smash{\llap{\lower2pt\hbox{\tt fp$\longrightarrow$}}}}
    % ^ place the fp arrow outside the alignment, \smash'ed (so it doesn't take
    % any vertical space), left over-lapping (\llap), and lowered (so it's on
    % the same level as the horizontal rule.
    &return address\cr
    &\tt a[9]\cr
  }
}
\bye

doncherry
  • 54,637
morbusg
  • 25,490
  • 4
  • 81
  • 162
3

For the task of drawing stack diagrams I once used the Groff PIC processor which can emit TeX. PIC is a diagram language from the Unix Troff tool. For the example below, the PIC code looked like this:

down
box wid 0.9 height (8/25) dotted "incoming"
ptr("$k = 0$" rjust)
box wid 0.9 height (12/25) "spills"
  { "~~completed region" ljust at last box .e }
box wid 0.9 height (4/25) 
box wid 0.9 height (4/25) "\tt a" 
  { "~~newly allocated slot in" ljust         "~~region under construction" ljust at last box .e }
ptr("$k = -12$ (cursor)" rjust)
box wid 0.9 height (14/25) dotted "not yet" "allocated" 

enter image description here

Obviously this is not a pure TeX solution but the description language is suffiently high level to mark an interesting point in the design space.

0

One way to do would be by making a Tikz image as shown here make each cell of a table as node and then you can connect arrows from anywhere in the document as long as your references are correct. How to draw lines around multiple table cells

Aku
  • 11,026