12

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

  • 2
    You work with multipart nodes instead of tables and the problem disappears. tex.stackexchange.com/questions/46712/… – Alain Matthes Jun 10 '12 at 8:39
  • @Altermundus So I guess I have to create a shape myself to use multipart nodes? – topskip Jun 10 '12 at 8: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 8: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 8:50
13
\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

  • +1, especially for out=0,in=180! – Brent.Longborough Jun 10 '12 at 13:05
  • I try to do the same thing but when I try to add a vertical line for the last nodepart, it does not work. any idea please Thank you – MAYA Jun 11 at 8:43

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.