矩阵中旋转节点的定位

矩阵中旋转节点的定位

我正在尝试创建类似于此图的 tikz 绘图:期望结果

在下面的代码中,我为两个“部分”使用了矩阵节点,但我无法让阶段(上图中文本向上的矩形)正确对齐。它们是旋转节点(因此文本指向上方)

我希望实现的目标以及寻求您的建议如下:

  • 两个“部分”的高度应相等(但宽度不相等,它们包含的相数不同)
  • 零件的高度由最高相的高度决定
  • 所有阶段应具有相同的高度
  • 我正在使用 beamer,所以任何东西都应该与 beamer 兼容
  • 尽管后者更好,但我并不坚持使用matrix或。rounded corners
  • 关于如何减少括号和描述节点之间的空间的任何建议都很好(我尝试了所有方法inner sepouter sepnode distance似乎没有任何帮助。

谢谢。


\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}

我现在得到了什么

答案1

描述放above装饰线:

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

对于零件框的相同高度,我指定了minimum width相位框的宽度(旋转后宽度变为高度)。额外的长度.6666em是其两倍,inner xsep因为宏没有考虑文本和线条之间的空间\widthof

另外:您还可以使用类似的方法minimum height=10pt+.6666em来获得同样高的相位框(字体大小 + 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}

更正

相关内容