# Positioning of rotated nodes in a matrix

I'm trying to create a tikz drawing similar to this picture:

In the code below I have used matrix nodes for both of the "parts" but I can't get the phases (in the picture above the rectangles with text going upwards) to align properly. They are rotated nodes (so the text is pointing upwards)

• Both "parts" should be of equal height (but they are not of equal width, they contain different numbers of phases)
• The height of the parts are determined by the height of the highest phase
• All phases should be of equal height
• I'm using beamer, so anything should be compatible to beamer
• I do not insist on using matrix or rounded corners although the latter would be nice to have.
• Any suggestion on how to reduce the space between the brace an the description node would be nice (I tried all sort of inner sep, outer sep and node distance but nothing seemed to help.

Thanks.

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\tikzstyle{phase}=[draw,fill=white,rotate=90,sloped];
\tikzstyle{every matrix}=[ampersand replacement={\&}];
\matrix (xA)[matrix anchor=east,draw,rounded corners,fill=blue!20]
{%
\node (title1) {First Part}; \\
\node[phase](phase1_1){Short Name}; \&
\node[phase](phase1_2){Longer Name}; \&
\node[phase](phase1_3){Even longer name}; \&
\node[phase](phase1_4){VSN}; \&
\node[phase](phase1_5){Last phase name}; \\
};

\matrix(xB)[matrix anchor=west,draw,rounded corners,fill=red!20]
{
\node (title2) {Second Part}; \\
\node[phase](phase2_a){Name}; \&
\node[phase](phase2_b){Another name}; \&
\node[phase](phase2_c){Another another name}; \&
\node[phase](phase2_d){Different name}; \&
\node[phase](phase2_e){Name other than others}; \&
\node[phase](phase2_f){Name of last phase}; \\
};
\draw[decorate,decoration={brace,raise=1ex}] (xB.north west) -- ( xB.north east);
\node(description)[above=of xB.north]{Description over brace};

\end{tikzpicture}
\end{document}


-
Welcome to LaTeX! As new user without image posting privileges simply include the image as normal and remove the ! in front of it to turn it into a link. A moderator or another user with edit privileges can then reinsert the ! to turn it into an image again until you get more rep points. –  percusse Sep 2 '12 at 18:18
Thanks @percusse. I got enough rep for the question (or your comment) so I can include the pictures know. I hope that helps. –  stacknick Sep 2 '12 at 18:26
For the description I'd use \draw[decorate,decoration={brace,raise=1ex}] (xB.north west) -- ( xB.north east) node[pos=.5,above=0.3] {Description over brace};. –  Qrrbrbirlbel Sep 2 '12 at 18:28
Thanks @Qrrbrbirlbel: This looks just the way I want. Newbie question: Should I edit the code to reflect your suggestion? –  stacknick Sep 2 '12 at 18:33

The description is put above the decoration line:

\draw[decorate,decoration={brace,raise=1ex}] (xB.north west) -- ( xB.north east)
node[pos=.5,above=.3] {Description over brace};


For the same height of the part boxes I specified a minimum width of the phase boxes (the width becomes the height after rotating). The additional .6666em is double the inner xsep length because the space between text and the line is not accounted for by the macro \widthof.

Addition: You could also use something like minimum height=10pt+.6666em to get equally tall phase boxes (font size + 2x inner ysep).

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning,decorations.pathreplacing}

\begin{document}

\begin{tikzpicture}
\tikzstyle{phase}=[draw,fill=white,rotate=90,sloped,minimum width=\widthof{Name other than others}+.6666em];
\tikzstyle{every matrix}=[ampersand replacement={\&}];

\matrix (xA)[matrix anchor=east,draw,rounded corners,fill=blue!20]
{
\node[left] (title1) {\rlap{First Part}}; \\[1ex]
\node[phase](phase1_1){Short Name}; \&
\node[phase](phase1_2){Longer Name}; \&
\node[phase](phase1_3){Even longer name}; \&
\node[phase](phase1_4){VSN}; \&
\node[phase](phase1_5){Last phase name}; \\
};

\matrix (xB)[matrix anchor=west,draw,rounded corners,fill=red!20]
{
\node[left] (title2) {\rlap{Second Part}}; \\[1ex]
\node[phase](phase2_a){Name}; \&
\node[phase](phase2_b){Another name}; \&
\node[phase](phase2_c){Another another name}; \&
\node[phase](phase2_d){Different name}; \&
\node[phase](phase2_e){Name other than others}; \&
\node[phase](phase2_f){Name of last phase}; \\
};
\draw[decorate,decoration={brace,raise=1ex}] (xB.north west) -- ( xB.north east) node[pos=.5,above=.3] {Description over brace};

\end{tikzpicture}
\end{document}


-
Thanks @Qrrbrbirlbel, you are my hero, It took me ten times the time you needed to answer the question just to ask the question let alone the time I used to try to solve the problem. One minor suggestion: I like the 1em extra space in the "inner" nodes more than the .6666em that you posted in the final answer, the latter looks a bit "tight". –  stacknick Sep 2 '12 at 19:00
@stacknick Thanks, I'm glad I could help. the +.6666em provides the minimal height/width of the phase boxes. Of course you can adjust it to your needs. You could also use the minimum height key to get phase boxes that equal in height. –  Qrrbrbirlbel Sep 2 '12 at 19:21