3

Trying to gain a little vertical padding with a matrix of nodes and having trouble. In a regular matrix I could just add [2em] etc after the row or column delimiter to add a little padding between rows or columns. That's not seeming to work in a matrix of nodes. Suggestions??

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

EDIT: I should have been more specific. I'm looking to add space only at the bottom and possibly to one side of the matrix of nodes

David Carlisle
  • 757,742
blitzvergnugen
  • 2,101
  • 2
  • 20
  • 20

1 Answers1

5

I'd suggest to add another empty row. If you want to have 2em in sum you'd add [.7em] to your last \\ as it will add another row sep.

Code

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

Output

enter image description here

Qrrbrbirlbel
  • 119,821
  • I'm sorry, I should have been more specific. I'm looking to add space only at the bottom and possibly to one side of the matrix of nodes The inner *sep is very close, but still adds to both ends. – blitzvergnugen Sep 12 '12 at 21:19
  • @blitzvergnugen If you add one more \\ after your last row you get an extra empty row (and the 2em get into account). You can then adjust it to your needs (but the empty row has its own height). – Qrrbrbirlbel Sep 12 '12 at 21:24
  • @blitzvergnugen I've updated my answer. Does this achieve what you wanted (looks odd to me, though)? – Qrrbrbirlbel Sep 12 '12 at 21:39
  • That works. I have a path that comes out of g.south and snakes up, so that's why I wanted the space at just the bottom. Seems like a deficiency of matrix of nodes to not have the same fine grained control of spacing like a regular matrix though. – blitzvergnugen Sep 13 '12 at 15:12
  • @blitzvergnugen Why not use \path (g.south) ++(0,-2em) … or the like? – Qrrbrbirlbel Sep 13 '12 at 15:21
  • I'm trying to keep the path inside the border of the matrix. – blitzvergnugen Sep 13 '12 at 18:14