矩阵和节点填充

矩阵和节点填充

尝试使用 获得一些垂直填充,但matrix of nodes遇到了麻烦。在常规情况下,matrix我可以[2em]在行或列分隔符后添加等,以在行或列之间添加一些填充。这似乎在 中不起作用matrix of nodes。有什么建议吗?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes, arrows, calc, positioning,matrix}

\tikzset{
    state/.style={rounded rectangle, draw, text centered, minimum height=3em ,minimum width = 6em, inner sep = 5pt},
    test/.style = {diamond, draw, shape aspect=2, inner sep = 0pt,text width = 7em,text centered},
    action/.style ={rectangle, draw,text width=8em,inner sep = 3pt, minimum height=5em},
    data/.style = {trapezium, draw, trapezium left angle=60, trapezium right angle=120pt, minimum height = 6em},
    line/.style = {draw, -triangle 45},
    list/.style = {rectangle, draw,minimum width = 6em},
    ptr-box/.style = {rectangle, text width = 8em}
}

\begin{document}
\begin{tikzpicture}[
    align = flush center,
    font = \small]
    \matrix [
        matrix of nodes,
        column sep = 0.5em,
        row sep = 1.3em, 
        draw, dashed,
        nodes = {solid},
        ] (mtrx)
    {  
    |[state]| \\
    |[data]|  b\\
    |[test]|  c\\
    |[action]|d\\
    |[test]|  e\\
    |[action]|f\\
    |[action]|g\\[2em] %Not working
    }; 
\end{tikzpicture}

\end{document}

编辑:我应该更具体一点。我只想在底部和可能在一侧添加空间matrix of nodes

答案1

我建议添加另一个空行。如果您想要2em总计,请将其添加[.7em]到最后一行\\,因为它会添加另一个row sep

代码

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes, arrows, calc, positioning,matrix}
\tikzset{
    state/.style={rounded rectangle, draw, text centered, minimum height=3em ,minimum width = 6em, inner sep = 5pt},
    test/.style = {diamond, draw, shape aspect=2, inner sep = 0pt,text width = 7em,text centered},
    action/.style ={rectangle, draw,text width=8em,inner sep = 3pt, minimum height=5em},
    data/.style = {trapezium, draw, trapezium left angle=60, trapezium right angle=120pt, minimum height = 6em},
    line/.style = {draw, -triangle 45},
    list/.style = {rectangle, draw,minimum width = 6em},
    ptr-box/.style = {rectangle, text width = 8em}
}
\begin{document}
\begin{tikzpicture}[
    align = flush center,
    font = \small]
    \matrix [
        matrix of nodes,
        column sep = 0.5em,
        row sep = 1.3em, 
        draw, dashed,
        nodes = {solid},
        ] (mtrx)
    {  
    |[state]| \\
    |[data]|  b\\
    |[test]|  c\\
    |[action]|d\\
    |[test]|  e\\
    |[action]|f\\
    |[action]|g\\[.7em]
    \\
   }; 
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

相关内容