13

I am new to TikZ, and this is probably regarded as do-my-homework-for-me question. I'd like to draw a diagram like this:

enter image description here

First I need the very basic help on the segments themselves. I have tried nodes with a tabular environment:

\documentclass{standalone}
\usepackage{tikz,tabularx}
\begin{document}
\begin{tikzpicture}
\draw (0,0) node {
  \begin{tabularx}{4cm}{|X|X|}
  \hline
   \multicolumn{2}{|c|}{foo} \\
  \hline
    prev \hfill & \hfill next \\
    \hline
   \multicolumn{2}{|c|}{type: local\_par} \\
   \multicolumn{2}{|c|}{width: 20pt} \\
  \hline
  \end{tabularx}
};
\end{tikzpicture}
\end{document}

enter image description here

which comes close, but has a drawbacks:

  • I have the feeling that this is not the right way to go
  • I don't know how to make the line go from the "next" field to the next table. (Or the prev field of the previous table) as I don't know the position
  • The width of the table should be "minimum n points but stretch if needed".

Ultimately I'd like to have the arrows start in the field (next to the entry "prev","next" and "list"), similar to this example:

enter image description here

Moriambar
  • 11,466
topskip
  • 37,020
  • 2
    You work with multipart nodes instead of tables and the problem disappears. http://tex.stackexchange.com/questions/46712/tikz-connecting-to-a-rectangle-split-shape – Alain Matthes Jun 10 '12 at 08:39
  • @Altermundus So I guess I have to create a shape myself to use multipart nodes? – topskip Jun 10 '12 at 08:42
  • No, you can use rectangle split. You need to define some styles for each parts. The little problem is prev|dev but it's easy to add manually the vertical line – Alain Matthes Jun 10 '12 at 08:44
  • @Altermundus OK, I have got the rectangle split to work. Now I am trying the next | prev field, and "easy" is relative... – topskip Jun 10 '12 at 08:50

1 Answers1

14
\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}

\begin{document}
\begin{tikzpicture}
  \node[rectangle split, rectangle split parts=5, 
       draw, minimum width=4cm,font=\small,
       rectangle split part align={center}] (t1)
    {             \textbf{Name : glyph}
     \nodepart{two}
                  prev \hspace*{4ex} next
     \nodepart{three}
                  width: 15pt  
     \nodepart{four}
                  height: 15pt 
     \nodepart{five}
                  list};
  \draw (t1.text split) -- (t1.two split);

  \begin{scope}[xshift=7cm]
    \node[rectangle split, rectangle split parts=5,
          draw, minimum width=4cm,font=\small,
         rectangle split part align={center}] (t2)
     {                \textbf{Name : glyph}
       \nodepart{two}
                      prev \hspace*{4ex} next
       \nodepart{three}
                      width: 15pt  
       \nodepart{four}
                      height: 15pt 
       \nodepart{five}
                      list}; 
    \draw (t2.text split) -- (t2.two split);
  \end{scope}

  \draw[->] (t1.two east) to [out=0, in=180](t2.text west);      
\end{tikzpicture}
\end{document}   

enter image description here

Alain Matthes
  • 95,075