Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider this:

misaligned nodes

There are several problems:

  1. The \exists operator is not horizontaly aligned with the following node (a,b).
  2. There is too little space between foobar and the node below it and between the (a,b) node and the nodes below it.
  3. The right arrow is not horizontally aligned with the preceding and following nodes. (I know that I can draw arrows with TikZ, this is just a placeholder.)

Any help on resolving these issues is greatly appreciated. Here is the code at present.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes.multipart,positioning,fit}

\begin{document}

\begin{tikzpicture}[
  node distance=3mm and 3mm,
  drs/.style={draw, rectangle split, rectangle split parts=2}
  ]
  \node[drs,align=left]
    { foo
      \nodepart{two}

        foobar \\

        \tikz{
          \node (operator) {$\exists$};
          \node[drs,right=of operator]{
            a%
            \nodepart{two}{
              b%
            }
          };
        } \\

        \tikz{
          \node[drs] (left side)
            { 1%
              \nodepart{two}
                2%
            };
          \node[right=of left side] (operator) {$\rightarrow$};
          \node[drs,right=of operator] (right side)
            { 3%
              \nodepart{two}
                4 \\
                5 \\
                6%
            };
        }
    };
\end{tikzpicture}


\end{document}
share|improve this question
    
By "horizontally aligned", do you mean you want their centers to be on the same height (i.e. vertical position)? –  Jake May 19 '11 at 18:46
    
see my answer to your other question Expandable nested boxed with tikz if you are interested in drawing DRS's independent of tikz. –  Alan Munn May 19 '11 at 21:58
add comment

1 Answer

up vote 3 down vote accepted

Problems 1) and 3): you can control the alignment using the mid anchor of nodes. Problem 2): you can use the optional argument of the line changing command \\; here's a modified version of your code, feel free to change the lengths according to your needs:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes.multipart,positioning,fit}

\begin{document}

\begin{tikzpicture}[
  drs/.style={draw, rectangle split, rectangle split parts=2}
  ]
  \node[drs,align=left]
    { foo
      \nodepart{two}
        foobar \\[.5em]
        \tikz{
          \node (operator) {$\exists$};
          \node[drs,right=2mm of operator.mid]{
            a%
            \nodepart{two}{
              b%
            }
          };
        } \\[.5em]
        \tikz{
          \node (operator) {$\rightarrow$};
          \node[drs,left=4mm of operator.mid] (left side)
            { 1%
              \nodepart{two}
                2%
            };
          \node[drs,right=4mm of operator.mid] (right side)
            { 3%
              \nodepart{two}
                4 \\
                5 \\
                6%
            };
        }
    };
\end{tikzpicture}

\end{document}

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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