I want to make the nodes in the following vector
-illustration touch each other. But no matter what I do to text width
or node distance
the distance between the nodes stays the same.
\usetikzlibrary{backgrounds}
\usetikzlibrary{decorations.pathreplacing}
\tikzstyle{cell} = [rectangle, draw, text width=1.3cm ]
\tikzstyle{capx} = [rectangle, draw, text width=1.3cm, color=black!40 ]
\begin{tikzpicture}[
every node/.style={text centered, minimum height=1.5em, minimum width=1.5cm,node distance=0pt},
background rectangle/.style={fill=black!10},show background rectangle,
]
\node at (10,0) [capx] (n5) {leer};
\node at (12,0) [capx] (n6) {leer};
\node at (14,0) [capx] (n7) {leer};
\node at (0,0) [cell] (n0) {wert};
\node at (2,0) [cell] (n1) {wert};
\node at (4,0) [cell] (n2) {wert};
\node at (6,0) [cell] (n3) {wert};
\node at (8,0) [cell] (n4) {wert};
\draw [decorate,decoration={brace,amplitude=10pt},xshift=-4pt,yshift=0pt]
(-0.6,0.5) -- (8.8,0.5) node [black,midway,xshift=-0.5cm,yshift=18pt]
{\hskip6ex size()};
\draw [decorate,decoration={brace,amplitude=10pt,mirror},xshift=-4pt,yshift=0pt,color=black!40]
(-0.6,-0.5) -- (14.8,-0.5) node [black,midway,xshift=-0.5cm,yshift=-18pt,color=black!40]
{\hskip6ex capacity()};
\end{tikzpicture}
Best Answer
Use the
positioning
library and place your nodes usingright= of <name>
:Some remarks:
\tikzstyle
is deprecated; I changed to\tikzset
instead.Use the anchors of the existing nodes to place the braces.
Set
outer sep
to0pt
so the lines of the nodes nicely overlap.Notice that I also changed the placement of the nodes for the braces.