Please look a next figure:

enter image description here

I've done it with:


       rounded corners, 
       draw=black, very thick, solid,
       text width=10em, 
       minimum height=3em, 
       inner sep=.3333em
        matrix of nodes,
        nodes = {box},
        column sep=.8cm,
        row sep=.8cm,
        inner sep=.2cm


\begin{tikzpicture}[node distance=2cm]
   \matrix (A) [vbox]{
        A11 & A12 \\

   \matrix (B) [vbox, matrix anchor=B-2-1.south, above=of A-1-1.north-|A.center] {
        B11\\ B21 \\

    \draw (A-1-1.north)--(A-1-2.north);
    \draw[<->] (B-2-1.south) -- (A-1-1.north-|A.center) node[midway,right] {node distance = 2cm};

As you can see, I first draw matrix A and later place matrix B with matrix anchor=B-2-1.south, above=of A-1-1.north-|A.center.

Now, I would like to do it the other way round, first matrix B and later matrix A using something like matrix anchor=A-1-1.north-|A.center, below=of B-2-1.south. But TiKZ doesn't like this matrix anchor.

I've tested with several combinations of {} and () without any success.

Is it possible to do it? If not, how can I place matrix A after matrix B?


First, if I'm not mistaken A-1-1.north-|A.center is [yshift=-inner ysep amount]A.north so it might be easier to switch to

   \matrix (B) [vbox] {
        B11\\ B21 \\

   \matrix (A) [vbox, matrix anchor=north, below={2cm-2mm} of B-2-1.south]{
        A11 & A12 \\

In your technique the problem is mainly due to the fact that the result is not an anchor of the matrix. Also TikZ tries to see whether you have provided an argument that contains a dot . otherwise it thinks that it's the anchor of the outer matrix rectangle.

But in both cases eventually the right portion of the <node>.<anchor> is sent to the \pgfmatrix{}{anchor}{}{}{shift}{}{} command. The left side is converted into a shift. That's why the complex part ends up in the wrong argument before it is parsed as a coordinate.

  • Is it possible to do it without having to use hard coded values 2cm-2mm but its names node distance-inner ysep amount?
    – Ignasi
    May 29 '13 at 21:48
  • @Ignasi Yes but the node distance part is a little tedious. I can have a look at it later. Main problem is that when node distance is set with 1cm and 2cm it is cumbersome the strip off the and part. Otherwise you can just use {2cm-\pgfkeysvalueof{/pgf/inner ysep}}
    – percusse
    May 29 '13 at 22:53

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.